Two questions at least here, 1. cavium-octeon platform seems start with smp cpus, it may broke this function 2. Commit 15ad838d281b ("[MIPS] Always do the ARC64_TWIDDLE_PC thing."), I don't know whether broken it. So RFC to get helps. Thanks! And Patch3 can be tested by vmlinuz. e.g. Use the follow patch, diff --git a/arch/mips/boot/compressed/Makefile b/arch/mips/boot/compressed/Makefile index f93f72b..499b38d 100644 --- a/arch/mips/boot/compressed/Makefile +++ b/arch/mips/boot/compressed/Makefile @@ -28,12 +28,11 @@ KBUILD_CFLAGS := $(filter-out -march=loongson3a, $(KBUILD_CFLAGS)) -march=mips64 endif KBUILD_CFLAGS := $(KBUILD_CFLAGS) -D__KERNEL__ -D__DISABLE_EXPORTS \ - -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" - -KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ - -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ + -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) -D"VMLINUX_LOAD_ADDRESS_ULL=$(VMLINUX_LOAD_ADDRESS)ull" \ -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) +KBUILD_AFLAGS := $(KBUILD_AFLAGS) -D__ASSEMBLY__ -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) + # Prevents link failures: __sanitizer_cov_trace_pc() is not linked in. KCOV_INSTRUMENT := n GCOV_PROFILE := n diff --git a/arch/mips/boot/compressed/decompress.c b/arch/mips/boot/compressed/decompress.c index 3d70d15..3f5cac9 100644 --- a/arch/mips/boot/compressed/decompress.c +++ b/arch/mips/boot/compressed/decompress.c @@ -85,9 +85,11 @@ void __stack_chk_fail(void) error("stack-protector: Kernel stack is corrupted\n"); } -void decompress_kernel(unsigned long boot_heap_start) +unsigned long decompress_kernel(unsigned long boot_heap_start) { unsigned long zimage_start, zimage_size; + unsigned long offset = 0x8000000; + unsigned long long load_address = VMLINUX_LOAD_ADDRESS_ULL + offset; zimage_start = (unsigned long)(&__image_begin); zimage_size = (unsigned long)(&__image_end) - @@ -105,12 +107,12 @@ void decompress_kernel(unsigned long boot_heap_start) /* Display standard Linux/MIPS boot prompt */ puts("Uncompressing Linux at load address "); - puthex(VMLINUX_LOAD_ADDRESS_ULL); + puthex(load_address); puts("\n"); /* Decompress the kernel with according algorithm */ __decompress((char *)zimage_start, zimage_size, 0, 0, - (void *)VMLINUX_LOAD_ADDRESS_ULL, 0, 0, error); + (void *)load_address, 0, 0, error); if (IS_ENABLED(CONFIG_MIPS_RAW_APPENDED_DTB) && fdt_magic((void *)&__appended_dtb) == FDT_MAGIC) { @@ -125,14 +127,16 @@ void decompress_kernel(unsigned long boot_heap_start) image_size = ALIGN(image_size, STRUCT_ALIGNMENT); puts("Copy device tree to address "); - puthex(VMLINUX_LOAD_ADDRESS_ULL + image_size); + puthex(load_address + image_size); puts("\n"); /* copy dtb to where the booted kernel will expect it */ - memcpy((void *)VMLINUX_LOAD_ADDRESS_ULL + image_size, + memcpy((void *)load_address + image_size, __appended_dtb, dtb_size); } /* FIXME: should we flush cache here? */ puts("Now, booting the kernel...\n"); + + return (KERNEL_ENTRY + offset); } diff --git a/arch/mips/boot/compressed/head.S b/arch/mips/boot/compressed/head.S index 5795d0a..36c5809 100644 --- a/arch/mips/boot/compressed/head.S +++ b/arch/mips/boot/compressed/head.S @@ -40,8 +40,7 @@ move a1, s1 move a2, s2 move a3, s3 - PTR_LI t9, KERNEL_ENTRY - jalr t9 + jalr v0 3: b 3b Jinyang He (3): MIPS: relocate: Only compile relocs when CONFIG_RELOCATABLE is enabled MIPS: relocate: Use CONFIG_RANDOMIZE_BASE to configure kaslr MIPS: relocate: Add support to relocate kernel auto arch/mips/Makefile | 2 + arch/mips/cavium-octeon/smp.c | 8 +- arch/mips/generic/init.c | 4 +- arch/mips/include/asm/bootinfo.h | 4 +- .../asm/mach-cavium-octeon/kernel-entry-init.h | 4 +- arch/mips/kernel/Makefile | 2 +- arch/mips/kernel/head.S | 155 ++++++++++++++++++++- arch/mips/kernel/{relocate.c => kaslr.c} | 15 -- 8 files changed, 165 insertions(+), 29 deletions(-) rename arch/mips/kernel/{relocate.c => kaslr.c} (97%) -- 2.1.0