Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86-32: fix cmpxchg8b_emu build error with clang

The kernel test robot reported that clang no longer compiles the 32-bit
x86 kernel in some configurations due to commit 95ece48165c1
("locking/atomic/x86: Rewrite x86_32 arch_atomic64_{,fetch}_{and,or,xor}()
functions").

The build fails with

arch/x86/include/asm/cmpxchg_32.h:149:9: error: inline assembly requires more registers than available

and the reason seems to be that not only does the cmpxchg8b instruction
need four fixed registers (EDX:EAX and ECX:EBX), with the emulation
fallback the inline asm also wants a fifth fixed register for the
address (it uses %esi for that, but that's just a software convention
with cmpxchg8b_emu).

Avoiding using another pointer input to the asm (and just forcing it to
use the "0(%esi)" addressing that we end up requiring for the sw
fallback) seems to fix the issue.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202406230912.F6XFIyA6-lkp@intel.com/
Fixes: 95ece48165c1 ("locking/atomic/x86: Rewrite x86_32 arch_atomic64_{,fetch}_{and,or,xor}() functions")
Link: https://lore.kernel.org/all/202406230912.F6XFIyA6-lkp@intel.com/
Suggested-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-and-Tested-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+5 -7
+5 -7
arch/x86/include/asm/cmpxchg_32.h
··· 93 93 \ 94 94 asm volatile(ALTERNATIVE(_lock_loc \ 95 95 "call cmpxchg8b_emu", \ 96 - _lock "cmpxchg8b %[ptr]", X86_FEATURE_CX8) \ 97 - : [ptr] "+m" (*(_ptr)), \ 98 - "+a" (o.low), "+d" (o.high) \ 99 - : "b" (n.low), "c" (n.high), "S" (_ptr) \ 96 + _lock "cmpxchg8b %a[ptr]", X86_FEATURE_CX8) \ 97 + : "+a" (o.low), "+d" (o.high) \ 98 + : "b" (n.low), "c" (n.high), [ptr] "S" (_ptr) \ 100 99 : "memory"); \ 101 100 \ 102 101 o.full; \ ··· 121 122 \ 122 123 asm volatile(ALTERNATIVE(_lock_loc \ 123 124 "call cmpxchg8b_emu", \ 124 - _lock "cmpxchg8b %[ptr]", X86_FEATURE_CX8) \ 125 + _lock "cmpxchg8b %a[ptr]", X86_FEATURE_CX8) \ 125 126 CC_SET(e) \ 126 127 : CC_OUT(e) (ret), \ 127 - [ptr] "+m" (*(_ptr)), \ 128 128 "+a" (o.low), "+d" (o.high) \ 129 - : "b" (n.low), "c" (n.high), "S" (_ptr) \ 129 + : "b" (n.low), "c" (n.high), [ptr] "S" (_ptr) \ 130 130 : "memory"); \ 131 131 \ 132 132 if (unlikely(!ret)) \