Message ID | 20180124223953.GO28231@n2100.armlinux.org.uk (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Hi, On Wed, Jan 24, 2018 at 10:39:53PM +0000, Russell King - ARM Linux wrote: > On Wed, Jan 24, 2018 at 11:21:33PM +0200, Aaro Koskinen wrote: > > So something is missing from the size calculation...? > > Maybe. Please try this patch on top of the previous one, and report > the new debug output. That patch is working. See below with results before and after the patch. Before: kernel: 0xb6a5d008 kernel_size: 0x3c6060 MEMORY RANGES 0000000080000000-0000000087ffffff (0) zImage header: 0x016f2818 0x00000000 0x003c6060 zImage size 0x3c6060, file size 0x3c6060 offset 0x00003b98 tag 0x5a534c4b size 8 Kernel: address=0x80008000 size=0x00f0e000 DT : address=0x80f17000 size=0x00008c35 kexec_load: entry = 0x80008000 flags = 0x280000 nr_segments = 2 segment[0].buf = 0xb6a5d008 segment[0].bufsz = 0x3c6060 segment[0].mem = 0x80008000 segment[0].memsz = 0x3c7000 segment[1].buf = 0x16e12b8 segment[1].bufsz = 0x8c35 segment[1].mem = 0x80f17000 segment[1].memsz = 0x9000 [ 4.840179] kexec_core: Starting new kernel [ 4.844604] Bye! After: kernel: 0xb6a79008 kernel_size: 0x3c6060 MEMORY RANGES 0000000080000000-0000000087ffffff (0) zImage header: 0x016f2818 0x00000000 0x003c6060 zImage size 0x3c6060, file size 0x3c6060 zImage requires 0x003d7060 bytes offset 0x00003b98 tag 0x5a534c4b size 8 Decompressed kernel sizes: text+data 0x00b47fa0 bss 0x0011674c total 0x00c5e6ec Resulting kernel space: 0x00f1f000 Kernel: address=0x80008000 size=0x00f1f000 DT : address=0x80f28000 size=0x00008c35 kexec_load: entry = 0x80008000 flags = 0x280000 nr_segments = 2 segment[0].buf = 0xb6a79008 segment[0].bufsz = 0x3c6064 segment[0].mem = 0x80008000 segment[0].memsz = 0x3c7000 segment[1].buf = 0x10152b8 segment[1].bufsz = 0x8c35 segment[1].mem = 0x80f28000 segment[1].memsz = 0x9000 [ 4.840240] kexec_core: Starting new kernel [ 4.844665] Bye! [ 0.000000] Booting Linux on physical CPU 0x0 A.
diff --git a/kexec/arch/arm/kexec-zImage-arm.c b/kexec/arch/arm/kexec-zImage-arm.c index 76a0b5b66745..2a7eea907769 100644 --- a/kexec/arch/arm/kexec-zImage-arm.c +++ b/kexec/arch/arm/kexec-zImage-arm.c @@ -553,6 +553,14 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len, kernel_mem_size = len + 4; /* + * The zImage length does not include its stack (4k) or its + * malloc space (64k). Include this. + */ + len += 0x11000; + + dbgprintf("zImage requires 0x%08llx bytes\n", (unsigned long long)len); + + /* * Check for a kernel size extension, and set or validate the * image size. This is the total space needed to avoid the * boot kernel BSS, so other data (such as initrd) does not get @@ -565,6 +573,12 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len, uint32_t bss_size = le32_to_cpu(tag->u.krnl_size.bss_size); uint32_t kernel_size = edata_size + bss_size; + dbgprintf("Decompressed kernel sizes:\n"); + dbgprintf(" text+data 0x%08lx bss 0x%08lx total 0x%08lx\n", + (unsigned long)edata_size, + (unsigned long)bss_size, + (unsigned long)kernel_size); + /* * While decompressing, the zImage is placed past _edata * of the decompressed kernel. Ensure we account for that. @@ -572,6 +586,9 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len, if (kernel_size < edata_size + len) kernel_size = edata_size + len; + dbgprintf("Resulting kernel space: 0x%08lx\n", + (unsigned long)kernel_size); + if (kexec_arm_image_size == 0) kexec_arm_image_size = kernel_size; else if (kexec_arm_image_size < kernel_size) {