Skip to contentSkip to conversation

ARM: vfp: force non-conditional encoding for external Thumb2 tail call

PATCH In review Ard Biesheuvel 2 participants 2 messages Sep 17, 2020 – Sep 18, 2020

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: vfp: force non-conditional encoding for external Thumb2 tail call

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.

---
 arch/arm/vfp/vfphw.S | 1 +
 1 file changed, 1 insertion(+)
arch/arm/vfp/vfphw.S +1 -0
index 4fcff9f59947..f1468702fbc9 100644
@@ -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?
Signature · 7 lines
2.17.1


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#1 lore raw
Quoted 11 lines · 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

FWIW this was my compiler version, too:

$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (Debian 9.3.0-8) 9.3.0
Quoted 32 lines

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.

---
 arch/arm/vfp/vfphw.S | 1 +
 1 file changed, 1 insertion(+)
arch/arm/vfp/vfphw.S +1 -1
index 4fcff9f59947..f1468702fbc9 100644
@@ -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

Signature · 2 lines
Thanks,
~Nick Desaulniers