kexec: x86: Use init_size in 32-bit case as well
Subsystems (2)
PATCH 1/1 kexec: x86: Use init_size in 32-bit case as well
If the region of the memory is not enough for the decompressed kernel, e.g., it follows by reserved memory, Bad Things may happen as it's proven to be in practice on Intel Merrifield platform.
Include decompressed kernel size into the calculations for finding the appropriate hole in memory to load kernel to.
Note, this has been already done for 64-bit case, this just synchronises the approach for 32-bit case.
--- kexec/arch/i386/kexec-bzImage.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
kexec/arch/i386/kexec-bzImage.c +9 -8
@@ -116,9 +116,9 @@ int do_bzImage_load(struct kexec_info *info,struct entry32_regs regs32;struct entry16_regs regs16;unsigned int relocatable_kernel =0 ; -unsigned long kernel32_load_addr;char *modified_cmdline;unsigned long cmdline_end; +unsigned long kernel32_load_addr, k_size;unsigned long kern16_size_needed;unsigned long heap_size =0 ;
@@ -274,8 +274,10 @@ int do_bzImage_load(struct kexec_info *info, }/* The main kernel segment */ - size = kernel_len - kern16_size; - + k_size = kernel_len - kern16_size; +/* need to use run-time size for buffer searching */ +dbgprintf ("kernel init_size 0x%x\n" , real_mode->init_size); + size =_ALIGN (real_mode->init_size,4096 );if (real_mode->protocol_version >=0x0205 && relocatable_kernel) {/* Relocatable bzImage */ unsigned long kern_align = real_mode->kernel_alignment;
@@ -285,14 +287,13 @@ int do_bzImage_load(struct kexec_info *info, kernel32_max_addr = real_mode->initrd_addr_max; kernel32_load_addr =add_buffer (info, kernel + kern16_size, - size, size, kern_align, + k_size, size, kern_align,0x100000 , kernel32_max_addr,1 ); - } -else { + }else { kernel32_load_addr =KERN32_BASE ; -add_segment (info, kernel + kern16_size, size, - kernel32_load_addr, size); +add_segment (info, kernel + kern16_size, k_size, + kernel32_load_addr, k_size); }dbgprintf ("Loaded 32bit kernel at 0x%lx\n" , kernel32_load_addr);
Signature · 7 lines
2.43.0.rc1.1336.g36b5255a03ac _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 11 lines · Andy Shevchenko
If the region of the memory is not enough for the decompressed kernel, e.g., it follows by reserved memory, Bad Things may happen as it's proven to be in practice on Intel Merrifield platform.
Include decompressed kernel size into the calculations for finding the appropriate hole in memory to load kernel to.
Note, this has been already done for 64-bit case, this just synchronises the approach for 32-bit case.
Signed-off-by Andy Shevchenko <[email protected]>
Thanks Andy, applied.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec