public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: will.deacon@arm•com (Will Deacon)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH] ARM: SWP emulation: Restore original *data when failed
Date: Wed, 28 Oct 2015 16:16:05 +0000	[thread overview]
Message-ID: <20151028161604.GI18966@arm.com> (raw)
In-Reply-To: <20151027154424.GG1689@arm.com>

On Tue, Oct 27, 2015 at 03:44:24PM +0000, Will Deacon wrote:
> On Fri, Oct 16, 2015 at 11:37:29AM +0100, Catalin Marinas wrote:
> > On Fri, Oct 16, 2015 at 08:52:24AM +0100, Vladimir Murzin wrote:
> > > > On 15/10/15 14:02, Will Deacon wrote:
> > > >> diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
> > > >> index bcee7abac68e..6039d1eb5912 100644
> > > >> --- a/arch/arm64/kernel/armv8_deprecated.c
> > > >> +++ b/arch/arm64/kernel/armv8_deprecated.c
> > > >> @@ -284,12 +284,12 @@ static void register_insn_emulation_sysctl(struct ctl_table *table)
> > > >>  	__asm__ __volatile__(					\
> > > >>  	ALTERNATIVE("nop", SET_PSTATE_PAN(0), ARM64_HAS_PAN,	\
> > > >>  		    CONFIG_ARM64_PAN)				\
> > > >> -	"	mov		%w2, %w1\n"			\
> > > >> -	"0:	ldxr"B"		%w1, [%3]\n"			\
> > > >> -	"1:	stxr"B"		%w0, %w2, [%3]\n"		\
> > > >> +	"0:	ldxr"B"		%w2, [%3]\n"			\
> > > >> +	"1:	stxr"B"		%w0, %w1, [%3]\n"		\
> > > >>  	"	cbz		%w0, 2f\n"			\
> > > >>  	"	mov		%w0, %w4\n"			\
> > > >>  	"2:\n"							\
> > > >> +	"	mov		%w1, %w2\n"			\
> > > >>  	"	.pushsection	 .fixup,\"ax\"\n"		\
> > > >>  	"	.align		2\n"				\
> > > >>  	"3:	mov		%w0, %w5\n"			\
> > > 
> > > On the second thought looks like we still update *data in case stxr
> > > fails (or I need more coffee).
> > 
> > I'm on the second cup and I see the same problem. Even if stxr fails, we
> > fall back through "mov %w1, %w2", so *data is always updated with the
> > loaded value. Maybe something like below on top of Will's patch:
> 
> Yeah, sorry, my original patch was an untested mess. I think we can avoid
> the "cc" clobber by adding a branch to the slow-path, as below.
> 
> Still needs testing, mind.

Right, it passes the simple test case I wrote (which fails under mainline).

Will

      reply	other threads:[~2015-10-28 16:16 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-14  2:51 [PATCH] ARM: SWP emulation: Restore original *data when failed Shengjiu Wang
2015-10-15  8:24 ` Russell King - ARM Linux
2015-10-15  8:36   ` Shengjiu Wang
2015-10-15  8:57     ` Russell King - ARM Linux
2015-10-15  9:17       ` Vladimir Murzin
2015-10-15 13:02         ` Will Deacon
2015-10-15 13:25           ` Vladimir Murzin
2015-10-16  7:52             ` Vladimir Murzin
2015-10-16 10:37               ` Catalin Marinas
2015-10-27 15:44                 ` Will Deacon
2015-10-28 16:16                   ` Will Deacon [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20151028161604.GI18966@arm.com \
    --to=will.deacon@arm$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox