diff options
| author | maxv <maxv@NetBSD.org> | 2019-02-13 07:04:12 +0000 |
|---|---|---|
| committer | maxv <maxv@NetBSD.org> | 2019-02-13 07:04:12 +0000 |
| commit | fbfdcdc6ee02f9490f3a4cb264e396be2b236445 (patch) | |
| tree | a03e425edec306786fbe84899a69f74173e8ddcf /sys/dev/nvmm | |
| parent | 3c220b290d4c12e9b1d8ffbc35ad944df119d785 (diff) | |
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.
Diffstat (limited to 'sys/dev/nvmm')
| -rw-r--r-- | sys/dev/nvmm/x86/nvmm_x86_svm.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/sys/dev/nvmm/x86/nvmm_x86_svm.c b/sys/dev/nvmm/x86/nvmm_x86_svm.c index 17aae469473..828491f7508 100644 --- a/sys/dev/nvmm/x86/nvmm_x86_svm.c +++ b/sys/dev/nvmm/x86/nvmm_x86_svm.c @@ -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_cpu *vcpu) { 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, struct nvmm_cpu *vcpu) /* 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 |
