Skip to contentSkip to conversation

package/qemu: host-qemu does not support AVX512 CPUs

PATCH Applied Yegor Yefremov via buildroot 1 participant 5 messages Sep 14 – Sep 25

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/qemu: host-qemu does not support AVX512 CPUs

From: Yegor Yefremov <[email protected]>

Building gobject-introspection for an x86 CPU variant with AVX512 fails when g-ir-scanner runs the freshly built target binaries under qemu-user:

qemu: uncaught target signal 4 (Illegal instruction) - core dumped

The Qemu TCG engine implements AVX, AVX2, F16C, FMA3 and VAES since Qemu 7.2, but it does not implement the AVX512 instruction set at all [0]. Therefore no -cpu value passed through BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS can make such binaries run, and user-mode emulation is simply not possible for these CPU variants.

Mark those CPUs as unsupported by host-qemu, the same way it is already done for x86_steamroller and x86_core_avx2. This relies on the existing BR2_X86_CPU_HAS_AVX512 symbol, so all AVX512 capable variants are covered, and it disables gobject-introspection and nodejs, which are the two packages needing host-qemu in user mode.

[0] https://gitlab.com/qemu-project/qemu/-/issues/2878

Fixes:

https://autobuild.buildroot.org/results/7ed7f9c36dae1ddb965a0f0021db6cd319927b47/

Assisted-by Claude:claude-opus-5
---
 package/qemu/Config.in.host | 4 ++++
 1 file changed, 4 insertions(+)
package/qemu/Config.in.host +4 -0
index c7dd5876e5..e5379e7224 100644
@@ -23,6 +23,10 @@ config BR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTS
 	default y if BR2_xtensa
 	default y if BR2_x86_64
 	depends on !BR2_x86_steamroller && !BR2_x86_core_avx2
+	# The Qemu TCG engine does not implement the AVX512
+	# instruction set, so binaries built for such CPUs cannot be
+	# emulated.
+	depends on !BR2_X86_CPU_HAS_AVX512
 	depends on !BR2_powerpc_620 && !BR2_powerpc_630
 
 config BR2_PACKAGE_HOST_QEMU_SYSTEM_ARCH_SUPPORTS
Signature · 6 lines
2.34.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hello,

Thanks for the patch!

Quoted 8 lines · Yegor Yefremov via buildroot

From: Yegor Yefremov <[email protected]>

Building gobject-introspection for an x86 CPU variant with AVX512 fails when g-ir-scanner runs the freshly built target binaries under qemu-user:

qemu: uncaught target signal 4 (Illegal instruction) - core dumped

Quoted 8 lines

The Qemu TCG engine implements AVX, AVX2, F16C, FMA3 and VAES since Qemu 7.2, but it does not implement the AVX512 instruction set at all [0]. Therefore no -cpu value passed through BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS can make such binaries run, and user-mode emulation is simply not possible for these CPU variants.

Mark those CPUs as unsupported by host-qemu, the same way it is already done for x86_steamroller and x86_core_avx2. This relies on the existing

Does our BR2_x86_core_avx2 exclusion still makes sense?

1. You're mentioning that the TCG engine implements AVX2, so why is supporting x86_core_avx2 a problem?

2. According to arch/Config.in.x86, BR2_x86_core_avx2 is deprecated and BR2_x86_haswell should be used instead, which I suppose means they are equivalent. But we do exclude BR2_x86_core_avx2 but not BR2_x86_haswell in BR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTS, which doesn't make much sense.

What do you think?

Quoted 4 lines

BR2_X86_CPU_HAS_AVX512 symbol, so all AVX512 capable variants are covered, and it disables gobject-introspection and nodejs, which are the two packages needing host-qemu in user mode.

Quoted 8 lines

[0] https://gitlab.com/qemu-project/qemu/-/issues/2878

Fixes:

https://autobuild.buildroot.org/results/7ed7f9c36dae1ddb965a0f0021db6cd319927b47/

