mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeremy Fitzhardinge <jeremy@goop.org>
To: Andrew Morton <akpm@osdl.org>, Andi Kleen <ak@suse.de>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] fix dubious segment register clear in cpu_init()
Date: Thu, 03 Aug 2006 16:49:03 -0700	[thread overview]
Message-ID: <44D28B6F.5030701@goop.org> (raw)

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>

diff -r ced3124154dc arch/i386/kernel/cpu/common.c
--- a/arch/i386/kernel/cpu/common.c	Mon Jul 31 18:52:19 2006 -0700
+++ b/arch/i386/kernel/cpu/common.c	Thu Aug 03 16:23:02 2006 -0700
@@ -675,7 +675,7 @@ old_gdt:
 #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);



             reply	other threads:[~2006-08-03 23:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-03 23:49 Jeremy Fitzhardinge [this message]
2006-08-04  0:23 ` Andi Kleen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=44D28B6F.5030701@goop.org \
    --to=jeremy@goop.org \
    --cc=ak@suse.de \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome