]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
LoongArch: Avoid using $r0/$r1 as "mask" for csrxchg
authorHuacai Chen <chenhuacai@loongson.cn>
Fri, 30 May 2025 13:45:48 +0000 (21:45 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 27 Jun 2025 10:07:36 +0000 (11:07 +0100)
commitb204e05b750575a1416f59bcd9058cbf16d36807
tree492d7376a077fbc5fe6a7767470d9bfde4eba6ef
parent9ae4c02a76c1942a892a9a5e1623c7f022904aa0
LoongArch: Avoid using $r0/$r1 as "mask" for csrxchg

commit 52c22661c79a7b6af7fad9f77200738fc6c51878 upstream.

When building kernel with LLVM there are occasionally such errors:

In file included from ./include/linux/spinlock.h:59:
In file included from ./include/linux/irqflags.h:17:
arch/loongarch/include/asm/irqflags.h:38:3: error: must not be $r0 or $r1
   38 |                 "csrxchg %[val], %[mask], %[reg]\n\t"
      |                 ^
<inline asm>:1:16: note: instantiated into assembly here
    1 |         csrxchg $a1, $ra, 0
      |                       ^

To prevent the compiler from allocating $r0 or $r1 for the "mask" of the
csrxchg instruction, the 'q' constraint must be used but Clang < 21 does
not support it. So force to use $t0 in the inline asm, in order to avoid
using $r0/$r1 while keeping the backward compatibility.

Cc: stable@vger.kernel.org
Link: https://github.com/llvm/llvm-project/pull/141037
Reviewed-by: Yanteng Si <si.yanteng@linux.dev>
Suggested-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/loongarch/include/asm/irqflags.h