Commit beb28000 authored by Jiaxun Yang's avatar Jiaxun Yang Committed by Huacai Chen

LoongArch: Fix entry point in kernel image header

Currently kernel entry in head.S is in DMW address range, firmware is
instructed to jump to this address after loading the kernel image.

However kernel should not make any assumption on firmware's DMW
setting, thus the entry point should be a physical address falls into
direct translation region.

Fix by converting entry address to physical and amend entry calculation
logic in libstub accordingly.

BTW, use ABSOLUTE() to calculate variables to make Clang/LLVM happy.

Cc: stable@vger.kernel.org
Signed-off-by: default avatarJiaxun Yang <jiaxun.yang@flygoat.com>
Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
parent 3de9c42d
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
_head: _head:
.word MZ_MAGIC /* "MZ", MS-DOS header */ .word MZ_MAGIC /* "MZ", MS-DOS header */
.org 0x8 .org 0x8
.dword kernel_entry /* Kernel entry point */ .dword _kernel_entry /* Kernel entry point (physical address) */
.dword _kernel_asize /* Kernel image effective size */ .dword _kernel_asize /* Kernel image effective size */
.quad PHYS_LINK_KADDR /* Kernel image load offset from start of RAM */ .quad PHYS_LINK_KADDR /* Kernel image load offset from start of RAM */
.org 0x38 /* 0x20 ~ 0x37 reserved */ .org 0x38 /* 0x20 ~ 0x37 reserved */
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#define PAGE_SIZE _PAGE_SIZE #define PAGE_SIZE _PAGE_SIZE
#define RO_EXCEPTION_TABLE_ALIGN 4 #define RO_EXCEPTION_TABLE_ALIGN 4
#define PHYSADDR_MASK 0xffffffffffff /* 48-bit */
/* /*
* Put .bss..swapper_pg_dir as the first thing in .bss. This will * Put .bss..swapper_pg_dir as the first thing in .bss. This will
...@@ -142,10 +143,11 @@ SECTIONS ...@@ -142,10 +143,11 @@ SECTIONS
#ifdef CONFIG_EFI_STUB #ifdef CONFIG_EFI_STUB
/* header symbols */ /* header symbols */
_kernel_asize = _end - _text; _kernel_entry = ABSOLUTE(kernel_entry & PHYSADDR_MASK);
_kernel_fsize = _edata - _text; _kernel_asize = ABSOLUTE(_end - _text);
_kernel_vsize = _end - __initdata_begin; _kernel_fsize = ABSOLUTE(_edata - _text);
_kernel_rsize = _edata - __initdata_begin; _kernel_vsize = ABSOLUTE(_end - __initdata_begin);
_kernel_rsize = ABSOLUTE(_edata - __initdata_begin);
#endif #endif
.gptab.sdata : { .gptab.sdata : {
......
...@@ -41,7 +41,7 @@ static efi_status_t exit_boot_func(struct efi_boot_memmap *map, void *priv) ...@@ -41,7 +41,7 @@ static efi_status_t exit_boot_func(struct efi_boot_memmap *map, void *priv)
unsigned long __weak kernel_entry_address(unsigned long kernel_addr, unsigned long __weak kernel_entry_address(unsigned long kernel_addr,
efi_loaded_image_t *image) efi_loaded_image_t *image)
{ {
return *(unsigned long *)(kernel_addr + 8) - VMLINUX_LOAD_ADDRESS + kernel_addr; return *(unsigned long *)(kernel_addr + 8) - PHYSADDR(VMLINUX_LOAD_ADDRESS) + kernel_addr;
} }
efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image, efi_status_t efi_boot_kernel(void *handle, efi_loaded_image_t *image,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment