[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


  • To: Roger Pau Monné <roger@xxxxxxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>
  • From: "Alejandro Vallejo" <alejandro.garciavallejo@xxxxxxx>
  • Date: Mon, 19 Oct 2026 11:57:03 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none
  • 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=20Xj4+fFCJ9DxG7VWK3ia5TVuJSi01rEY7gT0dVWtFM=; b=eb8doOJGy8Eg9P+u+nE3IUe1USC/vTw3ZIuOwZlE0kTfDxNFcJzCwkMKIqmUKQTZq6dbHoIm+uLY9nDYL18yV+tS5fHiVF3cHMRk+UHgu315ITm40awb7+F7mjivV/hzdOkGaDD4hNjnMKH7jerUpo59YF7OFaFAK1iojWBV21f+drzQe7/txDtwj5yP1YWlggGzR23PmoZEjrhNj7zEv77SilcffAAgHAV2dVmJJmb1hVGHiZDHRqArVG4CzQlCUIVRsTBueKIZF4r6IBTIJ3L+WLplRHkuHmxbNTYcfOtMXZYItfkBVRYdTe/L4seKaKAklp5nmWI/7j4vVdMZPQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Y/HnD1cErJqBGO/AD0qmQKY/4wrX4sxTAyBQdJM4hhzS0hxOqprgMY3a+IWKVfnJOYCIN4LOkCItQlOdwfy6hAl0pBuhTtuILR/RVMTVVtQAY4W53JhTkKG0aAWtQgWYn8Nqpv+zE+DbAvO41+0fcQDbV7x1eXglFL3e9LKMiX/BFitMw+HojzcKNf3pFLEYadrH4WXouCrjnF0WKOpoueP/1S4yFbX92twUKZYRVqdW/9cABtrylDsNeOn8NJ9rWIU5UAIgiGm4vgPspHiU6ykGig1NzoHQuftfBTSzTtThqhoWf86qOnxNfeCWvyA8WJEEhpX7wwqHyWcG+ve/wQ==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=amd.com header.i="@amd.com" header.h="From:Date:Subject:Message-Id:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results: mx.microsoft.com 1; dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com;
  • Cc: "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, "Andrew Cooper" <andrew.cooper3@xxxxxxxxxx>, "Teddy Astie" <teddy.astie@xxxxxxxxxx>, "Jason Andryuk" <jason.andryuk@xxxxxxx>
  • Delivery-date: Mon, 19 Oct 2026 09:57:20 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

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.




 


Rackspace

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