[PATCH] vmd: handle the reset control register at 0xcf9

ssnf <[email protected]>
Newsgroups gmane.os.openbsd.tech
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.