aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Johnston <markj@FreeBSD.org>2025-11-12 15:19:07 +0000
committerMark Johnston <markj@FreeBSD.org>2025-11-12 16:44:58 +0000
commitb6f25aca11c98acc49f111f2899ecd4e96c7debd (patch)
tree1743e20b966dde7a922d7d70c42632f35a13bab6
parentac0032344ca256f758a5eeb0fd6089dd647b0496 (diff)
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)
-rw-r--r--sys/arm64/vmm/vmm_arm64.c5
1 files 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: