]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
KVM: x86/pmu: Fix type length error when reading pmu->fixed_ctr_ctrl
authorMingwei Zhang <mizhang@google.com>
Tue, 23 Jan 2024 22:12:20 +0000 (22:12 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 23 Feb 2024 08:51:49 +0000 (09:51 +0100)
commit6d10c8c5abd1437dcbc209e307d930da60b86e91
treea9228643dfcc69b5f7bb579400bee76ea83b24a8
parentfa2b524a73545d25ae15e3d2930b9bfa83b40827
KVM: x86/pmu: Fix type length error when reading pmu->fixed_ctr_ctrl

commit 05519c86d6997cfb9bb6c82ce1595d1015b718dc upstream.

Use a u64 instead of a u8 when taking a snapshot of pmu->fixed_ctr_ctrl
when reprogramming fixed counters, as truncating the value results in KVM
thinking fixed counter 2 is already disabled (the bug also affects fixed
counters 3+, but KVM doesn't yet support those).  As a result, if the
guest disables fixed counter 2, KVM will get a false negative and fail to
reprogram/disable emulation of the counter, which can leads to incorrect
counts and spurious PMIs in the guest.

Fixes: 76d287b2342e ("KVM: x86/pmu: Drop "u8 ctrl, int idx" for reprogram_fixed_counter()")
Cc: stable@vger.kernel.org
Signed-off-by: Mingwei Zhang <mizhang@google.com>
Link: https://lore.kernel.org/r/20240123221220.3911317-1-mizhang@google.com
[sean: rewrite changelog to call out the effects of the bug]
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/vmx/pmu_intel.c