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 Improvements:
details: https://anonhg.NetBSD.org/src/rev/cbada201e65e
branches: trunk
changeset: 448524:cbada201e65e
user: maxv <maxv%NetBSD.org@localhost>
date: Mon Feb 04 12:11:18 2019 +0000
description:
Improvements:
- Guest reads/writes to PAT land in gPAT, so no need to emulate them.
- When emulating EFER, don't advance the RIP if a fault occurs, and don't
forget to flush the VMCB cache accordingly.
diffstat:
sys/dev/nvmm/x86/nvmm_x86_svm.c | 33 +++++++++++++++------------------
1 files changed, 15 insertions(+), 18 deletions(-)
diffs (100 lines):
diff -r aaabf8d42b2b -r cbada201e65e sys/dev/nvmm/x86/nvmm_x86_svm.c
--- a/sys/dev/nvmm/x86/nvmm_x86_svm.c Mon Feb 04 12:10:13 2019 +0000
+++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c Mon Feb 04 12:11:18 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_svm.c,v 1.18 2019/01/26 15:12:20 maxv Exp $ */
+/* $NetBSD: nvmm_x86_svm.c,v 1.19 2019/02/04 12:11:18 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.18 2019/01/26 15:12:20 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.19 2019/02/04 12:11:18 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -938,20 +938,15 @@
struct nvmm_exit *exit)
{
struct svm_cpudata *cpudata = vcpu->cpudata;
+ struct vmcb *vmcb = cpudata->vmcb;
uint64_t val;
size_t i;
switch (exit->u.msr.type) {
case NVMM_EXIT_MSR_RDMSR:
- if (exit->u.msr.msr == MSR_CR_PAT) {
- val = cpudata->vmcb->state.g_pat;
- cpudata->vmcb->state.rax = (val & 0xFFFFFFFF);
- cpudata->gprs[NVMM_X64_GPR_RDX] = (val >> 32);
- goto handled;
- }
if (exit->u.msr.msr == MSR_NB_CFG) {
val = NB_CFG_INITAPICCPUIDLO;
- cpudata->vmcb->state.rax = (val & 0xFFFFFFFF);
+ vmcb->state.rax = (val & 0xFFFFFFFF);
cpudata->gprs[NVMM_X64_GPR_RDX] = (val >> 32);
goto handled;
}
@@ -959,7 +954,7 @@
if (msr_ignore_list[i] != exit->u.msr.msr)
continue;
val = 0;
- cpudata->vmcb->state.rax = (val & 0xFFFFFFFF);
+ vmcb->state.rax = (val & 0xFFFFFFFF);
cpudata->gprs[NVMM_X64_GPR_RDX] = (val >> 32);
goto handled;
}
@@ -967,18 +962,14 @@
case NVMM_EXIT_MSR_WRMSR:
if (exit->u.msr.msr == MSR_EFER) {
if (__predict_false(exit->u.msr.val & ~EFER_VALID)) {
- svm_inject_gp(mach, vcpu);
- goto handled;
+ goto error;
}
- if ((cpudata->vmcb->state.efer ^ exit->u.msr.val) &
+ if ((vmcb->state.efer ^ exit->u.msr.val) &
EFER_TLB_FLUSH) {
cpudata->tlb_want_flush = true;
}
- cpudata->vmcb->state.efer = exit->u.msr.val | EFER_SVME;
- goto handled;
- }
- if (exit->u.msr.msr == MSR_CR_PAT) {
- cpudata->vmcb->state.g_pat = exit->u.msr.val;
+ vmcb->state.efer = exit->u.msr.val | EFER_SVME;
+ vmcb->ctrl.vmcb_clean &= ~VMCB_CTRL_VMCB_CLEAN_CR;
goto handled;
}
for (i = 0; i < __arraycount(msr_ignore_list); i++) {
@@ -994,6 +985,10 @@
handled:
svm_inkernel_advance(cpudata->vmcb);
return true;
+
+error:
+ svm_inject_gp(mach, vcpu);
+ return true;
}
static void
@@ -1557,6 +1552,7 @@
* - SYSENTER_EIP [read, write]
* - FSBASE [read, write]
* - GSBASE [read, write]
+ * - PAT [read, write]
* - TSC [read]
*
* Intercept the rest.
@@ -1573,6 +1569,7 @@
svm_vcpu_msr_allow(cpudata->msrbm, MSR_SYSENTER_EIP, true, true);
svm_vcpu_msr_allow(cpudata->msrbm, MSR_FSBASE, true, true);
svm_vcpu_msr_allow(cpudata->msrbm, MSR_GSBASE, true, true);
+ svm_vcpu_msr_allow(cpudata->msrbm, MSR_CR_PAT, true, true);
svm_vcpu_msr_allow(cpudata->msrbm, MSR_TSC, true, false);
vmcb->ctrl.msrpm_base_pa = cpudata->msrbm_pa;
Home |
Main Index |
Thread Index |
Old Index