Skip to content

Commit

Permalink
[PATCH] i386: fix dubious segment register clear in cpu_init()
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Jeremy Fitzhardinge authored and Andi Kleen committed Sep 26, 2006
1 parent 3b8d1fe commit 5758d5d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion arch/i386/kernel/cpu/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,7 @@ void __cpuinit cpu_init(void)
#endif

/* Clear %fs and %gs. */
asm volatile ("xorl %eax, %eax; movl %eax, %fs; movl %eax, %gs");
asm volatile ("movl %0, %%fs; movl %0, %%gs" : : "r" (0));

/* Clear all 6 debug registers: */
set_debugreg(0, 0);
Expand Down

0 comments on commit 5758d5d

Please sign in to comment.