From: acevest Date: Mon, 1 Nov 2021 08:20:17 +0000 (+0800) Subject: syscall_entry里不再间接寻址进程的内核栈esp0 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/named-checkconf.html?a=commitdiff_plain;h=b504ddc79bda7fb2aa3a01871778109d3b885ffa;p=kernel.git syscall_entry里不再间接寻址进程的内核栈esp0 --- diff --git a/kernel/sched.c b/kernel/sched.c index a72b401..6dde76d 100644 --- a/kernel/sched.c +++ b/kernel/sched.c @@ -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) diff --git a/kernel/syscall.S b/kernel/syscall.S index 7a44a44..fdd9772 100644 --- a/kernel/syscall.S +++ b/kernel/syscall.S @@ -30,8 +30,6 @@ .global syscall_exit syscall_entry: - movl (%esp),%esp - pushl $(SELECTOR_USER_SS) pushl %ebp pushfl diff --git a/kernel/syscall.c b/kernel/syscall.c index a1e4108..ef98edb 100644 --- a/kernel/syscall.c +++ b/kernel/syscall.c @@ -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(); }