From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/8] arm64: introduce mov_q macro to move a constant into a 64-bit register
Date: Mon, 18 Apr 2016 17:09:44 +0200 [thread overview]
Message-ID: <1460992188-23295-5-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1460992188-23295-1-git-send-email-ard.biesheuvel@linaro.org>
Implement a macro mov_q that can be used to move an immediate constant
into a 64-bit register, using between 2 and 4 movz/movk instructions
(depending on the operand)
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
arch/arm64/include/asm/assembler.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h
index 70f7b9e04598..9ea846ded55c 100644
--- a/arch/arm64/include/asm/assembler.h
+++ b/arch/arm64/include/asm/assembler.h
@@ -233,4 +233,24 @@ lr .req x30 // link register
.long \sym\()_hi32
.endm
+ /*
+ * mov_q - move an immediate constant into a 64-bit register using
+ * between 2 and 4 movz/movk instructions (depending on the
+ * magnitude and sign of the operand)
+ */
+ .macro mov_q, reg, val
+ .if (((\val) >> 31) == 0 || ((\val) >> 31) == 0x1ffffffff)
+ movz \reg, :abs_g1_s:\val
+ .else
+ .if (((\val) >> 47) == 0 || ((\val) >> 47) == 0x1ffff)
+ movz \reg, :abs_g2_s:\val
+ .else
+ movz \reg, :abs_g3:\val
+ movk \reg, :abs_g2_nc:\val
+ .endif
+ movk \reg, :abs_g1_nc:\val
+ .endif
+ movk \reg, :abs_g0_nc:\val
+ .endm
+
#endif /* __ASM_ASSEMBLER_H */
--
2.5.0
next prev parent reply other threads:[~2016-04-18 15:09 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-18 15:09 [PATCH 0/8] arm64: kaslr cleanups and improvements Ard Biesheuvel
2016-04-18 15:09 ` [PATCH 1/8] arm64: kernel: don't export local symbols from head.S Ard Biesheuvel
2016-04-18 15:35 ` Mark Rutland
2016-04-18 15:09 ` [PATCH 2/8] arm64: kernel: use literal for relocated address of __secondary_switched Ard Biesheuvel
2016-04-18 15:57 ` Mark Rutland
2016-04-18 15:09 ` [PATCH 3/8] arm64: kernel: perform relocation processing from ID map Ard Biesheuvel
2016-04-18 15:09 ` Ard Biesheuvel [this message]
2016-04-18 15:09 ` [PATCH 5/8] arm64: kernel: replace early 64-bit literal loads with move-immediates Ard Biesheuvel
2016-04-19 14:29 ` Laurentiu Tudor
2016-04-18 15:09 ` [PATCH 6/8] arm64: don't map TEXT_OFFSET bytes below the kernel if we can avoid it Ard Biesheuvel
2016-04-18 15:09 ` [PATCH 7/8] arm64: relocatable: deal with physically misaligned kernel images Ard Biesheuvel
2016-04-18 15:09 ` [PATCH 8/8] arm64: kaslr: increase randomization granularity Ard Biesheuvel
2016-04-26 11:27 ` Will Deacon
2016-04-26 15:27 ` Matt Fleming
2016-04-25 16:38 ` [PATCH 0/8] arm64: kaslr cleanups and improvements Catalin Marinas
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=1460992188-23295-5-git-send-email-ard.biesheuvel@linaro.org \
--to=ard.biesheuvel@linaro.org \
--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).