Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src A few changes:
details: https://anonhg.NetBSD.org/src/rev/8a62adf16638
branches: trunk
changeset: 846009:8a62adf16638
user: maxv <maxv%NetBSD.org@localhost>
date: Mon Oct 28 08:30:49 2019 +0000
description:
A few changes:
- Use smaller types in struct nvmm_capability.
- Use smaller type for nvmm_io.port.
- Switch exitstate to a compacted structure.
diffstat:
lib/libnvmm/libnvmm.3 | 10 ++++++----
lib/libnvmm/nvmm.h | 4 ++--
sys/dev/nvmm/nvmm.h | 10 +++++-----
sys/dev/nvmm/x86/nvmm_x86.h | 22 +++++++++++-----------
sys/dev/nvmm/x86/nvmm_x86_svm.c | 21 ++++++++-------------
sys/dev/nvmm/x86/nvmm_x86_vmx.c | 20 ++++++++------------
6 files changed, 40 insertions(+), 47 deletions(-)
diffs (216 lines):
diff -r 4c91c5de0515 -r 8a62adf16638 lib/libnvmm/libnvmm.3
--- a/lib/libnvmm/libnvmm.3 Mon Oct 28 06:37:51 2019 +0000
+++ b/lib/libnvmm/libnvmm.3 Mon Oct 28 08:30:49 2019 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: libnvmm.3,v 1.22 2019/10/27 10:28:55 maxv Exp $
+.\" $NetBSD: libnvmm.3,v 1.23 2019/10/28 08:30:49 maxv Exp $
.\"
.\" Copyright (c) 2018, 2019 The NetBSD Foundation, Inc.
.\" All rights reserved.
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd October 27, 2019
+.Dd October 28, 2019
.Dt LIBNVMM 3
.Os
.Sh NAME
@@ -502,7 +502,9 @@
union {
...
} u;
- uint64_t exitstate[8];
+ struct {
+ ...
+ } exitstate;
};
.Ed
.Pp
@@ -611,7 +613,7 @@
struct nvmm_io {
struct nvmm_machine *mach;
struct nvmm_vcpu *vcpu;
- uint64_t port;
+ uint16_t port;
bool in;
size_t size;
uint8_t *data;
diff -r 4c91c5de0515 -r 8a62adf16638 lib/libnvmm/nvmm.h
--- a/lib/libnvmm/nvmm.h Mon Oct 28 06:37:51 2019 +0000
+++ b/lib/libnvmm/nvmm.h Mon Oct 28 08:30:49 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm.h,v 1.16 2019/10/27 20:17:36 maxv Exp $ */
+/* $NetBSD: nvmm.h,v 1.17 2019/10/28 08:30:49 maxv Exp $ */
/*
* Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -65,7 +65,7 @@
struct nvmm_io {
struct nvmm_machine *mach;
struct nvmm_vcpu *vcpu;
- uint64_t port;
+ uint16_t port;
bool in;
size_t size;
uint8_t *data;
diff -r 4c91c5de0515 -r 8a62adf16638 sys/dev/nvmm/nvmm.h
--- a/sys/dev/nvmm/nvmm.h Mon Oct 28 06:37:51 2019 +0000
+++ b/sys/dev/nvmm/nvmm.h Mon Oct 28 08:30:49 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm.h,v 1.11 2019/10/23 07:01:11 maxv Exp $ */
+/* $NetBSD: nvmm.h,v 1.12 2019/10/28 08:30:49 maxv Exp $ */
/*
* Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -51,10 +51,10 @@
#define NVMM_KERN_VERSION 1
struct nvmm_capability {
- uint64_t version;
- uint64_t state_size;
- uint64_t max_machines;
- uint64_t max_vcpus;
+ uint32_t version;
+ uint32_t state_size;
+ uint32_t max_machines;
+ uint32_t max_vcpus;
uint64_t max_ram;
struct nvmm_cap_md arch;
};
diff -r 4c91c5de0515 -r 8a62adf16638 sys/dev/nvmm/x86/nvmm_x86.h
--- a/sys/dev/nvmm/x86/nvmm_x86.h Mon Oct 28 06:37:51 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86.h Mon Oct 28 08:30:49 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86.h,v 1.17 2019/10/27 10:28:55 maxv Exp $ */
+/* $NetBSD: nvmm_x86.h,v 1.18 2019/10/28 08:30:49 maxv Exp $ */
/*
* Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -102,7 +102,15 @@
struct nvmm_x86_exit_insn insn;
struct nvmm_x86_exit_invalid inv;
} u;
- uint64_t exitstate[8];
+ struct {
+ uint64_t rflags;
+ uint64_t cr8;
+ 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;
+ } exitstate;
};
#define NVMM_VCPU_EVENT_EXCP 0
@@ -128,7 +136,7 @@
uint64_t xcr0_mask;
uint32_t mxcsr_mask;
uint32_t conf_cpuid_maxops;
- uint64_t rsvd[4];
+ uint64_t rsvd[6];
};
#endif
@@ -236,14 +244,6 @@
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
#define NVMM_X64_STATE_GPRS 0x02
diff -r 4c91c5de0515 -r 8a62adf16638 sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c Mon Oct 28 06:37:51 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c Mon Oct 28 08:30:49 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_svm.c,v 1.52 2019/10/27 10:28:55 maxv Exp $ */
+/* $NetBSD: nvmm_x86_svm.c,v 1.53 2019/10/28 08:30:49 maxv Exp $ */
/*
* Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.52 2019/10/27 10:28:55 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.53 2019/10/28 08:30:49 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1452,18 +1452,13 @@
kpreempt_enable();
- exit->exitstate[NVMM_X64_EXITSTATE_CR8] = __SHIFTOUT(vmcb->ctrl.v,
- VMCB_CTRL_V_TPR);
- exit->exitstate[NVMM_X64_EXITSTATE_RFLAGS] = vmcb->state.rflags;
-
- exit->exitstate[NVMM_X64_EXITSTATE_INT_SHADOW] =
+ exit->exitstate.rflags = vmcb->state.rflags;
+ exit->exitstate.cr8 = __SHIFTOUT(vmcb->ctrl.v, VMCB_CTRL_V_TPR);
+ exit->exitstate.int_shadow =
((vmcb->ctrl.intr & VMCB_CTRL_INTR_SHADOW) != 0);
- exit->exitstate[NVMM_X64_EXITSTATE_INT_WINDOW_EXIT] =
- 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;
+ exit->exitstate.int_window_exiting = cpudata->int_window_exit;
+ exit->exitstate.nmi_window_exiting = cpudata->nmi_window_exit;
+ exit->exitstate.evt_pending = cpudata->evt_pending;
return 0;
}
diff -r 4c91c5de0515 -r 8a62adf16638 sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c Mon Oct 28 06:37:51 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c Mon Oct 28 08:30:49 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_vmx.c,v 1.43 2019/10/27 18:26:54 maxv Exp $ */
+/* $NetBSD: nvmm_x86_vmx.c,v 1.44 2019/10/28 08:30:49 maxv Exp $ */
/*
* Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.43 2019/10/27 18:26:54 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.44 2019/10/28 08:30:49 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2072,18 +2072,14 @@
vmx_vcpu_guest_misc_leave(vcpu);
vmx_vcpu_guest_dbregs_leave(vcpu);
- exit->exitstate[NVMM_X64_EXITSTATE_CR8] = cpudata->gcr8;
- exit->exitstate[NVMM_X64_EXITSTATE_RFLAGS] =
- vmx_vmread(VMCS_GUEST_RFLAGS);
+ exit->exitstate.rflags = vmx_vmread(VMCS_GUEST_RFLAGS);
+ exit->exitstate.cr8 = cpudata->gcr8;
intstate = vmx_vmread(VMCS_GUEST_INTERRUPTIBILITY);
- exit->exitstate[NVMM_X64_EXITSTATE_INT_SHADOW] =
+ exit->exitstate.int_shadow =
(intstate & (INT_STATE_STI|INT_STATE_MOVSS)) != 0;
- exit->exitstate[NVMM_X64_EXITSTATE_INT_WINDOW_EXIT] =
- 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;
+ exit->exitstate.int_window_exiting = cpudata->int_window_exit;
+ exit->exitstate.nmi_window_exiting = cpudata->nmi_window_exit;
+ exit->exitstate.evt_pending = cpudata->evt_pending;
vmx_vmcs_leave(vcpu);
Home |
Main Index |
Thread Index |
Old Index