[PATCH] elf: Compile AVX512 tests with -mno-vzeroupper [BZ #32882]

Florian Weimer fweimer@redhat.com
Thu Apr 17 05:44:41 GMT 2025


* Aurelien Jarno:

> Recent GCC versions (this got backported to stable branches) emit a
> vzeroupper instruction at the end of functions containing AVX
> instructions. This causes the tst-audit10 test to fails on CPUs lacking
> AVX instructions, despite the AVX512 check. The crash occurs in the
> pltenter function of tst-auditmod10b.c.
>
> Fix that by building the AVX512 tests with the -mno-vzeroupper option,
> similar to the existing approach for AVX tests.
>
> Tested on non-AVX, AVX2 and AVX512 machines.
> ---
>  sysdeps/x86_64/Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/x86_64/Makefile b/sysdeps/x86_64/Makefile
> index 9d31685e02..64c8c63cf1 100644
> --- a/sysdeps/x86_64/Makefile
> +++ b/sysdeps/x86_64/Makefile
> @@ -139,7 +139,7 @@ CFLAGS-tst-auditmod6c.c += $(AVX-CFLAGS)
>  CFLAGS-tst-auditmod7b.c += $(AVX-CFLAGS)
>  CFLAGS-tst-avx-aux.c += $(AVX-CFLAGS)
>  CFLAGS-tst-avxmod.c += $(AVX-CFLAGS)
> -AVX512-CFLAGS = -mavx512f
> +AVX512-CFLAGS = -mavx512f -mno-vzeroupper
>  CFLAGS-tst-audit10-aux.c += $(AVX512-CFLAGS)
>  CFLAGS-tst-auditmod10a.c += $(AVX512-CFLAGS)
>  CFLAGS-tst-auditmod10b.c += $(AVX512-CFLAGS)

This does not fix the bug: -mavx512f code still runs without run-time
checking.

More AVX-512 code needs to be split into separate files, as in:

commit 3c0f7407eedb524c9114bb675cd55b903c71daaa
Author: Florian Weimer <fweimer@redhat.com>
Date:   Mon Mar 7 16:00:25 2016 +0100

    tst-audit4, tst-audit10: Compile AVX/AVX-512 code separately [BZ #19269]
    
    This ensures that GCC will not use unsupported instructions before
    the run-time check to ensure support.

Alternatively, you can try if you can make this work in the same file,
with a target attribute.

Thanks,
Florian



More information about the Libc-alpha mailing list