]> git.corax.cc Git - corax/commitdiff
Switch back to the user page directory after having modified the _cpu structure,...
authorMatthias Kruk <m@m10k.eu>
Mon, 2 Dec 2019 09:37:16 +0000 (18:37 +0900)
committerMatthias Kruk <m@m10k.eu>
Mon, 2 Dec 2019 09:37:16 +0000 (18:37 +0900)
kernel/arch/entry.S

index 4ab9ea46e9b77cc91250e103516906a19acf20fb..13e63d0833b3be8ff4791ac939b0c682484da4af 100644 (file)
@@ -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