[RHEL7,COMMIT] KVM: x86/vPMU: handle access to LBR stack regardless of PMU counters presence

Submitted by Konstantin Khorenko on May 22, 2019, 3:22 p.m.

Details

Message ID 201905221522.x4MFMUGM032486@finist-ce7.sw.ru
State New
Series "KVM: x86/vPMU: handle access to LBR stack regardless of PMU counters presence"
Headers show

Commit Message

Konstantin Khorenko May 22, 2019, 3:22 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.2
------>
commit 5bccf8499613316a40b6bc87bad5c01c81673a31
Author: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
Date:   Wed May 22 18:22:29 2019 +0300

    KVM: x86/vPMU: handle access to LBR stack regardless of PMU counters presence
    
    Previously if no PMU counters were exposed to guest, KVM skipped whole
    remaining PMU-related initialisation, including filling of LBR-related
    information. It is wrong, since LBR support doesn't depend on
    existence of PMU counters.
    
    Fixes: 48b9f62 ("ms/KVM: x86/vPMU: ignore access to LBR-related MSRs")
    
    https://jira.sw.ru/browse/PSBM-94429
    Signed-off-by: Jan Dakinevich <jan.dakinevich@virtuozzo.com>
---
 arch/x86/kvm/pmu_intel.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Patch hide | download patch | download mbox

diff --git a/arch/x86/kvm/pmu_intel.c b/arch/x86/kvm/pmu_intel.c
index 3c18203d10c4..b61903f008ba 100644
--- a/arch/x86/kvm/pmu_intel.c
+++ b/arch/x86/kvm/pmu_intel.c
@@ -297,6 +297,11 @@  static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
 	pmu->version = 0;
 	pmu->reserved_bits = 0xffffffff00200000ull;
 
+	entry = kvm_find_cpuid_entry(vcpu, 1, 0);
+	if (entry)
+		intel_pmu_lbr_fill(&pmu->lbr,
+			x86_family(entry->eax), x86_model(entry->eax));
+
 	entry = kvm_find_cpuid_entry(vcpu, 0xa, 0);
 	if (!entry)
 		return;
@@ -332,11 +337,6 @@  static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
 	    (boot_cpu_has(X86_FEATURE_HLE) || boot_cpu_has(X86_FEATURE_RTM)) &&
 	    (entry->ebx & (X86_FEATURE_HLE|X86_FEATURE_RTM)))
 		pmu->reserved_bits ^= HSW_IN_TX|HSW_IN_TX_CHECKPOINTED;
-
-	entry = kvm_find_cpuid_entry(vcpu, 1, 0);
-	if (entry)
-		intel_pmu_lbr_fill(&pmu->lbr,
-			x86_family(entry->eax), x86_model(entry->eax));
 }
 
 static void intel_pmu_init(struct kvm_vcpu *vcpu)