Skip to contentSkip to conversation

arm64: shrink the tramp_alias macro

PATCH Applied Rémi Denis-Courmont 2 participants 2 messages Mar 4, 2020 arm64

lore
Share & tools
lore
#0 lore raw

PATCH 2/3 arm64: shrink the tramp_alias macro

From: Remi Denis-Courmont <[email protected]>

Aliases should be negative 48-bits values. They can be generated with 3 instructions: MOVN (lsl 32), MOVK (lsl 1) and MOVK.

So far, the mov_q macro set bits 63-12, and a separate ADD instruction sets the low 12 bits. This patch takes the last MOVK out of the mov_q macro, and merges it with the ADD instruction. (This depends on the earlier mov_q patch.)

---
 arch/arm64/kernel/entry.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/entry.S +2 -2
index 20259e6a2fd7..ae99bf8bb0ae 100644
@@ -120,8 +120,8 @@ alternative_else_nop_endif
 	.endm
 
 	.macro tramp_alias, dst, sym
-	mov_q	\dst, TRAMP_VALIAS
-	add	\dst, \dst, #(\sym - .entry.tramp.text)
+	mov_q	\dst, (TRAMP_VALIAS | 0xffff)
+	movk	\dst, #(TRAMP_VALIAS + \sym - .entry.tramp.text) & 0xffff
 	.endm
 
 	// This macro corrupts x0-x3. It is the caller's duty
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
reviewer
#1 lore raw
Quoted 20 lines · Rémi Denis-Courmont

From: Remi Denis-Courmont <[email protected]>

Aliases should be negative 48-bits values. They can be generated with 3 instructions: MOVN (lsl 32), MOVK (lsl 1) and MOVK.

So far, the mov_q macro set bits 63-12, and a separate ADD instruction sets the low 12 bits. This patch takes the last MOVK out of the mov_q macro, and merges it with the ADD instruction. (This depends on the earlier mov_q patch.)

---
 arch/arm64/kernel/entry.S | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/kernel/entry.S +0 -0
index 20259e6a2fd7..ae99bf8bb0ae 100644

arch/arm64/kernel/entry.S alternative_else_nop_endif · line 125

Quoted 8 lines
arch/arm64/kernel/entry.S +2 -2
@@ -120,8 +120,8 @@ alternative_else_nop_endif
 	.endm
 
 	.macro tramp_alias, dst, sym
-	mov_q	\dst, TRAMP_VALIAS
-	add	\dst, \dst, #(\sym - .entry.tramp.text)
+	mov_q	\dst, (TRAMP_VALIAS | 0xffff)
+	movk	\dst, #(TRAMP_VALIAS + \sym - .entry.tramp.text) & 0xffff
 	.endm

I think this is more legible as-is, and would prefer to leave it that way.

Thanks,
Mark.

Quoted 10 lines
arch/arm64/kernel/entry.S +0 -0
 	// This macro corrupts x0-x3. It is the caller's duty
Signature · 7 lines
2.25.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel