Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1544130

Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds

From Ard Biesheuvel <ard.biesheuvel@linaro.org>
Newsgroups linux.kernel
Subject Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds
Date 2016-12-18 13:00 +0100
Message-ID <sPIid-7in-3@gated-at.bofh.it> (permalink)
References <sOWZY-1DO-33@gated-at.bofh.it> <sP4ut-6D6-13@gated-at.bofh.it> <sP8HL-FW-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 16 December 2016 at 21:51, Arnd Bergmann <arnd@arndb.de> wrote:
> On Friday, December 16, 2016 5:20:22 PM CET Ard Biesheuvel wrote:
>>
>> Can't we use the old
>>
>> tst lr, #1
>> moveq pc, lr
>> bx lr
>>
>> trick? (where bx lr needs to be emitted as a plain opcode to hide it
>> from the assembler)
>>
>
> Yes, that should work around the specific problem in theory, but back
> when Jonas tried it, it still didn't work. There may also be other
> problems in that configuration.
>

This should do the trick as well, I think:

diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
index 9f157e7c51e7..3bfb32010234 100644
--- a/arch/arm/kernel/entry-armv.S
+++ b/arch/arm/kernel/entry-armv.S
@@ -835,7 +835,12 @@ ENDPROC(__switch_to)

        .macro  usr_ret, reg
 #ifdef CONFIG_ARM_THUMB
+#ifdef CONFIG_CPU_32v4
+       str     \reg, [sp, #-4]!
+       ldr     pc, [sp], #4
+#else
        bx      \reg
+#endif
 #else
        ret     \reg
 #endif

with the added benefit that we don't clobber the N and Z flags. Of
course, this will result in all CPUs using a non-optimal sequence if
support for v4 is compiled in.

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] ARM: disallow ARM_THUMB for ARMv4 builds Arnd Bergmann <arnd@arndb.de> - 2016-12-16 10:30 +0100
  Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-12-16 18:30 +0100
    Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds Arnd Bergmann <arnd@arndb.de> - 2016-12-16 23:00 +0100
      Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-12-18 13:00 +0100
        Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds Russell King - ARM Linux <linux@armlinux.org.uk> - 2016-12-18 15:20 +0100
          Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds Ard Biesheuvel <ard.biesheuvel@linaro.org> - 2016-12-18 16:10 +0100
            Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds Russell King - ARM Linux <linux@armlinux.org.uk> - 2016-12-19 00:50 +0100
              Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds Nicolas Pitre <nicolas.pitre@linaro.org> - 2016-12-19 05:20 +0100

csiph-web