mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: sbi_hart: reset hstatus
hstatus.HU must be cleared, because U-mode could otherwise use the HLS/HSV instructions. This would allow U-mode to read physical memory directly if vgatp and vsatp was 0. The remaining fields don't seem like a security vulnerability now, but clearing the whole CSR is not an issue, so do that be safe. Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com> Link: https://lore.kernel.org/r/20250429142549.3673976-5-rkrcmar@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -85,6 +85,9 @@ static void mstatus_init(struct sbi_scratch *scratch)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (misa_extension('H'))
|
||||||
|
csr_write(CSR_HSTATUS, 0);
|
||||||
|
|
||||||
if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMSTATEEN)) {
|
if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMSTATEEN)) {
|
||||||
mstateen_val = csr_read64(CSR_MSTATEEN0);
|
mstateen_val = csr_read64(CSR_MSTATEEN0);
|
||||||
mstateen_val |= SMSTATEEN_STATEN;
|
mstateen_val |= SMSTATEEN_STATEN;
|
||||||
|
Reference in New Issue
Block a user