From 8ce2011aa84b49f5db922aaa5750b27bbf3484b7 Mon Sep 17 00:00:00 2001 From: Matthias Kruk Date: Wed, 25 Sep 2019 18:57:58 +0900 Subject: [PATCH] Fix a bug in task_switch() that would cause the TSS update to be skipped --- kernel/arch/task.S | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/arch/task.S b/kernel/arch/task.S index 513c8a2..b78b2af 100644 --- a/kernel/arch/task.S +++ b/kernel/arch/task.S @@ -36,7 +36,7 @@ task_prepare: /* * int task_prepare(struct task*, u32_t cr3, u32_t eip, - * u32_t esp, u32_t priv) + * u32_t esp0, u32_t esp, u32_t priv) * * priv = 24(%esp) * esp = 20(%esp) @@ -164,7 +164,7 @@ task_switch: ret /* put the task's ESP0 into the TSS */ - movl OFFSET_ESP0(%edi), %ecx +2: movl OFFSET_ESP0(%edi), %ecx movl %ecx, CPU_ESP0(%eax) movl $KERNEL_DATA, CPU_SS0(%eax) @@ -173,14 +173,14 @@ task_switch: * set the segment registers accordingly */ /* - movl $KERNEL_CODE, CPU_CS(%eax) - movl $KERNEL_DATA, CPU_DS(%eax) - movl $KERNEL_DATA, CPU_ES(%eax) - movl $KERNEL_DATA, CPU_FS(%eax) - movl $KERNEL_DATA, CPU_GS(%eax) + movl $USER_CODE, CPU_CS(%eax) + movl $USER_DATA, CPU_DS(%eax) + movl $USER_DATA, CPU_ES(%eax) + movl $USER_DATA, CPU_FS(%eax) + movl $USER_DATA, CPU_GS(%eax) + movl $USER_DATA, CPU_SS(%eax) */ - -2: movl OFFSET_CR3(%edi), %ecx + movl OFFSET_CR3(%edi), %ecx /* check if we can avoid writing to cr3, which would clear the TLB */ movl %cr3, %edx -- 2.47.3