Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-9]: src/tests/lib/libnvmm Pull up following revision(s) (requeste...
details: https://anonhg.NetBSD.org/src/rev/d11b31b76f24
branches: netbsd-9
changeset: 963319:d11b31b76f24
user: martin <martin%NetBSD.org@localhost>
date: Mon Nov 25 16:39:29 2019 +0000
description:
Pull up following revision(s) (requested by maxv in ticket #475):
tests/lib/libnvmm/h_mem_assist.c: revision 1.18
sys/dev/nvmm/x86/nvmm_x86_vmx.c: revision 1.45
sys/dev/nvmm/x86/nvmm_x86_svm.c: revision 1.54
Hide XSAVES-specific stuff and the masked extended states.
Several improvements. In particular, reduce CS.limit, because Intel CPUs
perform strict sanity checks, and the previous (too high) limit caused the
VM entry to fail.
diffstat:
sys/dev/nvmm/x86/nvmm_x86_svm.c | 17 +++++++++++--
sys/dev/nvmm/x86/nvmm_x86_vmx.c | 17 +++++++++++--
tests/lib/libnvmm/h_mem_assist.c | 47 ++++++++++++++++++++++-----------------
3 files changed, 55 insertions(+), 26 deletions(-)
diffs (174 lines):
diff -r c5dd2a15ffc7 -r d11b31b76f24 sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c Mon Nov 25 16:37:06 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c Mon Nov 25 16:39:29 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_svm.c,v 1.46.4.2 2019/11/10 12:58:30 martin Exp $ */
+/* $NetBSD: nvmm_x86_svm.c,v 1.46.4.3 2019/11/25 16:39:30 martin 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.46.4.2 2019/11/10 12:58:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.46.4.3 2019/11/25 16:39:30 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -828,7 +828,18 @@
cpudata->gprs[NVMM_X64_GPR_RDX] = svm_xcr0_mask >> 32;
break;
case 1:
- cpudata->vmcb->state.rax &= ~CPUID_PES1_XSAVES;
+ cpudata->vmcb->state.rax &=
+ (CPUID_PES1_XSAVEOPT | CPUID_PES1_XSAVEC |
+ CPUID_PES1_XGETBV);
+ cpudata->gprs[NVMM_X64_GPR_RBX] = 0;
+ cpudata->gprs[NVMM_X64_GPR_RCX] = 0;
+ cpudata->gprs[NVMM_X64_GPR_RDX] = 0;
+ break;
+ default:
+ cpudata->vmcb->state.rax = 0;
+ cpudata->gprs[NVMM_X64_GPR_RBX] = 0;
+ cpudata->gprs[NVMM_X64_GPR_RCX] = 0;
+ cpudata->gprs[NVMM_X64_GPR_RDX] = 0;
break;
}
break;
diff -r c5dd2a15ffc7 -r d11b31b76f24 sys/dev/nvmm/x86/nvmm_x86_vmx.c
--- a/sys/dev/nvmm/x86/nvmm_x86_vmx.c Mon Nov 25 16:37:06 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_vmx.c Mon Nov 25 16:39:29 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_vmx.c,v 1.36.2.3 2019/11/10 12:58:30 martin Exp $ */
+/* $NetBSD: nvmm_x86_vmx.c,v 1.36.2.4 2019/11/25 16:39:30 martin 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.36.2.3 2019/11/10 12:58:30 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_vmx.c,v 1.36.2.4 2019/11/25 16:39:30 martin Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1203,7 +1203,18 @@
cpudata->gprs[NVMM_X64_GPR_RDX] = vmx_xcr0_mask >> 32;
break;
case 1:
- cpudata->gprs[NVMM_X64_GPR_RAX] &= ~CPUID_PES1_XSAVES;
+ cpudata->gprs[NVMM_X64_GPR_RAX] &=
+ (CPUID_PES1_XSAVEOPT | CPUID_PES1_XSAVEC |
+ CPUID_PES1_XGETBV);
+ cpudata->gprs[NVMM_X64_GPR_RBX] = 0;
+ cpudata->gprs[NVMM_X64_GPR_RCX] = 0;
+ cpudata->gprs[NVMM_X64_GPR_RDX] = 0;
+ break;
+ default:
+ cpudata->gprs[NVMM_X64_GPR_RAX] = 0;
+ cpudata->gprs[NVMM_X64_GPR_RBX] = 0;
+ cpudata->gprs[NVMM_X64_GPR_RCX] = 0;
+ cpudata->gprs[NVMM_X64_GPR_RDX] = 0;
break;
}
break;
diff -r c5dd2a15ffc7 -r d11b31b76f24 tests/lib/libnvmm/h_mem_assist.c
--- a/tests/lib/libnvmm/h_mem_assist.c Mon Nov 25 16:37:06 2019 +0000
+++ b/tests/lib/libnvmm/h_mem_assist.c Mon Nov 25 16:39:29 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: h_mem_assist.c,v 1.11.4.1 2019/11/10 12:58:30 martin Exp $ */
+/* $NetBSD: h_mem_assist.c,v 1.11.4.2 2019/11/25 16:39:29 martin Exp $ */
/*
* Copyright (c) 2018-2019 The NetBSD Foundation, Inc.
@@ -113,7 +113,7 @@
return;
default:
- printf("Invalid!\n");
+ printf("Invalid VMEXIT: 0x%lx\n", exit->reason);
return;
}
}
@@ -177,22 +177,22 @@
extern uint8_t test_64bit_16_begin, test_64bit_16_end;
static const struct test tests64[] = {
- { "test1 - MOV", &test1_begin, &test1_end, 0x3004, 0 },
- { "test2 - OR", &test2_begin, &test2_end, 0x16FF, 0 },
- { "test3 - AND", &test3_begin, &test3_end, 0x1FC0, 0 },
- { "test4 - XOR", &test4_begin, &test4_end, 0x10CF, 0 },
- { "test5 - Address Sizes", &test5_begin, &test5_end, 0x1F00, 0 },
- { "test6 - DMO", &test6_begin, &test6_end, 0xFFAB, 0 },
- { "test7 - STOS", &test7_begin, &test7_end, 0x00123456, 0 },
- { "test8 - LODS", &test8_begin, &test8_end, 0x12345678, 0 },
- { "test9 - MOVS", &test9_begin, &test9_end, 0x12345678, 0 },
- { "test10 - MOVZXB", &test10_begin, &test10_end, 0x00000078, 0 },
- { "test11 - MOVZXW", &test11_begin, &test11_end, 0x00005678, 0 },
- { "test12 - CMP", &test12_begin, &test12_end, 0x00000001, 0 },
- { "test13 - SUB", &test13_begin, &test13_end, 0x0000000F0000A0FF, 0 },
- { "test14 - TEST", &test14_begin, &test14_end, 0x00000001, 0 },
- { "test15 - XCHG", &test_64bit_15_begin, &test_64bit_15_end, 0x123456, 0 },
- { "test16 - XCHG", &test_64bit_16_begin, &test_64bit_16_end,
+ { "64bit test1 - MOV", &test1_begin, &test1_end, 0x3004, 0 },
+ { "64bit test2 - OR", &test2_begin, &test2_end, 0x16FF, 0 },
+ { "64bit test3 - AND", &test3_begin, &test3_end, 0x1FC0, 0 },
+ { "64bit test4 - XOR", &test4_begin, &test4_end, 0x10CF, 0 },
+ { "64bit test5 - Address Sizes", &test5_begin, &test5_end, 0x1F00, 0 },
+ { "64bit test6 - DMO", &test6_begin, &test6_end, 0xFFAB, 0 },
+ { "64bit test7 - STOS", &test7_begin, &test7_end, 0x00123456, 0 },
+ { "64bit test8 - LODS", &test8_begin, &test8_end, 0x12345678, 0 },
+ { "64bit test9 - MOVS", &test9_begin, &test9_end, 0x12345678, 0 },
+ { "64bit test10 - MOVZXB", &test10_begin, &test10_end, 0x00000078, 0 },
+ { "64bit test11 - MOVZXW", &test11_begin, &test11_end, 0x00005678, 0 },
+ { "64bit test12 - CMP", &test12_begin, &test12_end, 0x00000001, 0 },
+ { "64bit test13 - SUB", &test13_begin, &test13_end, 0x0000000F0000A0FF, 0 },
+ { "64bit test14 - TEST", &test14_begin, &test14_end, 0x00000001, 0 },
+ { "64bit test15 - XCHG", &test_64bit_15_begin, &test_64bit_15_end, 0x123456, 0 },
+ { "64bit test16 - XCHG", &test_64bit_16_begin, &test_64bit_16_end,
0x123456, 0 },
{ NULL, NULL, NULL, -1, 0 }
};
@@ -218,6 +218,9 @@
{
struct nvmm_x64_state *state = vcpu->state;
+ if (nvmm_vcpu_getstate(mach, vcpu, NVMM_X64_STATE_ALL) == -1)
+ err(errno, "nvmm_vcpu_getstate");
+
memset(state, 0, sizeof(*state));
/* Default. */
@@ -365,6 +368,8 @@
run_test(&mach, &vcpu, &tests64[i]);
}
+ if (nvmm_vcpu_destroy(&mach, &vcpu) == -1)
+ err(errno, "nvmm_vcpu_destroy");
if (nvmm_machine_destroy(&mach) == -1)
err(errno, "nvmm_machine_destroy");
}
@@ -400,10 +405,10 @@
struct nvmm_x64_state *state = vcpu->state;
if (nvmm_vcpu_getstate(mach, vcpu, NVMM_X64_STATE_ALL) == -1)
- err(errno, "nvmm_vcpu_setstate");
+ err(errno, "nvmm_vcpu_getstate");
state->segs[NVMM_X64_SEG_CS].base = 0;
- state->segs[NVMM_X64_SEG_CS].limit = 0xFFFFFFFF;
+ state->segs[NVMM_X64_SEG_CS].limit = 0x2FFF;
state->gprs[NVMM_X64_GPR_RIP] = 0x2000;
if (nvmm_vcpu_setstate(mach, vcpu, NVMM_X64_STATE_ALL) == -1)
@@ -451,6 +456,8 @@
run_test(&mach, &vcpu, &tests16[i]);
}
+ if (nvmm_vcpu_destroy(&mach, &vcpu) == -1)
+ err(errno, "nvmm_vcpu_destroy");
if (nvmm_machine_destroy(&mach) == -1)
err(errno, "nvmm_machine_destroy");
}
Home |
Main Index |
Thread Index |
Old Index