diff --git a/kernel/src/arch/riscv32/boot/trap.asm b/kernel/src/arch/riscv32/boot/trap.asm index 37afaf11..bf4aba54 100644 --- a/kernel/src/arch/riscv32/boot/trap.asm +++ b/kernel/src/arch/riscv32/boot/trap.asm @@ -62,7 +62,7 @@ _save_context: lw s1, 32*4(sp) # s1 = sstatus lw s2, 33*4(sp) # s2 = sepc andi s0, s1, 1 << 8 - bnez s0, _restore_context # back to U-mode? (sstatus.SPP = 1) + bnez s0, _restore_context # back to S-mode? (sstatus.SPP = 1) _save_kernel_sp: addi s0, sp, 36*4 csrw 0x140, s0 # sscratch = kernel-sp diff --git a/kernel/src/arch/riscv32/context.rs b/kernel/src/arch/riscv32/context.rs index d1a6d61a..0d412989 100644 --- a/kernel/src/arch/riscv32/context.rs +++ b/kernel/src/arch/riscv32/context.rs @@ -30,7 +30,8 @@ impl TrapFrame { tf.x[2] = sp; tf.sepc = entry_addr; tf.sstatus = sstatus::read(); - tf.sstatus.set_spie(false); // Enable interrupt + tf.sstatus.set_spie(true); + tf.sstatus.set_sie(false); tf.sstatus.set_spp(sstatus::SPP::User); tf }