MIPS: Fix a long-standing mistake in mips_atomic_set()
Subsystems (2)
PATCH 1/1 MIPS: Fix a long-standing mistake in mips_atomic_set()
This mistake comes from the commit f1e39a4a616cd99 ("MIPS: Rewrite sysmips(MIPS_ATOMIC_SET, ...) in C with inline assembler"). In the common case 'bnez' should be 'beqz' (as same as older kernels before 2.6.32), otherwise this syscall may cause an endless loop.
--- arch/mips/kernel/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/kernel/syscall.c +1 -1
@@ -134,7 +134,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" " .insn \n" " .subsection 2 \n"
Signature · 1 line
2.7.0
Hi Huacai,
Quoted 7 lines · Huacai Chen
This mistake comes from the commit
f1e39a4a616cd99("MIPS: Rewritesysmips(MIPS_ATOMIC_SET, ...)in C with inline assembler"). In the common case 'bnez' should be 'beqz' (as same as older kernels before 2.6.32), otherwise this syscall may cause an endless loop.Signed-off-by Huacai Chen <[email protected]>
Thats a coincidence. 8 years its been broken and I submitted an identical patch only a few weeks ago, along with some other related fixes:
https://patchwork.linux-mips.org/project/linux-mips/list/?series=313&state=*
Cheers
James
Quoted 23 lines
--- arch/mips/kernel/syscall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)arch/mips/kernel/syscall.c +1
-1@@ -134,7 +134,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" " .insn \n" " .subsection 2 \n" Signature · 1 line
2.7.0
Quoted 8 lines · James Hogan
Hi Huacai,
Quoted 5 lines · Huacai Chen
This mistake comes from the commit
f1e39a4a616cd99("MIPS: Rewritesysmips(MIPS_ATOMIC_SET, ...)in C with inline assembler"). In the common case 'bnez' should be 'beqz' (as same as older kernels before 2.6.32), otherwise this syscall may cause an endless loop.
Quoted 8 lines
Quoted 2 lines
Signed-off-by Huacai Chen <[email protected]>Thats a coincidence. 8 years its been broken and I submitted an identical patch only a few weeks ago, along with some other related fixes:
https://patchwork.linux-mips.org/project/linux-mips/list/?series=313&state=*
I take it as a proof that everybody is using LL/SC (or the LL/SC emulation) these days and sysmips(MIPS_ATOMIC_SET) finally has been obsoleted and is only useful for stoneage binary compatibility.
Which is really good. Unless people are using silly hacks such as $k0/$k1 being overwriten by exception handlers ...
Ralf