Disable kernel traps before going to userspace
This commit is contained in:
parent
cdd28787ed
commit
597b0b5f25
|
|
@ -77,6 +77,9 @@ impl RawUserContext {
|
|||
/// On return, the context will be reset to the status before the trap.
|
||||
/// Trap reason will be placed at `estat`.
|
||||
pub(in crate::arch) fn run(&mut self) {
|
||||
// Return to userspace with interrupts disabled. Otherwise, interrupts
|
||||
// after switching `SAVE_SCRATCH` will mess up the CPU state.
|
||||
crate::arch::irq::disable_local();
|
||||
unsafe { run_user(self as *mut RawUserContext) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -103,6 +103,9 @@ impl RawUserContext {
|
|||
/// On return, the context will be reset to the status before the trap.
|
||||
/// Trap reason and error code will be placed at `scause` and `stval`.
|
||||
pub(in crate::arch) fn run(&mut self) {
|
||||
// Return to userspace with interrupts disabled. Otherwise, interrupts
|
||||
// after switching `sscratch` will mess up the CPU state.
|
||||
crate::arch::irq::disable_local();
|
||||
unsafe { run_user(self) }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,9 +22,6 @@
|
|||
# extern "sysv64" fn syscall_return(&mut UserContext)
|
||||
.global syscall_return
|
||||
syscall_return:
|
||||
# disable interrupt
|
||||
cli
|
||||
|
||||
# save callee-saved registers
|
||||
push r15
|
||||
push r14
|
||||
|
|
|
|||
|
|
@ -96,6 +96,9 @@ impl RawUserContext {
|
|||
/// If `trap_num` is `0x100`, it will go user by `sysret` (`rcx` and `r11` are dropped),
|
||||
/// otherwise it will use `iret`.
|
||||
pub(in crate::arch) fn run(&mut self) {
|
||||
// Return to userspace with interrupts disabled. Otherwise, interrupts
|
||||
// after executing `swapgs` will mess up the CPU state.
|
||||
crate::arch::irq::disable_local();
|
||||
unsafe {
|
||||
syscall_return(self);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue