diff options
author | Jim Bos <jim876@xs4all.nl> | 2010-11-15 15:22:37 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-11-15 16:27:06 -0500 |
commit | 22d3243de86bc92d874abb7c5b185d5c47aba323 (patch) | |
tree | 9fd3cde28bd00b88c9958b4aaee402f63d34cfd4 /drivers | |
parent | 620751a25964582595c6e7935777af954b24cb96 (diff) |
Fix gcc 4.5.1 miscompiling drivers/char/i8k.c (again)
The fix in commit 6b4e81db2552 ("i8k: Tell gcc that *regs gets
clobbered") to work around the gcc miscompiling i8k.c to add "+m
(*regs)" caused register pressure problems and a build failure.
Changing the 'asm' statement to 'asm volatile' instead should prevent
that and works around the gcc bug as well, so we can remove the "+m".
[ Background on the gcc bug: a memory clobber fails to mark the function
the asm resides in as non-pure (aka "__attribute__((const))"), so if
the function does nothing else that triggers the non-pure logic, gcc
will think that that function has no side effects at all. As a result,
callers will be mis-compiled.
Adding the "+m" made gcc see that it's not a pure function, and so
does "asm volatile". The problem was never really the need to mark
"*regs" as changed, since the memory clobber did that part - the
problem was just a bug in the gcc "pure" function analysis - Linus ]
Signed-off-by: Jim Bos <jim876@xs4all.nl>
Acked-by: Jakub Jelinek <jakub@redhat.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/char/i8k.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/char/i8k.c b/drivers/char/i8k.c index f0863bec186f..d72433f2d310 100644 --- a/drivers/char/i8k.c +++ b/drivers/char/i8k.c | |||
@@ -120,7 +120,7 @@ static int i8k_smm(struct smm_regs *regs) | |||
120 | int eax = regs->eax; | 120 | int eax = regs->eax; |
121 | 121 | ||
122 | #if defined(CONFIG_X86_64) | 122 | #if defined(CONFIG_X86_64) |
123 | asm("pushq %%rax\n\t" | 123 | asm volatile("pushq %%rax\n\t" |
124 | "movl 0(%%rax),%%edx\n\t" | 124 | "movl 0(%%rax),%%edx\n\t" |
125 | "pushq %%rdx\n\t" | 125 | "pushq %%rdx\n\t" |
126 | "movl 4(%%rax),%%ebx\n\t" | 126 | "movl 4(%%rax),%%ebx\n\t" |
@@ -142,11 +142,11 @@ static int i8k_smm(struct smm_regs *regs) | |||
142 | "lahf\n\t" | 142 | "lahf\n\t" |
143 | "shrl $8,%%eax\n\t" | 143 | "shrl $8,%%eax\n\t" |
144 | "andl $1,%%eax\n" | 144 | "andl $1,%%eax\n" |
145 | :"=a"(rc), "+m" (*regs) | 145 | :"=a"(rc) |
146 | : "a"(regs) | 146 | : "a"(regs) |
147 | : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); | 147 | : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); |
148 | #else | 148 | #else |
149 | asm("pushl %%eax\n\t" | 149 | asm volatile("pushl %%eax\n\t" |
150 | "movl 0(%%eax),%%edx\n\t" | 150 | "movl 0(%%eax),%%edx\n\t" |
151 | "push %%edx\n\t" | 151 | "push %%edx\n\t" |
152 | "movl 4(%%eax),%%ebx\n\t" | 152 | "movl 4(%%eax),%%ebx\n\t" |
@@ -168,7 +168,7 @@ static int i8k_smm(struct smm_regs *regs) | |||
168 | "lahf\n\t" | 168 | "lahf\n\t" |
169 | "shrl $8,%%eax\n\t" | 169 | "shrl $8,%%eax\n\t" |
170 | "andl $1,%%eax\n" | 170 | "andl $1,%%eax\n" |
171 | :"=a"(rc), "+m" (*regs) | 171 | :"=a"(rc) |
172 | : "a"(regs) | 172 | : "a"(regs) |
173 | : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); | 173 | : "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory"); |
174 | #endif | 174 | #endif |