From: vladimir.murzin@arm.com (Vladimir Murzin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] ARM: SWP emulation: Restore original *data when failed
Date: Thu, 15 Oct 2015 10:17:47 +0100 [thread overview]
Message-ID: <561F6F3B.6030607@arm.com> (raw)
In-Reply-To: <20151015085700.GY32532@n2100.arm.linux.org.uk>
On 15/10/15 09:57, Russell King - ARM Linux wrote:
> On Thu, Oct 15, 2015 at 04:36:31PM +0800, Shengjiu Wang wrote:
>> On Thu, Oct 15, 2015 at 09:24:17AM +0100, Russell King - ARM Linux wrote:
>>> 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.
>>
>> I am ok with your change. Need I send another patch for this change? or will
>> you send it by yourself?
>
> Please send a new patch, thanks.
>
We might need the same change for arm64 counterpart (see
arch/arm64/kernel/armv8_deprecated.c).
Vladimir
WARNING: multiple messages have this Message-ID (diff)
From: Vladimir Murzin <vladimir.murzin@arm.com>
To: Russell King - ARM Linux <linux@arm.linux.org.uk>,
Shengjiu Wang <shengjiu.wang@freescale.com>
Cc: "ard.biesheuvel@linaro.org" <ard.biesheuvel@linaro.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"nico@linaro.org" <nico@linaro.org>,
Punit Agrawal <punit.agrawal@arm.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <Will.Deacon@arm.com>
Subject: Re: [PATCH] ARM: SWP emulation: Restore original *data when failed
Date: Thu, 15 Oct 2015 10:17:47 +0100 [thread overview]
Message-ID: <561F6F3B.6030607@arm.com> (raw)
In-Reply-To: <20151015085700.GY32532@n2100.arm.linux.org.uk>
On 15/10/15 09:57, Russell King - ARM Linux wrote:
> On Thu, Oct 15, 2015 at 04:36:31PM +0800, Shengjiu Wang wrote:
>> On Thu, Oct 15, 2015 at 09:24:17AM +0100, Russell King - ARM Linux wrote:
>>> 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.
>>
>> I am ok with your change. Need I send another patch for this change? or will
>> you send it by yourself?
>
> Please send a new patch, thanks.
>
We might need the same change for arm64 counterpart (see
arch/arm64/kernel/armv8_deprecated.c).
Vladimir
next prev parent reply other threads:[~2015-10-15 9:17 UTC|newest]
Thread overview: 22+ 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-14 2:51 ` Shengjiu Wang
2015-10-15 8:24 ` Russell King - ARM Linux
2015-10-15 8:24 ` Russell King - ARM Linux
2015-10-15 8:36 ` Shengjiu Wang
2015-10-15 8:36 ` Shengjiu Wang
2015-10-15 8:57 ` Russell King - ARM Linux
2015-10-15 8:57 ` Russell King - ARM Linux
2015-10-15 9:17 ` Vladimir Murzin [this message]
2015-10-15 9:17 ` Vladimir Murzin
2015-10-15 13:02 ` Will Deacon
2015-10-15 13:02 ` Will Deacon
2015-10-15 13:25 ` Vladimir Murzin
2015-10-15 13:25 ` Vladimir Murzin
2015-10-16 7:52 ` Vladimir Murzin
2015-10-16 7:52 ` Vladimir Murzin
2015-10-16 10:37 ` Catalin Marinas
2015-10-16 10:37 ` Catalin Marinas
2015-10-27 15:44 ` Will Deacon
2015-10-27 15:44 ` Will Deacon
2015-10-28 16:16 ` Will Deacon
2015-10-28 16:16 ` Will Deacon
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=561F6F3B.6030607@arm.com \
--to=vladimir.murzin@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.