Commit 5758d5dfef1c514200bda3f29ba700f1c3e3bc99

Authored by Jeremy Fitzhardinge
Committed by Andi Kleen
1 parent 3b8d1fe0f2

[PATCH] i386: fix dubious segment register clear in cpu_init()

Fix a very dubious piece of code in
arch/i386/kernel/cpu/common.c:cpu_init().  This clears out %fs and
%gs, but clobbers %eax in the process without telling gcc.  It turns
out that gcc happens to be not using %eax at that point anyway so it
doesn't matter much, but it looks like a bomb waiting to go off.

This does end up saving an instruction, because gcc wants %eax==0 for
the set_debugreg()s below.

Signed-off-by: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Andi Kleen <ak@suse.de>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

arch/i386/kernel/cpu/common.c
... ... @@ -675,7 +675,7 @@
675 675 #endif
676 676  
677 677 /* Clear %fs and %gs. */
678   - asm volatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs");
  678 + asm volatile ("movl %0, %%fs; movl %0, %%gs" : : "r" (0));
679 679  
680 680 /* Clear all 6 debug registers: */
681 681 set_debugreg(0, 0);