* [PATCH] lib: sbi: Disable hw a/d updating by default
@ 2025-03-14 10:33 Andrew Jones
2026-04-01 22:12 ` Andrew Jones
0 siblings, 1 reply; 2+ messages in thread
From: Andrew Jones @ 2025-03-14 10:33 UTC (permalink / raw)
To: opensbi
SBI FWFT specifies zero for PTE_AD_HW_UPDATING's reset value, so
ensure ENVCFG_ADUE is cleared on init. S-mode will use SBI FWFT
to set it when desired.
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
---
This issue was found with kvm-unit-tests SBI FWFT tests.
lib/sbi/sbi_hart.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/lib/sbi/sbi_hart.c b/lib/sbi/sbi_hart.c
index 8e2979b54586..5c649b781724 100644
--- a/lib/sbi/sbi_hart.c
+++ b/lib/sbi/sbi_hart.c
@@ -117,6 +117,9 @@ static void mstatus_init(struct sbi_scratch *scratch)
menvcfg_val |= ((uint64_t)csr_read(CSR_MENVCFGH)) << 32;
#endif
+ /* Disable HW A/D updating by default */
+ menvcfg_val &= ~ENVCFG_ADUE;
+
/* Disable double trap by default */
menvcfg_val &= ~ENVCFG_DTE;
@@ -138,19 +141,9 @@ static void mstatus_init(struct sbi_scratch *scratch)
#endif
__set_menvcfg_ext(SBI_HART_EXT_SSTC, ENVCFG_STCE)
__set_menvcfg_ext(SBI_HART_EXT_SMCDELEG, ENVCFG_CDE);
- __set_menvcfg_ext(SBI_HART_EXT_SVADU, ENVCFG_ADUE);
#undef __set_menvcfg_ext
- /*
- * When both Svade and Svadu are present in DT, the default scheme for managing
- * the PTE A/D bits should use Svade. Check Svadu before Svade extension to ensure
- * that the ADUE bit is cleared when the Svade support are specified.
- */
-
- if (sbi_hart_has_extension(scratch, SBI_HART_EXT_SVADE))
- menvcfg_val &= ~ENVCFG_ADUE;
-
csr_write(CSR_MENVCFG, menvcfg_val);
#if __riscv_xlen == 32
csr_write(CSR_MENVCFGH, menvcfg_val >> 32);
--
2.48.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] lib: sbi: Disable hw a/d updating by default
2025-03-14 10:33 [PATCH] lib: sbi: Disable hw a/d updating by default Andrew Jones
@ 2026-04-01 22:12 ` Andrew Jones
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Jones @ 2026-04-01 22:12 UTC (permalink / raw)
To: Andrew Jones; +Cc: opensbi
On Fri, Mar 14, 2025 at 11:33:02AM +0100, Andrew Jones wrote:
> SBI FWFT specifies zero for PTE_AD_HW_UPDATING's reset value, so
> ensure ENVCFG_ADUE is cleared on init. S-mode will use SBI FWFT
> to set it when desired.
>
> Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
> ---
>
Self-nacking. I've just sent an improved patch.
https://lore.kernel.org/opensbi/20260401220845.190680-1-andrew.jones@oss.qualcomm.com/
Thanks,
drew
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-04-01 22:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-14 10:33 [PATCH] lib: sbi: Disable hw a/d updating by default Andrew Jones
2026-04-01 22:12 ` Andrew Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox