Re: [PATCH] x86/build/64: Prevent native builds from generating APX instructions
From: David Laight
Date: Sat Aug 01 2026 - 07:44:48 EST
On Wed, 8 Jul 2026 21:14:35 +0000
"Chang S. Bae" <chang.seok.bae@xxxxxxxxx> wrote:
> Omar reported this broad concern to me, when resolving a separate issue
> with his custom module. CONFIG_X86_NATIVE_CPU=y allows builds to
> opportunistically emit APX instructions when the build host supports APX
> since commit:
>
> ea1dcca1de12 ("x86/kbuild/64: Add the CONFIG_X86_NATIVE_CPU option to locally optimize the kernel with '-march=native'")
>
> The kernel is not yet prepared to use APX internally. For example, there
> is no context-switch support for general in-kernel use of the extended
> GPRs.
Isn't this a just a big compiler bug?
Much like when AVX support was added, -march-native needs to check that the
operating system is saving the registers not that the cpu supports them.
I'd have thought that would be true even if the code is actually destined
to be part of a different kernel - the compiler doesn't really know what
the code is being compiler for.
David