aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm
diff options
context:
space:
mode:
authorAvi Kivity <avi@qumranet.com>2007-04-17 08:30:24 -0400
committerAvi Kivity <avi@qumranet.com>2007-05-03 03:52:29 -0400
commit2345df8c555ecb92c0c36172c07d5ac321a92dc7 (patch)
treee61e3a6714d4fd06dbddb3d381494e505fd91ff0 /drivers/kvm
parentc9047f533373e934b96d19d6a3d313ca2132fbe5 (diff)
KVM: VMX: Reduce unnecessary saving of host msrs
THe automatically switched msrs are never changed on the host (with the exception of MSR_KERNEL_GS_BASE) and thus there is no need to save them on every vm entry. This reduces vmexit latency by ~400 cycles on i386 and by ~900 cycles (10%) on x86_64. Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers/kvm')
-rw-r--r--drivers/kvm/vmx.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/drivers/kvm/vmx.c b/drivers/kvm/vmx.c
index 8c0115b54802..3745e6ccc5b4 100644
--- a/drivers/kvm/vmx.c
+++ b/drivers/kvm/vmx.c
@@ -78,6 +78,10 @@ static const u32 vmx_msr_index[] = {
78}; 78};
79#define NR_VMX_MSR ARRAY_SIZE(vmx_msr_index) 79#define NR_VMX_MSR ARRAY_SIZE(vmx_msr_index)
80 80
81#ifdef CONFIG_X86_64
82static unsigned msr_offset_kernel_gs_base;
83#endif
84
81static inline int is_page_fault(u32 intr_info) 85static inline int is_page_fault(u32 intr_info)
82{ 86{
83 return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VECTOR_MASK | 87 return (intr_info & (INTR_INFO_INTR_TYPE_MASK | INTR_INFO_VECTOR_MASK |
@@ -1129,6 +1133,10 @@ static int vmx_vcpu_setup(struct kvm_vcpu *vcpu)
1129 vcpu->host_msrs[j].reserved = 0; 1133 vcpu->host_msrs[j].reserved = 0;
1130 vcpu->host_msrs[j].data = data; 1134 vcpu->host_msrs[j].data = data;
1131 vcpu->guest_msrs[j] = vcpu->host_msrs[j]; 1135 vcpu->guest_msrs[j] = vcpu->host_msrs[j];
1136#ifdef CONFIG_X86_64
1137 if (index == MSR_KERNEL_GS_BASE)
1138 msr_offset_kernel_gs_base = j;
1139#endif
1132 ++vcpu->nmsrs; 1140 ++vcpu->nmsrs;
1133 } 1141 }
1134 1142
@@ -1760,7 +1768,9 @@ again:
1760 fx_save(vcpu->host_fx_image); 1768 fx_save(vcpu->host_fx_image);
1761 fx_restore(vcpu->guest_fx_image); 1769 fx_restore(vcpu->guest_fx_image);
1762 1770
1763 save_msrs(vcpu->host_msrs, vcpu->nmsrs); 1771#ifdef CONFIG_X86_64
1772 save_msrs(vcpu->host_msrs + msr_offset_kernel_gs_base, 1);
1773#endif
1764 load_msrs(vcpu->guest_msrs, NR_BAD_MSRS); 1774 load_msrs(vcpu->guest_msrs, NR_BAD_MSRS);
1765 1775
1766 asm ( 1776 asm (