From: Matthias Kruk Date: Mon, 2 Dec 2019 09:37:16 +0000 (+0900) Subject: Switch back to the user page directory after having modified the _cpu structure,... X-Git-Url: https://git.corax.cc/?a=commitdiff_plain;h=576e6142bb5685a0a361b4fcac846658e3e06d5a;p=corax Switch back to the user page directory after having modified the _cpu structure, so it can be removed from the process's page directory --- diff --git a/kernel/arch/entry.S b/kernel/arch/entry.S index 4ab9ea4..13e63d0 100644 --- a/kernel/arch/entry.S +++ b/kernel/arch/entry.S @@ -404,19 +404,16 @@ _already_in_kernel: _int_restore: /* pop the page directory from the stack */ - popl %eax + popl %edi /* * Check if the destination of the iret is in the kernel or user-space. * In the former case, we can skip rebasing the stack and restoring the * page directory. */ - cmpl %eax, (_kernel_cr3) + cmpl %edi, (_kernel_cr3) je _return_to_kernel - /* switch page directory first since we'll need the register */ - movl %eax, %cr3 - cpuidx %ecx movl $_cpu, %eax 0: subl $1, %ecx @@ -432,6 +429,12 @@ _int_restore: subl OFFSET_TASK_KSTACK(%eax), %ebp addl $CONFIG_KERNEL_STACK_BASE, %ebp + /* + * Restore the page directory last since the .bss segement where the _cpu + * structure resides is not mapped into the process address space + */ + movl %edi, %cr3 + _return_to_kernel: popl %eax movw %ax, %ds