]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Aug 2022 15:59:32 +0000 (17:59 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 15 Aug 2022 15:59:32 +0000 (17:59 +0200)
added patches:
kvm-x86-pmu-fix-the-compare-function-used-by-the-pmu-event-filter.patch

queue-5.10/kvm-x86-pmu-fix-the-compare-function-used-by-the-pmu-event-filter.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/kvm-x86-pmu-fix-the-compare-function-used-by-the-pmu-event-filter.patch b/queue-5.10/kvm-x86-pmu-fix-the-compare-function-used-by-the-pmu-event-filter.patch
new file mode 100644 (file)
index 0000000..092f209
--- /dev/null
@@ -0,0 +1,44 @@
+From 4ac19ead0dfbabd8e0bfc731f507cfb0b95d6c99 Mon Sep 17 00:00:00 2001
+From: Aaron Lewis <aaronlewis@google.com>
+Date: Tue, 17 May 2022 05:12:36 +0000
+Subject: kvm: x86/pmu: Fix the compare function used by the pmu event filter
+
+From: Aaron Lewis <aaronlewis@google.com>
+
+commit 4ac19ead0dfbabd8e0bfc731f507cfb0b95d6c99 upstream.
+
+When returning from the compare function the u64 is truncated to an
+int.  This results in a loss of the high nybble[1] in the event select
+and its sign if that nybble is in use.  Switch from using a result that
+can end up being truncated to a result that can only be: 1, 0, -1.
+
+[1] bits 35:32 in the event select register and bits 11:8 in the event
+    select.
+
+Fixes: 7ff775aca48ad ("KVM: x86/pmu: Use binary search to check filtered events")
+Signed-off-by: Aaron Lewis <aaronlewis@google.com>
+Reviewed-by: Sean Christopherson <seanjc@google.com>
+Message-Id: <20220517051238.2566934-1-aaronlewis@google.com>
+Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+ arch/x86/kvm/pmu.c |    7 +++++--
+ 1 file changed, 5 insertions(+), 2 deletions(-)
+
+--- a/arch/x86/kvm/pmu.c
++++ b/arch/x86/kvm/pmu.c
+@@ -170,9 +170,12 @@ static bool pmc_resume_counter(struct kv
+       return true;
+ }
+-static int cmp_u64(const void *a, const void *b)
++static int cmp_u64(const void *pa, const void *pb)
+ {
+-      return *(__u64 *)a - *(__u64 *)b;
++      u64 a = *(u64 *)pa;
++      u64 b = *(u64 *)pb;
++
++      return (a > b) - (a < b);
+ }
+ void reprogram_gp_counter(struct kvm_pmc *pmc, u64 eventsel)
index 5c8ab7a5753205579e83422399d2b62c4164f713..8130d962fc96366df311344ab480da681f96e6ad 100644 (file)
@@ -541,3 +541,4 @@ drm-vc4-change-vc4_dma_range_matches-from-a-global-to-static.patch
 revert-net-usb-ax88179_178a-needs-flag_send_zlp.patch
 bluetooth-l2cap-fix-l2cap_global_chan_by_psm-regression.patch
 mtd-rawnand-arasan-prevent-an-unsupported-configuration.patch
+kvm-x86-pmu-fix-the-compare-function-used-by-the-pmu-event-filter.patch