From: Mike Larkin Subject: Re: [PATCH] vmd: handle the reset control register at 0xcf9 To: ssnf Cc: tech@openbsd.org Date: Tue, 25 Aug 2026 11:47:57 -0700 On Sun, Aug 23, 2026 at 12:28:28AM +0000, ssnf wrote: > 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 > I am not opposed to the general idea of supporting this register, but I would ask for the following changes: 1. move the checks above into vcpu_exit_inout ; that function is where in/out instruction emulation is done, not directly in the vcpu_exit handler. make vcpu_exit_inout return a value, and you can return EAGAIN there and pass it up the chain like you are doing above. 2. use #defines for 0xcf9 and whatever 0x06 means Happy to take a look again if those changes are made. Thx!