Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1247553

Re: [PATCH] ARM: SWP emulation: Restore original *data when failed

From Russell King - ARM Linux <linux@arm.linux.org.uk>
Newsgroups linux.kernel
Subject Re: [PATCH] ARM: SWP emulation: Restore original *data when failed
Date 2015-10-15 10:30 +0200
Message-ID <qjM5c-QH-9@gated-at.bofh.it> (permalink)
References <qjM5c-QH-11@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Wed, Oct 14, 2015 at 10:51:17AM +0800, Shengjiu Wang wrote:
> __user_swpX_asm maybe failed in first STREX operation, emulate_swpX
> will try again, but the *data has been changed in first time. which
> cause the result is wrong. So need to recover the *data when failed.
> 
> Signed-off-by: Shengjiu Wang <shengjiu.wang@freescale.com>
> ---
>  arch/arm/kernel/swp_emulate.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/kernel/swp_emulate.c b/arch/arm/kernel/swp_emulate.c
> index 5b26e7e..c61fbf92 100644
> --- a/arch/arm/kernel/swp_emulate.c
> +++ b/arch/arm/kernel/swp_emulate.c
> @@ -41,6 +41,7 @@
>  	"1:	strex"B"	%0, %2, [%3]\n"			\
>  	"	cmp		%0, #0\n"			\
>  	"	movne		%0, %4\n"			\
> +	"	movne		%1, %2\n"			\
>  	"2:\n"							\
>  	"	.section	 .text.fixup,\"ax\"\n"		\
>  	"	.align		2\n"				\

I think I'd prefer this to be:

	__asm__ __volatile__(					\
	"0:	ldrex"B"	%2, [%3]\n"			\
	"1:	strex"B"	%0, %1, [%3]\n" 		\
	"	cmp		%0, #0\n"			\
	"	moveq		%1, %2\n"			\
	"	movne		%0, %4\n"			\

so that we're not loading into %1 (an in-out non-temporary) but rather
loading it into a temporary - and only overwriting the saved register
value if the swap succeeds.

Thanks.

-- 
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: [PATCH] ARM: SWP emulation: Restore original *data when failed Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-10-15 10:30 +0200
  Re: [PATCH] ARM: SWP emulation: Restore original *data when failed Russell King - ARM Linux <linux@arm.linux.org.uk> - 2015-10-15 11:00 +0200
    Re: [PATCH] ARM: SWP emulation: Restore original *data when failed Vladimir Murzin <vladimir.murzin@arm.com> - 2015-10-15 11:20 +0200
      Re: [PATCH] ARM: SWP emulation: Restore original *data when failed Will Deacon <will.deacon@arm.com> - 2015-10-15 15:10 +0200
        Re: [PATCH] ARM: SWP emulation: Restore original *data when failed Vladimir Murzin <vladimir.murzin@arm.com> - 2015-10-15 15:30 +0200
          Re: [PATCH] ARM: SWP emulation: Restore original *data when failed Vladimir Murzin <vladimir.murzin@arm.com> - 2015-10-16 10:00 +0200
            Re: [PATCH] ARM: SWP emulation: Restore original *data when failed Catalin Marinas <catalin.marinas@arm.com> - 2015-10-16 12:40 +0200

csiph-web