diff --git a/arch/x86/kernel/entry32.asm b/arch/x86/kernel/entry32.asm index 7443ff7f..c5096863 100644 --- a/arch/x86/kernel/entry32.asm +++ b/arch/x86/kernel/entry32.asm @@ -799,8 +799,14 @@ common_switch: xor eax, eax %endif add eax, task_state_segments - ; set esp0 in TSS - mov [eax+4], esp + + ; determine and set esp0 in TSS + mov ebx, esp + mov ecx, KERNEL_STACK_SIZE-1 + not ecx + and ebx, ecx + add ebx, KERNEL_STACK_SIZE-16 + mov [eax+4], ebx ; call cleanup code call finish_task_switch