git: d54631360276 - main - arm64: Add CPTR_TRAP_ALL and use it in vmm
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 11 Sep 2024 10:42:06 UTC
The branch main has been updated by andrew:
URL: https://cgit.FreeBSD.org/src/commit/?id=d54631360276d3fdbaa9a7872f8af82f1f4287da
commit d54631360276d3fdbaa9a7872f8af82f1f4287da
Author: Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-09-11 09:38:27 +0000
Commit: Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-09-11 10:25:09 +0000
arm64: Add CPTR_TRAP_ALL and use it in vmm
Add a new macro that enables all CPTR_EL2 traps. This helps ensure we
trap all extensions we don't support.
Sponsored by: Arm Ltd
Differential Revision: https://reviews.freebsd.org/D46516
---
sys/arm64/include/hypervisor.h | 2 ++
sys/arm64/vmm/vmm_reset.c | 5 +++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/sys/arm64/include/hypervisor.h b/sys/arm64/include/hypervisor.h
index 738eeca66ffe..0a138006b108 100644
--- a/sys/arm64/include/hypervisor.h
+++ b/sys/arm64/include/hypervisor.h
@@ -53,11 +53,13 @@
/* CPTR_EL2 - Architecture feature trap register */
/* Valid if HCR_EL2.E2H == 0 */
+#define CPTR_TRAP_ALL 0xc01037ff /* Enable all traps */
#define CPTR_RES0 0x7fefc800
#define CPTR_RES1 0x000033ff
#define CPTR_TFP 0x00000400
#define CPTR_TTA 0x00100000
/* Valid if HCR_EL2.E2H == 1 */
+#define CPTR_E2H_TRAP_ALL 0xd0000000
#define CPTR_E2H_FPEN 0x00300000
#define CPTR_E2H_TTA 0x10000000
/* Unconditionally valid */
diff --git a/sys/arm64/vmm/vmm_reset.c b/sys/arm64/vmm/vmm_reset.c
index 3195bc10dedd..8ccb83e7a0ea 100644
--- a/sys/arm64/vmm/vmm_reset.c
+++ b/sys/arm64/vmm/vmm_reset.c
@@ -170,9 +170,10 @@ reset_vm_el2_regs(void *vcpu)
* and floating point functionality to EL2.
*/
if (in_vhe())
- el2ctx->cptr_el2 = CPACR_FPEN_TRAP_NONE;
+ el2ctx->cptr_el2 = CPTR_E2H_TRAP_ALL | CPTR_E2H_FPEN;
else
- el2ctx->cptr_el2 = CPTR_RES1;
+ el2ctx->cptr_el2 = CPTR_TRAP_ALL & ~CPTR_TFP;
+ el2ctx->cptr_el2 &= ~CPTR_TCPAC;
/*
* Disable interrupts in the guest. The guest OS will re-enable
* them.