diff options
author | Owen Hofmann <osh@google.com> | 2016-03-01 16:36:13 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2016-03-02 04:37:32 -0500 |
commit | 2680d6da455b636dd006636780c0f235c6561d70 (patch) | |
tree | 670ef91dac86f41a879067abd51aa91f8b62a230 | |
parent | 0178fd7dcc4451fcb90bec5e91226586962478d2 (diff) |
kvm: x86: Update tsc multiplier on change.
vmx.c writes the TSC_MULTIPLIER field in vmx_vcpu_load, but only when a
vcpu has migrated physical cpus. Record the last value written and
update in vmx_vcpu_load on any change, otherwise a cpu migration must
occur for TSC frequency scaling to take effect.
Cc: stable@vger.kernel.org
Fixes: ff2c3a1803775cc72dc6f624b59554956396b0ee
Signed-off-by: Owen Hofmann <osh@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | arch/x86/kvm/vmx.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c index e2951b6edbbc..0ff453749a90 100644 --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c | |||
@@ -596,6 +596,8 @@ struct vcpu_vmx { | |||
596 | /* Support for PML */ | 596 | /* Support for PML */ |
597 | #define PML_ENTITY_NUM 512 | 597 | #define PML_ENTITY_NUM 512 |
598 | struct page *pml_pg; | 598 | struct page *pml_pg; |
599 | |||
600 | u64 current_tsc_ratio; | ||
599 | }; | 601 | }; |
600 | 602 | ||
601 | enum segment_cache_field { | 603 | enum segment_cache_field { |
@@ -2127,14 +2129,16 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu) | |||
2127 | rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp); | 2129 | rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp); |
2128 | vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */ | 2130 | vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */ |
2129 | 2131 | ||
2130 | /* Setup TSC multiplier */ | ||
2131 | if (cpu_has_vmx_tsc_scaling()) | ||
2132 | vmcs_write64(TSC_MULTIPLIER, | ||
2133 | vcpu->arch.tsc_scaling_ratio); | ||
2134 | |||
2135 | vmx->loaded_vmcs->cpu = cpu; | 2132 | vmx->loaded_vmcs->cpu = cpu; |
2136 | } | 2133 | } |
2137 | 2134 | ||
2135 | /* Setup TSC multiplier */ | ||
2136 | if (kvm_has_tsc_control && | ||
2137 | vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) { | ||
2138 | vmx->current_tsc_ratio = vcpu->arch.tsc_scaling_ratio; | ||
2139 | vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio); | ||
2140 | } | ||
2141 | |||
2138 | vmx_vcpu_pi_load(vcpu, cpu); | 2142 | vmx_vcpu_pi_load(vcpu, cpu); |
2139 | } | 2143 | } |
2140 | 2144 | ||