[PATCH 8/8] lib: sbi_hart: properly reset Ssstateen
Radim Krčmář
rkrcmar at ventanamicro.com
Mon Apr 28 06:44:53 PDT 2025
2025-04-28T18:09:47+05:30, Anup Patel <anup at brainfault.org>:
> On Tue, Apr 15, 2025 at 8:13 PM Radim Krčmář <rkrcmar at ventanamicro.com> wrote:
>>
>> sstateen* and hstateen* CSRs must be zeroed by M-mode if the mstateen*
>> registers are missing, to avoid security issues.
>>
>> Signed-off-by: Radim Krčmář <rkrcmar at ventanamicro.com>
>> ---
>> diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
>> @@ -114,12 +114,22 @@ static void mstatus_init(struct sbi_scratch *scratch)
>> csr_write64(CSR_MSTATEEN1, SMSTATEEN_STATEN);
>> csr_write64(CSR_MSTATEEN2, SMSTATEEN_STATEN);
>> csr_write64(CSR_MSTATEEN3, SMSTATEEN_STATEN);
>> + }
>>
>> - if (misa_extension('S'))
>> + if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SMSTATEEN) ||
>> + sbi_hart_has_extension(scratch, SBI_HART_EXT_SSSTATEEN)) {
>
> This should only check SSSTATEEEN.
Right, Smstateen implies Ssstateen, thanks.
More information about the opensbi
mailing list