From: Thomas Koeller <thomas.koeller@baslerweb.com>
To: linux-mips@linux-mips.org
Subject: [PATCH] The compiler's revenge
Date: Thu, 4 Nov 2004 11:35:31 +0100 [thread overview]
Message-ID: <200411041135.31503.thomas.koeller@baslerweb.com> (raw)
... 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
==============================
reply other threads:[~2004-11-04 10:31 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200411041135.31503.thomas.koeller@baslerweb.com \
--to=thomas.koeller@baslerweb.com \
--cc=linux-mips@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox