lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8ca78cd6-12ad-56c4-ad73-e88757364ba9@redhat.com>
Date:   Thu, 9 Dec 2021 19:49:18 +0100
From:   Paolo Bonzini <pbonzini@...hat.com>
To:     Jim Mattson <jmattson@...gle.com>,
        Like Xu <like.xu.linux@...il.com>
Cc:     Sean Christopherson <seanjc@...gle.com>,
        Vitaly Kuznetsov <vkuznets@...hat.com>,
        Wanpeng Li <wanpengli@...cent.com>,
        Joerg Roedel <joro@...tes.org>, kvm@...r.kernel.org,
        linux-kernel@...r.kernel.org, Like Xu <likexu@...cent.com>
Subject: Re: [PATCH v2 1/6] KVM: x86/pmu: Setup pmc->eventsel for fixed PMCs

On 12/6/21 20:57, Jim Mattson wrote:
>> +
>> +       for (i = 0; i < pmu->nr_arch_fixed_counters; i++) {
>> +               pmc = &pmu->fixed_counters[i];
>> +               event = fixed_pmc_events[array_index_nospec(i, size)];
> How do we know that i < size? For example, Ice Lake supports 4 fixed
> counters, but fixed_pmc_events only has three entries.

We don't, and it's a preexisting bug in intel_pmu_refresh.  Either we hack around it like

diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
index 1b7456b2177b..6f03c8bf1bc2 100644
--- a/arch/x86/kvm/vmx/pmu_intel.c
+++ b/arch/x86/kvm/vmx/pmu_intel.c
@@ -500,8 +500,9 @@ static void intel_pmu_refresh(struct kvm_vcpu *vcpu)
  		pmu->nr_arch_fixed_counters = 0;
  	} else {
  		pmu->nr_arch_fixed_counters =
-			min_t(int, edx.split.num_counters_fixed,
-			      x86_pmu.num_counters_fixed);
+			min3(ARRAY_SIZE(fixed_pmc_events),
+			     (size_t) edx.split.num_counters_fixed,
+			     (size_t) x86_pmu.num_counters_fixed);
  		edx.split.bit_width_fixed = min_t(int,
  			edx.split.bit_width_fixed, x86_pmu.bit_width_fixed);
  		pmu->counter_bitmask[KVM_PMC_FIXED] =

or we modify find_fixed_event and its caller to support PERF_TYPE_RAW
counters, and then add support for the IceLake TOPDOWN.SLOTS fixed
counter.

What's your preference?

Paolo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