linux-mips
[Top] [All Lists]

[PATCH] The compiler's revenge

To: linux-mips@linux-mips.org
Subject: [PATCH] The compiler's revenge
From: Thomas Koeller <thomas.koeller@baslerweb.com>
Date: Thu, 4 Nov 2004 11:35:31 +0100
Organization: Basler AG
Original-recipient: rfc822;linux-mips@linux-mips.org
Sender: linux-mips-bounce@linux-mips.org
User-agent: KMail/1.6.2
... for lying to it is to produce code that does unexpected things.

In include/asm-mips/io.h, mips_io_port_base is declared to be const,
but can actually be modified using set_io_port_base(). The compiler
believes the const declaration and uses the uninitialized value if
an in(b|w|l) or out(b|w|l) is used right after set_io_port_base().


Signed-off-by: Thomas Koeller <thomas.koeller@baslerweb.com>



--- linux-mips-cvs/include/asm-mips/io.h        2004-10-25 11:16:42.000000000 
+0200
+++ linux-mips-basler/include/asm-mips/io.h     2004-11-04 10:40:57.796646368 
+0100
@@ -67,10 +67,9 @@
  * instruction, so the lower 16 bits must be zero.  Should be true on
  * on any sane architecture; generic code does not use this assumption.
  */
-extern const unsigned long mips_io_port_base;
+extern unsigned long mips_io_port_base;
 
-#define set_io_port_base(base) \
-       do { * (unsigned long *) &mips_io_port_base = (base); } while (0)
+#define set_io_port_base(base) mips_io_port_base = (base)
 
 /*
  * Thanks to James van Artsdalen for a better timing-fix than
--- linux-mips-cvs/arch/mips/kernel/setup.c     2004-07-14 16:21:29.000000000 
+0200
+++ linux-mips-basler/arch/mips/kernel/setup.c  2004-11-04 10:39:45.359658464 
+0100
@@ -78,7 +78,7 @@
  * mips_io_port_base is the begin of the address space to which x86 style
  * I/O ports are mapped.
  */
-const unsigned long mips_io_port_base = -1;
+unsigned long mips_io_port_base = -1;
 EXPORT_SYMBOL(mips_io_port_base);
 
 /*

-- 
--------------------------------------------------

Thomas Koeller, Software Development
Basler Vision Technologies

thomas dot koeller at baslerweb dot com
http://www.baslerweb.com

==============================


<Prev in Thread] Current Thread [Next in Thread>
  • [PATCH] The compiler's revenge, Thomas Koeller <=