Index | Thread | Search

From:
ssnf <ssnf@ssnf.xyz>
Subject:
[PATCH] vmd: handle the reset control register at 0xcf9
To:
tech@openbsd.org
Cc:
ssnf <ssnf@ssnf.xyz>
Date:
Sun, 23 Aug 2026 00:28:28 +0000

Download raw body.

Thread
Handle guest writes to the x86 reset control register and terminate
the VM on a reset request.

Tested on a 9front guest with fshalt -r.
---
 usr.sbin/vmd/x86_vm.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/usr.sbin/vmd/x86_vm.c b/usr.sbin/vmd/x86_vm.c
index 1b5ade90f9b..a0197c34b4c 100644
--- a/usr.sbin/vmd/x86_vm.c
+++ b/usr.sbin/vmd/x86_vm.c
@@ -507,6 +507,7 @@ vcpu_exit_inout(struct vm_run_params *vrp)
 int
 vcpu_exit(struct vm_run_params *vrp)
 {
+	struct vm_exit *vei = vrp->vrp_exit;
 	int ret;
 
 	switch (vrp->vrp_exit_reason) {
@@ -533,6 +534,10 @@ vcpu_exit(struct vm_run_params *vrp)
 		break;
 	case VMX_EXIT_IO:
 	case SVM_VMEXIT_IOIO:
+		if (vei->vei.vei_dir == VEI_DIR_OUT &&
+		    vei->vei.vei_port == 0xcf9 &&
+		    (vei->vei.vei_data & 0x06) == 0x06)
+			return (EAGAIN);
 		vcpu_exit_inout(vrp);
 		break;
 	case VMX_EXIT_HLT:
-- 
2.51.0