Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src Reorder the NVMM headers, to make a clear(er) distinction be...
details: https://anonhg.NetBSD.org/src/rev/be7e288d4057
branches: trunk
changeset: 456221:be7e288d4057
user: maxv <maxv%NetBSD.org@localhost>
date: Sat Apr 27 15:45:21 2019 +0000
description:
Reorder the NVMM headers, to make a clear(er) distinction between MI and
MD. Also use #defines for the exit reasons rather than an union. No ABI
change, and no API change except 'cap->u.{}' renamed to 'cap->arch'.
diffstat:
lib/libnvmm/nvmm.h | 5 +-
sys/dev/nvmm/nvmm.h | 95 +++++++---------------------------------
sys/dev/nvmm/x86/nvmm_x86.h | 72 ++++++++++++++++++++++++++++++-
sys/dev/nvmm/x86/nvmm_x86_svm.c | 10 ++--
sys/dev/nvmm/x86/nvmm_x86_vmx.c | 10 ++--
5 files changed, 99 insertions(+), 93 deletions(-)
diffs (286 lines):
diff -r 5203b084ad58 -r be7e288d4057 lib/libnvmm/nvmm.h
--- a/lib/libnvmm/nvmm.h Sat Apr 27 15:43:09 2019 +0000
+++ b/lib/libnvmm/nvmm.h Sat Apr 27 15:45:21 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm.h,v 1.8 2019/04/10 18:49:04 maxv Exp $ */
+/* $NetBSD: nvmm.h,v 1.9 2019/04/27 15:45:21 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -37,9 +37,6 @@
#include <dev/nvmm/nvmm.h>
#include <dev/nvmm/nvmm_ioctl.h>
-#ifdef __x86_64__
-#include <dev/nvmm/x86/nvmm_x86.h>
-#endif
struct nvmm_machine {
nvmm_machid_t machid;
diff -r 5203b084ad58 -r be7e288d4057 sys/dev/nvmm/nvmm.h
--- a/sys/dev/nvmm/nvmm.h Sat Apr 27 15:43:09 2019 +0000
+++ b/sys/dev/nvmm/nvmm.h Sat Apr 27 15:45:21 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm.h,v 1.6 2019/04/24 18:19:28 maxv Exp $ */
+/* $NetBSD: nvmm.h,v 1.7 2019/04/27 15:45:21 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -44,78 +44,24 @@
typedef uint32_t nvmm_machid_t;
typedef uint32_t nvmm_cpuid_t;
-enum nvmm_exit_reason {
- NVMM_EXIT_NONE = 0x0000000000000000,
-
- /* General. */
- NVMM_EXIT_MEMORY = 0x0000000000000001,
- NVMM_EXIT_IO = 0x0000000000000002,
- NVMM_EXIT_MSR = 0x0000000000000003,
- NVMM_EXIT_INT_READY = 0x0000000000000004,
- NVMM_EXIT_NMI_READY = 0x0000000000000005,
- NVMM_EXIT_HALTED = 0x0000000000000006,
- NVMM_EXIT_SHUTDOWN = 0x0000000000000007,
-
- /* Instructions (x86). */
- NVMM_EXIT_MONITOR = 0x0000000000001000,
- NVMM_EXIT_MWAIT = 0x0000000000001001,
- NVMM_EXIT_MWAIT_COND = 0x0000000000001002,
-
- NVMM_EXIT_INVALID = 0xFFFFFFFFFFFFFFFF
-};
-
-struct nvmm_exit_memory {
- int prot;
- gpaddr_t gpa;
- uint8_t inst_len;
- uint8_t inst_bytes[15];
-};
+#ifdef __x86_64__
+#include <dev/nvmm/x86/nvmm_x86.h>
+#endif
-enum nvmm_exit_io_type {
- NVMM_EXIT_IO_IN,
- NVMM_EXIT_IO_OUT
-};
-
-struct nvmm_exit_io {
- enum nvmm_exit_io_type type;
- uint16_t port;
- int seg;
- uint8_t address_size;
- uint8_t operand_size;
- bool rep;
- bool str;
- uint64_t npc;
-};
-
-enum nvmm_exit_msr_type {
- NVMM_EXIT_MSR_RDMSR,
- NVMM_EXIT_MSR_WRMSR
-};
-
-struct nvmm_exit_msr {
- enum nvmm_exit_msr_type type;
- uint64_t msr;
- uint64_t val;
- uint64_t npc;
-};
-
-struct nvmm_exit_insn {
- uint64_t npc;
-};
-
-struct nvmm_exit_invalid {
- uint64_t hwcode;
-};
+#define NVMM_EXIT_NONE 0x0000000000000000ULL
+#define NVMM_EXIT_MEMORY 0x0000000000000001ULL
+#define NVMM_EXIT_IO 0x0000000000000002ULL
+#define NVMM_EXIT_MSR 0x0000000000000003ULL /* x86 only? */
+#define NVMM_EXIT_INT_READY 0x0000000000000004ULL
+#define NVMM_EXIT_NMI_READY 0x0000000000000005ULL
+#define NVMM_EXIT_HALTED 0x0000000000000006ULL
+#define NVMM_EXIT_SHUTDOWN 0x0000000000000007ULL
+/* Range 0x1000-0x10000 is MD. */
+#define NVMM_EXIT_INVALID 0xFFFFFFFFFFFFFFFFULL
struct nvmm_exit {
- enum nvmm_exit_reason reason;
- union {
- struct nvmm_exit_memory mem;
- struct nvmm_exit_io io;
- struct nvmm_exit_msr msr;
- struct nvmm_exit_insn insn;
- struct nvmm_exit_invalid inv;
- } u;
+ uint64_t reason;
+ union nvmm_exit_md u;
uint64_t exitstate[8];
};
@@ -145,14 +91,7 @@
uint64_t max_machines;
uint64_t max_vcpus;
uint64_t max_ram;
- union {
- struct {
- uint64_t xcr0_mask;
- uint64_t mxcsr_mask;
- uint64_t conf_cpuid_maxops;
- } x86;
- uint64_t rsvd[8];
- } u;
+ struct nvmm_cap_md arch;
};
#endif
diff -r 5203b084ad58 -r be7e288d4057 sys/dev/nvmm/x86/nvmm_x86.h
--- a/sys/dev/nvmm/x86/nvmm_x86.h Sat Apr 27 15:43:09 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86.h Sat Apr 27 15:45:21 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86.h,v 1.11 2019/04/06 11:49:53 maxv Exp $ */
+/* $NetBSD: nvmm_x86.h,v 1.12 2019/04/27 15:45:21 maxv Exp $ */
/*
* Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,6 +32,76 @@
#ifndef _NVMM_X86_H_
#define _NVMM_X86_H_
+/* --------------------------------------------------------------------- */
+
+#ifndef ASM_NVMM
+
+struct nvmm_exit_memory {
+ int prot;
+ gpaddr_t gpa;
+ uint8_t inst_len;
+ uint8_t inst_bytes[15];
+};
+
+enum nvmm_exit_io_type {
+ NVMM_EXIT_IO_IN,
+ NVMM_EXIT_IO_OUT
+};
+
+struct nvmm_exit_io {
+ enum nvmm_exit_io_type type;
+ uint16_t port;
+ int seg;
+ uint8_t address_size;
+ uint8_t operand_size;
+ bool rep;
+ bool str;
+ uint64_t npc;
+};
+
+enum nvmm_exit_msr_type {
+ NVMM_EXIT_MSR_RDMSR,
+ NVMM_EXIT_MSR_WRMSR
+};
+
+struct nvmm_exit_msr {
+ enum nvmm_exit_msr_type type;
+ uint64_t msr;
+ uint64_t val;
+ uint64_t npc;
+};
+
+struct nvmm_exit_insn {
+ uint64_t npc;
+};
+
+struct nvmm_exit_invalid {
+ uint64_t hwcode;
+};
+
+union nvmm_exit_md {
+ struct nvmm_exit_memory mem;
+ struct nvmm_exit_io io;
+ struct nvmm_exit_msr msr;
+ struct nvmm_exit_insn insn;
+ struct nvmm_exit_invalid inv;
+};
+
+#define NVMM_EXIT_MONITOR 0x0000000000001000ULL
+#define NVMM_EXIT_MWAIT 0x0000000000001001ULL
+#define NVMM_EXIT_MWAIT_COND 0x0000000000001002ULL
+
+struct nvmm_cap_md {
+ uint64_t xcr0_mask;
+ uint64_t mxcsr_mask;
+ uint64_t conf_cpuid_maxops;
+ uint64_t rsvd[5];
+};
+
+#endif
+
+/* --------------------------------------------------------------------- */
+
/* Segments. */
#define NVMM_X64_SEG_ES 0
#define NVMM_X64_SEG_CS 1
diff -r 5203b084ad58 -r be7e288d4057 sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c Sat Apr 27 15:43:09 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c Sat Apr 27 15:45:21 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_svm.c,v 1.41 2019/04/27 09:06:18 maxv Exp $ */
+/* $NetBSD: nvmm_x86_svm.c,v 1.42 2019/04/27 15:45:21 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.41 2019/04/27 09:06:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.42 2019/04/27 15:45:21 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -2288,9 +2288,9 @@
static void
svm_capability(struct nvmm_capability *cap)
{
- cap->u.x86.xcr0_mask = svm_xcr0_mask;
- cap->u.x86.mxcsr_mask = x86_fpu_mxcsr_mask;
- cap->u.x86.conf_cpuid_maxops = SVM_NCPUIDS;
+ cap->arch.xcr0_mask = svm_xcr0_mask;
+ cap->arch.mxcsr_mask = x86_fpu_mxcsr_mask;
+ cap->arch.conf_cpuid_maxops = SVM_NCPUIDS;
}
const struct nvmm_impl nvmm_x86_svm = {
diff -r 5203b084ad58 -r be7e288d4057 sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sat Apr 27 15:43:09 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c Sat Apr 27 15:45:21 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_vmx.c,v 1.29 2019/04/27 09:06:18 maxv Exp $ */
+/* $NetBSD: nvmm_x86_vmx.c,v 1.30 2019/04/27 15:45:21 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.29 2019/04/27 09:06:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.30 2019/04/27 15:45:21 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -3083,9 +3083,9 @@
static void
vmx_capability(struct nvmm_capability *cap)
{
- cap->u.x86.xcr0_mask = vmx_xcr0_mask;
- cap->u.x86.mxcsr_mask = x86_fpu_mxcsr_mask;
- cap->u.x86.conf_cpuid_maxops = VMX_NCPUIDS;
+ cap->arch.xcr0_mask = vmx_xcr0_mask;
+ cap->arch.mxcsr_mask = x86_fpu_mxcsr_mask;
+ cap->arch.conf_cpuid_maxops = VMX_NCPUIDS;
}
const struct nvmm_impl nvmm_x86_vmx = {
Home |
Main Index |
Thread Index |
Old Index