Skip to content

Commit a841aa8

Browse files
daveyoungtorvalds
authored andcommitted
kexec_file: do not add extra alignment to efi memmap
Chun-Yi reported a kernel warning message below: WARNING: CPU: 0 PID: 0 at ../mm/early_ioremap.c:182 early_iounmap+0x4f/0x12c() early_iounmap(ffffffffff200180, 00000118) [0] size not consistent 00000120 The problem is x86 kexec_file_load adds extra alignment to the efi memmap: in bzImage64_load(): efi_map_sz = efi_get_runtime_map_size(); efi_map_sz = ALIGN(efi_map_sz, 16); And __efi_memmap_init maps with the size including the alignment bytes but efi_memmap_unmap use nr_maps * desc_size which does not include the extra bytes. The alignment in kexec code is only needed for the kexec buffer internal use Actually kexec should pass exact size of the efi memmap to 2nd kernel. Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Dave Young <[email protected]> Reported-by: joeyli <[email protected]> Tested-by: Randy Wright <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9a1015b commit a841aa8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

arch/x86/kernel/kexec-bzimage64.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -398,19 +398,18 @@ static void *bzImage64_load(struct kimage *image, char *kernel,
398398
* little bit simple
399399
*/
400400
efi_map_sz = efi_get_runtime_map_size();
401-
efi_map_sz = ALIGN(efi_map_sz, 16);
402401
params_cmdline_sz = sizeof(struct boot_params) + cmdline_len +
403402
MAX_ELFCOREHDR_STR_LEN;
404403
params_cmdline_sz = ALIGN(params_cmdline_sz, 16);
405-
kbuf.bufsz = params_cmdline_sz + efi_map_sz +
404+
kbuf.bufsz = params_cmdline_sz + ALIGN(efi_map_sz, 16) +
406405
sizeof(struct setup_data) +
407406
sizeof(struct efi_setup_data);
408407

409408
params = kzalloc(kbuf.bufsz, GFP_KERNEL);
410409
if (!params)
411410
return ERR_PTR(-ENOMEM);
412411
efi_map_offset = params_cmdline_sz;
413-
efi_setup_data_offset = efi_map_offset + efi_map_sz;
412+
efi_setup_data_offset = efi_map_offset + ALIGN(efi_map_sz, 16);
414413

415414
/* Copy setup header onto bootparams. Documentation/x86/boot.txt */
416415
setup_header_size = 0x0202 + kernel[0x0201] - setup_hdr_offset;

0 commit comments

Comments
 (0)