Skip to content

Commit 9eb9ea3

Browse files
Merge patch series "riscv: kexec_file: Support loading Image binary file"
Björn Töpel <[email protected]> says: From: Björn Töpel <[email protected]> Hi! For over a year ago, Daniel and I was testing the V2 of Song's series. I also promised to take the V2, that had been sitting on the lists for too long, to rebase it on a new kernel, and re-test it. One year later, here's the V3! ;-) There are no changes from V2 other, than some simple checkpatch cleanups. Song's original cover: | This series makes the kexec_file_load() syscall support to load | Image binary file. At the same time, corresponding support for | kexec-tools had been pushed to my repo[2]. | | Now, we can leverage that kexec-tools and this series to use the | kexec_load() or kexec_file_load() syscall to boot both vmlinux and | Image file, as seen in these combo tests: | | ``` | 1. kexec -l vmlinux | 2. kexec -l Image | 3. kexec -s -l vmlinux | 4. kexec -s -l Image | ``` Notably, kexec-tools has still not made it upstream. I've prepared a branch on my GH [3], that I indend to post ASAP. That branch is a collection of fixes/features, including Song's userland Image loading. The V2 is here [2], and V1 [1]. I've tested the kexec-file/Image on qemu-rv64, with following combinations: * ACPI/UEFI * DT/UEFI * DT both "regular" kexec (-s + -e), and crashkernels (-p). Note that there are two purgatory patches that has to be present (part of -rc1, so all good): commit 28093cf ("riscv/kexec_file: Handle R_RISCV_64 in purgatory relocator") commit 3f70231 ("riscv/purgatory: 4B align purgatory_start") [1] https://lore.kernel.org/linux-riscv/[email protected]/ [2] https://lore.kernel.org/linux-riscv/[email protected]/ [3] https://github.com/bjoto/kexec-tools/tree/rv-on-master * patches from https://lore.kernel.org/r/[email protected]: riscv: kexec_file: Support loading Image binary file riscv: kexec_file: Split the loading of kernel and others Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexandre Ghiti <[email protected]> Signed-off-by: Palmer Dabbelt <[email protected]>
2 parents 48d9aab + 809a11e commit 9eb9ea3

File tree

7 files changed

+610
-486
lines changed

7 files changed

+610
-486
lines changed

arch/riscv/include/asm/image.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
RISCV_HEADER_VERSION_MINOR)
3131

3232
#ifndef __ASSEMBLY__
33+
#define riscv_image_flag_field(flags, field)\
34+
(((flags) >> field##_SHIFT) & field##_MASK)
3335
/**
3436
* struct riscv_image_header - riscv kernel image header
3537
* @code0: Executable code

arch/riscv/include/asm/kexec.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ extern riscv_kexec_method riscv_kexec_norelocate;
5656

5757
#ifdef CONFIG_KEXEC_FILE
5858
extern const struct kexec_file_ops elf_kexec_ops;
59+
extern const struct kexec_file_ops image_kexec_ops;
5960

6061
struct purgatory_info;
6162
int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
@@ -67,6 +68,11 @@ int arch_kexec_apply_relocations_add(struct purgatory_info *pi,
6768
struct kimage;
6869
int arch_kimage_file_post_load_cleanup(struct kimage *image);
6970
#define arch_kimage_file_post_load_cleanup arch_kimage_file_post_load_cleanup
71+
72+
int load_extra_segments(struct kimage *image, unsigned long kernel_start,
73+
unsigned long kernel_len, char *initrd,
74+
unsigned long initrd_len, char *cmdline,
75+
unsigned long cmdline_len);
7076
#endif
7177

7278
#endif

arch/riscv/kernel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ obj-$(CONFIG_HOTPLUG_CPU) += cpu-hotplug.o
107107
obj-$(CONFIG_PARAVIRT) += paravirt.o
108108
obj-$(CONFIG_KGDB) += kgdb.o
109109
obj-$(CONFIG_KEXEC_CORE) += kexec_relocate.o crash_save_regs.o machine_kexec.o
110-
obj-$(CONFIG_KEXEC_FILE) += elf_kexec.o machine_kexec_file.o
110+
obj-$(CONFIG_KEXEC_FILE) += kexec_elf.o kexec_image.o machine_kexec_file.o
111111
obj-$(CONFIG_CRASH_DUMP) += crash_dump.o
112112
obj-$(CONFIG_VMCORE_INFO) += vmcore_info.o
113113

0 commit comments

Comments
 (0)