[PATCH v1 1/1] kexec: x86: Use init_size in 32-bit case as well
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Wed Nov 6 09:58:07 PST 2024
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 <andriy.shevchenko at linux.intel.com>
---
kexec/arch/i386/kexec-bzImage.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/kexec/arch/i386/kexec-bzImage.c b/kexec/arch/i386/kexec-bzImage.c
index 1b8f20c5b7d6..62260139862c 100644
--- a/kexec/arch/i386/kexec-bzImage.c
+++ b/kexec/arch/i386/kexec-bzImage.c
@@ -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);
--
2.43.0.rc1.1336.g36b5255a03ac
More information about the kexec
mailing list