git: 334f81f41185 - main - arm64/vmm: Fix translation regime in s2_tlbi_range

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Tue, 22 Sep 2026 13:32:34 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=334f81f411857ad7b3cdeaec20b44316dde01ae8

commit 334f81f411857ad7b3cdeaec20b44316dde01ae8
Author:     Kajetan Puchalski <kajetan.puchalski@arm.com>
AuthorDate: 2026-09-15 16:17:56 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2026-09-18 19:07:49 +0000

    arm64/vmm: Fix translation regime in s2_tlbi_range
    
    s2_tlbi_range under VHE is supposed to clear HCR_EL2.TGE, but it erroneously
    clears an unrelated bit 27 in TCR_EL2 (HWU61). Since HCR_TGE determines which
    translation regime will be used by a tlbi, the instruction targets the
    wrong regime when it is not cleared.
    
    Fix the register accessed by the function to actually clear HCR_EL2.TGE.
    
    Signed-off-by: Kajetan Puchalski <kajetan.puchalski@arm.com>
    Reviewed by:    andrew
    Sponsored by:   Arm Ltd
    Differential Revision:  https://github.com/freebsd/freebsd-src/pull/2435
---
 sys/arm64/vmm/vmm_hyp.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/sys/arm64/vmm/vmm_hyp.c b/sys/arm64/vmm/vmm_hyp.c
index 6eb1208e4fb5..99a5b3728192 100644
--- a/sys/arm64/vmm/vmm_hyp.c
+++ b/sys/arm64/vmm/vmm_hyp.c
@@ -835,7 +835,7 @@ VMM_HYP_FUNC(s2_tlbi_range)(uint64_t vttbr, vm_offset_t sva, vm_offset_t eva,
 	uint64_t end, r, start;
 	uint64_t host_vttbr;
 #ifdef VMM_VHE
-	uint64_t host_tcr;
+	uint64_t host_hcr;
 #endif
 
 	dsb(ishst);
@@ -852,8 +852,8 @@ VMM_HYP_FUNC(s2_tlbi_range)(uint64_t vttbr, vm_offset_t sva, vm_offset_t eva,
 	isb();
 
 #ifdef VMM_VHE
-	host_tcr = READ_SPECIALREG(tcr_el2);
-	WRITE_SPECIALREG(tcr_el2, host_tcr & ~HCR_TGE);
+	host_hcr = READ_SPECIALREG(hcr_el2);
+	WRITE_SPECIALREG(hcr_el2, host_hcr & ~HCR_TGE);
 	isb();
 #endif
 
@@ -882,7 +882,7 @@ VMM_HYP_FUNC(s2_tlbi_range)(uint64_t vttbr, vm_offset_t sva, vm_offset_t eva,
 	isb();
 
 #ifdef VMM_VHE
-	WRITE_SPECIALREG(tcr_el2, host_tcr);
+	WRITE_SPECIALREG(hcr_el2, host_hcr);
 	isb();
 #endif