From f2867b873653dd88d2882f122a28ccace0cb8e7c Mon Sep 17 00:00:00 2001 From: John Baldwin Date: Fri, 22 Nov 2024 13:06:48 -0500 Subject: [PATCH] vmm: Don't trap access to Morello instructions for guests --- sys/arm64/vmm/vmm_reset.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/sys/arm64/vmm/vmm_reset.c b/sys/arm64/vmm/vmm_reset.c index a55c50b2f3dd..bb8867e7fdef 100644 --- a/sys/arm64/vmm/vmm_reset.c +++ b/sys/arm64/vmm/vmm_reset.c @@ -181,6 +181,13 @@ reset_vm_el2_regs(void *vcpu) el2ctx->cptr_el2 = CPTR_E2H_TRAP_ALL | CPTR_E2H_FPEN; else el2ctx->cptr_el2 = CPTR_TRAP_ALL & ~CPTR_TFP; +#if __has_feature(capabilities) + /* Don't trap accesses to capability registers. */ + if (in_vhe()) + el2ctx->cptr_el2 |= CPTR_E2H_CEN; + else + el2ctx->cptr_el2 &= ~CPTR_TC; +#endif el2ctx->cptr_el2 &= ~CPTR_TCPAC; /* * Disable interrupts in the guest. The guest OS will re-enable