Provide the hardware error code for NVMM_EXIT_INVALID, useful when

debugging.
This commit is contained in:
maxv 2019-04-24 18:19:28 +00:00
parent f8f9f44113
commit 9019e1da46
3 changed files with 26 additions and 7 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: nvmm.h,v 1.5 2019/03/21 20:21:40 maxv Exp $ */
/* $NetBSD: nvmm.h,v 1.6 2019/04/24 18:19:28 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@ -103,6 +103,10 @@ struct nvmm_exit_insn {
uint64_t npc;
};
struct nvmm_exit_invalid {
uint64_t hwcode;
};
struct nvmm_exit {
enum nvmm_exit_reason reason;
union {
@ -110,6 +114,7 @@ struct nvmm_exit {
struct nvmm_exit_io io;
struct nvmm_exit_msr msr;
struct nvmm_exit_insn insn;
struct nvmm_exit_invalid inv;
} u;
uint64_t exitstate[8];
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: nvmm_x86_svm.c,v 1.39 2019/04/20 08:45:30 maxv Exp $ */
/* $NetBSD: nvmm_x86_svm.c,v 1.40 2019/04/24 18:19:28 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.39 2019/04/20 08:45:30 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.40 2019/04/24 18:19:28 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1118,6 +1118,13 @@ error:
svm_inject_gp(mach, vcpu);
}
static void
svm_exit_invalid(struct nvmm_exit *exit, uint64_t code)
{
exit->u.inv.hwcode = code;
exit->reason = NVMM_EXIT_INVALID;
}
/* -------------------------------------------------------------------------- */
static void
@ -1364,7 +1371,7 @@ svm_vcpu_run(struct nvmm_machine *mach, struct nvmm_cpu *vcpu,
break;
case VMCB_EXITCODE_FERR_FREEZE: /* ? */
default:
exit->reason = NVMM_EXIT_INVALID;
svm_exit_invalid(exit, vmcb->ctrl.exitcode);
break;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: nvmm_x86_vmx.c,v 1.26 2019/04/20 08:45:30 maxv Exp $ */
/* $NetBSD: nvmm_x86_vmx.c,v 1.27 2019/04/24 18:19:28 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.26 2019/04/20 08:45:30 maxv Exp $");
__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.27 2019/04/24 18:19:28 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1623,6 +1623,13 @@ vmx_exit_epf(struct nvmm_machine *mach, struct nvmm_cpu *vcpu,
exit->u.mem.inst_len = 0;
}
static void
vmx_exit_invalid(struct nvmm_exit *exit, uint64_t code)
{
exit->u.inv.hwcode = code;
exit->reason = NVMM_EXIT_INVALID;
}
/* -------------------------------------------------------------------------- */
static void
@ -1917,7 +1924,7 @@ vmx_vcpu_run(struct nvmm_machine *mach, struct nvmm_cpu *vcpu,
exit->reason = NVMM_EXIT_NMI_READY;
break;
default:
exit->reason = NVMM_EXIT_INVALID;
vmx_exit_invalid(exit, exitcode);
break;
}