diff options
| author | Andrew Waterman <[email protected]> | 2025-11-27 16:51:21 +0530 |
|---|---|---|
| committer | Anup Patel <[email protected]> | 2025-12-16 20:19:21 +0530 |
| commit | 111738090c6cdf2d852717b3ad15b65e2085d237 (patch) | |
| tree | 83cf3441941caec45f43c8e0e15253369ab40fe3 /lib | |
| parent | 843e916dcab4163e84bab9a22ef2db89ff269979 (diff) | |
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 <[email protected]>
Signed-off-by: Anup Patel <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Anup Patel <[email protected]>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/sbi/sbi_fwft.c | 13 |
1 files changed, 12 insertions, 1 deletions
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) |
