mirror of
https://github.com/riscv-software-src/opensbi.git
synced 2025-08-24 15:31:22 +01:00
lib: sbi_hart: reset sstateen and hstateen
Not resetting sstateen is a potential security hole, because U might be able to access state that S does not properly context-switch. Similar for hstateen with VS and HS. Reviewed-by: Anup Patel <anup@brainfault.org> Signed-off-by: Radim Krčmář <rkrcmar@ventanamicro.com> Link: https://lore.kernel.org/r/20250429142549.3673976-6-rkrcmar@ventanamicro.com Signed-off-by: Anup Patel <anup@brainfault.org>
This commit is contained in:
@@ -111,6 +111,12 @@ static void mstatus_init(struct sbi_scratch *scratch)
|
|||||||
mstateen_val &= ~SMSTATEEN0_CTR;
|
mstateen_val &= ~SMSTATEEN0_CTR;
|
||||||
|
|
||||||
csr_write64(CSR_MSTATEEN0, mstateen_val);
|
csr_write64(CSR_MSTATEEN0, mstateen_val);
|
||||||
|
|
||||||
|
if (misa_extension('S'))
|
||||||
|
csr_write(CSR_SSTATEEN0, 0);
|
||||||
|
|
||||||
|
if (misa_extension('H'))
|
||||||
|
csr_write64(CSR_HSTATEEN0, (uint64_t)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_12) {
|
if (sbi_hart_priv_version(scratch) >= SBI_HART_PRIV_VER_1_12) {
|
||||||
|
Reference in New Issue
Block a user