From d0e3065cededd0ea53a0112e2c748342d0134eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Holz?= Date: Mon, 5 Feb 2024 00:27:13 +0100 Subject: [PATCH] Kernel/riscv64: Don't touch reserved fields of the sstatus CSR in boot.S Multiple fields in sstatus are defined as WPRI "Reserved Writes Preserve Values, Reads Ignore Values", which means we have to preserve their values when writing to other fields in the same CSR. We don't really need to touch any fields except SIE. Interrupts are probably already disabled, but just to be safe, disable them explicitly. --- Kernel/Arch/riscv64/boot.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Kernel/Arch/riscv64/boot.S b/Kernel/Arch/riscv64/boot.S index 39e801555a..e1fbe960db 100644 --- a/Kernel/Arch/riscv64/boot.S +++ b/Kernel/Arch/riscv64/boot.S @@ -16,8 +16,8 @@ start: // Don't touch a0/a1 as we expect those registers to contain the hart ID // and a pointer to the Flattened Fevice Tree. - // Set sstatus to a known state (which includes disabling supervisor interrupts). - csrw sstatus, zero + // Clear sstatus.SIE, which disables all interrupts in supervisor mode. + csrci sstatus, 1 << 1 // Also, disable all interrupts sources and mark them as non-pending. csrw sie, zero