MIPS: Fix mips_atomic_set() retry condition
authorJames Hogan <james.hogan@imgtec.com>
Wed, 31 May 2017 15:19:47 +0000 (16:19 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 2 Nov 2017 06:16:17 +0000 (07:16 +0100)
commit 2ec420b26f7b6ff332393f0bb5a7d245f7ad87f0 upstream.

The inline asm retry check in the MIPS_ATOMIC_SET operation of the
sysmips system call has been backwards since commit f1e39a4a616c ("MIPS:
Rewrite sysmips(MIPS_ATOMIC_SET, ...) in C with inline assembler")
merged in v2.6.32, resulting in the non R10000_LLSC_WAR case retrying
until the operation was inatomic, before returning the new value that
was probably just written multiple times instead of the old value.

Invert the branch condition to fix that particular issue.

Fixes: f1e39a4a616c ("MIPS: Rewrite sysmips(MIPS_ATOMIC_SET, ...) in C with inline assembler")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: stable@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/16148/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Signed-off-by: Willy Tarreau <w@1wt.eu>
arch/mips/kernel/syscall.c

index b79d13f95bf01b5d666e18fa22caf0ff66e0188b..eb0f4dfb385cbd5a376da5cb32beab5934fcf521 100644 (file)
@@ -140,7 +140,7 @@ static inline int mips_atomic_set(unsigned long addr, unsigned long new)
                "1:     ll      %[old], (%[addr])                       \n"
                "       move    %[tmp], %[new]                          \n"
                "2:     sc      %[tmp], (%[addr])                       \n"
-               "       bnez    %[tmp], 4f                              \n"
+               "       beqz    %[tmp], 4f                              \n"
                "3:                                                     \n"
                "       .subsection 2                                   \n"
                "4:     b       1b                                      \n"