git: 05704402ac85 - main - bhyve: Add a stub VM_EXITCODE_REG_EMUL handler

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 04 Jun 2024 20:06:33 UTC
The branch main has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=05704402ac85e0864eda63cecc20eb7810ecb503

commit 05704402ac85e0864eda63cecc20eb7810ecb503
Author:     Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2024-06-04 19:06:42 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2024-06-04 19:06:42 +0000

    bhyve: Add a stub VM_EXITCODE_REG_EMUL handler
    
    This lets us print a few fields of interest before aborting the VM loop.
    
    No functional change intended.
    
    Reviewed by:    corvink, andrew
    Sponsored by:   Innovate UK
    Differential Revision:  https://reviews.freebsd.org/D44741
---
 usr.sbin/bhyve/aarch64/vmexit.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/usr.sbin/bhyve/aarch64/vmexit.c b/usr.sbin/bhyve/aarch64/vmexit.c
index 03fc2f8b21e3..a47df27e54fc 100644
--- a/usr.sbin/bhyve/aarch64/vmexit.c
+++ b/usr.sbin/bhyve/aarch64/vmexit.c
@@ -84,6 +84,21 @@ fail:
 	return (VMEXIT_ABORT);
 }
 
+static int
+vmexit_reg_emul(struct vmctx *ctx __unused, struct vcpu *vcpu __unused,
+    struct vm_run *vmrun)
+{
+	struct vm_exit *vme;
+	struct vre *vre;
+
+	vme = vmrun->vm_exit;
+	vre = &vme->u.reg_emul.vre;
+
+	EPRINTLN("Unhandled register access: pc %#lx syndrome %#x reg %d\n",
+	    vme->pc, vre->inst_syndrome, vre->reg);
+	return (VMEXIT_ABORT);
+}
+
 static int
 vmexit_suspend(struct vmctx *ctx, struct vcpu *vcpu, struct vm_run *vmrun)
 {
@@ -269,6 +284,7 @@ vmexit_ss(struct vmctx *ctx __unused, struct vcpu *vcpu, struct vm_run *vmrun)
 const vmexit_handler_t vmexit_handlers[VM_EXITCODE_MAX] = {
 	[VM_EXITCODE_BOGUS]  = vmexit_bogus,
 	[VM_EXITCODE_INST_EMUL] = vmexit_inst_emul,
+	[VM_EXITCODE_REG_EMUL] = vmexit_reg_emul,
 	[VM_EXITCODE_SUSPENDED] = vmexit_suspend,
 	[VM_EXITCODE_DEBUG] = vmexit_debug,
 	[VM_EXITCODE_SMCCC] = vmexit_smccc,