* [PATCH] Remove unnecessary #GP after flush_thread()
@ 2005-01-05 23:22 Arun Sharma
0 siblings, 0 replies; only message in thread
From: Arun Sharma @ 2005-01-05 23:22 UTC (permalink / raw)
To: linux-kernel; +Cc: mingo
[-- 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));
/*
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2005-01-05 23:24 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-05 23:22 [PATCH] Remove unnecessary #GP after flush_thread() Arun Sharma
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox