From 3c1b270160abc24fed0925767ef6feed230ca76b Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Sat, 14 Jul 2012 11:16:29 +0200 Subject: [PATCH] fix bug in the calculation of esp0 --- arch/x86/kernel/entry32.asm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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