Always set hwcode on error. Useful for debugging. trunk
authormaxv <maxv@NetBSD.org>
Fri, 13 Sep 2019 14:19:13 +0000
branchtrunk
changeset 454330 029f0939d2ef
parent 454329 c7b69021d966
child 454331 661d910e0fd7
Always set hwcode on error. Useful for debugging.
sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Fri Sep 13 14:01:33 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c	Fri Sep 13 14:19:13 2019 +0000
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_vmx.c,v 1.36 2019/06/16 18:30:31 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_vmx.c,v 1.37 2019/09/13 14:19:13 maxv Exp $	*/
 
 /*
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.36 2019/06/16 18:30:31 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.37 2019/09/13 14:19:13 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1106,6 +1106,13 @@
 }
 
 static void
+vmx_exit_invalid(struct nvmm_exit *exit, uint64_t code)
+{
+	exit->u.inv.hwcode = code;
+	exit->reason = NVMM_EXIT_INVALID;
+}
+
+static void
 vmx_exit_exc_nmi(struct nvmm_machine *mach, struct nvmm_cpu *vcpu,
     struct nvmm_exit *exit)
 {
@@ -1124,7 +1131,7 @@
 	return;
 
 error:
-	exit->reason = NVMM_EXIT_INVALID;
+	vmx_exit_invalid(exit, VMCS_EXITCODE_EXC_NMI);
 }
 
 static void
@@ -1689,13 +1696,6 @@
 	    NVMM_X64_STATE_CRS | NVMM_X64_STATE_MSRS);
 }
 
-static void
-vmx_exit_invalid(struct nvmm_exit *exit, uint64_t code)
-{
-	exit->u.inv.hwcode = code;
-	exit->reason = NVMM_EXIT_INVALID;
-}
-
 /* -------------------------------------------------------------------------- */
 
 static void
@@ -1940,7 +1940,7 @@
 		splx(s);
 
 		if (__predict_false(ret != 0)) {
-			exit->reason = NVMM_EXIT_INVALID;
+			vmx_exit_invalid(exit, -1);
 			break;
 		}
 		vmx_exit_evt(cpudata);