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: [PATCH v2 2/2] ARM: Thumb2: use "bx reg" not "mov pc, reg" for all registers
Date: Tue, 21 Apr 2015 12:59:43 +0200	[thread overview]
Message-ID: <1429613983-22739-3-git-send-email-ard.biesheuvel@linaro.org> (raw)
In-Reply-To: <1429613983-22739-1-git-send-email-ard.biesheuvel@linaro.org>

Commit 6ebbf2ce437b (ARM: convert all "mov.* pc, reg" to "bx reg"
for ARMv6+) replaced all occurrences of 'mov pc, <reg>' with the
'ret' macro. However, this macro only emits the 'bx' instruction
when used with the 'lr' register, but still uses 'mov pc, <reg>'
for everything else.

Since ARM/Thumb2 interworking is allowed in the static kernel
(i.e., inside vmlinux), this is potentially unsafe, since the
Thumb mov instruction T1 variant that allows PC as the target will
not switch modes based on the Thumb bit

So when building a Thumb2 kernel, emit the 'bx' instruction for
all registers, not just the 'lr' register.

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

diff --git a/arch/arm/include/asm/assembler.h b/arch/arm/include/asm/assembler.h
index 186270b3e194..1c057f923258 100644
--- a/arch/arm/include/asm/assembler.h
+++ b/arch/arm/include/asm/assembler.h
@@ -434,6 +434,8 @@ THUMB(	orr	\reg , \reg , #PSR_T_BIT	)
 	.macro	ret\c, reg
 #if __LINUX_ARM_ARCH__ < 6
 	mov\c	pc, \reg
+#elif defined(CONFIG_THUMB2_KERNEL)
+	bx\c	\reg
 #else
 	.ifeqs	"\reg", "lr"
 	bx\c	\reg
-- 
1.8.3.2

  parent reply	other threads:[~2015-04-21 10:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-21 10:59 [PATCH v2 0/2] ARM: honor Thumb bit when calling procinfo setup functions Ard Biesheuvel
2015-04-21 10:59 ` [PATCH v2 1/2] ARM: use ENDPROC() to annotate all v7 asm " Ard Biesheuvel
2015-04-21 10:59 ` Ard Biesheuvel [this message]
2015-04-21 11:15   ` [PATCH v2 2/2] ARM: Thumb2: use "bx reg" not "mov pc, reg" for all registers Dave P Martin
2015-04-21 11:19     ` Ard Biesheuvel

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=1429613983-22739-3-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).