git: 095a7871f432 - main - arm64/vmm: Add HYP_FEAT_FGT{,2}

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Tue, 03 Feb 2026 17:27:49 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=095a7871f4320e7667a644e6e34a27e1f526b053

commit 095a7871f4320e7667a644e6e34a27e1f526b053
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2026-02-03 17:14:26 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2026-02-03 17:14:26 +0000

    arm64/vmm: Add HYP_FEAT_FGT{,2}
    
    Add the macros and detection for Fine-grained traps (FEAT_FGT and
    FEAT_FGT2).
    
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D54686
---
 sys/arm64/vmm/arm64.h     |  2 ++
 sys/arm64/vmm/vmm_arm64.c | 12 ++++++++++++
 2 files changed, 14 insertions(+)

diff --git a/sys/arm64/vmm/arm64.h b/sys/arm64/vmm/arm64.h
index f530dab05331..1b8762545925 100644
--- a/sys/arm64/vmm/arm64.h
+++ b/sys/arm64/vmm/arm64.h
@@ -131,6 +131,8 @@ struct hyp {
 	uint64_t	feats;		/* Which features are enabled */
 #define	HYP_FEAT_HCX		(0x1ul << 0)
 #define	HYP_FEAT_ECV_POFF	(0x1ul << 1)
+#define	HYP_FEAT_FGT		(0x1ul << 2)
+#define	HYP_FEAT_FGT2		(0x1ul << 3)
 	bool		vgic_attached;
 	struct vgic_v3	*vgic;
 	struct hypctx	*ctx[];
diff --git a/sys/arm64/vmm/vmm_arm64.c b/sys/arm64/vmm/vmm_arm64.c
index d529f000b828..6643d32684d8 100644
--- a/sys/arm64/vmm/vmm_arm64.c
+++ b/sys/arm64/vmm/vmm_arm64.c
@@ -525,6 +525,18 @@ vmmops_init(struct vm *vm, pmap_t pmap)
 	if (get_kernel_reg(ID_AA64MMFR0_EL1, &idreg)) {
 		if (ID_AA64MMFR0_ECV_VAL(idreg) >= ID_AA64MMFR0_ECV_POFF)
 			hyp->feats |= HYP_FEAT_ECV_POFF;
+
+		switch (ID_AA64MMFR0_FGT_VAL(idreg)) {
+		case ID_AA64MMFR0_FGT_NONE:
+			break;
+		default:
+		case ID_AA64MMFR0_FGT_8_9:
+			hyp->feats |= HYP_FEAT_FGT2;
+			/* FALLTHROUGH */
+		case ID_AA64MMFR0_FGT_8_6:
+			hyp->feats |= HYP_FEAT_FGT;
+			break;
+		}
 	}
 
 	if (get_kernel_reg(ID_AA64MMFR1_EL1, &idreg)) {