linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/4] arm64: cmpxchg: Use "K" instead of "L" for ll/sc immediate constraint
Date: Tue, 27 Nov 2018 19:44:47 +0000	[thread overview]
Message-ID: <1543347887-21101-5-git-send-email-will.deacon@arm.com> (raw)
In-Reply-To: <1543347887-21101-1-git-send-email-will.deacon@arm.com>

The "L" AArch64 machine constraint, which we use for the "old" value in
an LL/SC cmpxchg(), generates an immediate that is suitable for a 64-bit
logical instruction. However, for cmpxchg() operations on types smaller
than 64 bits, this constraint can result in an invalid instruction which
is correctly rejected by GAS, such as EOR W1, W1, #0xffffffff.

Whilst we could special-case the constraint based on the cmpxchg size,
it's far easier to change the constraint to "K" and put up with using
a register for large 64-bit immediates. For out-of-line LL/SC atomics,
this is all moot anyway.

Reported-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/atomic_ll_sc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/include/asm/atomic_ll_sc.h b/arch/arm64/include/asm/atomic_ll_sc.h
index b53f70dd6e10..af7b99005453 100644
--- a/arch/arm64/include/asm/atomic_ll_sc.h
+++ b/arch/arm64/include/asm/atomic_ll_sc.h
@@ -276,7 +276,7 @@ __LL_SC_PREFIX(__cmpxchg_case_##name##sz(volatile void *ptr,		\
 	"2:"								\
 	: [tmp] "=&r" (tmp), [oldval] "=&r" (oldval),			\
 	  [v] "+Q" (*(u##sz *)ptr)					\
-	: [old] "Lr" (old), [new] "r" (new)				\
+	: [old] "Kr" (old), [new] "r" (new)				\
 	: cl);								\
 									\
 	return oldval;							\
-- 
2.1.4

  parent reply	other threads:[~2018-11-27 19:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-27 19:44 [PATCH 0/4] Rewrite of percpu atomics and introduction of LSE Will Deacon
2018-11-27 19:44 ` [PATCH 1/4] arm64: Avoid redundant type conversions in xchg() and cmpxchg() Will Deacon
2018-12-04 17:29   ` Ard Biesheuvel
2018-11-27 19:44 ` [PATCH 2/4] arm64: Avoid masking "old" for LSE cmpxchg() implementation Will Deacon
2018-12-04 16:58   ` Ard Biesheuvel
2018-12-07 15:49     ` Will Deacon
2018-12-07 16:05       ` Ard Biesheuvel
2018-12-07 16:22         ` Will Deacon
2018-12-07 17:03           ` Ard Biesheuvel
2018-12-07 17:15             ` Will Deacon
2018-12-07 17:18               ` Ard Biesheuvel
2018-11-27 19:44 ` [PATCH 3/4] arm64: percpu: Rewrite per-cpu ops to allow use of LSE atomics Will Deacon
2018-11-27 19:44 ` Will Deacon [this message]
2018-12-04 17:17   ` [PATCH 4/4] arm64: cmpxchg: Use "K" instead of "L" for ll/sc immediate constraint Ard Biesheuvel

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=1543347887-21101-5-git-send-email-will.deacon@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).