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

Reply via email to