All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: decompressor: deal with ADR going out of range in efi_enter_kernel()
@ 2020-04-07  7:46 Ard Biesheuvel
  2020-04-07  8:06 ` Ard Biesheuvel
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2020-04-07  7:46 UTC (permalink / raw)
  To: linux-arm-kernel; +Cc: linux, arnd, Ard Biesheuvel

Commit 0698fac4ac2a ("efi/arm: Clean EFI stub exit code from cache instead
of avoiding it") introduced a PC-relative reference to 'call_cache_fn' into
efi_enter_kernel(), which lives way at the end of head.S. In some cases,
the ARM version of the ADR instruction does not have sufficient range,
resulting in a build error:

  arch/arm/boot/compressed/head.S:1453: Error: invalid constant (fffffffffffffbe4) after fixup

ARM defines an alternative with a wider range, called ADRL, but this does
not exist for Thumb-2. At the same time, the ADR instruction in Thumb-2
has a wider range, and so it does not suffer from the same issue.

So let's switch to ADRL for ARM builds, and keep the ADR for Thumb-2 builds.

Reported-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
 arch/arm/boot/compressed/head.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index cabdd8f4a248..e8e1c866e413 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -1450,7 +1450,8 @@ ENTRY(efi_enter_kernel)
 		@ running beyond the PoU, and so calling cache_off below from
 		@ inside the PE/COFF loader allocated region is unsafe unless
 		@ we explicitly clean it to the PoC.
-		adr	r0, call_cache_fn		@ region of code we will
+ ARM(		adrl	r0, call_cache_fn	)
+ THUMB(		adr	r0, call_cache_fn	)	@ region of code we will
 		adr	r1, 0f				@ run with MMU off
 		bl	cache_clean_flush
 		bl	cache_off
-- 
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] 3+ messages in thread

* Re: [PATCH] ARM: decompressor: deal with ADR going out of range in efi_enter_kernel()
  2020-04-07  7:46 [PATCH] ARM: decompressor: deal with ADR going out of range in efi_enter_kernel() Ard Biesheuvel
@ 2020-04-07  8:06 ` Ard Biesheuvel
  2020-04-07 10:13   ` Arnd Bergmann
  0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2020-04-07  8:06 UTC (permalink / raw)
  To: Linux ARM; +Cc: Russell King, Arnd Bergmann

On Tue, 7 Apr 2020 at 09:46, Ard Biesheuvel <ardb@kernel.org> wrote:
>
> Commit 0698fac4ac2a ("efi/arm: Clean EFI stub exit code from cache instead
> of avoiding it") introduced a PC-relative reference to 'call_cache_fn' into
> efi_enter_kernel(), which lives way at the end of head.S. In some cases,
> the ARM version of the ADR instruction does not have sufficient range,
> resulting in a build error:
>
>   arch/arm/boot/compressed/head.S:1453: Error: invalid constant (fffffffffffffbe4) after fixup
>
> ARM defines an alternative with a wider range, called ADRL, but this does
> not exist for Thumb-2. At the same time, the ADR instruction in Thumb-2
> has a wider range, and so it does not suffer from the same issue.
>
> So let's switch to ADRL for ARM builds, and keep the ADR for Thumb-2 builds.
>
> Reported-by: Arnd Bergmann <arnd@arndb.de>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>

If nobody has any objections, I'll take this as a EFI fix.


> ---
>  arch/arm/boot/compressed/head.S | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index cabdd8f4a248..e8e1c866e413 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -1450,7 +1450,8 @@ ENTRY(efi_enter_kernel)
>                 @ running beyond the PoU, and so calling cache_off below from
>                 @ inside the PE/COFF loader allocated region is unsafe unless
>                 @ we explicitly clean it to the PoC.
> -               adr     r0, call_cache_fn               @ region of code we will
> + ARM(          adrl    r0, call_cache_fn       )
> + THUMB(                adr     r0, call_cache_fn       )       @ region of code we will
>                 adr     r1, 0f                          @ run with MMU off
>                 bl      cache_clean_flush
>                 bl      cache_off
> --
> 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	[flat|nested] 3+ messages in thread

* Re: [PATCH] ARM: decompressor: deal with ADR going out of range in efi_enter_kernel()
  2020-04-07  8:06 ` Ard Biesheuvel
@ 2020-04-07 10:13   ` Arnd Bergmann
  0 siblings, 0 replies; 3+ messages in thread
From: Arnd Bergmann @ 2020-04-07 10:13 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: Russell King, Linux ARM

On Tue, Apr 7, 2020 at 10:06 AM Ard Biesheuvel <ardb@kernel.org> wrote:
>
> On Tue, 7 Apr 2020 at 09:46, Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > Commit 0698fac4ac2a ("efi/arm: Clean EFI stub exit code from cache instead
> > of avoiding it") introduced a PC-relative reference to 'call_cache_fn' into
> > efi_enter_kernel(), which lives way at the end of head.S. In some cases,
> > the ARM version of the ADR instruction does not have sufficient range,
> > resulting in a build error:
> >
> >   arch/arm/boot/compressed/head.S:1453: Error: invalid constant (fffffffffffffbe4) after fixup
> >
> > ARM defines an alternative with a wider range, called ADRL, but this does
> > not exist for Thumb-2. At the same time, the ADR instruction in Thumb-2
> > has a wider range, and so it does not suffer from the same issue.
> >
> > So let's switch to ADRL for ARM builds, and keep the ADR for Thumb-2 builds.
> >
> > Reported-by: Arnd Bergmann <arnd@arndb.de>
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
>
> If nobody has any objections, I'll take this as a EFI fix.

I've added it to my randconfig build tree. If you don't hear back from
me today, you can add my

Tested-by: Arnd Bergmann <arnd@arndb.de>

_______________________________________________
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] 3+ messages in thread

end of thread, other threads:[~2020-04-07 10:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-07  7:46 [PATCH] ARM: decompressor: deal with ADR going out of range in efi_enter_kernel() Ard Biesheuvel
2020-04-07  8:06 ` Ard Biesheuvel
2020-04-07 10:13   ` Arnd Bergmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.