Skip to content

Commit

Permalink
LoongArch: Load vmlinux.efi to the link address
Browse files Browse the repository at this point in the history
Currently, kexec loads vmlinux.efi to address 0 instead of the link
address. This causes kexec to fail to boot the new vmlinux.efi on qemu.

  pei_loongarch_load: kernel_segment: 0000000000000000
  pei_loongarch_load: kernel_entry:   00000000013f1000
  pei_loongarch_load: image_size:     0000000001ca0000
  pei_loongarch_load: text_offset:    0000000000200000
  pei_loongarch_load: phys_offset:    0000000000000000
  pei_loongarch_load: PE format:      yes
  loongarch_load_other_segments:333: command_line: kexec console=ttyS0,115200
  kexec_load: entry = 0x13f1000 flags = 0x1020000
  nr_segments = 2
  segment[0].buf   = 0x7fffeea38010
  segment[0].bufsz = 0x1b55200
  segment[0].mem   = (nil)
  segment[0].memsz = 0x1ca0000
  segment[1].buf   = 0x5555570940b0
  segment[1].bufsz = 0x200
  segment[1].mem   = 0x1ca0000
  segment[1].memsz = 0x4000

This patch constrains the range of the kernel segment by `hole_min`
and `hole_max` to place vmlinux.efi exactly at the link address.

  pei_loongarch_load: kernel_segment: 0000000000200000
  pei_loongarch_load: kernel_entry:   00000000013f1000
  pei_loongarch_load: image_size:     0000000001ca0000
  pei_loongarch_load: text_offset:    0000000000200000
  pei_loongarch_load: phys_offset:    0000000000000000
  pei_loongarch_load: PE format:      yes
  loongarch_load_other_segments:339: command_line: kexec console=ttyS0,115200
  kexec_load: entry = 0x13f1000 flags = 0x1020000
  nr_segments = 2
  segment[0].buf   = 0x7ffff2028010
  segment[0].bufsz = 0x1b55200
  segment[0].mem   = 0x200000
  segment[0].memsz = 0x1ca0000
  segment[1].buf   = 0x555557498098
  segment[1].bufsz = 0x200
  segment[1].mem   = 0x1ea0000
  segment[1].memsz = 0x4000

Signed-off-by: WANG Rui <wangrui@loongson.cn>
Signed-off-by: Simon Horman <horms@kernel.org>
  • Loading branch information
heiher authored and horms committed Dec 1, 2023
1 parent eaa717e commit c88226c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions kexec/arch/loongarch/kexec-loongarch.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,13 @@ unsigned long loongarch_locate_kernel_segment(struct kexec_info *info)
hole = ULONG_MAX;
}
} else {
hole = locate_hole(info,
loongarch_mem.text_offset + loongarch_mem.image_size,
MiB(1), 0, ULONG_MAX, 1);
unsigned long hole_min;
unsigned long hole_max;

hole_min = loongarch_mem.text_offset;
hole_max = hole_min + loongarch_mem.image_size;
hole = locate_hole(info, loongarch_mem.image_size,
MiB(1), hole_min, hole_max, 1);

if (hole == ULONG_MAX)
dbgprintf("%s: locate_hole failed\n", __func__);
Expand Down

0 comments on commit c88226c

Please sign in to comment.