Skip to content

Commit

Permalink
fix(riscv64): use sstatus instead of mstatus
Browse files Browse the repository at this point in the history
Operating systems typically run at Supervisor privilege level without
access to machine-mode registers.

Signed-off-by: Martin Kröning <martin.kroening@eonerc.rwth-aachen.de>
  • Loading branch information
mkroening committed Nov 2, 2023
1 parent c512ffc commit d3a3d7c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/imp/riscv64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ pub fn read_disable() -> Flags {
asm!(
// Atomic Read and Clear Immediate Bits in CSR
// `csrx rd, csr, rs1`
// Set SIE and MIE
"csrrci {rd}, mstatus, 0b1010",
// Set SIE
"csrrci {rd}, sstatus, 0b10",
rd = out(reg) flags,
// Omit `nomem` to imitate a lock acquire.
// Otherwise, the compiler is free to move
Expand All @@ -26,7 +26,7 @@ pub fn restore(flags: Flags) {
unsafe {
asm!(
// Atomic Set Bits in CSR
"csrs mstatus, {rs1}",
"csrs sstatus, {rs1}",
rs1 = in(reg) flags,
// Omit `nomem` to imitate a lock release.
// Otherwise, the compiler is free to move
Expand Down

0 comments on commit d3a3d7c

Please sign in to comment.