linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] efistub: LoongArch: Reimplement kernel_entry_address()
@ 2023-03-07 10:57 Youling Tang
  2023-03-08 20:50 ` kernel test robot
  0 siblings, 1 reply; 2+ messages in thread
From: Youling Tang @ 2023-03-07 10:57 UTC (permalink / raw)
  To: Huacai Chen, Ard Biesheuvel
  Cc: Xuerui Wang, linux-efi, loongarch, linux-kernel, loongson-kernel

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(-)

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,
-- 
2.37.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] efistub: LoongArch: Reimplement kernel_entry_address()
  2023-03-07 10:57 [PATCH] efistub: LoongArch: Reimplement kernel_entry_address() Youling Tang
@ 2023-03-08 20:50 ` kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2023-03-08 20:50 UTC (permalink / raw)
  To: Youling Tang, Huacai Chen, Ard Biesheuvel
  Cc: oe-kbuild-all, Xuerui Wang, linux-efi, loongarch, linux-kernel,
	loongson-kernel

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	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-08 20:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-07 10:57 [PATCH] efistub: LoongArch: Reimplement kernel_entry_address() Youling Tang
2023-03-08 20:50 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).