]> Zhao Yanbai Git Server - kernel.git/commitdiff
syscall_entry里不再间接寻址进程的内核栈esp0
authoracevest <zhaoyanbai@126.com>
Mon, 1 Nov 2021 08:20:17 +0000 (16:20 +0800)
committeracevest <zhaoyanbai@126.com>
Wed, 3 Nov 2021 02:45:45 +0000 (10:45 +0800)
kernel/sched.c
kernel/syscall.S
kernel/syscall.c

index a72b401d9597d007b6c5eb78827ca5098b7e0f8d..6dde76da1c9e98921deb06ea8727aadfeb0b0ffe 100644 (file)
@@ -18,6 +18,7 @@
 #include "assert.h"
 #include "mm.h"
 #include "init.h"
+#include "msr.h"
 
 task_union root_task __attribute__((__aligned__(PAGE_SIZE)));
 
@@ -66,6 +67,7 @@ void init_root_tsk()
     root_task.cr3 = (unsigned long)init_pgd;
 
     tss.esp0 = root_task.esp0;
+    wrmsr(MSR_SYSENTER_ESP, root_task.esp0, 0);
 
     printk("init_root_task tss.esp0 %08x\n", tss.esp0);
 }
@@ -96,6 +98,7 @@ void switch_to()
 {
     LOAD_CR3(current->cr3);
     tss.esp0 = current->esp0;
+    wrmsr(MSR_SYSENTER_ESP, current->esp0, 0);
 }
 
 void context_switch(task_union *prev, task_union *next)
index 7a44a44ed2a9d02d8692345eac7745e1ce2cdadb..fdd9772c371bc51ef69ab75f3b2a06c064423008 100644 (file)
@@ -30,8 +30,6 @@
 .global syscall_exit
 
 syscall_entry:
-    movl    (%esp),%esp
-
     pushl   $(SELECTOR_USER_SS)
     pushl   %ebp
     pushfl
index a1e4108b3552c5c67679538ccb0f4d92339dc0c2..ef98edb137f1619290ad2d9ff96650cc7051175a 100644 (file)
@@ -27,7 +27,7 @@ void setup_sysc()
 {
     wrmsr(MSR_SYSENTER_CS, SELECTOR_KRNL_CS, 0);
     wrmsr(MSR_SYSENTER_EIP, syscall_entry, 0);
-    wrmsr(MSR_SYSENTER_ESP, &(tss.esp0), 0);
+    //wrmsr(MSR_SYSENTER_ESP, &(tss.esp0), 0);
 
     init_sysc_handler_table();
 }