[Devel,RHEL7,COMMIT] ms/KVM: VMX: Setup TSC scaling ratio when a vcpu is loaded

Submitted by Konstantin Khorenko on Nov. 16, 2016, 12:46 p.m.

Details

Message ID 201611161246.uAGCk0YO013460@finist_cl7.x64_64.work.ct
State New
Series "add tsc_scale and fix VM pause/resume"
Headers show

Commit Message

Konstantin Khorenko Nov. 16, 2016, 12:46 p.m.
The commit is pushed to "branch-rh7-3.10.0-327.36.1.vz7.19.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-327.36.1.vz7.19.9
------>
commit 60bfe12327f82624856ff08bc78ad24a24a93071
Author: Haozhong Zhang <haozhong.zhang@intel.com>
Date:   Wed Nov 16 16:46:00 2016 +0400

    ms/KVM: VMX: Setup TSC scaling ratio when a vcpu is loaded
    
    This patch makes kvm-intel module to load TSC scaling ratio into TSC
    multiplier field of VMCS when a vcpu is loaded, so that TSC scaling
    ratio can take effect if VMX TSC scaling is enabled.
    
    Signed-off-by: Haozhong Zhang <haozhong.zhang@intel.com>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry-picked from commit ff2c3a1803775cc72dc6f624b59554956396b0ee)
    Signed-off-by: Denis Plotnikov <dplotnikov@virtuozzo.com>
    Signed-off-by: Roman Kagan <rkagan@virtuozzo.com>
---
 arch/x86/kvm/vmx.c | 6 ++++++
 1 file changed, 6 insertions(+)

Patch hide | download patch | download mbox

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ab8a678..265bc0e 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1883,6 +1883,12 @@  static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
 
 		rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
 		vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
+
+		/* Setup TSC multiplier */
+		if (cpu_has_vmx_tsc_scaling())
+			vmcs_write64(TSC_MULTIPLIER,
+				     vcpu->arch.tsc_scaling_ratio);
+
 		vmx->loaded_vmcs->cpu = cpu;
 	}
 }