|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v4 3/3] x86: short-circuit certain cpu_has_* when x86-64-v{2,3} are in effect
On Mon Oct 19, 2026 at 11:34 AM CEST, Roger Pau Monné wrote:
> On Thu, Oct 15, 2026 at 11:11:39AM +0200, Jan Beulich wrote:
> > Certain fallback code can be made subject to DCE this way. Note that
> > CX16 has no compiler provided manifest constant, so CONFIG_* are used
> > there instead. Note also that we don't have cpu_has_movbe nor
> > cpu_has_lzcnt (aka cpu_has_abm), and we no longer have
> > cpu_has_{popcnt,bmi1,bmi2}.
> >
> > Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> > Reviewed-by: Jason Andryuk <jandryuk@xxxxxxxxx>
> > ---
> > Of course we could use IS_ENABLED(CONFIG_X86_64_V<n>) everywhere, but as
> > CX16 shows this isn't necessarily better than the #if/#else approach
> > based on compiler-provided manifest symbols. While not really intended
> > to be used that way, it looks as if we could also use
> > IS_ENABLED(__POPCNT__) and alike if we thought this would end up neater
> > (because of avoiding the #ifdef).
> >
> > We could go further and also short-circuit SSE*, AVX and alike, which we
> > don't use outside of the emulator. This then would of course call for
> > also having a way to select x86-64-v4.
> > ---
> > v4: Re-base (over dropped cpu_has_{popcnt,bmi1,bmi2}).
> > v2: Also cover XSAVE.
> >
> > --- a/xen/arch/x86/include/asm/cpufeature.h
> > +++ b/xen/arch/x86/include/asm/cpufeature.h
> > @@ -132,11 +132,17 @@ static inline bool boot_cpu_has(unsigned
> > #define cpu_has_monitor boot_cpu_has(X86_FEATURE_MONITOR)
> > #define cpu_has_vmx boot_cpu_has(X86_FEATURE_VMX)
> > #define cpu_has_eist boot_cpu_has(X86_FEATURE_EIST)
> > -#define cpu_has_cx16 boot_cpu_has(X86_FEATURE_CX16)
> > +#define cpu_has_cx16 (IS_ENABLED(CONFIG_X86_64_V2) || \
> > + IS_ENABLED(CONFIG_X86_64_V3) || \
> > + boot_cpu_has(X86_FEATURE_CX16))
> > #define cpu_has_pdcm boot_cpu_has(X86_FEATURE_PDCM)
> > #define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
> > #define cpu_has_x2apic boot_cpu_has(X86_FEATURE_X2APIC)
> > +#ifdef __XSAVE__
> > +#define cpu_has_xsave true
> > +#else
> > #define cpu_has_xsave boot_cpu_has(X86_FEATURE_XSAVE)
> > +#endif
> > #define cpu_has_avx boot_cpu_has(X86_FEATURE_AVX)
> > #define cpu_has_rdrand boot_cpu_has(X86_FEATURE_RDRAND)
> > #define cpu_has_hypervisor boot_cpu_has(X86_FEATURE_HYPERVISOR)
>
> Alejandro (now added on Cc) is working on something that achieves the
> same end, but it's more transparent and doesn't require modifying
> individual cpu_has_ macros every time we want to short-circuit one of
> those. I think it would be helpful here also.
Yes, my cpu_has work would simplify this quite a lot, and it would
effectively deprecate the ad-hoc nature of REQUIRE_NX cont-ification.
I'll try sending upstream an adapted version some time early this week.
Cheers,
Alejandro
>
> Regards, Roger.
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |