Hi Jiaxun,

On 2026-10-16T06:54:41, Yao Zi <[email protected]> wrote:
> efi: LoongArch: Implement everything
>
> Implement crt, relocator, linker scripts, and handling of PE relocation
> IMAGE_REL_BASED_LOONGARCH64_MARK_LA. Wire things up in Makefiles and
> Kconfig. The relocator originates gnu-efi project.

Grammar nit: "The relocator originates from the gnu-efi project".

>
> Signed-off-by: Jiaxun Yang <[email protected]>
> Signed-off-by: Yao Zi <[email protected]>
>
>  arch/loongarch/config.mk                 |   4 +
>  arch/loongarch/lib/Makefile              |  12 ++
>  arch/loongarch/lib/crt0_loongarch_efi.S  | 182 
> +++++++++++++++++++++++++++++++
>  arch/loongarch/lib/elf_loongarch_efi.lds |  76 +++++++++++++
>  arch/loongarch/lib/reloc_loongarch_efi.c | 102 +++++++++++++++++
>  lib/efi_loader/Kconfig                   |   2 +-
>  lib/efi_loader/efi_helper.c              |   3 +
>  lib/efi_loader/efi_image_loader.c        |  31 ++++++
>  8 files changed, 411 insertions(+), 1 deletion(-)

> diff --git a/arch/loongarch/lib/Makefile b/arch/loongarch/lib/Makefile
> @@ -12,3 +12,15 @@ ifeq ($(CONFIG_$(SPL_)SYSRESET),)
> +extra-$(CONFIG_CMD_BOOTEFI_HELLO_COMPILE) += $(EFI_CRT0) $(EFI_RELOC)
> +extra-$(CONFIG_CMD_BOOTEFI_SELFTEST) += $(EFI_CRT0) $(EFI_RELOC)
> +extra-$(CONFIG_EFI) += $(EFI_CRT0) $(EFI_RELOC)

CMD_BOOTEFI_HELLO_COMPILE and CMD_BOOTEFI_SELFTEST both select
EFI_LOADER (which selects EFI), so the first two lines look redundant
with the third. The arm and riscv Makefiles rely on CFLAGS alone - was
any of this needed to make the build work?

> diff --git a/arch/loongarch/lib/crt0_loongarch_efi.S 
> b/arch/loongarch/lib/crt0_loongarch_efi.S
> @@ -0,0 +1,182 @@
> +     la.local        a0, ImageBase   /* a0: ImageBase */
> +     la.local        a1, _DYNAMIC    /* a1: DynamicSection */
> +     bl              _relocate

Odd mix of spaces and tabs after 'bl' - please make it a single tab.

> diff --git a/arch/loongarch/lib/reloc_loongarch_efi.c 
> b/arch/loongarch/lib/reloc_loongarch_efi.c
> @@ -0,0 +1,102 @@
> +     return EFI_SUCCESS;
> +}
> +

Trailing blank line at EOF - please drop it.

> diff --git a/lib/efi_loader/efi_image_loader.c 
> b/lib/efi_loader/efi_image_loader.c
> @@ -230,6 +232,35 @@ static efi_status_t efi_loader_relocate(const 
> IMAGE_BASE_RELOCATION *rel,
> +                             /*
> +                              * Apply an offset to a 64-bit immedate loaded
> +                              * by four instructions, lu12i.w, ori, lu32i.d,
> +                              * and lu52i.d.
> +                              */

Typo: 'immedate' should be 'immediate'.

> diff --git a/lib/efi_loader/efi_image_loader.c 
> b/lib/efi_loader/efi_image_loader.c
> @@ -165,6 +166,7 @@ static efi_status_t efi_loader_relocate(const 
> IMAGE_BASE_RELOCATION *rel,
> +                     __maybe_unused uint64_t tmp;

The __maybe_unused is only there because 'tmp' is used in exactly one
case under an #if. It would read more naturally as a plain local
declared inside the IMAGE_REL_BASED_LOONGARCH64_MARK_LA case block,
which would also drop the attribute.

In any case:

Reviewed-by: Simon Glass <[email protected]>

Regards,
Simon

Reply via email to