Assisted-by Claude:claude-opus-5

Nevertheless, your patch is good by itself, so I've applied it to master. Thanks!

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#2 lore raw

Hi Thomas,

Quoted 28 lines · Thomas Petazzoni

Hello,

Thanks for the patch!

Quoted 8 lines · Yegor Yefremov via buildroot

From: Yegor Yefremov <[email protected]>

Building gobject-introspection for an x86 CPU variant with AVX512 fails when g-ir-scanner runs the freshly built target binaries under qemu-user:

qemu: uncaught target signal 4 (Illegal instruction) - core dumped

Quoted 8 lines

The Qemu TCG engine implements AVX, AVX2, F16C, FMA3 and VAES since Qemu 7.2, but it does not implement the AVX512 instruction set at all [0]. Therefore no -cpu value passed through BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS can make such binaries run, and user-mode emulation is simply not possible for these CPU variants.

Mark those CPUs as unsupported by host-qemu, the same way it is already done for x86_steamroller and x86_core_avx2. This relies on the existing

Does our BR2_x86_core_avx2 exclusion still makes sense?

1. You're mentioning that the TCG engine implements AVX2, so why is supporting x86_core_avx2 a problem?

Quoted 7 lines

2. According to arch/Config.in.x86, BR2_x86_core_avx2 is deprecated and BR2_x86_haswell should be used instead, which I suppose means they are equivalent. But we do exclude BR2_x86_core_avx2 but not BR2_x86_haswell in BR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTS, which doesn't make much sense.

What do you think?

No, I don't think it does anymore, and I believe it can simply be dropped.

1. The exclusion comes from commit 1f7efaf89f03 ("package/qemu: do not support x86_steamroller or x86_core_avx2", Feb 2020), i.e. from the Qemu 4.2 era, when TCG had no AVX support at all. Since Qemu 7.2, TCG implements AVX, AVX2, F16C, FMA3 and VAES. In Qemu 11.0.0, target/i386/cpu.c:

    #define TCG_EXT_FEATURES (... | CPUID_EXT_AVX | CPUID_EXT_F16C | \
              CPUID_EXT_FMA | ...)
    #define TCG_7_0_EBX_FEATURES (... | CPUID_7_0_EBX_BMI1 | \
              CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_AVX2 | ...)

which covers everything -march=core-avx2 can generate.

2. You are right that core-avx2 and haswell are equivalent: gcc's core-avx2 is a deprecated alias for haswell, and "gcc -march=core-avx2 -Q --help=target" yields exactly the same feature bits as -march=haswell. In arch/Config.in.x86 both also select the very same BR2_X86_CPU_HAS_* symbols. So excluding one and not the other never made much sense. The same applies to broadwell, skylake, zen*, x86-64-v3, ..., which all enable AVX2 and were never excluded - and they do build fine on the autobuilders, which is another hint that AVX2 is not the problem.

3. The steamroller exclusion, however, is still needed - but it is incomplete. steamroller is bdver3, and what TCG cannot emulate there is not AVX, but XOP/FMA4/TBM/LWP. Qemu 11.0.0 has:

    #define TCG_EXT3_FEATURES (CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM | \
              CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A  | \
              CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_KERNEL_FEATURES | \
              CPUID_EXT3_CMP_LEG)

CPUID_EXT3_XOP, CPUID_EXT3_FMA4, CPUID_EXT3_TBM and CPUID_EXT3_LWP are defined in target/i386/cpu.h, but are deliberately not part of that mask.

And the whole Bulldozer family is affected, not only steamroller (checked with gcc -march=<variant> -Q --help=target):

bdver1 (bulldozer): XOP, FMA4, LWP
bdver2 (piledriver): XOP, FMA4, TBM, LWP
bdver3 (steamroller): XOP, FMA4, TBM, LWP
bdver4 (excavator): XOP, FMA4, TBM, LWP (and AVX2)

