Remove unnecessary #GP after flush_thread()
PATCH 1/1 Remove unnecessary #GP after flush_thread()
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.
i386/kernel/process.c 2005-01-05 15:13:55.129762272 -0800 renamed from i386/kernel/process.c- 2005-01-05 15:13:51.450321632 -0800 +6 -0
@@ -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 <[email protected]>
arch/i386/kernel/process.c renamed from arch/i386/kernel/process.c- +1 -0
@@ -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));/*