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

Re: [RFC PATCH 09/11] x86: Migrate spec_ctrl vendor checks to x86_vendor_is()


  • To: Jan Beulich <jbeulich@xxxxxxxx>
  • From: Alejandro Vallejo <alejandro.garciavallejo@xxxxxxx>
  • Date: Thu, 11 Dec 2025 11:31:33 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=suse.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none (0)
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=KrATn+ccNbKkWs0oIjMBYpxk6/j0tgAD1k9Q4EulALw=; b=kaLAy2B6skHqp37rGFBypPUAttpdgi92H4EJVEik6qQUCBAWv8FHGkYow1oAbeXl+e//52i0It/4HKfp4OZaBlELOP1wlXKo4dJIJnRAsnQ20MloWvRlTQUdAONsk6B966kJHMQiYSWlV5CZ4C2wkEwZIdgq0/l4z5RnYlZZ2BrCNJ44RNOTCFatGdVemtPvX5276HMTz4STvD9EtmsPjhQHJ5A5gsRgxGLssEMkTCzRZrw2/UVC4RLoprI1MOOCAwTZ9cuZd4FV5pOg3AneygJeCLmMtYj5cDzscYpUGkqBKeGmDz5H7bXUb00SBiwrWUTdNlFuXcjeXl507v792A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=KjVZvTLrdzmpR/9/RL/+fTRgosDYsIDbd4ievO+Z8r5wEZXikpkcZwZWxEa7HzEe9uPURz3xa6BQCwj4Q8x10YdbwJf8TaVPGiayP7cz/lMA83klWdWgIkjcf4BY/KRiDCy+WXDIQ0BRqBc4DeKSrlxXt+aVtuNKp06i/8suX3N+nIQg7A8//eXrcUNHozeGtfdWeSH0YapeWgls/ZHTpJoofnSQOCDRvXhEExGmrR2KwZF0TejQmOlUzbUuNa/GKxALbnpJ8CisQNcDU6/BB3uMviUb0GLb9QmfTIEKrTvd3TcMG1QsGNBfdA6n9tAZMVvYvt+5QifNLrUHtycPeg==
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Jason Andryuk <jason.andryuk@xxxxxxx>, Xenia Ragiadakou <xenia.ragiadakou@xxxxxxx>, "Stefano Stabellini" <sstabellini@xxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • Delivery-date: Thu, 11 Dec 2025 10:31:49 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On Mon Dec 8, 2025 at 5:04 PM CET, Jan Beulich wrote:
> On 26.11.2025 17:44, Alejandro Vallejo wrote:
>> @@ -938,7 +938,7 @@ static bool __init retpoline_calculations(void)
>>   */
>>  static bool __init rsb_is_full_width(void)
>>  {
>> -    if ( boot_cpu_data.vendor != X86_VENDOR_INTEL ||
>> +    if ( !x86_vendor_is(boot_cpu_data.x86_vendor, X86_VENDOR_INTEL) ||
>
> One other aspect: If already you touch lines still using the old (being
> phased out) field names, please rename at the same time. This may then
> also help with line length in some cases.
>
> Jan

Yes, of course. I didn't even notice the difference at first. On the note on
length, I'm revising the idea, keeping the same principle but making it less
verbose.

Seeing how both you and Andrew seem onboard with dropping cross-vendor support
and having these turn into constants, I'm leaning into transforming everything
to a single "cpu_vendor", both host checks and policy checks would become
something of the form:

    if ( cpu_vendor != X86_VENDOR_INTEL )
      ...

    if ( cpu_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON))
      ...

where cpu_vendor would be defined as a runtime check on boot_cpu_data.vendor 
masked with X86_ENABLED_VENDORS when multiple vendors are compiled in, and
the single vendor compiled-in. Perhaps something like... (untested)

#define cpu_vendor \
    ((!IS_ENABLED(CONFIG_UNKNOWN_CPU_VENDOR) && X86_ENABLED_VENDORS &&
      (X86_ENABLED_VENDORS == ISOLATE_LSB(X86_ENABLED_VENDORS)))
        ? X86_ENABLED_VENDORS
        : (boot_cpu_data.vendor & X86_ENABLED_VENDORS))

I _think_ it would have the same DCE implications, but it would be much nicer
to read at the callsites and cause far fewer line wraps.

This brings down complexity, allows for the switches to stay (DCE understands
unreachable labels) and improves the general code quality.

I'm busy atm chasing emulator woes, but a non-rfc series of this will reach
the mailing list at some point. I'll make sure to s/x86_vendor/vendor while at
it.

Cheers,
Alejandro



 


Rackspace

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