Explorar o código

[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>
Jeremy Fitzhardinge %!s(int64=19) %!d(string=hai) anos
pai
achega
5758d5dfef
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      arch/i386/kernel/cpu/common.c

+ 1 - 1
arch/i386/kernel/cpu/common.c

@@ -675,7 +675,7 @@ old_gdt:
 #endif
 #endif
 
 
 	/* Clear %fs and %gs. */
 	/* 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: */
 	/* Clear all 6 debug registers: */
 	set_debugreg(0, 0);
 	set_debugreg(0, 0);