So BR2_x86_bulldozer, BR2_x86_piledriver and BR2_x86_excavator ought to be excluded as well.

If you agree, I'll send a follow-up patch that:

- drops the !BR2_x86_core_avx2 dependency,
- adds a hidden BR2_X86_CPU_HAS_XOP symbol in arch/Config.in.x86, selected by the four bdver variants, and replaces !BR2_x86_steamroller with !BR2_X86_CPU_HAS_XOP in BR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTS - i.e. the same pattern as the existing BR2_X86_CPU_HAS_AVX512 dependency.

If you'd rather not add a new BR2_X86_CPU_HAS_* symbol for a single user, I can just list the four variants explicitly instead.

Yegor

Quoted 13 lines
Quoted 4 lines

BR2_X86_CPU_HAS_AVX512 symbol, so all AVX512 capable variants are covered, and it disables gobject-introspection and nodejs, which are the two packages needing host-qemu in user mode.

Quoted 8 lines

[0] https://gitlab.com/qemu-project/qemu/-/issues/2878

Fixes:

https://autobuild.buildroot.org/results/7ed7f9c36dae1ddb965a0f0021db6cd319927b47/

Assisted-by Claude:claude-opus-5
Quoted 8 lines

Nevertheless, your patch is good by itself, so I've applied it to master. Thanks!

Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin Embedded Linux and Kernel engineering and training
https://bootlin.com

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

Hello Yegor,

Quoted 8 lines · Yegor Yefremov

No, I don't think it does anymore, and I believe it can simply be dropped.

1. The exclusion comes from commit 1f7efaf89f03 ("package/qemu: do not support x86_steamroller or x86_core_avx2", Feb 2020), i.e. from the Qemu 4.2 era, when TCG had no AVX support at all. Since Qemu 7.2, TCG implements AVX, AVX2, F16C, FMA3 and VAES. In Qemu 11.0.0, target/i386/cpu.c:

Quoted 6 lines
    #define TCG_EXT_FEATURES (... | CPUID_EXT_AVX | CPUID_EXT_F16C | \
              CPUID_EXT_FMA | ...)
    #define TCG_7_0_EBX_FEATURES (... | CPUID_7_0_EBX_BMI1 | \
              CPUID_7_0_EBX_BMI2 | CPUID_7_0_EBX_AVX2 | ...)

which covers everything -march=core-avx2 can generate.

Cool!

Quoted 3 lines

2. You are right that core-avx2 and haswell are equivalent: gcc's core-avx2 is a deprecated alias for haswell, and "gcc -march=core-avx2 -Q --help=target" yields exactly the same feature bits as

TIL about "gcc -march=core-avx2 -Q --help=target", nice!

Quoted 6 lines

-march=haswell. In arch/Config.in.x86 both also select the very same BR2_X86_CPU_HAS_* symbols. So excluding one and not the other never made much sense. The same applies to broadwell, skylake, zen*, x86-64-v3, ..., which all enable AVX2 and were never excluded - and they do build fine on the autobuilders, which is another hint that AVX2 is not the problem.

ACK.

Quoted 24 lines

3. The steamroller exclusion, however, is still needed - but it is incomplete. steamroller is bdver3, and what TCG cannot emulate there is not AVX, but XOP/FMA4/TBM/LWP. Qemu 11.0.0 has:

    #define TCG_EXT3_FEATURES (CPUID_EXT3_LAHF_LM | CPUID_EXT3_SVM | \
              CPUID_EXT3_CR8LEG | CPUID_EXT3_ABM | CPUID_EXT3_SSE4A  | \
              CPUID_EXT3_3DNOWPREFETCH | CPUID_EXT3_KERNEL_FEATURES | \
              CPUID_EXT3_CMP_LEG)

