From fbfdcdc6ee02f9490f3a4cb264e396be2b236445 Mon Sep 17 00:00:00 2001 From: maxv Date: Wed, 13 Feb 2019 07:04:12 +0000 Subject: 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. --- sys/dev/nvmm/x86/nvmm_x86_svm.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'sys/dev') 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 -__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 #include @@ -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 -- cgit