From: Anup Patel <apatel@ventanamicro.com>
To: Atish Patra <atishp@rivosinc.com>
Cc: Andrew Jones <ajones@ventanamicro.com>,
Anup Patel <anup@brainfault.org>,
opensbi@lists.infradead.org, Andrew Waterman <andrew@sifive.com>,
Anup Patel <apatel@ventanamicro.com>
Subject: [PATCH 2/2] lib: sbi: Flush TLBs upon FWFT ADUE change
Date: Thu, 27 Nov 2025 16:51:21 +0530 [thread overview]
Message-ID: <20251127112121.334023-3-apatel@ventanamicro.com> (raw)
In-Reply-To: <20251127112121.334023-1-apatel@ventanamicro.com>
From: Andrew Waterman <andrew@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@sifive.com>
Signed-off-by: Anup Patel <apatel@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
--
opensbi mailing list
opensbi@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
next prev parent reply other threads:[~2025-11-27 11:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-27 11:21 [PATCH 0/2] OpenSBI FWFT ADUE update fix Anup Patel
2025-11-27 11:21 ` [PATCH 1/2] lib: sbi: Expose __sbi_sfence_vma_all() function Anup Patel
2025-11-27 11:21 ` Anup Patel [this message]
2025-12-16 14:55 ` [PATCH 0/2] OpenSBI FWFT ADUE update fix Anup Patel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251127112121.334023-3-apatel@ventanamicro.com \
--to=apatel@ventanamicro.com \
--cc=ajones@ventanamicro.com \
--cc=andrew@sifive.com \
--cc=anup@brainfault.org \
--cc=atishp@rivosinc.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox