Skip to content

Commit

Permalink
efistub: LoongArch: Reimplement kernel_entry_address()
Browse files Browse the repository at this point in the history
When EFI_KIMG_PREFERRED_ADDRESS is not equal to PHYS_LINK_KADDR, we
should not jump to the link address but the actual load address, so
fix the processing of kernel_entry_address().

Signed-off-by: Youling Tang <tangyouling@loongson.cn>
  • Loading branch information
Youling Tang authored and intel-lab-lkp committed Mar 7, 2023
1 parent e1d4471 commit 1f509b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
2 changes: 0 additions & 2 deletions arch/loongarch/include/asm/efi.h
Expand Up @@ -32,6 +32,4 @@ static inline unsigned long efi_get_kimg_min_align(void)

#define EFI_KIMG_PREFERRED_ADDRESS PHYSADDR(VMLINUX_LOAD_ADDRESS)

unsigned long kernel_entry_address(void);

#endif /* _ASM_LOONGARCH_EFI_H */
7 changes: 0 additions & 7 deletions drivers/firmware/efi/libstub/loongarch-stub.c
Expand Up @@ -44,10 +44,3 @@ efi_status_t handle_kernel_image(unsigned long *image_addr,

return status;
}

unsigned long kernel_entry_address(void)
{
unsigned long base = (unsigned long)&kernel_offset - kernel_offset;

return (unsigned long)&kernel_entry - base + VMLINUX_LOAD_ADDRESS;
}
14 changes: 12 additions & 2 deletions drivers/firmware/efi/libstub/loongarch.c
Expand Up @@ -37,9 +37,19 @@ static efi_status_t exit_boot_func(struct efi_boot_memmap *map, void *priv)
return EFI_SUCCESS;
}

unsigned long __weak kernel_entry_address(void)
/*
* Get the offset of EFI_KIMG_PREFERRED_ADDRESS relative to the physical
* link address.
*/
static long get_kernel_offset(void)
{
return EFI_KIMG_PREFERRED_ADDRESS - PHYS_LINK_KADDR;
}

unsigned long kernel_entry_address(void)
{
return *(unsigned long *)(PHYSADDR(VMLINUX_LOAD_ADDRESS) + 8);
return *(unsigned long *)(EFI_KIMG_PREFERRED_ADDRESS + 8) +
get_kernel_offset();
}

efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
Expand Down

0 comments on commit 1f509b4

Please sign in to comment.