Module Name:    src
Committed By:   maxv
Date:           Wed Feb 13 07:04:13 UTC 2019

Modified Files:
        src/sys/dev/nvmm/x86: nvmm_x86_svm.c

Log Message:
Micro optimization: the STAR/LSTAR/CSTAR/SFMASK MSRs are static, so rather
than saving them on each VMENTRY, save them only once, at VCPU creation
time.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 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.20 src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.21
--- src/sys/dev/nvmm/x86/nvmm_x86_svm.c:1.20	Tue Feb 12 14:54:59 2019
+++ src/sys/dev/nvmm/x86/nvmm_x86_svm.c	Wed Feb 13 07:04:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvmm_x86_svm.c,v 1.20 2019/02/12 14:54:59 maxv Exp $	*/
+/*	$NetBSD: nvmm_x86_svm.c,v 1.21 2019/02/13 07:04:12 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.20 2019/02/12 14:54:59 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvmm_x86_svm.c,v 1.21 2019/02/13 07:04:12 maxv Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1157,10 +1157,6 @@ svm_vcpu_guest_misc_enter(struct nvmm_cp
 {
 	struct svm_cpudata *cpudata = vcpu->cpudata;
 
-	cpudata->star = rdmsr(MSR_STAR);
-	cpudata->lstar = rdmsr(MSR_LSTAR);
-	cpudata->cstar = rdmsr(MSR_CSTAR);
-	cpudata->sfmask = rdmsr(MSR_SFMASK);
 	cpudata->fsbase = rdmsr(MSR_FSBASE);
 	cpudata->kernelgsbase = rdmsr(MSR_KERNELGSBASE);
 }
@@ -1592,6 +1588,12 @@ svm_vcpu_init(struct nvmm_machine *mach,
 
 	/* Bluntly hide the host TSC. */
 	cpudata->tsc_offset = rdtsc();
+
+	/* These MSRs are static. */
+	cpudata->star = rdmsr(MSR_STAR);
+	cpudata->lstar = rdmsr(MSR_LSTAR);
+	cpudata->cstar = rdmsr(MSR_CSTAR);
+	cpudata->sfmask = rdmsr(MSR_SFMASK);
 }
 
 static int

Reply via email to