From 8732c71624623210e9e8217b22269e93892f230f Mon Sep 17 00:00:00 2001 From: dv Date: Fri, 13 May 2022 18:19:32 +0000 Subject: [PATCH] vmm: add additional fault type, fixing vm receive After vmm(4)/vmd(8) "receive" a vm via vmctl(8), vmd on Intel hosts was incorrectly identifying the fault type for nested page fault exits and resetting the vm. This commit adds a new fault type to signify the page fault was serviced in vmm and any exit to userland does not require an assist. ok mlarkin@ --- sys/arch/amd64/amd64/vmm.c | 12 +++++++----- sys/arch/amd64/include/vmmvar.h | 5 +++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/sys/arch/amd64/amd64/vmm.c b/sys/arch/amd64/amd64/vmm.c index 090feb6623a..2784aaf654f 100644 --- a/sys/arch/amd64/amd64/vmm.c +++ b/sys/arch/amd64/amd64/vmm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vmm.c,v 1.308 2022/05/04 02:24:26 dv Exp $ */ +/* $OpenBSD: vmm.c,v 1.309 2022/05/13 18:19:32 dv Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -5732,14 +5732,16 @@ vmx_fault_page(struct vcpu *vcpu, paddr_t gpa) int fault_type, ret; fault_type = vmx_get_guest_faulttype(); - if (fault_type == -1) { + switch (fault_type) { + case -1: printf("%s: invalid fault type\n", __func__); return (EINVAL); - } - - if (fault_type == VM_FAULT_PROTECT) { + case VM_FAULT_PROTECT: vcpu->vc_exit.vee.vee_fault_type = VEE_FAULT_PROTECT; return (EAGAIN); + default: + vcpu->vc_exit.vee.vee_fault_type = VEE_FAULT_HANDLED; + break; } /* We may sleep during uvm_fault(9), so reload VMCS. */ diff --git a/sys/arch/amd64/include/vmmvar.h b/sys/arch/amd64/include/vmmvar.h index f798674dd0f..42b811a2e42 100644 --- a/sys/arch/amd64/include/vmmvar.h +++ b/sys/arch/amd64/include/vmmvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: vmmvar.h,v 1.75 2022/05/03 21:39:19 dv Exp $ */ +/* $OpenBSD: vmmvar.h,v 1.76 2022/05/13 18:19:32 dv Exp $ */ /* * Copyright (c) 2014 Mike Larkin * @@ -324,7 +324,8 @@ enum { }; enum { - VEE_FAULT_PROTECT + VEE_FAULT_HANDLED, + VEE_FAULT_PROTECT, }; enum { -- 2.20.1