Patch "kvm: x86/pmu: Fix the compare function used by the pmu event filter" has been added to the 5.17-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    kvm: x86/pmu: Fix the compare function used by the pmu event filter

to the 5.17-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     kvm-x86-pmu-fix-the-compare-function-used-by-the-pmu.patch
and it can be found in the queue-5.17 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 60a912e144bc006f5ab66c298f5457a25c909eff
Author: Aaron Lewis <aaronlewis@xxxxxxxxxx>
Date:   Tue May 17 05:12:36 2022 +0000

    kvm: x86/pmu: Fix the compare function used by the pmu event filter
    
    [ Upstream commit 4ac19ead0dfbabd8e0bfc731f507cfb0b95d6c99 ]
    
    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@xxxxxxxxxx>
    Reviewed-by: Sean Christopherson <seanjc@xxxxxxxxxx>
    Message-Id: <20220517051238.2566934-1-aaronlewis@xxxxxxxxxx>
    Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index eca39f56c231..0604bc29f0b8 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -171,9 +171,12 @@ static bool pmc_resume_counter(struct kvm_pmc *pmc)
 	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)



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux