DPDK-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Bruce Richardson <bruce.richardson@intel.com>
To: Dragos Tarcatu <dragos.tarcatu@keysight.com>
Cc: <dev@dpdk.org>, <konstantin.v.ananyev@yandex.ru>, <stable@dpdk.org>
Subject: Re: [PATCH] eal/x86: check OS support for AVX and AVX512 state
Date: Wed, 7 Oct 2026 14:01:13 +0100	[thread overview]
Message-ID: <asZCmYlJ2KmItl7J@bricha3-mobl1.ger.corp.intel.com> (raw)
In-Reply-To: <20261006082056.46426-1-dragos.tarcatu@keysight.com>

On Tue, Oct 06, 2026 at 08:20:56AM +0000, Dragos Tarcatu wrote:
> rte_cpu_get_flag_enabled() reads only the CPUID feature bits.  CPUID
> tells what the CPU implements, not what the OS enables.  If the OS does
> not enable the related state components in XCR0, the first AVX or AVX512
> instruction raises #UD.
> 
> CPUID can report AVX512 while XCR0 has no AVX512 state. Old kernels
> without AVX512 state support leave XCR0 at 0x7. A kernel booted with
> clearcpuid=avx512f removes the AVX512 state from XCR0, but CPUID still
> reports AVX512F. Similarly, gather_data_sampling=force removes the AVX
> state.
> 
> On such a system, the rte_net_crc constructor selects the AVX512 code
> from CPUID alone. The dynamic loader runs this constructor before main(),
> so the application gets SIGILL before EAL can parse any argument.
> 
> For the AVX-class and AVX512-class flags, also read XCR0 with XGETBV.
> Report the flag only when the OS has enabled the related state.  Use
> XGETBV only when CPUID reports OSXSAVE, because the instruction faults
> otherwise.
> 
> This change also affects rte_cpu_is_supported(). If DPDK is built for
> AVX512 and the OS does not enable AVX512 state, EAL can now stop with an
> error that names the missing flag. This is possible only if no AVX512
> instruction executes before rte_eal_init(), for example in a constructor.
> 
> Fixes: 3934bb741354 ("eal/x86: identify AVX512 CPU flag") Cc:
> stable@dpdk.org
> 
> Signed-off-by: Dragos Tarcatu <dragos.tarcatu@keysight.com> ---
> lib/eal/include/generic/rte_cpuflags.h |   3 + lib/eal/x86/rte_cpuflags.c
> | 102 ++++++++++++++++++++----- 2 files changed, 86 insertions(+), 19
> deletions(-)
> 
Tested this using two "x86-generic" builds from test-meson-builds.sh, one
with this patch and one without. The test app from the one without the
patch gives illegal instruction on an initializer for avx512 crc, while the
one with runs successfully.

Code looks correct to me also.

Tested-by: Bruce Richardson <bruce.richardson@intel.com>
Acked-by: Bruce Richardson <bruce.richardson@intel.com>


  reply	other threads:[~2026-10-07 13:01 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-06  8:20 [PATCH] eal/x86: check OS support for AVX and AVX512 state Dragos Tarcatu
2026-10-07 13:01 ` Bruce Richardson [this message]
2026-10-07 13:03   ` Bruce Richardson

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=asZCmYlJ2KmItl7J@bricha3-mobl1.ger.corp.intel.com \
    --to=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=dragos.tarcatu@keysight.com \
    --cc=konstantin.v.ananyev@yandex.ru \
    --cc=stable@dpdk.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox