All of lore.kernel.org
 help / color / mirror / Atom feed
From: Arun Sharma <arun.sharma@intel.com>
To: linux-kernel@vger.kernel.org
Cc: mingo@redhat.com
Subject: [PATCH] Remove unnecessary #GP after flush_thread()
Date: Wed, 05 Jan 2005 15:22:40 -0800	[thread overview]
Message-ID: <41DC76C0.20408@intel.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]


During execve(), we seem to have a window between flush_thread() and start_thread() where %gs = 0x33, but cpu_gdt_table[cpu][6] == 0. This causes an unnecessary #GP fault on __switch_to() if there is a context switch during the window. But most people are not noticing it because of the fixup in loadsegment().

Specifically, this BUG() was triggered during normal execution.

--- arch/i386/kernel/process.c- 2005-01-05 15:13:51.450321632 -0800
+++ arch/i386/kernel/process.c  2005-01-05 15:13:55.129762272 -0800
@@ -764,6 +764,12 @@
         * Restore %fs and %gs if needed.
         */
        if (unlikely(prev->fs | prev->gs | next->fs | next->gs)) {
+#if 1
+                if ((next->gs == 0x33)
+                        && (cpu_gdt_table[cpu][6].a == 0)
+                        && (cpu_gdt_table[cpu][6].b == 0))
+                        BUG();
+#endif
                loadsegment(fs, next->fs);
                loadsegment(gs, next->gs);


This patch sets %gs = 0 _before_ the thread.tls_array is zeroed.

Signed-off-by: Arun Sharma <arun.sharma@intel.com>


[-- Attachment #2: flush_thread_gp.patch --]
[-- Type: text/plain, Size: 393 bytes --]

--- linux-2.6.10/arch/i386/kernel/process.c-	2005-01-05 15:15:25.469541136 -0800
+++ linux-2.6.10/arch/i386/kernel/process.c	2005-01-05 15:15:26.939317696 -0800
@@ -329,6 +329,7 @@
 {
 	struct task_struct *tsk = current;
 
+	__asm__("movl %0,%%gs": :"r" (0));
 	memset(tsk->thread.debugreg, 0, sizeof(unsigned long)*8);
 	memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));	
 	/*

                 reply	other threads:[~2005-01-05 23:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=41DC76C0.20408@intel.com \
    --to=arun.sharma@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.