Message ID | 20200917061948.12403-1-ardb@kernel.org |
---|---|
State | New |
Headers | show |
Series | ARM: vfp: force non-conditional encoding for external Thumb2 tail call | expand |
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
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?