The compiler's revenge
PATCH 1/1 The compiler's revenge
... 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 <[email protected]>
include/asm-mips/io.h +2 -3
@@ -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
arch/mips/kernel/setup.c +1 -1
@@ -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);/*
Signature · 9 lines
-------------------------------------------------- Thomas Koeller, Software Development Basler Vision Technologies thomas dot koeller at baslerweb dot com http://www.baslerweb.com ==============================