Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 926536

Summary: sys-apps/kexec-tools broken with -mtune=native on zen3
Product: Gentoo Linux Reporter: xpenev
Component: Current packagesAssignee: Gentoo's Team for Core System packages <base-system>
Status: UNCONFIRMED ---    
Severity: normal CC: liaoyuan, proxy-maint
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description xpenev 2024-03-09 05:01:35 UTC
This bug is specific to the Gentoo ebuilds. The upstream source code produces working binaries even with

        ./bootstrap && CFLAGS='-march=native -O2 -pipe' && make

on zen3. The breakage comes from the Gentoo ebuild overriding the PURGATORY compiler flags. Specifically, the following gcc flags (which are all set with -march=znver3) when applied to the PURGATORY cflags result in broken binaries:

        -mavx
        -mavx2
        -mfma
        -mbmi
        -mbmi2
        -mf16c
        -mmovbe

One way to reproduce / verify the broken state of the package is:

# CFLAGS='-O2 -pipe' ebuild /var/db/repos/gentoo/sys-apps/kexec-tools/kexec-tools-9999.ebuild clean compile
# /var/tmp/portage/sys-apps/kexec-tools-9999/work/kexec-tools-9999/build/sbin/kexec -c -d -l /boot/vmlinuz-$(uname -r) --reuse-cmdline &> ~/broken
# CFLAGS='-march=znver3 -O2 -pipe' ebuild /var/db/repos/gentoo/sys-apps/kexec-tools/kexec-tools-9999.ebuild clean compile
# /var/tmp/portage/sys-apps/kexec-tools-9999/work/kexec-tools-9999/build/sbin/kexec -c -d -l /boot/vmlinuz-$(uname -r) --reuse-cmdline &> ~/broken
# diff -u ~/working ~/broken | wc -l
644

Attempting to kexec kernels with the broken kexec tools results in a silent failure (without any kernel backtraces) and hard reset.

The diff should show ~34 lines of differences (mostly randomized buffer addresses), rather than the 644 lines of differences across various elf symbols.

Note that although I have used version 9999 as an example, the other ebuilds are also broken. It's just that kexec-tools-2.0.24 is also broken in a different way [1].

[1] https://lore.kernel.org/all/Zb9TtfGOtstr3aTj@MiWiFi-R3L-srv/T/