[PATCH 2/2] lib: sbi: Flush TLBs upon FWFT ADUE change
Anup Patel
apatel at ventanamicro.com
Thu Nov 27 03:21:21 PST 2025
From: Andrew Waterman <andrew at sifive.com>
A clarification has been added to the RISC-V privileged specification
regarding synchronization requirements when xenvcfg.ADUE changes.
(Refer, the following commit in the RISC-V Privileged ISA spec
https://github.com/riscv/riscv-isa-manual/commit/4e540263db8ae3a27d132a1752cc0fad222facd8)
As-per these requirements, the SBI FWFT ADUE implementation must
flush TLBs upon changes in ADUE state on a hart.
Signed-off-by: Andrew Waterman <andrew at sifive.com>
Signed-off-by: Anup Patel <apatel at ventanamicro.com>
---
lib/sbi/sbi_fwft.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/lib/sbi/sbi_fwft.c b/lib/sbi/sbi_fwft.c
index a2aefb9a..373140b7 100644
--- a/lib/sbi/sbi_fwft.c
+++ b/lib/sbi/sbi_fwft.c
@@ -13,8 +13,10 @@
#include <sbi/sbi_error.h>
#include <sbi/sbi_hart.h>
#include <sbi/sbi_heap.h>
+#include <sbi/sbi_hfence.h>
#include <sbi/sbi_scratch.h>
#include <sbi/sbi_string.h>
+#include <sbi/sbi_tlb.h>
#include <sbi/sbi_types.h>
#include <sbi/riscv_asm.h>
@@ -167,7 +169,16 @@ static int fwft_adue_supported(struct fwft_config *conf)
static int fwft_set_adue(struct fwft_config *conf, unsigned long value)
{
- return fwft_menvcfg_set_bit(value, ENVCFG_ADUE_SHIFT);
+ int res = fwft_menvcfg_set_bit(value, ENVCFG_ADUE_SHIFT);
+
+ if (res == SBI_OK) {
+ __sbi_sfence_vma_all();
+
+ if (misa_extension('H'))
+ __sbi_hfence_gvma_all();
+ }
+
+ return res;
}
static int fwft_get_adue(struct fwft_config *conf, unsigned long *value)
--
2.43.0
More information about the opensbi
mailing list