Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/nvmm/x86 Replace the misc[] state by a new compresse...
details: https://anonhg.NetBSD.org/src/rev/febd9f47959a
branches: trunk
changeset: 998060:febd9f47959a
user: maxv <maxv%NetBSD.org@localhost>
date: Sat Apr 06 11:49:53 2019 +0000
description:
Replace the misc[] state by a new compressed nvmm_x64_state_intr structure,
which describes the interruptibility state of the guest.
Add evt_pending, read-only, that allows the virtualizer to know if an event
is pending.
diffstat:
sys/dev/nvmm/x86/nvmm_x86.c | 13 +++++++------
sys/dev/nvmm/x86/nvmm_x86.h | 23 +++++++++++++----------
sys/dev/nvmm/x86/nvmm_x86_svm.c | 31 ++++++++++++++++++-------------
sys/dev/nvmm/x86/nvmm_x86_vmx.c | 32 ++++++++++++++++++--------------
4 files changed, 56 insertions(+), 43 deletions(-)
diffs (truncated from 304 to 300 lines):
diff -r e91085bb7fc1 -r febd9f47959a sys/dev/nvmm/x86/nvmm_x86.c
--- a/sys/dev/nvmm/x86/nvmm_x86.c Sat Apr 06 10:37:57 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86.c Sat Apr 06 11:49:53 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86.c,v 1.5 2019/04/03 19:10:58 maxv Exp $ */
+/* $NetBSD: nvmm_x86.c,v 1.6 2019/04/06 11:49:53 maxv Exp $ */
/*
* Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.5 2019/04/03 19:10:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86.c,v 1.6 2019/04/06 11:49:53 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -213,10 +213,11 @@
[NVMM_X64_MSR_TSC] = 0,
},
- .misc = {
- [NVMM_X64_MISC_INT_SHADOW] = 0,
- [NVMM_X64_MISC_INT_WINDOW_EXIT] = 0,
- [NVMM_X64_MISC_NMI_WINDOW_EXIT] = 0,
+ .intr = {
+ .int_shadow = 0,
+ .int_window_exiting = 0,
+ .nmi_window_exiting = 0,
+ .evt_pending = 0,
},
.fpu = {
diff -r e91085bb7fc1 -r febd9f47959a sys/dev/nvmm/x86/nvmm_x86.h
--- a/sys/dev/nvmm/x86/nvmm_x86.h Sat Apr 06 10:37:57 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86.h Sat Apr 06 11:49:53 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86.h,v 1.10 2019/04/03 19:10:58 maxv Exp $ */
+/* $NetBSD: nvmm_x86.h,v 1.11 2019/04/06 11:49:53 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -98,12 +98,6 @@
#define NVMM_X64_MSR_TSC 10
#define NVMM_X64_NMSR 11
-/* Misc. */
-#define NVMM_X64_MISC_INT_SHADOW 0
-#define NVMM_X64_MISC_INT_WINDOW_EXIT 1
-#define NVMM_X64_MISC_NMI_WINDOW_EXIT 2
-#define NVMM_X64_NMISC 3
-
#ifndef ASM_NVMM
#include <sys/types.h>
@@ -126,12 +120,21 @@
uint64_t base; /* hidden */
};
+struct nvmm_x64_state_intr {
+ uint64_t int_shadow:1;
+ uint64_t int_window_exiting:1;
+ uint64_t nmi_window_exiting:1;
+ uint64_t evt_pending:1;
+ uint64_t rsvd:60;
+};
+
/* VM exit state indexes. */
#define NVMM_X64_EXITSTATE_CR8 0
#define NVMM_X64_EXITSTATE_RFLAGS 1
#define NVMM_X64_EXITSTATE_INT_SHADOW 2
#define NVMM_X64_EXITSTATE_INT_WINDOW_EXIT 3
#define NVMM_X64_EXITSTATE_NMI_WINDOW_EXIT 4
+#define NVMM_X64_EXITSTATE_EVT_PENDING 5
/* Flags. */
#define NVMM_X64_STATE_SEGS 0x01
@@ -139,11 +142,11 @@
#define NVMM_X64_STATE_CRS 0x04
#define NVMM_X64_STATE_DRS 0x08
#define NVMM_X64_STATE_MSRS 0x10
-#define NVMM_X64_STATE_MISC 0x20
+#define NVMM_X64_STATE_INTR 0x20
#define NVMM_X64_STATE_FPU 0x40
#define NVMM_X64_STATE_ALL \
(NVMM_X64_STATE_SEGS | NVMM_X64_STATE_GPRS | NVMM_X64_STATE_CRS | \
- NVMM_X64_STATE_DRS | NVMM_X64_STATE_MSRS | NVMM_X64_STATE_MISC | \
+ NVMM_X64_STATE_DRS | NVMM_X64_STATE_MSRS | NVMM_X64_STATE_INTR | \
NVMM_X64_STATE_FPU)
struct nvmm_x64_state {
@@ -152,7 +155,7 @@
uint64_t crs[NVMM_X64_NCR];
uint64_t drs[NVMM_X64_NDR];
uint64_t msrs[NVMM_X64_NMSR];
- uint64_t misc[NVMM_X64_NMISC];
+ struct nvmm_x64_state_intr intr;
struct fxsave fpu;
};
diff -r e91085bb7fc1 -r febd9f47959a sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c Sat Apr 06 10:37:57 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c Sat Apr 06 11:49:53 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_svm.c,v 1.36 2019/04/03 17:32:58 maxv Exp $ */
+/* $NetBSD: nvmm_x86_svm.c,v 1.37 2019/04/06 11:49:53 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.36 2019/04/03 17:32:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.37 2019/04/06 11:49:53 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -531,9 +531,10 @@
bool ts_set;
struct xsave_header hfpu __aligned(64);
- /* Event state */
+ /* Intr state */
bool int_window_exit;
bool nmi_window_exit;
+ bool evt_pending;
/* Guest state */
uint64_t gxcr0;
@@ -709,6 +710,8 @@
__SHIFTIN(1, VMCB_CTRL_EVENTINJ_V) |
__SHIFTIN(event->u.error, VMCB_CTRL_EVENTINJ_ERRORCODE);
+ cpudata->evt_pending = true;
+
return 0;
}
@@ -1301,6 +1304,7 @@
cpudata->gtsc_want_update = false;
vcpu->hcpu_last = hcpu;
}
+ cpudata->evt_pending = false;
switch (vmcb->ctrl.exitcode) {
case VMCB_EXITCODE_INTR:
@@ -1397,6 +1401,8 @@
cpudata->int_window_exit;
exit->exitstate[NVMM_X64_EXITSTATE_NMI_WINDOW_EXIT] =
cpudata->nmi_window_exit;
+ exit->exitstate[NVMM_X64_EXITSTATE_EVT_PENDING] =
+ cpudata->evt_pending;
return 0;
}
@@ -1655,20 +1661,20 @@
cpudata->gtsc_want_update = true;
}
- if (flags & NVMM_X64_STATE_MISC) {
- if (state->misc[NVMM_X64_MISC_INT_SHADOW]) {
+ if (flags & NVMM_X64_STATE_INTR) {
+ if (state->intr.int_shadow) {
vmcb->ctrl.intr |= VMCB_CTRL_INTR_SHADOW;
} else {
vmcb->ctrl.intr &= ~VMCB_CTRL_INTR_SHADOW;
}
- if (state->misc[NVMM_X64_MISC_INT_WINDOW_EXIT]) {
+ if (state->intr.int_window_exiting) {
svm_event_waitexit_enable(vcpu, false);
} else {
svm_event_waitexit_disable(vcpu, false);
}
- if (state->misc[NVMM_X64_MISC_NMI_WINDOW_EXIT]) {
+ if (state->intr.nmi_window_exiting) {
svm_event_waitexit_enable(vcpu, true);
} else {
svm_event_waitexit_disable(vcpu, true);
@@ -1774,13 +1780,12 @@
state->msrs[NVMM_X64_MSR_EFER] &= ~EFER_SVME;
}
- if (flags & NVMM_X64_STATE_MISC) {
- state->misc[NVMM_X64_MISC_INT_SHADOW] =
+ if (flags & NVMM_X64_STATE_INTR) {
+ state->intr.int_shadow =
(vmcb->ctrl.intr & VMCB_CTRL_INTR_SHADOW) != 0;
- state->misc[NVMM_X64_MISC_INT_WINDOW_EXIT] =
- cpudata->int_window_exit;
- state->misc[NVMM_X64_MISC_NMI_WINDOW_EXIT] =
- cpudata->nmi_window_exit;
+ state->intr.int_window_exiting = cpudata->int_window_exit;
+ state->intr.nmi_window_exiting = cpudata->nmi_window_exit;
+ state->intr.evt_pending = cpudata->evt_pending;
}
CTASSERT(sizeof(cpudata->gfpu.xsh_fxsave) == sizeof(state->fpu));
diff -r e91085bb7fc1 -r febd9f47959a sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sat Apr 06 10:37:57 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sat Apr 06 11:49:53 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_vmx.c,v 1.23 2019/04/03 19:10:58 maxv Exp $ */
+/* $NetBSD: nvmm_x86_vmx.c,v 1.24 2019/04/06 11:49:53 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.23 2019/04/03 19:10:58 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.24 2019/04/06 11:49:53 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -670,9 +670,10 @@
bool ts_set;
struct xsave_header hfpu __aligned(64);
- /* Event state */
+ /* Intr state */
bool int_window_exit;
bool nmi_window_exit;
+ bool evt_pending;
/* Guest state */
struct msr_entry *gmsr;
@@ -995,6 +996,8 @@
vmx_vmwrite(VMCS_ENTRY_INTR_INFO, info);
vmx_vmwrite(VMCS_ENTRY_EXCEPTION_ERROR, event->u.error);
+ cpudata->evt_pending = true;
+
out:
vmx_vmcs_leave(vcpu);
return ret;
@@ -1842,6 +1845,7 @@
exit->reason = NVMM_EXIT_INVALID;
break;
}
+ cpudata->evt_pending = false;
launched = true;
@@ -1951,6 +1955,8 @@
cpudata->int_window_exit;
exit->exitstate[NVMM_X64_EXITSTATE_NMI_WINDOW_EXIT] =
cpudata->nmi_window_exit;
+ exit->exitstate[NVMM_X64_EXITSTATE_EVT_PENDING] =
+ cpudata->evt_pending;
vmx_vmcs_leave(vcpu);
@@ -2231,21 +2237,21 @@
vmx_vmwrite(VMCS_ENTRY_CTLS, ctls1);
}
- if (flags & NVMM_X64_STATE_MISC) {
+ if (flags & NVMM_X64_STATE_INTR) {
vmx_vmread(VMCS_GUEST_INTERRUPTIBILITY, &intstate);
intstate &= ~(INT_STATE_STI|INT_STATE_MOVSS);
- if (state->misc[NVMM_X64_MISC_INT_SHADOW]) {
+ if (state->intr.int_shadow) {
intstate |= INT_STATE_MOVSS;
}
vmx_vmwrite(VMCS_GUEST_INTERRUPTIBILITY, intstate);
- if (state->misc[NVMM_X64_MISC_INT_WINDOW_EXIT]) {
+ if (state->intr.int_window_exiting) {
vmx_event_waitexit_enable(vcpu, false);
} else {
vmx_event_waitexit_disable(vcpu, false);
}
- if (state->misc[NVMM_X64_MISC_NMI_WINDOW_EXIT]) {
+ if (state->intr.nmi_window_exiting) {
vmx_event_waitexit_enable(vcpu, true);
} else {
vmx_event_waitexit_disable(vcpu, true);
@@ -2346,15 +2352,13 @@
state->msrs[NVMM_X64_MSR_TSC] = cpudata->gtsc;
}
- if (flags & NVMM_X64_STATE_MISC) {
+ if (flags & NVMM_X64_STATE_INTR) {
vmx_vmread(VMCS_GUEST_INTERRUPTIBILITY, &intstate);
- state->misc[NVMM_X64_MISC_INT_SHADOW] =
+ state->intr.int_shadow =
(intstate & (INT_STATE_STI|INT_STATE_MOVSS)) != 0;
-
- state->misc[NVMM_X64_MISC_INT_WINDOW_EXIT] =
- cpudata->int_window_exit;
- state->misc[NVMM_X64_MISC_NMI_WINDOW_EXIT] =
- cpudata->nmi_window_exit;
+ state->intr.int_window_exiting = cpudata->int_window_exit;
+ state->intr.nmi_window_exiting = cpudata->nmi_window_exit;
Home |
Main Index |
Thread Index |
Old Index