public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86/vPMU: ignore the check of IA32_PERF_GLOBAL_CTRL bit35
@ 2023-06-02  7:02 Gao Shiyuan
  2023-06-02 18:43 ` Jim Mattson
  0 siblings, 1 reply; 12+ messages in thread
From: Gao Shiyuan @ 2023-06-02  7:02 UTC (permalink / raw)
  To: seanjc, pbonzini, x86, kvm; +Cc: likexu, Shiyuan Gao

From: Shiyuan Gao <gaoshiyuan@baidu.com>

When live-migrate VM on icelake microarchitecture, if the source
host kernel before commit 2e8cd7a3b828 ("kvm: x86: limit the maximum
number of vPMU fixed counters to 3") and the dest host kernel after this
commit, the migration will fail.

The source VM's CPUID.0xA.edx[0..4]=4 that is reported by KVM and
the IA32_PERF_GLOBAL_CTRL MSR is 0xf000000ff. However the dest VM's
CPUID.0xA.edx[0..4]=3 and the IA32_PERF_GLOBAL_CTRL MSR is 0x7000000ff.
This inconsistency leads to migration failure.

The QEMU limits the maximum number of vPMU fixed counters to 3, so ignore
the check of IA32_PERF_GLOBAL_CTRL bit35.

Fixes: 2e8cd7a3b828 ("kvm: x86: limit the maximum number of vPMU fixed counters to 3")

Signed-off-by: Shiyuan Gao <gaoshiyuan@baidu.com>
---
 arch/x86/kvm/pmu.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h
index 5c7bbf03b599..9895311d334e 100644
--- a/arch/x86/kvm/pmu.h
+++ b/arch/x86/kvm/pmu.h
@@ -91,7 +91,7 @@ static inline bool pmc_is_fixed(struct kvm_pmc *pmc)
 static inline bool kvm_valid_perf_global_ctrl(struct kvm_pmu *pmu,
 						 u64 data)
 {
-	return !(pmu->global_ctrl_mask & data);
+	return !(pmu->global_ctrl_mask & (data & ~(1ULL << 35)));
 }
 
 /* returns general purpose PMC with the specified MSR. Note that it can be
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-06-14 12:37 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-02  7:02 [PATCH] KVM: x86/vPMU: ignore the check of IA32_PERF_GLOBAL_CTRL bit35 Gao Shiyuan
2023-06-02 18:43 ` Jim Mattson
2023-06-02 19:16   ` Sean Christopherson
2023-06-02 19:30     ` Jim Mattson
2023-06-02 21:48       ` Sean Christopherson
2023-06-02 22:38         ` Jim Mattson
2023-06-02 22:52           ` Sean Christopherson
2023-06-02 23:09             ` Jim Mattson
2023-06-05  3:53               ` Gao,Shiyuan
2023-06-13 21:00                 ` Sean Christopherson
2023-06-14 12:36                   ` Gao,Shiyuan
2023-06-05  3:31             ` Gao,Shiyuan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox