root_task.cr3 = va2pa((unsigned long)(init_pgd));
tss.esp0 = root_task.esp0;
-
+#if FIX_SYSENTER_ESP_MODE
+ // do nothing
+#else
wrmsr(MSR_SYSENTER_ESP, root_task.esp0, 0);
+#endif
printk("init_root_task tss.esp0 %08x\n", tss.esp0);
}
void switch_to() {
LoadCR3(current->cr3);
tss.esp0 = current->esp0;
+#if FIX_SYSENTER_ESP_MODE
+ // do nothing
+#else
wrmsr(MSR_SYSENTER_ESP, current->esp0, 0);
+#endif
}
void context_switch(task_union *prev, task_union *next) {
// printk("switch to: %s:%d\n", next->name, next->pid);
list_for_each_safe(pos, t, &all_tasks) {
p = list_entry(pos, task_union, list);
- printl(MPL_TASK_0 + p->pid * 2, " "); //清掉上一次显示的 '>'
+ printl(MPL_TASK_0 + p->pid * 2, " "); // 清掉上一次显示的 '>'
printl(MPL_TASK_0 + p->pid * 2, "%s%4s:%d [%08x] state %s weight %03d sched %u", next == p ? ">" : " ",
p->name, p->pid, p, task_state(p->state), p->weight, p->sched_cnt);
}
void setup_kernel() {
init_ttys();
+ printk("sysenter esp mode: %s\n",
+#if FIX_SYSENTER_ESP_MODE
+ "fixed to &tss.esp0"
+#else
+ "use task union stack"
+#endif
+ );
+
init_mm();
// printk("kernel: %08x - %08x\n", system.kernel_begin, system.kernel_end);
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);
-
+#if FIX_SYSENTER_ESP_MODE
+ wrmsr(MSR_SYSENTER_ESP, &(tss.esp0), 0);
+#endif
init_sysc_handler_table();
}