Skip to content

Commit f6f0a6f

Browse files
Jim BosAndi Kleen
authored andcommitted
Fix gcc 4.5.1 miscompiling drivers/char/i8k.c (again)
[ upstream commit 22d3243 ] The fix in commit 6b4e81d ("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> Signed-off-by: Andi Kleen <ak@linux.intel.com>
1 parent e58c04b commit f6f0a6f

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

drivers/char/i8k.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ static int i8k_smm(struct smm_regs *regs)
119119
int eax = regs->eax;
120120

121121
#if defined(CONFIG_X86_64)
122-
asm("pushq %%rax\n\t"
122+
asm volatile("pushq %%rax\n\t"
123123
"movl 0(%%rax),%%edx\n\t"
124124
"pushq %%rdx\n\t"
125125
"movl 4(%%rax),%%ebx\n\t"
@@ -141,11 +141,11 @@ static int i8k_smm(struct smm_regs *regs)
141141
"lahf\n\t"
142142
"shrl $8,%%eax\n\t"
143143
"andl $1,%%eax\n"
144-
:"=a"(rc), "+m" (*regs)
144+
:"=a"(rc)
145145
: "a"(regs)
146146
: "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
147147
#else
148-
asm("pushl %%eax\n\t"
148+
asm volatile("pushl %%eax\n\t"
149149
"movl 0(%%eax),%%edx\n\t"
150150
"push %%edx\n\t"
151151
"movl 4(%%eax),%%ebx\n\t"
@@ -167,7 +167,7 @@ static int i8k_smm(struct smm_regs *regs)
167167
"lahf\n\t"
168168
"shrl $8,%%eax\n\t"
169169
"andl $1,%%eax\n"
170-
:"=a"(rc), "+m" (*regs)
170+
:"=a"(rc)
171171
: "a"(regs)
172172
: "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
173173
#endif

0 commit comments

Comments
 (0)