Skip to contentSkip to conversation

Patch "kvm: x86: Update tsc multiplier on change." has been added to the 4.4-stable tree

PATCH [email protected] 1 participant 1 message Mar 4, 2016

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer Applied
#0 lore raw

This is a note to let you know that I've just added the patch titled

kvm: x86: Update tsc multiplier on change.

to the 4.4-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
kvm-x86-update-tsc-multiplier-on-change.patch
and it can be found in the queue-4.4 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.

Quoted 1 line

From 2680d6da455b636dd006636780c0f235c6561d70 Mon Sep 17 00:00:00 2001

From: Owen Hofmann <[email protected]>
Date: Tue, 1 Mar 2016 13:36:13 -0800
Subject: kvm: x86: Update tsc multiplier on change.

From: Owen Hofmann <[email protected]>

commit 2680d6da455b636dd006636780c0f235c6561d70 upstream.

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.

Fixes ff2c3a1803775cc72dc6f624b59554956396b0ee
---
 arch/x86/kvm/vmx.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
arch/x86/kvm/vmx.c +9 -5
@@ -595,6 +595,8 @@ struct vcpu_vmx {
 	/* Support for PML */
 #define PML_ENTITY_NUM		512
 	struct page *pml_pg;
+
+	u64 current_tsc_ratio;
 };
 
 enum segment_cache_field {
@@ -2062,14 +2064,16 @@ static void vmx_vcpu_load(struct kvm_vcp
 		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;
 	}
 
+	/* Setup TSC multiplier */
+	if (kvm_has_tsc_control &&
+	    vmx->current_tsc_ratio != vcpu->arch.tsc_scaling_ratio) {
+		vmx->current_tsc_ratio = vcpu->arch.tsc_scaling_ratio;
+		vmcs_write64(TSC_MULTIPLIER, vmx->current_tsc_ratio);
+	}
+
 	vmx_vcpu_pi_load(vcpu, cpu);
 }
 

Patches currently in stable-queue which might be from [email protected] are

queue-4.4/kvm-x86-update-tsc-multiplier-on-change.patch