From 111738090c6cdf2d852717b3ad15b65e2085d237 Mon Sep 17 00:00:00 2001 From: Andrew Waterman Date: Thu, 27 Nov 2025 16:51:21 +0530 Subject: [PATCH] lib: sbi: Flush TLBs upon FWFT ADUE change 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 Signed-off-by: Anup Patel Link: https://lore.kernel.org/r/20251127112121.334023-3-apatel@ventanamicro.com Signed-off-by: Anup Patel --- 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 #include #include +#include #include #include +#include #include #include @@ -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)