1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-27 02:03:29 +04:00

Fix user process bug on RV32.

Set sstatus.SIE = 0 on the initial TrapFrame, to prevent interrupt on switching.
This commit is contained in:
WangRunji 2018-11-01 19:53:30 +08:00
parent 6fc23e1134
commit ed20aa45fd
2 changed files with 3 additions and 2 deletions

View File

@ -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

View File

@ -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
} }