ARM: 9039/1: assembler: generalize byte swapping macro into rev_l
authorArd Biesheuvel <ardb@kernel.org>
Wed, 9 Dec 2020 16:21:43 +0000 (17:21 +0100)
committerRussell King <rmk+kernel@armlinux.org.uk>
Mon, 1 Feb 2021 19:41:30 +0000 (19:41 +0000)
Take the 4 instruction byte swapping sequence from the decompressor's
head.S, and turn it into a rev_l GAS macro for general use. While
at it, make it use the 'rev' instruction when compiling for v6 or
later.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Nicolas Pitre <nico@fluxnic.net>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
arch/arm/boot/compressed/head.S
arch/arm/include/asm/assembler.h

index d9cce72..d4837c2 100644 (file)
                .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_l   \val, \tmp
 #endif
                .endm
 
index 6ed3042..e2b1fd5 100644 (file)
@@ -578,4 +578,21 @@ THUMB(     orr     \reg , \reg , #PSR_T_BIT        )
        __adldst_l      str, \src, \sym, \tmp, \cond
        .endm
 
+       /*
+        * rev_l - byte-swap a 32-bit value
+        *
+        * @val: source/destination register
+        * @tmp: scratch register
+        */
+       .macro          rev_l, 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__ */