i386 without CONFIG_X86_CMPXCHG64 "error: inline assembly requires more registers than available" in kernel/bpf/core.c after commit 95ece48165c1 in -next #2018
After commit 95ece48165c1 ("locking/atomic/x86: Rewrite x86_32 archatomic64{,fetch}_{and,or,xor}() functions") in -next, I see the following error with Debian's i386 configuration:
$ curl -LSso .config https://github.com/nathanchance/llvm-kernel-testing/raw/9e1ae215de95b32d83b8635aceac3d47d261a0b2/configs/debian/i386.config
$ make -skj"$(nproc)" ARCH=i386 LLVM=1 olddefconfig kernel/bpf/core.o
In file included from kernel/bpf/core.c:21:
In file included from include/linux/filter.h:8:
In file included from include/linux/atomic.h:7:
In file included from arch/x86/include/asm/atomic.h:8:
In file included from arch/x86/include/asm/cmpxchg.h:143:
arch/x86/include/asm/cmpxchg_32.h:156:9: error: inline assembly requires more registers than available
156 | return __arch_try_cmpxchg64_emu(ptr, oldp, new);
| ^
arch/x86/include/asm/cmpxchg_32.h:138:15: note: expanded from macro '__arch_try_cmpxchg64_emu'
138 | asm volatile(ALTERNATIVE(LOCK_PREFIX_HERE \
| ^
arch/x86/include/asm/alternative.h:218:2: note: expanded from macro 'ALTERNATIVE'
218 | OLDINSTR(oldinstr, 1) \
| ^
arch/x86/include/asm/alternative.h:168:2: note: expanded from macro 'OLDINSTR'
168 | "# ALT: oldnstr\n" \
| ^
In file included from kernel/bpf/core.c:21:
In file included from include/linux/filter.h:8:
In file included from include/linux/atomic.h:7:
In file included from arch/x86/include/asm/atomic.h:8:
In file included from arch/x86/include/asm/cmpxchg.h:143:
arch/x86/include/asm/cmpxchg_32.h:156:9: error: inline assembly requires more registers than available
arch/x86/include/asm/cmpxchg_32.h:138:15: note: expanded from macro '__arch_try_cmpxchg64_emu'
138 | asm volatile(ALTERNATIVE(LOCK_PREFIX_HERE \
| ^
arch/x86/include/asm/alternative.h:218:2: note: expanded from macro 'ALTERNATIVE'
218 | OLDINSTR(oldinstr, 1) \
| ^
arch/x86/include/asm/alternative.h:168:2: note: expanded from macro 'OLDINSTR'
168 | "# ALT: oldnstr\n" \
| ^
In file included from kernel/bpf/core.c:21:
In file included from include/linux/filter.h:8:
In file included from include/linux/atomic.h:7:
In file included from arch/x86/include/asm/atomic.h:8:
In file included from arch/x86/include/asm/cmpxchg.h:143:
arch/x86/include/asm/cmpxchg_32.h:156:9: error: inline assembly requires more registers than available
arch/x86/include/asm/cmpxchg_32.h:138:15: note: expanded from macro '__arch_try_cmpxchg64_emu'
138 | asm volatile(ALTERNATIVE(LOCK_PREFIX_HERE \
| ^
arch/x86/include/asm/alternative.h:218:2: note: expanded from macro 'ALTERNATIVE'
218 | OLDINSTR(oldinstr, 1) \
| ^
arch/x86/include/asm/alternative.h:168:2: note: expanded from macro 'OLDINSTR'
168 | "# ALT: oldnstr\n" \
| ^
...
This code is only built when CONFIG_X86_CMPXCHG64 is disabled, which can be achieved by setting a lower processor baseline like Debian does.
$ echo 'CONFIG_M686=n
CONFIG_MGEODE_LX=y' >arch/x86/configs/repro.config
$ make -skj"$(nproc)" ARCH=i386 LLVM=1 {def,repro.}config kernel/bpf/core.o
<error like above>
After commit 95ece48165c1 ("locking/atomic/x86: Rewrite x86_32 archatomic64{,fetch}_{and,or,xor}() functions") in -next, I see the following error with Debian's i386 configuration:
This code is only built when
CONFIG_X86_CMPXCHG64
is disabled, which can be achieved by setting a lower processor baseline like Debian does.cvise
spits out a fun looking reproducer:It only appears with
-fno-omit-frame-pointer
and-O2
though.