linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/6] arm64: sysreg: allow write_sysreg to use XZR
Date: Thu,  8 Sep 2016 13:55:34 +0100	[thread overview]
Message-ID: <1473339339-32334-2-git-send-email-mark.rutland@arm.com> (raw)
In-Reply-To: <1473339339-32334-1-git-send-email-mark.rutland@arm.com>

Currently write_sysreg has to allocate a temporary register to write
zero to a system register, which is unfortunate given that the MSR
instruction accepts XZR as an operand.

Allow XZR to be used when appropriate by fiddling with the assembly
constraints.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Robin Murphy <robin.murphy@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
---
 arch/arm64/include/asm/sysreg.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h
index cc06794..39fed2e 100644
--- a/arch/arm64/include/asm/sysreg.h
+++ b/arch/arm64/include/asm/sysreg.h
@@ -273,10 +273,14 @@ static inline void config_sctlr_el1(u32 clear, u32 set)
 	__val;							\
 })
 
+/*
+ * The "Z" constraint normally means a zero immediate, but when combined with
+ * the "%x0" template means XZR.
+ */
 #define write_sysreg(v, r) do {					\
 	u64 __val = (u64)v;					\
-	asm volatile("msr " __stringify(r) ", %0"		\
-		     : : "r" (__val));				\
+	asm volatile("msr " __stringify(r) ", %x0"		\
+		     : : "rZ" (__val));				\
 } while (0)
 
 #endif
-- 
1.9.1

  reply	other threads:[~2016-09-08 12:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-08 12:55 [PATCH 0/6] arm64: replace open-coded {msr, mrs} with {read, write}_sysreg() Mark Rutland
2016-09-08 12:55 ` Mark Rutland [this message]
2016-09-08 14:12   ` [PATCH 1/6] arm64: sysreg: allow write_sysreg to use XZR Robin Murphy
2016-09-08 12:55 ` [PATCH 2/6] arm64: arch_timer: simplify accessors Mark Rutland
2016-09-08 12:55 ` [PATCH 3/6] arm64: dcc: " Mark Rutland
2016-09-08 12:55 ` [PATCH 4/6] arm64/kvm: use {read,write}_sysreg() Mark Rutland
2016-09-08 13:34   ` Christoffer Dall
2016-09-08 12:55 ` [PATCH 5/6] arm64: simplify sysreg manipulation Mark Rutland
2016-09-08 12:55 ` [PATCH 6/6] arm64: simplify contextidr_thread_switch Mark Rutland

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=1473339339-32334-2-git-send-email-mark.rutland@arm.com \
    --to=mark.rutland@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).