All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger@xenproject.org>
To: Jan Beulich <jbeulich@suse.com>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Andrew Cooper <andrew.cooper3@citrix.com>,
	Teddy Astie <teddy.astie@vates.tech>,
	Jason Andryuk <jason.andryuk@amd.com>,
	alejandro.garciavallejo@amd.com
Subject: Re: [PATCH v4 3/3] x86: short-circuit certain cpu_has_* when x86-64-v{2,3} are in effect
Date: Mon, 19 Oct 2026 11:34:16 +0200	[thread overview]
Message-ID: <atXkGLicylXMQ8_H@Mac.lan> (raw)
In-Reply-To: <18b38bd8-bc6b-4925-8880-234c7d2b9497@suse.com>

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@suse.com>
> Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
> ---
> 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.

Regards, Roger.


  reply	other threads:[~2026-10-19  9:34 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15  9:08 [PATCH v4 0/3] x86: allow Kconfig control over psABI level Jan Beulich
2026-10-15  9:09 ` [PATCH v4 1/3] x86: allow Kconfig control over psABI level to use Jan Beulich
2026-10-15  9:10 ` [PATCH v4 2/3] x86: use __builtin_popcountl() for arch_hweightl() when available Jan Beulich
2026-10-15 10:37   ` Andrew Cooper
2026-10-15 12:22     ` Jan Beulich
2026-10-15  9:11 ` [PATCH v4 3/3] x86: short-circuit certain cpu_has_* when x86-64-v{2,3} are in effect Jan Beulich
2026-10-19  9:34   ` Roger Pau Monné [this message]
2026-10-19  9:57     ` Alejandro Vallejo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=atXkGLicylXMQ8_H@Mac.lan \
    --to=roger@xenproject.org \
    --cc=alejandro.garciavallejo@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jason.andryuk@amd.com \
    --cc=jbeulich@suse.com \
    --cc=teddy.astie@vates.tech \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.