* [PATCH] MIPS: Fix a long-standing mistake in mips_atomic_set()
@ 2017-06-22 10:45 Huacai Chen
2017-06-22 12:31 ` James Hogan
0 siblings, 1 reply; 3+ messages in thread
From: Huacai Chen @ 2017-06-22 10:45 UTC (permalink / raw)
To: Ralf Baechle
Cc: John Crispin, Steven J . Hill, linux-mips, Fuxin Zhang,
Zhangjin Wu, Huacai Chen, stable
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.
Cc: stable@vger.kernel.org
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
arch/mips/kernel/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
index 1dfa7f5..95e1b30 100644
--- a/arch/mips/kernel/syscall.c
+++ b/arch/mips/kernel/syscall.c
@@ -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"
--
2.7.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: Fix a long-standing mistake in mips_atomic_set()
2017-06-22 10:45 [PATCH] MIPS: Fix a long-standing mistake in mips_atomic_set() Huacai Chen
@ 2017-06-22 12:31 ` James Hogan
2017-06-22 12:50 ` Ralf Baechle
0 siblings, 1 reply; 3+ messages in thread
From: James Hogan @ 2017-06-22 12:31 UTC (permalink / raw)
To: Huacai Chen
Cc: Ralf Baechle, John Crispin, Steven J . Hill, linux-mips,
Fuxin Zhang, Zhangjin Wu, stable
[-- Attachment #1: Type: text/plain, Size: 1325 bytes --]
Hi Huacai,
On Thu, Jun 22, 2017 at 06:45:45PM +0800, Huacai Chen wrote:
> 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.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
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
> ---
> arch/mips/kernel/syscall.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/mips/kernel/syscall.c b/arch/mips/kernel/syscall.c
> index 1dfa7f5..95e1b30 100644
> --- a/arch/mips/kernel/syscall.c
> +++ b/arch/mips/kernel/syscall.c
> @@ -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"
> --
> 2.7.0
>
>
>
>
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: Fix a long-standing mistake in mips_atomic_set()
2017-06-22 12:31 ` James Hogan
@ 2017-06-22 12:50 ` Ralf Baechle
0 siblings, 0 replies; 3+ messages in thread
From: Ralf Baechle @ 2017-06-22 12:50 UTC (permalink / raw)
To: James Hogan
Cc: Huacai Chen, John Crispin, Steven J . Hill, linux-mips,
Fuxin Zhang, Zhangjin Wu, stable
On Thu, Jun 22, 2017 at 01:31:59PM +0100, James Hogan wrote:
> Hi Huacai,
>
> On Thu, Jun 22, 2017 at 06:45:45PM +0800, Huacai Chen wrote:
> > 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.
> >
> > Cc: stable@vger.kernel.org
> > Signed-off-by: Huacai Chen <chenhc@lemote.com>
>
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-06-22 13:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-22 10:45 [PATCH] MIPS: Fix a long-standing mistake in mips_atomic_set() Huacai Chen
2017-06-22 12:31 ` James Hogan
2017-06-22 12:50 ` Ralf Baechle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox