linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ardb@kernel.org>
To: linux@armlinux.org.uk
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	Eric Biggers <ebiggers@google.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Nicolas Pitre <nico@fluxnic.net>,
	Ard Biesheuvel <ardb@kernel.org>,
	linux-arm-kernel@lists.infradead.org
Subject: [PATCH 1/3] ARM: assembler: generalize byte swapping macro into rev_32
Date: Wed,  9 Dec 2020 11:36:32 +0100	[thread overview]
Message-ID: <20201209103634.1422-2-ardb@kernel.org> (raw)
In-Reply-To: <20201209103634.1422-1-ardb@kernel.org>

Take the 4 instruction byte swapping sequence from the decompressor's
head.S, and turn it into a rev_32 GAS macro for general use. While
at it, make it use the 'rev' instruction when compiling for v6 or
later.

Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/boot/compressed/head.S  |  5 +----
 arch/arm/include/asm/assembler.h | 11 +++++++++++
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 804d66668019..d70c78ab68c8 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -174,10 +174,7 @@
 		.macro	be32tocpu, val, tmp
 #ifndef __ARMEB__
 		/* convert to little endian */
-		eor	\tmp, \val, \val, ror #16
-		bic	\tmp, \tmp, #0x00ff0000
-		mov	\val, \val, ror #8
-		eor	\val, \val, \tmp, lsr #8
+		rev_32	\val, \tmp
 #endif
 		.endm
 
diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 6ed30421f697..a674eba4cd27 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -578,4 +578,15 @@ THUMB(	orr	\reg , \reg , #PSR_T_BIT	)
 	__adldst_l	str, \src, \sym, \tmp, \cond
 	.endm
 
+	.macro		rev_32, val:req, tmp:req
+	.if		__LINUX_ARM_ARCH__ < 6
+	eor		\tmp, \val, \val, ror #16
+	bic		\tmp, \tmp, #0x00ff0000
+	mov		\val, \val, ror #8
+	eor		\val, \val, \tmp, lsr #8
+	.else
+	rev		\val, \val
+	.endif
+	.endm
+
 #endif /* __ASM_ASSEMBLER_H__ */
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-12-09 10:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-09 10:36 [PATCH 0/3] ARM: assembler: clean up byte swapping macros Ard Biesheuvel
2020-12-09 10:36 ` Ard Biesheuvel [this message]
2020-12-09 11:05   ` [PATCH 1/3] ARM: assembler: generalize byte swapping macro into rev_32 Geert Uytterhoeven
2020-12-11 22:53   ` Linus Walleij
2020-12-09 10:36 ` [PATCH 2/3] crypto: arm/aes-scalar - switch to common rev_32/mov_l macros Ard Biesheuvel
2020-12-09 11:13   ` Geert Uytterhoeven
2020-12-11 22:55   ` Linus Walleij
2020-12-09 10:36 ` [PATCH 3/3] crypto: arm/chacha-scalar - switch to common rev_32 macro Ard Biesheuvel
2020-12-09 11:19   ` Geert Uytterhoeven
2020-12-11 22:56   ` Linus Walleij
2020-12-09 11:02 ` [PATCH 0/3] ARM: assembler: clean up byte swapping macros Geert Uytterhoeven
2020-12-09 14:48 ` Nicolas Pitre

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=20201209103634.1422-2-ardb@kernel.org \
    --to=ardb@kernel.org \
    --cc=ebiggers@google.com \
    --cc=geert+renesas@glider.be \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=nico@fluxnic.net \
    /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).