Module Name: src
Committed By: maxv
Date: Tue Feb 12 14:54:59 UTC 2019
Modified Files:
src/sys/dev/nvmm/x86: nvmm_x86_svm.c
Log Message:
Optimize: the hardware does not clear the TLB flush command after a
VMENTRY, so clear it ourselves, to avoid uselessly flushing the guest
TLB. While here also fix the processing of EFER-induced flushes, they
shouldn't be delayed.
To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/nvmm/x86/nvmm_x86_svm.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/nvmm/x86/nvmm_x86_svm.c
diff -u src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.19 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.20
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.19 Mon Feb 4 12:11:18 2019
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c Tue Feb 12 14:54:59 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: nvmm_x86_svm.c,v 1.19 2019/02/04 12:11:18 maxv Exp $ */
+/* $NetBSD: nvmm_x86_svm.c,v 1.20 2019/02/12 14:54:59 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.19 2019/02/04 12:11:18 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.20 2019/02/12 14:54:59 maxv Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1194,12 +1194,6 @@ svm_vcpu_run(struct nvmm_machine *mach,
tlb_need_flush = true;
}
- if (cpudata->tlb_want_flush || tlb_need_flush) {
- vmcb->ctrl.tlb_ctrl = svm_ctrl_tlb_flush;
- } else {
- vmcb->ctrl.tlb_ctrl = 0;
- }
-
if (vcpu->hcpu_last != hcpu) {
vmcb->ctrl.tsc_offset = cpudata->tsc_offset +
curcpu()->ci_data.cpu_cc_skew;
@@ -1210,6 +1204,12 @@ svm_vcpu_run(struct nvmm_machine *mach,
svm_vcpu_guest_misc_enter(vcpu);
while (1) {
+ if (cpudata->tlb_want_flush || tlb_need_flush) {
+ vmcb->ctrl.tlb_ctrl = svm_ctrl_tlb_flush;
+ } else {
+ vmcb->ctrl.tlb_ctrl = 0;
+ }
+
s = splhigh();
svm_vcpu_guest_fpu_enter(vcpu);
svm_vmrun(cpudata->vmcb_pa, cpudata->gprs);
@@ -1219,9 +1219,8 @@ svm_vcpu_run(struct nvmm_machine *mach,
svm_vmcb_cache_default(vmcb);
if (vmcb->ctrl.exitcode != VMCB_EXITCODE_INVALID) {
- if (cpudata->tlb_want_flush) {
- cpudata->tlb_want_flush = false;
- }
+ cpudata->tlb_want_flush = false;
+ tlb_need_flush = false;
vcpu->hcpu_last = hcpu;
}