From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1761190AbcLRL5D (ORCPT ); Sun, 18 Dec 2016 06:57:03 -0500 Received: from mail-io0-f179.google.com ([209.85.223.179]:34949 "EHLO mail-io0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757927AbcLRL5B (ORCPT ); Sun, 18 Dec 2016 06:57:01 -0500 MIME-Version: 1.0 In-Reply-To: <4112999.Nl7pxYH1YF@wuerfel> References: <20161216091457.2452987-1-arnd@arndb.de> <4112999.Nl7pxYH1YF@wuerfel> From: Ard Biesheuvel Date: Sun, 18 Dec 2016 11:57:00 +0000 Message-ID: Subject: Re: [PATCH] ARM: disallow ARM_THUMB for ARMv4 builds To: Arnd Bergmann Cc: Russell King , Nicolas Pitre , "linux-kernel@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Jonas Jensen Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 16 December 2016 at 21:51, Arnd Bergmann 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.