Message ID | 1678186653-27659-1-git-send-email-tangyouling@loongson.cn |
---|---|
State | New |
Headers | show |
Series | efistub: LoongArch: Reimplement kernel_entry_address() | expand |
Hi Youling, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on efi/next] [also build test WARNING on linus/master v6.3-rc1 next-20230308] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Youling-Tang/efistub-LoongArch-Reimplement-kernel_entry_address/20230307-190013 base: https://git.kernel.org/pub/scm/linux/kernel/git/efi/efi.git next patch link: https://lore.kernel.org/r/1678186653-27659-1-git-send-email-tangyouling%40loongson.cn patch subject: [PATCH] efistub: LoongArch: Reimplement kernel_entry_address() config: loongarch-defconfig (https://download.01.org/0day-ci/archive/20230309/202303090430.e6BB0Txr-lkp@intel.com/config) compiler: loongarch64-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/1f509b49ceeeeb3c59483c685592f8d87b70f169 git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Youling-Tang/efistub-LoongArch-Reimplement-kernel_entry_address/20230307-190013 git checkout 1f509b49ceeeeb3c59483c685592f8d87b70f169 # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash drivers/firmware/efi/libstub/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> | Link: https://lore.kernel.org/oe-kbuild-all/202303090430.e6BB0Txr-lkp@intel.com/ All warnings (new ones prefixed by >>): drivers/firmware/efi/libstub/loongarch.c: In function 'get_kernel_offset': drivers/firmware/efi/libstub/loongarch.c:46:45: error: 'PHYS_LINK_KADDR' undeclared (first use in this function) 46 | return EFI_KIMG_PREFERRED_ADDRESS - PHYS_LINK_KADDR; | ^~~~~~~~~~~~~~~ drivers/firmware/efi/libstub/loongarch.c:46:45: note: each undeclared identifier is reported only once for each function it appears in drivers/firmware/efi/libstub/loongarch.c: At top level: >> drivers/firmware/efi/libstub/loongarch.c:49:15: warning: no previous prototype for 'kernel_entry_address' [-Wmissing-prototypes] 49 | unsigned long kernel_entry_address(void) | ^~~~~~~~~~~~~~~~~~~~ drivers/firmware/efi/libstub/loongarch.c: In function 'get_kernel_offset': drivers/firmware/efi/libstub/loongarch.c:47:1: error: control reaches end of non-void function [-Werror=return-type] 47 | } | ^ cc1: some warnings being treated as errors vim +/kernel_entry_address +49 drivers/firmware/efi/libstub/loongarch.c 48 > 49 unsigned long kernel_entry_address(void) 50 { 51 return *(unsigned long *)(EFI_KIMG_PREFERRED_ADDRESS + 8) + 52 get_kernel_offset(); 53 } 54
diff --git a/arch/loongarch/include/asm/efi.h b/arch/loongarch/include/asm/efi.h index 091897d40b03..eddc8e79b3fa 100644 --- a/arch/loongarch/include/asm/efi.h +++ b/arch/loongarch/include/asm/efi.h @@ -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 */ diff --git a/drivers/firmware/efi/libstub/loongarch-stub.c b/drivers/firmware/efi/libstub/loongarch-stub.c index eee7ed43cdfb..71d178f87274 100644 --- a/drivers/firmware/efi/libstub/loongarch-stub.c +++ b/drivers/firmware/efi/libstub/loongarch-stub.c @@ -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; -} diff --git a/drivers/firmware/efi/libstub/loongarch.c b/drivers/firmware/efi/libstub/loongarch.c index 807cba2693fc..79fa16a765ce 100644 --- a/drivers/firmware/efi/libstub/loongarch.c +++ b/drivers/firmware/efi/libstub/loongarch.c @@ -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,
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> --- - EFI_KIMG_PREFERRED_ADDRESS = PHYS_LINK_KADDR: / # cat /proc/iomem 00000000-0fffffff : System RAM 00000000-001fffff : Reserved 00200000-0113ffff : Kernel code 01140000-01a0e5ff : Kernel data 01a0e600-01b0b337 : Kernel bss - EFI_KIMG_PREFERRED_ADDRESS = PHYS_LINK_KADDR + 0x4000000 (Enable CONFIG_RELOCATABLE): # cat /proc/iomem 00000000-0fffffff : System RAM 00000000-041fffff : Reserved 04200000-0513ffff : Kernel code 05140000-05a0e5ff : Kernel data 05a0e600-05b0b337 : Kernel bss arch/loongarch/include/asm/efi.h | 2 -- drivers/firmware/efi/libstub/loongarch-stub.c | 7 ------- drivers/firmware/efi/libstub/loongarch.c | 14 ++++++++++++-- 3 files changed, 12 insertions(+), 11 deletions(-)