From: Andi Kleen <ak@muc.de>
To: torvalds@transmeta.com, linux-kernel@vger.kernel.org,
Paul.Russell@rustcorp.com.au
Subject: [PATCH] Fix RELOC_HIDE miscompilation
Date: Sun, 1 Sep 2002 11:42:42 +0200 [thread overview]
Message-ID: <20020901114242.21242@colin.muc.de> (raw)
[resend due to mailer problems]
RELOC_HIDE got miscompiled on gcc3.1/x86-64 in the access to softirq.c's per
cpu variables. This patch fixes the problem.
Clearly to hide the relocation the addition needs to be done after the
value obfuscation, not before.
I don't know if it triggers on other architectures (x86-64 is especially
stressf here because it has negative kernel addresses), but seems like the
right thing to do.
Also does the arithmetic in unsigned long to avoid undue assumptions of the
comp for pointers.
-Andi
--- linux/include/linux/compiler.h-o Sun Apr 14 21:18:44 2002
+++ linux/include/linux/compiler.h Sun Sep 1 02:52:31 2002
@@ -16,7 +16,7 @@
/* This macro obfuscates arithmetic on a variable address so that gcc
shouldn't recognize the original var, and make assumptions about it */
#define RELOC_HIDE(ptr, off) \
- ({ __typeof__(ptr) __ptr; \
- __asm__ ("" : "=g"(__ptr) : "0"((void *)(ptr) + (off))); \
- __ptr; })
+ ({ unsigned long __ptr; \
+ __asm__ ("" : "=g"(__ptr) : "0"(ptr)); \
+ (typeof(ptr)) (__ptr + (off)); })
#endif /* __LINUX_COMPILER_H */
next reply other threads:[~2002-09-01 9:38 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-09-01 9:42 Andi Kleen [this message]
2002-09-02 2:11 ` [PATCH] Fix RELOC_HIDE miscompilation Rusty Russell
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=20020901114242.21242@colin.muc.de \
--to=ak@muc.de \
--cc=Paul.Russell@rustcorp.com.au \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/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;
as well as URLs for NNTP newsgroup(s).