git: b6f25aca11c9 - main - arm64/vmm: Fix handling of MDCR_EL2.TDE
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 12 Nov 2025 16:52:51 UTC
The branch main has been updated by markj:
URL: https://cgit.FreeBSD.org/src/commit/?id=b6f25aca11c98acc49f111f2899ecd4e96c7debd
commit b6f25aca11c98acc49f111f2899ecd4e96c7debd
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-11-12 15:19:07 +0000
Commit: Mark Johnston <markj@FreeBSD.org>
CommitDate: 2025-11-12 16:44:58 +0000
arm64/vmm: Fix handling of MDCR_EL2.TDE
TDE (make EL2 the target EL for debug exceptions) is set both when
setting guest breakpoints and when single-stepping the guest. In some
cases we may configure both capabilities, and when subsequently
disabling one of them we need to take care to avoid clearing TDE if the
other is still configured.
MFC after: 3 days
Fixes: 75cb949228bb ("arm64/vmm: Add breakpoint and single-stepping support")
Sponsored by: CHERI Research Centre (EPSRC grant UKRI3001)
---
sys/arm64/vmm/vmm_arm64.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sys/arm64/vmm/vmm_arm64.c b/sys/arm64/vmm/vmm_arm64.c
index 991b0d2bc345..aa1361049f49 100644
--- a/sys/arm64/vmm/vmm_arm64.c
+++ b/sys/arm64/vmm/vmm_arm64.c
@@ -1364,7 +1364,7 @@ vmmops_setcap(void *vcpui, int num, int val)
break;
if (val != 0)
hypctx->mdcr_el2 |= MDCR_EL2_TDE;
- else
+ else if ((hypctx->setcaps & (1ul << VM_CAP_SS_EXIT)) == 0)
hypctx->mdcr_el2 &= ~MDCR_EL2_TDE;
break;
case VM_CAP_SS_EXIT:
@@ -1385,7 +1385,8 @@ vmmops_setcap(void *vcpui, int num, int val)
hypctx->mdscr_el1 &= ~MDSCR_SS;
hypctx->mdscr_el1 |= hypctx->debug_mdscr;
hypctx->debug_mdscr &= ~MDSCR_SS;
- hypctx->mdcr_el2 &= ~MDCR_EL2_TDE;
+ if ((hypctx->setcaps & (1ul << VM_CAP_BRK_EXIT)) == 0)
+ hypctx->mdcr_el2 &= ~MDCR_EL2_TDE;
}
break;
case VM_CAP_MASK_HWINTR: