linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: vfp: force non-conditional encoding for external Thumb2 tail call
@ 2020-09-17  6:19 Ard Biesheuvel
  2020-09-18 19:42 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2020-09-17  6:19 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: ndesaulniers, linux, stable, Ard Biesheuvel

Nick reports that the following error is produced in some cases when
using GCC+ld.bfd to build the ARM defconfig with Thumb2 enabled:

  arch/arm/vfp/vfphw.o: in function `vfp_support_entry':
  (.text+0xa): relocation truncated to fit: R_ARM_THM_JUMP19 against
  symbol `vfp_kmode_exception' defined in .text.unlikely section in
  arch/arm/vfp/vfpmodule.o

  $ arm-linux-gnueabihf-ld --version
  GNU ld (GNU Binutils for Debian) 2.34

Generally, the linker should be able to fix up out of range branches by
emitting veneers, but apparently, it fails to do so in this particular
case, i.e., a conditional 'tail call' to vfp_kmode_exception(), which
is not defined in the same object file.

So let's force the use of a non-conditional encoding of the B instruction,
which has more space for an immediate offset.

Cc: <stable@vger.kernel.org>
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Tested-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/vfp/vfphw.S | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
index 4fcff9f59947..f1468702fbc9 100644
--- a/arch/arm/vfp/vfphw.S
+++ b/arch/arm/vfp/vfphw.S
@@ -82,6 +82,7 @@ ENTRY(vfp_support_entry)
 	ldr	r3, [sp, #S_PSR]	@ Neither lazy restore nor FP exceptions
 	and	r3, r3, #MODE_MASK	@ are supported in kernel mode
 	teq	r3, #USR_MODE
+THUMB(	it	ne			)
 	bne	vfp_kmode_exception	@ Returns through lr
 
 	VFPFMRX	r1, FPEXC		@ Is the VFP enabled?
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ARM: vfp: force non-conditional encoding for external Thumb2 tail call
  2020-09-17  6:19 [PATCH] ARM: vfp: force non-conditional encoding for external Thumb2 tail call Ard Biesheuvel
@ 2020-09-18 19:42 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2020-09-18 19:42 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: # 3.4.x, Russell King, Linux ARM

On Wed, Sep 16, 2020 at 11:19 PM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> Nick reports that the following error is produced in some cases when
> using GCC+ld.bfd to build the ARM defconfig with Thumb2 enabled:
>
>   arch/arm/vfp/vfphw.o: in function `vfp_support_entry':
>   (.text+0xa): relocation truncated to fit: R_ARM_THM_JUMP19 against
>   symbol `vfp_kmode_exception' defined in .text.unlikely section in
>   arch/arm/vfp/vfpmodule.o
>
>   $ arm-linux-gnueabihf-ld --version
>   GNU ld (GNU Binutils for Debian) 2.34

FWIW this was my compiler version, too:
$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Debian 9.3.0-8) 9.3.0

>
> Generally, the linker should be able to fix up out of range branches by
> emitting veneers, but apparently, it fails to do so in this particular
> case, i.e., a conditional 'tail call' to vfp_kmode_exception(), which
> is not defined in the same object file.
>
> So let's force the use of a non-conditional encoding of the B instruction,
> which has more space for an immediate offset.
>
> Cc: <stable@vger.kernel.org>
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Tested-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> ---
>  arch/arm/vfp/vfphw.S | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S
> index 4fcff9f59947..f1468702fbc9 100644
> --- a/arch/arm/vfp/vfphw.S
> +++ b/arch/arm/vfp/vfphw.S
> @@ -82,6 +82,7 @@ ENTRY(vfp_support_entry)
>         ldr     r3, [sp, #S_PSR]        @ Neither lazy restore nor FP exceptions
>         and     r3, r3, #MODE_MASK      @ are supported in kernel mode
>         teq     r3, #USR_MODE
> +THUMB( it      ne                      )
>         bne     vfp_kmode_exception     @ Returns through lr
>
>         VFPFMRX r1, FPEXC               @ Is the VFP enabled?
> --
> 2.17.1
>


-- 
Thanks,
~Nick Desaulniers

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-09-18 19:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-17  6:19 [PATCH] ARM: vfp: force non-conditional encoding for external Thumb2 tail call Ard Biesheuvel
2020-09-18 19:42 ` Nick Desaulniers

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).