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: Thu, 15 Oct 2015 14:02:47 +0100 [thread overview]
Message-ID: <20151015130247.GB29301@arm.com> (raw)
In-Reply-To: <561F6F3B.6030607@arm.com>
On Thu, Oct 15, 2015 at 10:17:47AM +0100, Vladimir Murzin wrote:
> We might need the same change for arm64 counterpart (see
> arch/arm64/kernel/armv8_deprecated.c).
Something like below?
Will
>From 63c3e83073cfac2e011adf0ed6f335275cc977a7 Mon Sep 17 00:00:00 2001
From: Will Deacon <will.deacon@arm.com>
Date: Thu, 15 Oct 2015 13:55:53 +0100
Subject: [PATCH] arm64: compat: fix stxr failure case in SWP emulation
If the STXR instruction fails in the SWP emulation code, we leave *data
overwritten with the loaded value, therefore corrupting the data written
by a subsequent, successful attempt.
This patch re-jigs the code so that we only write back to *data once we
know that the update has happened.
Reported-by: Shengjiu Wang <shengjiu.wang@freescale.com>
Reported-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm64/kernel/armv8_deprecated.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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" \
--
2.1.4
WARNING: multiple messages have this Message-ID (diff)
From: Will Deacon <will.deacon@arm.com>
To: Vladimir Murzin <vladimir.murzin@arm.com>
Cc: Russell King - ARM Linux <linux@arm.linux.org.uk>,
Shengjiu Wang <shengjiu.wang@freescale.com>,
"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>
Subject: Re: [PATCH] ARM: SWP emulation: Restore original *data when failed
Date: Thu, 15 Oct 2015 14:02:47 +0100 [thread overview]
Message-ID: <20151015130247.GB29301@arm.com> (raw)
In-Reply-To: <561F6F3B.6030607@arm.com>
On Thu, Oct 15, 2015 at 10:17:47AM +0100, Vladimir Murzin wrote:
> We might need the same change for arm64 counterpart (see
> arch/arm64/kernel/armv8_deprecated.c).
Something like below?
Will
>From 63c3e83073cfac2e011adf0ed6f335275cc977a7 Mon Sep 17 00:00:00 2001
From: Will Deacon <will.deacon@arm.com>
Date: Thu, 15 Oct 2015 13:55:53 +0100
Subject: [PATCH] arm64: compat: fix stxr failure case in SWP emulation
If the STXR instruction fails in the SWP emulation code, we leave *data
overwritten with the loaded value, therefore corrupting the data written
by a subsequent, successful attempt.
This patch re-jigs the code so that we only write back to *data once we
know that the update has happened.
Reported-by: Shengjiu Wang <shengjiu.wang@freescale.com>
Reported-by: Vladimir Murzin <vladimir.murzin@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
arch/arm64/kernel/armv8_deprecated.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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" \
--
2.1.4
next prev parent reply other threads:[~2015-10-15 13:02 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
2015-10-15 9:17 ` Vladimir Murzin
2015-10-15 13:02 ` Will Deacon [this message]
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=20151015130247.GB29301@arm.com \
--to=will.deacon@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.