Fix user process bug on RV32.

Set sstatus.SIE = 0 on the initial TrapFrame, to prevent interrupt on switching.
master
WangRunji 6 years ago
parent 6fc23e1134
commit ed20aa45fd

@ -62,7 +62,7 @@ _save_context:
lw s1, 32*4(sp) # s1 = sstatus lw s1, 32*4(sp) # s1 = sstatus
lw s2, 33*4(sp) # s2 = sepc lw s2, 33*4(sp) # s2 = sepc
andi s0, s1, 1 << 8 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: _save_kernel_sp:
addi s0, sp, 36*4 addi s0, sp, 36*4
csrw 0x140, s0 # sscratch = kernel-sp csrw 0x140, s0 # sscratch = kernel-sp

@ -30,7 +30,8 @@ impl TrapFrame {
tf.x[2] = sp; tf.x[2] = sp;
tf.sepc = entry_addr; tf.sepc = entry_addr;
tf.sstatus = sstatus::read(); 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.sstatus.set_spp(sstatus::SPP::User);
tf tf
} }

Loading…
Cancel
Save