git: a644aba2da7b - main - riscv: Fence after enabling the MMU in locore
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Nov 2026 16:23:04 UTC
The branch main has been updated by mhorne:
URL: https://cgit.FreeBSD.org/src/commit/?id=a644aba2da7bd41135fae1b9172e1030202838cb
commit a644aba2da7bd41135fae1b9172e1030202838cb
Author: Han Gao <gaohan@iscas.ac.cn>
AuthorDate: 2026-10-31 13:41:43 +0000
Commit: Mitchell Horne <mhorne@FreeBSD.org>
CommitDate: 2026-11-26 16:22:42 +0000
riscv: Fence after enabling the MMU in locore
Writing satp doesn't flush cached translations. If the kernel is entered
with translation already on, the hart may keep using the firmware's
mappings after locore switches page tables if they share an ASID.
Add an sfence.vma after each satp write in locore.
Signed-off-by: Han Gao <gaohan@iscas.ac.cn>
Reviewed by: mhorne
MFC after: 1 week
Pull Request: https://github.com/freebsd/freebsd-src/pull/2522
---
sys/riscv/riscv/locore.S | 3 +++
1 file changed, 3 insertions(+)
diff --git a/sys/riscv/riscv/locore.S b/sys/riscv/riscv/locore.S
index 792a49e6d4b4..d901b2ae5262 100644
--- a/sys/riscv/riscv/locore.S
+++ b/sys/riscv/riscv/locore.S
@@ -230,6 +230,8 @@ pagetables:
or s2, s2, t0
sfence.vma
csrw satp, s2
+ /* Ensure old translations are flushed. */
+ sfence.vma
.align 2
va:
@@ -390,6 +392,7 @@ ENTRY(mpentry)
ld s2, PM_SATP(t2)
sfence.vma
csrw satp, s2
+ sfence.vma
.align 2
mpva: