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

Re: [PATCH] x86/cpu-policy: Remove cpu_policy.x86_vendor


  • To: ODIN Thomas <thomas.odin@xxxxxxxxxx>
  • From: Jan Beulich <jbeulich@xxxxxxxx>
  • Date: Thu, 3 Dec 2026 12:05:14 +0100
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=google header.d=suse.com header.i="@suse.com" header.h="Content-Transfer-Encoding:Content-Type:In-Reply-To:Autocrypt:From:Content-Language:References:Cc:To:Subject:User-Agent:MIME-Version:Date:Message-ID"
  • Autocrypt: addr=jbeulich@xxxxxxxx; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC1gbb3K3qk+LpBtvjBu1RY9drYk0NymiGbJWZgab6t1jM7sk2vuf0Py O9Hf9XBmK0uE9IgMaiCpc32XV9oASz6UJebwkX+zF2jG5I1BfnO9g7KlotcA/v5ClMjgo6Gl MDY4HxoSRu3i1cqqSDtVlt+AOVBJBACrZcnHAUSuCXBPy0jOlBhxPqRWv6ND4c9PH1xjQ3NP nxJuMBS8rnNg22uyfAgmBKNLpLgAGVRMZGaGoJObGf72s6TeIqKJo/LtggAS9qAUiuKVnygo 3wjfkS9A3DRO+SpU7JqWdsveeIQyeyEJ/8PTowmSQLakF+3fote9ybzd880fSmFuIEJldWxp Y2ggPGpiZXVsaWNoQHN1c2UuY29tPsJgBBMRAgAgBQJZN5xEAhsDBgsJCAcDAgQVAggDBBYC AwECHgECF4AACgkQoDSui/t3IH4J+wCfQ5jHdEjCRHj23O/5ttg9r9OIruwAn3103WUITZee e7Sbg12UgcQ5lv7SzsFNBFk3nEQQCACCuTjCjFOUdi5Nm244F+78kLghRcin/awv+IrTcIWF hUpSs1Y91iQQ7KItirz5uwCPlwejSJDQJLIS+QtJHaXDXeV6NI0Uef1hP20+y8qydDiVkv6l IreXjTb7DvksRgJNvCkWtYnlS3mYvQ9NzS9PhyALWbXnH6sIJd2O9lKS1Mrfq+y0IXCP10eS FFGg+Av3IQeFatkJAyju0PPthyTqxSI4lZYuJVPknzgaeuJv/2NccrPvmeDg6Coe7ZIeQ8Yj t0ARxu2xytAkkLCel1Lz1WLmwLstV30g80nkgZf/wr+/BXJW/oIvRlonUkxv+IbBM3dX2OV8 AmRv1ySWPTP7AAMFB/9PQK/VtlNUJvg8GXj9ootzrteGfVZVVT4XBJkfwBcpC/XcPzldjv+3 HYudvpdNK3lLujXeA5fLOH+Z/G9WBc5pFVSMocI71I8bT8lIAzreg0WvkWg5V2WZsUMlnDL9 mpwIGFhlbM3gfDMs7MPMu8YQRFVdUvtSpaAs8OFfGQ0ia3LGZcjA6Ik2+xcqscEJzNH+qh8V m5jjp28yZgaqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger@xxxxxxxxxxxxxx>, Teddy Astie <teddy.astie@xxxxxxxxxx>, Anthony PERARD <anthony.perard@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
  • Delivery-date: Thu, 03 Dec 2026 11:05:28 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

On 03.12.2026 11:39, ODIN Thomas wrote:
> On 12/2/26 16:07, Jan Beulich wrote:
>> On 02.12.2026 10:42, ODIN Thomas wrote:
>>> c520286a53 ("x86: Reject CPU policies with vendors other than the
>>> host's") made x86_cpu_policies_are_compatible() reject any guest CPU
>>> policy whose vendor doesn't match the host's, and that check runs
>>> before a policy is ever installed.  Every cpu_policy visible to a
>>> running domain, or to any other in-hypervisor consumer (the
>>> raw/host/pv_max/hvm_max policies, all derived from the host's own
>>> CPUID), therefore now necessarily has the same vendor as
>>> boot_cpu_data.x86_vendor.
>>>
>>> The cached x86_vendor field is thus redundant, so we drop it, and
>>> x86_cpu_policy_recalc_synth() along with it, since that function's
>>> only job was to compute it.
>>>
>>> The lib/x86 code shared with the toolstack and the emulator's
>>> standalone test suite has no boot_cpu_data to fall back on (and isn't
>>> covered by the same guarantee), so those few spots compute the vendor
>>> from basic.vendor_ebx/ecx/edx via x86_cpuid_lookup_vendor() instead of
>>> caching it.
>>
>> I wonder whether this somewhat ugly aspect was taken into account when ...
>>
>>> No functional change.
>>>
>>> Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
>>
>> ... Andrew suggested this.
> 
> To be fair, in our discussion Andrew only suggested removing 
> cpu_policy.x86_vendor as a small, isolated cleanup task (since c520286a53
> made it redundant with the host vendor in Xen) to get familiar with the
> patch workflow before tackling the larger x86_cpu_policies_are_compatible() 
> work.
> 
> The x86_cpuid_lookup_vendor() fallback in the shared lib/x86 paths was 
> something I ran into when implementing the removal, since those consumers 
> don't have boot_cpu_data. There are five call sites that each spell out 
> x86_cpuid_lookup_vendor(p->basic.vendor_ebx, p->basic.vendor_ecx,
> p->basic.vendor_edx) instead of going through one accessor. Would a
> small helper wrapping that call be better here, or would you rather I keep
> the cached field around instead of working around its absence in lib/x86?

Well, first and foremost you will need Andrew's input.

Then: Yes, a helper would remove the fragility at call sites. It wouldn't
remove the extra overhead. Take _amd_like() for example. That's a simple
logical-and expression right now, and you switch it to a function call.
That's okay-ish for the test/fuzzing harnesses, but less so for code Xen.
(Yes, emulation is slow anyway, but we shouldn't make it yet slower when
we can avoid doing so.) I'm therefore inclined to suggest that this gain
__XEN__-dependent logic, e.g.:

static inline bool
_amd_like(const struct cpu_policy *cp)
{
#ifdef __XEN__
    return boot_cpu_data.vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON);
#else
    unsigned int vendor = x86_cpu_policy_lookup_vendor(cp);

    return vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON);
#endif
}

Of course the vendor retrieval itself may want further breaking out into
a function, thus limiting the #ifdef-ary to just there.

Jan



 


Rackspace

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