linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: ard.biesheuvel@linaro.org (Ard Biesheuvel)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFT/RFC PATCH 3/6] ARM: add macro to perform far branches (b/bl)
Date: Thu, 12 Mar 2015 18:38:09 +0100	[thread overview]
Message-ID: <1426181892-15440-4-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1426181892-15440-1-git-send-email-ard.biesheuvel@linaro.org>

These macros execute PC-relative branches, but with a larger
reach than the 24 bits that are available in the b and bl opcodes.

Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 arch/arm/include/asm/assembler.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index f67fd3afebdf..bd08c3c1b73f 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -108,6 +108,35 @@
 	.endm
 #endif
 
+	/*
+	 * Macros to emit relative branches that may exceed the range
+	 * of the 24-bit immediate of the ordinary b/bl instructions.
+	 * NOTE: this doesn't work with locally defined symbols, as they
+	 * might lack the ARM/Thumb annotation (even if they are annotated
+	 * as functions)
+	 */
+	.macro  b_far, target, tmpreg
+#if defined(CONFIG_CPU_32v7) || defined(CONFIG_CPU_32v7M)
+ ARM(	movt	\tmpreg, #:upper16:(\target - (8888f + 8))	)
+ ARM(	movw	\tmpreg, #:lower16:(\target - (8888f + 8))	)
+ THUMB(	movt    \tmpreg, #:upper16:(\target - (8888f + 4))	)
+ THUMB(	movw	\tmpreg, #:lower16:(\target - (8888f + 4))	)
+8888:	add	pc, pc, \tmpreg
+#else
+	ldr	\tmpreg, 8889f
+8888:	add	pc, pc, \tmpreg
+	.align 	2
+8889:
+ ARM(	.word   \target - (8888b + 8)           )
+#endif
+	.endm
+
+	.macro	bl_far, target, tmpreg=ip
+	adr	lr, 8887f
+	b_far	\target, \tmpreg
+8887:
+	.endm
+
 	.macro asm_trace_hardirqs_off
 #if defined(CONFIG_TRACE_IRQFLAGS)
 	stmdb   sp!, {r0-r3, ip, lr}
-- 
1.8.3.2

  parent reply	other threads:[~2015-03-12 17:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12 17:38 [RFT/RFC PATCH 0/6] ARM kernel size fixes Ard Biesheuvel
2015-03-12 17:38 ` [RFT/RFC PATCH 1/6] ARM: replace PROCINFO embedded branch with relative offset Ard Biesheuvel
2015-03-12 20:24   ` Nicolas Pitre
2015-03-12 20:50   ` Russell King - ARM Linux
2015-03-12 21:00     ` Ard Biesheuvel
2015-03-12 17:38 ` [RFT/RFC PATCH 2/6] ARM: move HYP text to end of .text section Ard Biesheuvel
2015-03-12 17:38 ` Ard Biesheuvel [this message]
2015-03-12 20:32   ` [RFT/RFC PATCH 3/6] ARM: add macro to perform far branches (b/bl) Nicolas Pitre
2015-03-12 20:36     ` Ard Biesheuvel
2015-03-12 21:03       ` Nicolas Pitre
2015-03-12 21:15         ` Ard Biesheuvel
2015-03-12 21:37           ` Ard Biesheuvel
2015-03-12 22:26             ` Nicolas Pitre
2015-03-12 20:56   ` Russell King - ARM Linux
2015-03-12 17:38 ` [RFT/RFC PATCH 4/6] ARM: use bl_far to call __hyp_stub_install_secondary from the .data section Ard Biesheuvel
2015-03-12 17:38 ` [RFT/RFC PATCH 5/6] ARM: move the .idmap.text section closer to .head.text Ard Biesheuvel
2015-03-12 20:33   ` Nicolas Pitre
2015-03-12 17:38 ` [RFT/RFC PATCH 6/6] ARM: keep .text and .fixup regions together Ard Biesheuvel
2015-03-12 20:34   ` Nicolas Pitre
2015-03-12 21:10   ` Russell King - ARM Linux
2015-03-12 21:18     ` Ard Biesheuvel
2015-03-12 21:22       ` Russell King - ARM Linux
2015-03-13 11:18         ` Arnd Bergmann
2015-03-13 11:26           ` Ard Biesheuvel
2015-03-13 11:52             ` Arnd Bergmann

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=1426181892-15440-4-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).