CPUID_EXT3_XOP, CPUID_EXT3_FMA4, CPUID_EXT3_TBM and CPUID_EXT3_LWP are defined in target/i386/cpu.h, but are deliberately not part of that mask.

And the whole Bulldozer family is affected, not only steamroller (checked with gcc -march=<variant> -Q --help=target):

bdver1 (bulldozer): XOP, FMA4, LWP
bdver2 (piledriver): XOP, FMA4, TBM, LWP
bdver3 (steamroller): XOP, FMA4, TBM, LWP
bdver4 (excavator): XOP, FMA4, TBM, LWP (and AVX2)

So BR2_x86_bulldozer, BR2_x86_piledriver and BR2_x86_excavator ought to be excluded as well.

Quoted 8 lines

If you agree, I'll send a follow-up patch that:

- drops the !BR2_x86_core_avx2 dependency,
- adds a hidden BR2_X86_CPU_HAS_XOP symbol in arch/Config.in.x86, selected by the four bdver variants, and replaces !BR2_x86_steamroller with !BR2_X86_CPU_HAS_XOP in BR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTS - i.e. the same pattern as the existing BR2_X86_CPU_HAS_AVX512 dependency.

This looks perfect!

Quoted 2 lines

If you'd rather not add a new BR2_X86_CPU_HAS_* symbol for a single user, I can just list the four variants explicitly instead.

I think adding BR2_X86_CPU_HAS_XOP is better, even if it has a single user. Indeed, it makes it explicit what is the feature that isn't implemented by Qemu.

Thanks a lot for this very thorough answer!

Best regards,

Thomas

Signature · 7 lines
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw
In reply to Yegor Yefremov via buildroot

In reply of:

Quoted 18 lines

Building gobject-introspection for an x86 CPU variant with AVX512 fails when g-ir-scanner runs the freshly built target binaries under qemu-user:

qemu: uncaught target signal 4 (Illegal instruction) - core dumped

The Qemu TCG engine implements AVX, AVX2, F16C, FMA3 and VAES since Qemu 7.2, but it does not implement the AVX512 instruction set at all [0]. Therefore no -cpu value passed through BR2_PACKAGE_HOST_QEMU_USER_MODE_ARGS can make such binaries run, and user-mode emulation is simply not possible for these CPU variants.

Mark those CPUs as unsupported by host-qemu, the same way it is already done for x86_steamroller and x86_core_avx2. This relies on the existing BR2_X86_CPU_HAS_AVX512 symbol, so all AVX512 capable variants are covered, and it disables gobject-introspection and nodejs, which are the two packages needing host-qemu in user mode.

Quoted 8 lines

[0] https://gitlab.com/qemu-project/qemu/-/issues/2878

Fixes:

https://autobuild.buildroot.org/results/7ed7f9c36dae1ddb965a0f0021db6cd319927b47/

Assisted-by Claude:claude-opus-5

Applied to 2025.02.x, 2026.08.x. Thanks

Quoted 9 lines
---
 package/qemu/Config.in.host | 4 ++++
 1 file changed, 4 insertions(+)
package/qemu/Config.in.host +0 -0
index c7dd5876e5..e5379e7224 100644

package/qemu/Config.in.host config BR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTS · line 32

Quoted 10 lines
package/qemu/Config.in.host +4 -0
@@ -23,6 +23,10 @@ config BR2_PACKAGE_HOST_QEMU_ARCH_SUPPORTS
 	default y if BR2_xtensa
 	default y if BR2_x86_64
 	depends on !BR2_x86_steamroller && !BR2_x86_core_avx2
+	# The Qemu TCG engine does not implement the AVX512
+	# instruction set, so binaries built for such CPUs cannot be
+	# emulated.
+	depends on !BR2_X86_CPU_HAS_AVX512
 	depends on !BR2_powerpc_620 && !BR2_powerpc_630
 
 config BR2_PACKAGE_HOST_QEMU_SYSTEM_ARCH_SUPPORTS

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot