From b97aaee746c548b8cae9111441363776aa72d943 Mon Sep 17 00:00:00 2001 From: fslongjin Date: Wed, 1 Jun 2022 17:13:12 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E4=BF=AE=E5=A4=8D=E4=BA=86=E8=BF=9B?= =?UTF-8?q?=E7=A8=8B=E7=94=B1=E4=BA=8E=E5=BC=82=E5=B8=B8=E8=A2=AB=E6=8D=95?= =?UTF-8?q?=E8=8E=B7=E5=90=8E=EF=BC=8C=E5=85=B6=E4=BB=96=E8=BF=9B=E7=A8=8B?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E8=A2=AB=E6=AD=A3=E5=B8=B8=E8=B0=83=E5=BA=A6?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/exception/entry.S | 2 +- kernel/exception/trap.c | 44 ++++++++++++++++++++-------------------- kernel/sched/sched.c | 1 + 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/kernel/exception/entry.S b/kernel/exception/entry.S index df38194f..823034ca 100644 --- a/kernel/exception/entry.S +++ b/kernel/exception/entry.S @@ -53,7 +53,7 @@ Restore_all: popq %rax addq $0x10, %rsp // 弹出变量FUNC和errcode - sti + // sti iretq ret_from_exception: diff --git a/kernel/exception/trap.c b/kernel/exception/trap.c index 12d57d1e..3485d385 100644 --- a/kernel/exception/trap.c +++ b/kernel/exception/trap.c @@ -9,8 +9,8 @@ void do_divide_error(struct pt_regs *regs, unsigned long error_code) { //kerror("do_divide_error(0)"); - kerror("do_divide_error(0),\tError Code:%#18lx,\tRSP:%#18lx,\tRIP:%#18lx\t CPU:%d\n", error_code, regs->rsp, regs->rip, proc_current_cpu_id); - + kerror("do_divide_error(0),\tError Code:%#18lx,\tRSP:%#18lx,\tRIP:%#18lx\t CPU:%d\t pid=%d\n", error_code, regs->rsp, regs->rip, proc_current_cpu_id, current_pcb->pid); + current_pcb->state = PROC_STOPPED; while (1) hlt(); } @@ -285,27 +285,27 @@ void do_virtualization_exception(struct pt_regs *regs, unsigned long error_code) void sys_vector_init() { - set_trap_gate(0, 1, divide_error); - set_trap_gate(1, 1, debug); - set_intr_gate(2, 1, nmi); - set_system_trap_gate(3, 1, int3); - set_system_trap_gate(4, 1, overflow); - set_system_trap_gate(5, 1, bounds); - set_trap_gate(6, 1, undefined_opcode); - set_trap_gate(7, 1, dev_not_avaliable); - set_trap_gate(8, 1, double_fault); - set_trap_gate(9, 1, coprocessor_segment_overrun); - set_trap_gate(10, 1, invalid_TSS); - set_trap_gate(11, 1, segment_not_exists); - set_trap_gate(12, 1, stack_segment_fault); - set_trap_gate(13, 1, general_protection); - set_trap_gate(14, 1, page_fault); + set_trap_gate(0, 0, divide_error); + set_trap_gate(1, 0, debug); + set_intr_gate(2, 0, nmi); + set_system_trap_gate(3, 0, int3); + set_system_trap_gate(4, 0, overflow); + set_system_trap_gate(5, 0, bounds); + set_trap_gate(6, 0, undefined_opcode); + set_trap_gate(7, 0, dev_not_avaliable); + set_trap_gate(8, 0, double_fault); + set_trap_gate(9, 0, coprocessor_segment_overrun); + set_trap_gate(10, 0, invalid_TSS); + set_trap_gate(11, 0, segment_not_exists); + set_trap_gate(12, 0, stack_segment_fault); + set_trap_gate(13, 0, general_protection); + set_trap_gate(14, 0, page_fault); // 中断号15由Intel保留,不能使用 - set_trap_gate(16, 1, x87_FPU_error); - set_trap_gate(17, 1, alignment_check); - set_trap_gate(18, 1, machine_check); - set_trap_gate(19, 1, SIMD_exception); - set_trap_gate(20, 1, virtualization_exception); + set_trap_gate(16, 0, x87_FPU_error); + set_trap_gate(17, 0, alignment_check); + set_trap_gate(18, 0, machine_check); + set_trap_gate(19, 0, SIMD_exception); + set_trap_gate(20, 0, virtualization_exception); // 中断号21-31由Intel保留,不能使用 diff --git a/kernel/sched/sched.c b/kernel/sched/sched.c index f6ff843f..1a73ecfa 100644 --- a/kernel/sched/sched.c +++ b/kernel/sched/sched.c @@ -75,6 +75,7 @@ void sched_cfs() } } // kdebug("before switch, next.rip = %#018lx\tnext->gs=%#018lx", proc->thread->rip, proc->thread->gs); + // kdebug("currentpcb=%#018lx", (uint64_t)current_pcb); process_switch_mm(proc); switch_proc(current_pcb, proc); }