Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  • Linus Torvalds's avatar
    x86-32: fix cmpxchg8b_emu build error with clang · 76932725
    Linus Torvalds authored
    The kernel test robot reported that clang no longer compiles the 32-bit
    x86 kernel in some configurations due to commit 95ece481
    
    
    ("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: default avatarkernel test robot <lkp@intel.com>
    Closes: https://lore.kernel.org/oe-kbuild-all/202406230912.F6XFIyA6-lkp@intel.com/
    Fixes: 95ece481 (...
    76932725