[PATCH] efi_loader: Avoid emitting efi_var_buf to .GOT
Ilias Apalodimas
ilias.apalodimas at linaro.org
Sat Jan 16 16:08:54 CET 2021
On Fri, Jan 15, 2021 at 11:33:40AM -0800, Atish Patra wrote:
> On Fri, Jan 15, 2021 at 8:00 AM Ilias Apalodimas
> <ilias.apalodimas at linaro.org> wrote:
> >
> > Atish reports than on RISC-V, accessing the EFI variables causes
> > a kernel panic. An objdump of the file verifies that, since the
> > global pointer for efi_var_buf ends up in .GOT section which is
> > not mapped in virtual address space for Linux.
> >
> > <snip of efi_var_mem_find>
> >
> > 0000000000000084 <efi_var_mem_find>:
> > 84: 715d addi sp,sp,-80
> >
> > * objdump -dr
> > 0000000000000086 <.LCFI2>:
> > 86: e0a2 sd s0,64(sp)
> > 88: fc26 sd s1,56(sp)
> > 8a: e486 sd ra,72(sp)
> > 8c: f84a sd s2,48(sp)
> > 8e: f44e sd s3,40(sp)
> > 90: f052 sd s4,32(sp)
> > 92: ec56 sd s5,24(sp)
> > 94: 00000497 auipc s1,0x0
> > 94: R_RISCV_GOT_HI20 efi_var_buf
> > 98: 0004b483 ld s1,0(s1) # 94 <.LCFI2+0xe>
> > 98: R_RISCV_PCREL_LO12_I .L0
> > 98: R_RISCV_RELAX *ABS*
> >
> > * objdump -t
> > 0000000000000084 g F .text.efi_runtime 00000000000000b8 efi_var_mem_find
> >
> > With the patch applied:
> >
> > * objdump -dr
> > 0000000000000086 <.LCFI2>:
> > 86: e0a2 sd s0,64(sp)
> > 88: fc26 sd s1,56(sp)
> > 8a: e486 sd ra,72(sp)
> > 8c: f84a sd s2,48(sp)
> > 8e: f44e sd s3,40(sp)
> > 90: f052 sd s4,32(sp)
> > 92: ec56 sd s5,24(sp)
> > 94: 00000497 auipc s1,0x0
> > 94: R_RISCV_PCREL_HI20 .LANCHOR0
> > 94: R_RISCV_RELAX *ABS*
> > 98: 00048493 mv s1,s1
> > 98: R_RISCV_PCREL_LO12_I .L0
> > 98: R_RISCV_RELAX *ABS*
> >
> > * objdump -t
> > 0000000000000008 l O .data.efi_runtime 0000000000000008 efi_var_buf
> >
> > On arm64 this works, because there's no .GOT entries for this
> > and everything is converted to relative references.
> >
>
> Just curious to know: Is it because of linker script magic or compiler
> optimization ?
> I might have missed something but I did not find anything relevant in
> the arm64 linker scripts.
>
I replied on the original thread regarding what happens in Arm and we get the
feature working [1]
[1] https://lists.denx.de/pipermail/u-boot/2021-January/437484.html
Cheers
/Ilias
More information about the U-Boot
mailing list