public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86/pmu: Fix type length error when reading pmu->fixed_ctr_ctrl
@ 2024-01-23 22:12 Mingwei Zhang
  2024-01-31 15:43 ` Sean Christopherson
  2024-02-03  0:11 ` Sean Christopherson
  0 siblings, 2 replies; 13+ messages in thread
From: Mingwei Zhang @ 2024-01-23 22:12 UTC (permalink / raw)
  To: Sean Christopherson, Paolo Bonzini
  Cc: H. Peter Anvin, kvm, linux-kernel, Mingwei Zhang

Fix type length error since pmu->fixed_ctr_ctrl is u64 but the local
variable old_fixed_ctr_ctrl is u8. Truncating the value leads to
information loss at runtime. This leads to incorrect value in old_ctrl
retrieved from each field of old_fixed_ctr_ctrl and causes incorrect code
execution within the for loop of reprogram_fixed_counters(). So fix this
type to u64.

Fixes: 76d287b2342e ("KVM: x86/pmu: Drop "u8 ctrl, int idx" for reprogram_fixed_counter()")
Signed-off-by: Mingwei Zhang <mizhang@google.com>
---
 arch/x86/kvm/vmx/pmu_intel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
index a6216c874729..315c7c2ba89b 100644
--- a/arch/x86/kvm/vmx/pmu_intel.c
+++ b/arch/x86/kvm/vmx/pmu_intel.c
@@ -71,7 +71,7 @@ static int fixed_pmc_events[] = {
 static void reprogram_fixed_counters(struct kvm_pmu *pmu, u64 data)
 {
 	struct kvm_pmc *pmc;
-	u8 old_fixed_ctr_ctrl = pmu->fixed_ctr_ctrl;
+	u64 old_fixed_ctr_ctrl = pmu->fixed_ctr_ctrl;
 	int i;
 
 	pmu->fixed_ctr_ctrl = data;

base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d
-- 
2.43.0.429.g432eaa2c6b-goog


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

end of thread, other threads:[~2024-02-03  0:12 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-23 22:12 [PATCH] KVM: x86/pmu: Fix type length error when reading pmu->fixed_ctr_ctrl Mingwei Zhang
2024-01-31 15:43 ` Sean Christopherson
2024-01-31 17:02   ` Dongli Zhang
2024-01-31 17:13     ` Mingwei Zhang
2024-02-01 17:28       ` Sean Christopherson
2024-02-01 18:30         ` Mingwei Zhang
2024-02-01 19:36           ` Sean Christopherson
2024-02-01 19:53             ` Mingwei Zhang
2024-02-01 22:53               ` Sean Christopherson
2024-02-01 23:00                 ` Mingwei Zhang
2024-02-02  3:25             ` Zhang, Xiong Y
2024-02-02 17:07               ` Sean Christopherson
2024-02-03  0:11 ` Sean Christopherson

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