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

Re: [PATCH 4/6] x86/vpmu: Sanitise Intel PMU version


  • To: "Jan Beulich" <jbeulich@xxxxxxxx>
  • From: "Teddy Astie" <teddy.astie@xxxxxxxxxx>
  • Date: Wed, 25 Mar 2026 09:52:34 +0000
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=mte1 header.d=mandrillapp.com header.i="@mandrillapp.com" header.h="From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"; dkim=pass header.s=mte1 header.d=vates.tech header.i="teddy.astie@xxxxxxxxxx" header.h="From:Subject:Message-Id:To:Cc:References:In-Reply-To:Feedback-ID:Date:MIME-Version:Content-Type:Content-Transfer-Encoding"
  • Cc: "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx>, "Roger Pau Monné" <roger.pau@xxxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Wed, 25 Mar 2026 09:52:44 +0000
  • Feedback-id: 30504962:30504962.20260325:md
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Le 24/03/2026 à 17:03, Jan Beulich a écrit :
> On 10.03.2026 17:44, Teddy Astie wrote:
>> --- a/xen/arch/x86/cpu-policy.c
>> +++ b/xen/arch/x86/cpu-policy.c
>> @@ -253,6 +253,33 @@ static void recalculate_xstate(struct cpu_policy *p)
>>       }
>>   }
>>
>> +static void sanitise_vpmu(struct cpu_policy *p)
>> +{
>> +switch ( p->x86_vendor )
>
> Nit: Lack of indentation.
>
>> +    {
>> +    case X86_VENDOR_INTEL:
>> +        if ( !p->basic.pmu.version )
>> +            return;
>
> Better use "break", but: Why is this check needed anyway? Nothing ...
>

My idea was to return early if there is no version (keeping everything
0). But as I only added checks for PMU version in this patch, this is
effectively redundant at this moment.

Although, "x86/vpmu: Limit to using supported general/fixed counters"
makes some additional adjustments to the CPUID if pmu.version != 0
making it non redundant anymore.

But yes, it wants 'break' here.

>> +        /*
>> +         * Expose up to PMU version 2
>> +         *
>> +         * PMU version 3 introduced the AnyThread bit we don't want
>> +         * to support (see "AnyThread Counting and Software Evolution"
>> +         * regarding notes with virtualization). This is the only known
>> +         * feature introduced in PMU version 3.
>> +         *
>> +         * PMU version 5 deprecated AnyThread, and introduced a CPUID
>> +         * bit (ANYTHREAD_DEPRECATION) to indicate that this bit isn't 
>> supported.
>> +         * That CPUID bit should be set for PMU version 5.
>> +         */
>> +        if ( p->basic.pmu.version > 2 )
>> +            p->basic.pmu.version = 2;
>> +
>> +        break;
>> +    }
>
> ... here breaks if it was dropped.
>
> Jan
>

Teddy


--
Teddy Astie | Vates XCP-ng Developer

XCP-ng & Xen Orchestra - Vates solutions

web: https://vates.tech





 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.