kexec_file_load implementation for PowerPC
Subsystems (8)
v9 cover kexec_file_load implementation for PowerPC
Hello,
This version has the following changes:
1. Rebased on v4.9-rc1. This should fix the conflicts in next and -mm that these patches were having with the s/CONFIG_WORD_SIZE/BITS/ change.
2. Changed patch "powerpc: Factor out relocation code in module_64.c" to make as little changes as possible to arch/powerpc/module_64.c and <asm/module.h>. This meant factoring out only the switch statement from apply_relocate_add into its own function, and keeping it in module_64.c. arch_kexec_apply_relocations_add and apply_relocate_add share a bit less code now. This addresses a concern expressed by Michael Ellerman that there were too many changes being made to the module loading code.
3. Reduced number of patches in the series by squashing one patch and redistributing the code in two other patches. They were smaller after the change above and didn't make that much sense on their own anymore.
4. Moved code implementing kexec_file_load to a new file instead of adding it to the existing arch/powerpc/machine_kexec_64.c.
5. Cleaned up the purgatory code a bit to fix checkpatch warnings: removed unused code related to crashdump support and added __section(".data") to global variables instead of initializing them to zero to avoid them going to .bss.
The changes in 3. and 4. made the patches somewhat different from v8 but it's just code moving from one patch to another, or to a new file. Apart from what is described in 2. and 5., there's very little actual code changed. The patches are all bisectable, each one was tested with several kernel configs.
The gory details are in the detailed changelog at the end of this email.
Original cover letter:
This patch series implements the kexec_file_load system call on PowerPC.
This system call moves the reading of the kernel, initrd and the device tree from the userspace kexec tool to the kernel. This is needed if you want to do one or both of the following:
1. only allow loading of signed kernels.
2. "measure" (i.e., record the hashes of) the kernel, initrd, kernel command line and other boot inputs for the Integrity Measurement Architecture subsystem.
The above are the functions kexec already has built into kexec_file_load. Yesterday I posted a set of patches which allows a third feature:
3. have IMA pass-on its event log (where integrity measurements are registered) accross kexec to the second kernel, so that the event history is preserved.
Because OpenPower uses an intermediary Linux instance as a boot loader (skiroot), feature 1 is needed to implement secure boot for the platform, while features 2 and 3 are needed to implement trusted boot.
This patch series starts by removing an x86 assumption from kexec_file:kexec_add_buffer uses iomem to find reserved memory ranges, but PowerPC uses the memblock subsystem. A hook is added so that each arch can specify how memory ranges can be found.
Also, the memory-walking logic in kexec_add_buffer is useful in this implementation to find a free area for the purgatory's stack, so the next patch moves that logic to kexec_locate_mem_hole.
The kexec_file_load system call needs to apply relocations to the purgatory but adding code for that would duplicate functionality with the module loading mechanism, which also needs to apply relocations to the kernel modules. Therefore, this patch series factors out the module relocation code so that it can be shared.
One thing that is still missing is crashkernel support, which I intend to submit shortly. For now, arch_kexec_kernel_image_probe rejects crash kernels.
This code is based on kexec-tools, but with many modifications to adapt it to the kernel environment and facilities. Except the purgatory, which only has minimal changes.
Changes for v9:
- Rebased on top of v4.9-rc1
- Patch "powerpc: Change places using CONFIG_KEXEC to use CONFIG_KEXEC_CORE instead."
- Fixed conflict with patch renaming CONFIG_WORD_SIZE to BITS.
- Patch "powerpc: Factor out relocation code from module_64.c to elf_util_64.c."
- Retitled to "powerpc: Factor out relocation code in module_64.c"
- Fixed conflict with patch renaming CONFIG_WORD_SIZE to BITS.
- Put relocation code in function elf64_apply_relocate_add_item in module_64.c itself instead of moving it to elf_util_64.c.
- Only factored out the switch statement to apply the relocations instead of the whole logic to iterate through all of the relocations.
- There's no elf_util_64.c anymore.
- Doesn't change <asm/module.h> anymore.
- Doesn't change arch/powerpc/kernel/Makefile anymore.
- Moved creation of <asm/elf_util.h> to patch "Implement kexec_file_load."
- Patch "powerpc: Generalize elf64_apply_relocate_add."
- Dropped patch from series.
- Moved changes adding address variable to patch "powerpc: Implement kexec_file_load."
- Patch "powerpc: Adapt elf64_apply_relocate_add for kexec_file_load."
- Dropped patch from series.
- Moved new relocs needed by the purgatory to patch "powerpc: Implement kexec_file_load."
- Patch "powerpc: Implement kexec_file_load."
- Fixed conflict with patch renaming CONFIG_WORD_SIZE to BITS.
- Put code in a new file machine_kexec_file_64.c instead of adding it to
machine_kexec_64.c.
- arch_kexec_apply_relocations_add now has the for loop which was previously factored out in elf64_apply_relocate_add.
- Moved definition of setup_purgatory to "powerpc: Add support for loading ELF kernels with kexec_file_load.".
- Introduce <asm/elf_util.h> and elf_util.c in this patch.
- Only build elf_util.c if CONFIG_KEXEC_FILE=y.
- Renamed my_r2 to elf_my_r2 and changed it to receive a pointer to struct elf_shdr instead of struct elf_info.
- Added toc_section function.
- Removed elf_init_elf_info function.
- Patch "powerpc: Add functions to read ELF files of any endianness."
- Fixed conflict with patch renaming CONFIG_WORD_SIZE to BITS.
- Introduce struct elf_info in this patch.
- Removed stubs_section and toc_section from struct elf_info.
- Doesn't change arch/powerpc/kernel/Makefile anymore.
- Patch "powerpc: Add code to work with device trees in kexec_file_load."
- Squashed into "powerpc: Add support for loading ELF kernels with kexec_file_load.". The code is unchanged.
- Patch "powerpc: Add support for loading ELF kernels with kexec_file_load."
- Fixed conflict with patch renaming CONFIG_WORD_SIZE to BITS.
- Fixed uninitialized variable warning when building with GCC 4.6.3.
- Don't create <asm/kexec_elf_64.h> anymore, put declaration of kexec_el_64_ops in <asm/kexec.h> instead.
- Removed unused extern declaration of kexec_purgatory_size.
- Made elf64_load static.
- Factor out delete_fdt_mem_rsv from setup_new_fdt. This change was in the patch series for preserving IMA measurements accross kexec.
- Patch "powerpc: Add purgatory for kexec_file_load implementation."
- Fixed conflict with patch renaming CONFIG_WORD_SIZE to BITS.
- Changed purgatory Makefile to use the kernel KBUILD_CFLAGS, filtering out the flags for ftrace. (Michael Ellerman)
- Added extern declaration of the debug global variable to purgatory.h and included it in console-ppc64.c to fix checkpatch.pl warning.
- Added __section attribute to global variables in purgatory-ppc64.c and don't initialize them to zero, to fix checkpatch.pl warning.
- Fixed type of debug global variable to int instead of unsigned int.
- Included <linux/compiler.h> in purgatory.h and use __printf macro to fix checkpatch.pl warning.
- Removed crashdump-ppc64.h, crashdump_backup.c and purgatory-ppc64.h.
Changes for v8:
- Rebased on top of v4.8-rc5.
- Patch "powerpc: Add purgatory for kexec_file_load implementation."
- Fix cross build from ppc64 LE to BE and vice-versa.
- Don't build the purgatory during archprepare.
Changes for v7:
- Rebased on top of v4.8-rc4.
- Patch "powerpc: Change places using CONFIG_KEXEC to use CONFIG_KEXEC_CORE instead."
- New patch. Fixes build when CONFIG_KEXEC=n and CONFIG_KEXEC_FILE=y.
- Patch "powerpc: Adapt elf64_apply_relocate_add for kexec_file_load."
- Fixed checkpatch warning "else is not generally useful after a break or return".
- Fixed checkpatch warnings about line length. (Andrew Morton)
- Patch "powerpc: Add code to work with device trees in kexec_file_load."
- Remove space before tabs in doc comment for setup_new_fdt. (Andrew Morton)
- Fixed checkpatch warnings about line length.
- Patch "powerpc: Add support for loading ELF kernels with kexec_file_load."
- Removed duplicate #include <linux/kexec.h>.
Changes for v6:
- Based directly on top of v4.8-rc1.
- Patch "powerpc: Adapt elf64_apply_relocate_add for kexec_file_load."
- Allow undefined symbols if they are relocations for the TOC in the big endian ABI.
- Fixed build error in this patch by adding the ehdr member to elf_info here instead of in the next patch.
- Initialize elf_info.ehdr in module_64.c:module_frob_arch_sections.
- Patch "powerpc: Add code to work with device trees in kexec_file_load."
- Changed find_debug_console to look for /chosen instead of receiving its offset as an argument.
- setup_new_fdt: no need to find /chosen again after deleting the memory reservation for initrd.
- Patch "powerpc: Add support for loading ELF kernels with kexec_file_load."
- Don't pass the offset to /chosen to find_debug_console.
- Patch "powerpc: Allow userspace to set device tree properties in kexec_file_load"
- Dropped patch.
- Patch "powerpc: Add purgatory for kexec_file_load implementation."
- Make boot/string.S use the DOTSYM macro so that it can be
used by the ppc64 big endian purgatory.
- Use -mcall-aixdesc to compile the purgatory on big endian ppc64.
Changes for v5:
- Rebased series on v4.8-rc1 + the extend kexec_file_load series.
- Patch "powerpc: Adapt elf64_apply_relocate_add for kexec_file_load."
- New patch. These changes were previously in patch 10.
The code itself is unchanged from v4.
- Patch "powerpc: Implement kexec_file_load."
- Moved arch_kexec_walk_mem, arch_kexec_apply_relocations_add and setup_purgatory from patch 10 to this patch.
- arch_kexec_apply_relocations_add is unchanged from v4.
- Fixed off-by-one error in arch_kexec_walk_mem when passing range to func.
- Moved setup_purgatory from kexec_elf_64.c to machine_kexec_64.c, and changed it to receive a pointer to the slave code directly rather than a struct elf_info and getting the pointer from there.
- Patch "powerpc: Add code to work with device trees in kexec_file_load."
- New patch. These changes were previously in patch 10.
- find_debug_console moved from kexec_elf_64.c to machine_kexec_64.c. The code is unchanged from v4.
- setup_new_fdt is a new function factored out of elf64_load. The only code change from v4 is to create /chosen if it doesn't exist yet.
- Patch "powerpc: Add support for loading ELF kernels with kexec_file_load."
- This patch was too big, so moved some of its changes to other patches to facilitate review.
- Allow loading ELF file type ET_DYN, which is what the BE kernel uses.
- The code adapting the device tree for booting the new kernel was moved out of elf64_load to setup_new_fdt.
- Patch "powerpc: Allow userspace to set device tree properties in kexec_file_load"
- New patch.
- The code in this patch didn't exist in v4.
- This is the only patch that depends on the extend kexec_file_load series.
- Patch "powerpc: Enable CONFIG_KEXEC_FILE in powerpc server defconfigs."
- New patch.
Thiago Jung Bauermann (10):
kexec_file: Allow arch-specific memory walking for kexec_add_buffer
kexec_file: Change kexec_add_buffer to take kexec_buf as argument.
kexec_file: Factor out kexec_locate_mem_hole from kexec_add_buffer.
powerpc: Change places using CONFIG_KEXEC to use CONFIG_KEXEC_CORE
instead.
powerpc: Factor out relocation code in module_64.c
powerpc: Implement kexec_file_load.
powerpc: Add functions to read ELF files of any endianness.
powerpc: Add support for loading ELF kernels with kexec_file_load.
powerpc: Add purgatory for kexec_file_load implementation.
powerpc: Enable CONFIG_KEXEC_FILE in powerpc server defconfigs.
arch/powerpc/Kconfig | 15 +- arch/powerpc/Makefile | 1 + arch/powerpc/boot/string.S | 67 +-- arch/powerpc/configs/powernv_defconfig | 2 + arch/powerpc/configs/ppc64_defconfig | 2 + arch/powerpc/configs/pseries_defconfig | 2 + arch/powerpc/include/asm/debug.h | 2 +- arch/powerpc/include/asm/elf_util.h | 64 +++ arch/powerpc/include/asm/kexec.h | 18 +- arch/powerpc/include/asm/machdep.h | 4 +- arch/powerpc/include/asm/smp.h | 2 +- arch/powerpc/include/asm/systbl.h | 1 + arch/powerpc/include/asm/unistd.h | 2 +- arch/powerpc/include/uapi/asm/unistd.h | 1 + arch/powerpc/kernel/Makefile | 6 +- arch/powerpc/kernel/elf_util.c | 464 +++++++++++++++++++++ arch/powerpc/kernel/head_64.S | 2 +- arch/powerpc/kernel/kexec_elf_64.c | 280 +++++++++++++ arch/powerpc/kernel/machine_kexec_file_64.c | 579 ++++++++++++++++++++++++++ arch/powerpc/kernel/misc_32.S | 2 +- arch/powerpc/kernel/misc_64.S | 6 +- arch/powerpc/kernel/module_64.c | 383 ++++++++++------- arch/powerpc/kernel/prom.c | 2 +- arch/powerpc/kernel/setup_64.c | 4 +- arch/powerpc/kernel/smp.c | 6 +- arch/powerpc/kernel/traps.c | 2 +- arch/powerpc/platforms/85xx/corenet_generic.c | 2 +- arch/powerpc/platforms/85xx/smp.c | 8 +- arch/powerpc/platforms/cell/spu_base.c | 2 +- arch/powerpc/platforms/powernv/setup.c | 6 +- arch/powerpc/platforms/ps3/setup.c | 4 +- arch/powerpc/platforms/pseries/Makefile | 2 +- arch/powerpc/platforms/pseries/setup.c | 4 +- arch/powerpc/purgatory/.gitignore | 2 + arch/powerpc/purgatory/Makefile | 33 ++ arch/powerpc/purgatory/console-ppc64.c | 37 ++ arch/powerpc/purgatory/crtsavres.S | 5 + arch/powerpc/purgatory/hvCall.S | 27 ++ arch/powerpc/purgatory/hvCall.h | 8 + arch/powerpc/purgatory/kexec-sha256.h | 11 + arch/powerpc/purgatory/ppc64_asm.h | 20 + arch/powerpc/purgatory/printf.c | 164 ++++++++ arch/powerpc/purgatory/purgatory-ppc64.c | 36 ++ arch/powerpc/purgatory/purgatory.c | 62 +++ arch/powerpc/purgatory/purgatory.h | 14 + arch/powerpc/purgatory/sha256.c | 6 + arch/powerpc/purgatory/sha256.h | 1 + arch/powerpc/purgatory/string.S | 2 + arch/powerpc/purgatory/v2wrap.S | 134 ++++++ arch/x86/kernel/crash.c | 37 +- arch/x86/kernel/kexec-bzimage64.c | 48 ++- include/linux/kexec.h | 36 +- kernel/kexec_file.c | 141 ++++--- kernel/kexec_internal.h | 16 - 54 files changed, 2437 insertions(+), 350 deletions(-) create mode 100644 arch/powerpc/include/asm/elf_util.h create mode 100644 arch/powerpc/kernel/elf_util.c create mode 100644 arch/powerpc/kernel/kexec_elf_64.c create mode 100644 arch/powerpc/kernel/machine_kexec_file_64.c create mode 100644 arch/powerpc/purgatory/.gitignore create mode 100644 arch/powerpc/purgatory/Makefile create mode 100644 arch/powerpc/purgatory/console-ppc64.c create mode 100644 arch/powerpc/purgatory/crtsavres.S create mode 100644 arch/powerpc/purgatory/hvCall.S create mode 100644 arch/powerpc/purgatory/hvCall.h create mode 100644 arch/powerpc/purgatory/kexec-sha256.h create mode 100644 arch/powerpc/purgatory/ppc64_asm.h create mode 100644 arch/powerpc/purgatory/printf.c create mode 100644 arch/powerpc/purgatory/purgatory-ppc64.c create mode 100644 arch/powerpc/purgatory/purgatory.c create mode 100644 arch/powerpc/purgatory/purgatory.h create mode 100644 arch/powerpc/purgatory/sha256.c create mode 100644 arch/powerpc/purgatory/sha256.h create mode 100644 arch/powerpc/purgatory/string.S create mode 100644 arch/powerpc/purgatory/v2wrap.S
Signature · 1 line
2.7.4
PATCH v9 1/10 kexec_file: Allow arch-specific memory walking for kexec_add_buffer
Allow architectures to specify a different memory walking function for kexec_add_buffer. x86 uses iomem to track reserved memory ranges, but PowerPC uses the memblock subsystem.
--- include/linux/kexec.h | 29 ++++++++++++++++++++++++++++- kernel/kexec_file.c | 30 ++++++++++++++++++++++-------- kernel/kexec_internal.h | 16 ---------------- 3 files changed, 50 insertions(+), 25 deletions(-)
include/linux/kexec.h +28 -1
@@ -148,7 +148,34 @@ struct kexec_file_ops {kexec_verify_sig_t *verify_sig;#endif }; -#endif + +/** +* struct kexec_buf - parameters for finding a place for a buffer in memory +* @image: kexec image in which memory to search. +* @buffer: Contents which will be copied to the allocated memory. +* @bufsz: Size of @buffer. +* @mem: On return will have address of the buffer in memory. +* @memsz: Size for the buffer in memory. +* @buf_align: Minimum alignment needed. +* @buf_min: The buffer can't be placed below this address. +* @buf_max: The buffer can't be placed above this address. +* @top_down: Allocate from top of memory. +*/ +struct kexec_buf { +struct kimage *image; +char *buffer; +unsigned long bufsz; +unsigned long mem; +unsigned long memsz; +unsigned long buf_align; +unsigned long buf_min; +unsigned long buf_max; +bool top_down; +}; + +int __weak arch_kexec_walk_mem (struct kexec_buf *kbuf, +int (*func)(u64 ,u64 ,void *)); +#endif /* CONFIG_KEXEC_FILE */ struct kimage {kimage_entry_t head;
kernel/kexec_file.c +22 -8
@@ -428,6 +428,27 @@ static int locate_mem_hole_callback(u64 start, u64 end, void *arg)return locate_mem_hole_bottom_up (start, end, kbuf); } +/** +* arch_kexec_walk_mem - call func(data) on free memory regions +* @kbuf: Context info for the search. Also passed to @func. +* @func: Function to call for each memory region. +* +* Return: The memory walk will stop when func returns a non-zero value +* and that value will be returned. If all free regions are visited without +* func returning non-zero, then zero will be returned. +*/ +int __weak arch_kexec_walk_mem (struct kexec_buf *kbuf, +int (*func)(u64 ,u64 ,void *)) +{ +if (kbuf->image->type ==KEXEC_TYPE_CRASH ) +return walk_iomem_res_desc (crashk_res.desc, +IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , + crashk_res.start, crashk_res.end, + kbuf, func); +else +return walk_system_ram_res (0 ,ULONG_MAX , kbuf, func); +} +/* * Helper function for placing a buffer in a kexec segment. This assumes * that kexec_mutex is held.
@@ -474,14 +495,7 @@ int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz, kbuf->top_down = top_down;/* Walk the RAM ranges and allocate a suitable range for the buffer */ -if (image->type ==KEXEC_TYPE_CRASH ) - ret =walk_iomem_res_desc (crashk_res.desc, -IORESOURCE_SYSTEM_RAM |IORESOURCE_BUSY , - crashk_res.start, crashk_res.end, kbuf, - locate_mem_hole_callback); -else - ret =walk_system_ram_res (0 ,-1 , kbuf, - locate_mem_hole_callback); + ret =arch_kexec_walk_mem (kbuf, locate_mem_hole_callback);if (ret !=1 ) {/* A suitable memory range could not be found for buffer */ return -EADDRNOTAVAIL ;
kernel/kexec_internal.h +0 -16
@@ -20,22 +20,6 @@ struct kexec_sha_region { unsigned long len; }; -/* -* Keeps track of buffer parameters as provided by caller for requesting -* memory placement of buffer. -*/ -struct kexec_buf { -struct kimage *image; -char *buffer; -unsigned long bufsz; -unsigned long mem; -unsigned long memsz; -unsigned long buf_align; -unsigned long buf_min; -unsigned long buf_max; -bool top_down;/* allocate from top of memory hole */ -}; -void kimage_file_post_load_cleanup (struct kimage *image);#else /* CONFIG_KEXEC_FILE */ static inline void kimage_file_post_load_cleanup (struct kimage *image) { }
Signature · 1 line
2.7.4
PATCH v9 2/10 kexec_file: Change kexec_add_buffer to take kexec_buf as argument.
In reply to Thiago Jung BauermannThis is done to simplify the kexec_add_buffer argument list. Adapt all callers to set up a kexec_buf to pass to kexec_add_buffer.
In addition, change the type of kexec_buf.buffer from char * to void *. There is no particular reason for it to be a char *, and the change allows us to get rid of 3 existing casts to char * in the code.
--- arch/x86/kernel/crash.c | 37 ++++++++-------- arch/x86/kernel/kexec-bzimage64.c | 48 +++++++++++---------- include/linux/kexec.h | 8 +--- kernel/kexec_file.c | 88 ++++++++++++++++++--------------------- 4 files changed, 87 insertions(+), 94 deletions(-)
arch/x86/kernel/crash.c +19 -18
@@ -631,9 +631,9 @@ static int determine_backup_region(u64 start, u64 end, void *arg)int crash_load_segments (struct kimage *image) { -unsigned long src_start, src_sz, elf_sz; -void *elf_addr;int ret; +struct kexec_buf kbuf = { .image = image, .buf_min =0 , + .buf_max =ULONG_MAX , .top_down = false };/* * Determine and load a segment for backup area. First 640K RAM
@@ -647,43 +647,44 @@ int crash_load_segments(struct kimage *image)if (ret <0 )return ret; - src_start = image->arch.backup_src_start; - src_sz = image->arch.backup_src_sz; -/* Add backup segment. */ -if (src_sz) { +if (image->arch.backup_src_sz) { + kbuf.buffer = &crash_zero_bytes; + kbuf.bufsz =sizeof (crash_zero_bytes); + kbuf.memsz = image->arch.backup_src_sz; + kbuf.buf_align =PAGE_SIZE ;/* * Ideally there is no source for backup segment. This is * copied in purgatory after crash. Just add a zero filled * segment for now to make sure checksum logic works fine. */ - ret =kexec_add_buffer (image, (char *)&crash_zero_bytes, -sizeof (crash_zero_bytes), src_sz, -PAGE_SIZE ,0 ,-1 ,0 , - &image->arch.backup_load_addr); + ret =kexec_add_buffer (&kbuf);if (ret)return ret; + image->arch.backup_load_addr = kbuf.mem;pr_debug ("Loaded backup region at 0x%lx backup_start=0x%lx memsz=0x%lx\n" , - image->arch.backup_load_addr, src_start, src_sz); + image->arch.backup_load_addr, + image->arch.backup_src_start, kbuf.memsz); }/* Prepare elf headers and add a segment */ - ret =prepare_elf_headers (image, &elf_addr, &elf_sz); + ret =prepare_elf_headers (image, &kbuf.buffer, &kbuf.bufsz);if (ret)return ret; - image->arch.elf_headers = elf_addr; - image->arch.elf_headers_sz = elf_sz; + image->arch.elf_headers = kbuf.buffer; + image->arch.elf_headers_sz = kbuf.bufsz; - ret =kexec_add_buffer (image, (char *)elf_addr, elf_sz, elf_sz, -ELF_CORE_HEADER_ALIGN ,0 ,-1 ,0 , - &image->arch.elf_load_addr); + kbuf.memsz = kbuf.bufsz; + kbuf.buf_align =ELF_CORE_HEADER_ALIGN ; + ret =kexec_add_buffer (&kbuf);if (ret) {vfree ((void *)image->arch.elf_headers);return ret; } + image->arch.elf_load_addr = kbuf.mem;pr_debug ("Loaded ELF headers at 0x%lx bufsz=0x%lx memsz=0x%lx\n" , - image->arch.elf_load_addr, elf_sz, elf_sz); + image->arch.elf_load_addr, kbuf.bufsz, kbuf.bufsz);return ret; }
arch/x86/kernel/kexec-bzimage64.c +26 -22
91 lines not on this page · raw message
include/linux/kexec.h +2 -6
@@ -163,7 +163,7 @@ struct kexec_file_ops {*/ struct kexec_buf {struct kimage *image; -char *buffer; +void *buffer;unsigned long bufsz;unsigned long mem;unsigned long memsz;
@@ -175,6 +175,7 @@ struct kexec_buf {int __weak arch_kexec_walk_mem (struct kexec_buf *kbuf,int (*func)(u64 ,u64 ,void *)); +extern int kexec_add_buffer (struct kexec_buf *kbuf);#endif /* CONFIG_KEXEC_FILE */ struct kimage {
@@ -239,11 +240,6 @@ extern asmlinkage long sys_kexec_load(unsigned long entry,struct kexec_segment __user *segments, unsigned long flags);extern int kernel_kexec (void ); -extern int kexec_add_buffer (struct kimage *image,char *buffer, -unsigned long bufsz,unsigned long memsz, -unsigned long buf_align,unsigned long buf_min, -unsigned long buf_max,bool top_down, -unsigned long *load_addr);extern struct page *kimage_alloc_control_pages (struct kimage *image,unsigned int order); extern int kexec_load_purgatory(struct kimage *image, unsigned long min,
kernel/kexec_file.c +40 -48
175 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v9 3/10 kexec_file: Factor out kexec_locate_mem_hole from kexec_add_buffer.
In reply to Thiago Jung Bauermannkexec_locate_mem_hole will be used by the PowerPC kexec_file_load implementation to find free memory for the purgatory stack.
--- include/linux/kexec.h | 1 + kernel/kexec_file.c | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 5 deletions(-)
include/linux/kexec.h +1 -0
@@ -176,6 +176,7 @@ struct kexec_buf {int __weak arch_kexec_walk_mem (struct kexec_buf *kbuf,int (*func)(u64 ,u64 ,void *));extern int kexec_add_buffer (struct kexec_buf *kbuf); +int kexec_locate_mem_hole (struct kexec_buf *kbuf);#endif /* CONFIG_KEXEC_FILE */ struct kimage {
kernel/kexec_file.c +20 -5
@@ -450,6 +450,23 @@ int __weak arch_kexec_walk_mem(struct kexec_buf *kbuf, }/** +* kexec_locate_mem_hole - find free memory for the purgatory or the next kernel +* @kbuf: Parameters for the memory search. +* +* On success, kbuf->mem will have the start address of the memory region found. +* +* Return: 0 on success, negative errno on error. +*/ +int kexec_locate_mem_hole (struct kexec_buf *kbuf) +{ +int ret; + + ret =arch_kexec_walk_mem (kbuf, locate_mem_hole_callback); + +return ret ==1 ?0 : -EADDRNOTAVAIL ; +} + +/** * kexec_add_buffer - place a buffer in a kexec segment * @kbuf: Buffer contents and memory parameters. *
@@ -489,11 +506,9 @@ int kexec_add_buffer(struct kexec_buf *kbuf) kbuf->buf_align =max (kbuf->buf_align,PAGE_SIZE );/* Walk the RAM ranges and allocate a suitable range for the buffer */ - ret =arch_kexec_walk_mem (kbuf, locate_mem_hole_callback); -if (ret !=1 ) { -/* A suitable memory range could not be found for buffer */ -return -EADDRNOTAVAIL ; - } + ret =kexec_locate_mem_hole (kbuf); +if (ret) +return ret;/* Found a suitable memory range */ ksegment = &kbuf->image->segment[kbuf->image->nr_segments];
Signature · 1 line
2.7.4
PATCH v9 4/10 powerpc: Change places using CONFIG_KEXEC to use CONFIG_KEXEC_CORE instead.
In reply to Thiago Jung BauermannCommit 2965faa5e03d ("kexec: split kexec_load syscall from kexec core code") introduced CONFIG_KEXEC_CORE so that CONFIG_KEXEC means whether the kexec_load system call should be compiled-in and CONFIG_KEXEC_FILE means whether the kexec_file_load system call should be compiled-in. These options can be set independently from each other.
Since until now powerpc only supported kexec_load, CONFIG_KEXEC and CONFIG_KEXEC_CORE were synonyms. That is not the case anymore, so we need to make a distinction. Almost all places where CONFIG_KEXEC was being used should be using CONFIG_KEXEC_CORE instead, since kexec_file_load also needs that code compiled in.
--- arch/powerpc/Kconfig | 2 +- arch/powerpc/include/asm/debug.h | 2 +- arch/powerpc/include/asm/kexec.h | 6 +++--- arch/powerpc/include/asm/machdep.h | 4 ++-- arch/powerpc/include/asm/smp.h | 2 +- arch/powerpc/kernel/Makefile | 4 ++-- arch/powerpc/kernel/head_64.S | 2 +- arch/powerpc/kernel/misc_32.S | 2 +- arch/powerpc/kernel/misc_64.S | 6 +++--- arch/powerpc/kernel/prom.c | 2 +- arch/powerpc/kernel/setup_64.c | 4 ++-- arch/powerpc/kernel/smp.c | 6 +++--- arch/powerpc/kernel/traps.c | 2 +- arch/powerpc/platforms/85xx/corenet_generic.c | 2 +- arch/powerpc/platforms/85xx/smp.c | 8 ++++---- arch/powerpc/platforms/cell/spu_base.c | 2 +- arch/powerpc/platforms/powernv/setup.c | 6 +++--- arch/powerpc/platforms/ps3/setup.c | 4 ++-- arch/powerpc/platforms/pseries/Makefile | 2 +- arch/powerpc/platforms/pseries/setup.c | 4 ++-- 20 files changed, 36 insertions(+), 36 deletions(-)
arch/powerpc/Kconfig +1 -1
@@ -489,7 +489,7 @@ config CRASH_DUMP config FA_DUMP bool "Firmware-assisted dump" - depends on PPC64 && PPC_RTAS && CRASH_DUMP && KEXEC + depends on PPC64 && PPC_RTAS && CRASH_DUMP && KEXEC_CORE help A robust mechanism to get reliable kernel crash dump with assistance from firmware. This approach does not use kexec,
arch/powerpc/include/asm/debug.h +1 -1
@@ -10,7 +10,7 @@ struct pt_regs;extern struct dentry *powerpc_debugfs_root; -#if defined(CONFIG_DEBUGGER ) || defined(CONFIG_KEXEC ) +#if defined(CONFIG_DEBUGGER ) || defined(CONFIG_KEXEC_CORE )extern int (*__debugger)(struct pt_regs *regs);extern int (*__debugger_ipi)(struct pt_regs *regs);
arch/powerpc/include/asm/kexec.h +3 -3
@@ -53,7 +53,7 @@typedef void (*crash_shutdown_t )(void ); -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE /* * This function is responsible for capturing register states if coming
@@ -91,7 +91,7 @@ static inline bool kdump_in_progress(void) return crashing_cpu >= 0; } -#else /* !CONFIG_KEXEC */ +#else /* !CONFIG_KEXEC_CORE */ static inline void crash_kexec_secondary (struct pt_regs *regs) { }static inline int overlaps_crashkernel (unsigned long start,unsigned long size)
@@ -116,7 +116,7 @@ static inline bool kdump_in_progress(void)return false; } -#endif /* CONFIG_KEXEC */ +#endif /* CONFIG_KEXEC_CORE */ #endif /* ! __ASSEMBLY__ */ #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_KEXEC_H */
arch/powerpc/include/asm/machdep.h +2 -2
@@ -183,7 +183,7 @@ struct machdep_calls {*/ void (*machine_shutdown)(void ); -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE void (*kexec_cpu_down)(int crash_shutdown,int secondary);/* Called to do what every setup is needed on image and the
@@ -198,7 +198,7 @@ struct machdep_calls {* no return. */ void (*machine_kexec)(struct kimage *image); -#endif /* CONFIG_KEXEC */ +#endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_SUSPEND /* These are called to disable and enable, respectively, IRQs when
arch/powerpc/include/asm/smp.h +1 -1
@@ -176,7 +176,7 @@ static inline void set_hard_smp_processor_id(int cpu, int phys)#endif /* !CONFIG_SMP */ #endif /* !CONFIG_PPC64 */ -#if defined(CONFIG_PPC64 ) && (defined(CONFIG_SMP ) || defined(CONFIG_KEXEC )) +#if defined(CONFIG_PPC64 ) && (defined(CONFIG_SMP ) || defined(CONFIG_KEXEC_CORE ))extern void smp_release_cpus (void );#else static inline void smp_release_cpus (void ) { };
arch/powerpc/kernel/Makefile +2 -2
@@ -107,7 +107,7 @@ pci64-$(CONFIG_PPC64) += pci_dn.o pci-hotplug.o isa-bridge.o obj-$(CONFIG_PCI) += pci_$(BITS).o $(pci64-y) \ pci-common.o pci_of_scan.o obj-$(CONFIG_PCI_MSI) += msi.o -obj-$(CONFIG_KEXEC) += machine_kexec.o crash.o \ +obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o crash.o \ machine_kexec_$(BITS).o obj-$(CONFIG_AUDIT) += audit.o obj64-$(CONFIG_AUDIT) += compat_audit.o
@@ -128,7 +128,7 @@ obj64-$(CONFIG_PPC_TRANSACTIONAL_MEM) += tm.o obj-$(CONFIG_PPC64) += $(obj64-y) obj-$(CONFIG_PPC32) += $(obj32-y) -ifneq ($(CONFIG_XMON)$(CONFIG_KEXEC),) +ifneq ($(CONFIG_XMON)$(CONFIG_KEXEC_CORE),) obj-y += ppc_save_regs.o endif
arch/powerpc/kernel/head_64.S +1 -1
@@ -153,7 +153,7 @@ __secondary_hold: cmpdi 0,r12,0 beq 100b -#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC) +#if defined(CONFIG_SMP) || defined(CONFIG_KEXEC_CORE) #ifdef CONFIG_PPC_BOOK3E tovirt(r12,r12) #endif
arch/powerpc/kernel/misc_32.S +1 -1
@@ -614,7 +614,7 @@ _GLOBAL(start_secondary_resume) _GLOBAL(__main) blr -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE /* * Must be relocatable PIC code callable as a C function. */
arch/powerpc/kernel/misc_64.S +3 -3
@@ -478,7 +478,7 @@ _GLOBAL(kexec_wait) addi r5,r5,kexec_flag-1b 99: HMT_LOW -#ifdef CONFIG_KEXEC /* use no memory without kexec */ +#ifdef CONFIG_KEXEC_CORE /* use no memory without kexec */ lwz r4,0(r5) cmpwi 0,r4,0 beq 99b
@@ -503,7 +503,7 @@ kexec_flag: .long 0 -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE #ifdef CONFIG_PPC_BOOK3E /* * BOOK3E has no real MMU mode, so we have to setup the initial TLB
@@ -716,4 +716,4 @@ _GLOBAL(kexec_sequence) mtlr 4 li r5,0 blr /* image->start(physid, image->start, 0); */ -#endif /* CONFIG_KEXEC */ +#endif /* CONFIG_KEXEC_CORE */
arch/powerpc/kernel/prom.c +1 -1
@@ -427,7 +427,7 @@ static int __init early_init_dt_scan_chosen_ppc(unsigned long node, tce_alloc_end = *lprop;#endif -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE lprop =of_get_flat_dt_prop (node,"linux,crashkernel-base" ,NULL );if (lprop) crashk_res.start = *lprop;
arch/powerpc/kernel/setup_64.c +2 -2
@@ -346,7 +346,7 @@ void early_setup_secondary(void)#endif /* CONFIG_SMP */ -#if defined(CONFIG_SMP ) || defined(CONFIG_KEXEC ) +#if defined(CONFIG_SMP ) || defined(CONFIG_KEXEC_CORE )static bool use_spinloop (void ) {if (!IS_ENABLED (CONFIG_PPC_BOOK3E ))
@@ -391,7 +391,7 @@ void smp_release_cpus(void) DBG(" <- smp_release_cpus()\n"); } -#endif /* CONFIG_SMP || CONFIG_KEXEC */ +#endif /* CONFIG_SMP || CONFIG_KEXEC_CORE */ /* * Initialize some remaining members of the ppc64_caches and systemcfg
arch/powerpc/kernel/smp.c +3 -3
@@ -193,7 +193,7 @@ int smp_request_message_ipi(int virq, int msg)if (msg <0 || msg >PPC_MSG_DEBUGGER_BREAK ) {return -EINVAL ; } -#if !defined(CONFIG_DEBUGGER ) && !defined(CONFIG_KEXEC ) +#if !defined(CONFIG_DEBUGGER ) && !defined(CONFIG_KEXEC_CORE )if (msg ==PPC_MSG_DEBUGGER_BREAK ) {return 1 ; }
@@ -325,7 +325,7 @@ void tick_broadcast(const struct cpumask *mask) }#endif -#if defined(CONFIG_DEBUGGER ) || defined(CONFIG_KEXEC ) +#if defined(CONFIG_DEBUGGER ) || defined(CONFIG_KEXEC_CORE )void smp_send_debugger_break (void ) {int cpu;
@@ -340,7 +340,7 @@ void smp_send_debugger_break(void) }#endif -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE void crash_send_ipi (void (*crash_ipi_callback)(struct pt_regs *)) { crash_ipi_function_ptr = crash_ipi_callback;
arch/powerpc/kernel/traps.c +1 -1
@@ -65,7 +65,7 @@#include <asm/hmi.h> #include <sysdev/fsl_pci.h> -#if defined(CONFIG_DEBUGGER ) || defined(CONFIG_KEXEC ) +#if defined(CONFIG_DEBUGGER ) || defined(CONFIG_KEXEC_CORE )int (*__debugger)(struct pt_regs *regs)__read_mostly ;int (*__debugger_ipi)(struct pt_regs *regs)__read_mostly ;int (*__debugger_bpt)(struct pt_regs *regs)__read_mostly ;
arch/powerpc/platforms/85xx/corenet_generic.c +1 -1
@@ -220,7 +220,7 @@ define_machine(corenet_generic) {* * Likewise, problems have been seen with kexec when coreint is enabled. */ -#if defined(CONFIG_HOTPLUG_CPU ) || defined(CONFIG_KEXEC ) +#if defined(CONFIG_HOTPLUG_CPU ) || defined(CONFIG_KEXEC_CORE ) .get_irq = mpic_get_irq, #else .get_irq = mpic_get_coreint_irq,
arch/powerpc/platforms/85xx/smp.c +4 -4
@@ -349,13 +349,13 @@ struct smp_ops_t smp_85xx_ops = { .cpu_disable = generic_cpu_disable, .cpu_die = generic_cpu_die,#endif -#if defined(CONFIG_KEXEC ) && !defined(CONFIG_PPC64 ) +#if defined(CONFIG_KEXEC_CORE ) && !defined(CONFIG_PPC64 ) .give_timebase = smp_generic_give_timebase, .take_timebase = smp_generic_take_timebase,#endif }; -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE #ifdef CONFIG_PPC32 atomic_t kexec_down_cpus =ATOMIC_INIT (0 );
@@ -458,7 +458,7 @@ static void mpc85xx_smp_machine_kexec(struct kimage *image) default_machine_kexec(image); } -#endif /* CONFIG_KEXEC */ +#endif /* CONFIG_KEXEC_CORE */ static void smp_85xx_basic_setup (int cpu_nr) {
@@ -512,7 +512,7 @@ void __init mpc85xx_smp_init(void)#endif smp_ops = &smp_85xx_ops; -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE ppc_md.kexec_cpu_down = mpc85xx_smp_kexec_cpu_down; ppc_md.machine_kexec = mpc85xx_smp_machine_kexec;#endif
arch/powerpc/platforms/cell/spu_base.c +1 -1
@@ -676,7 +676,7 @@ static ssize_t spu_stat_show(struct device *dev, static DEVICE_ATTR(stat, 0444, spu_stat_show, NULL); -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE struct crash_spu_info { struct spu *spu;
arch/powerpc/platforms/powernv/setup.c +3 -3
@@ -174,7 +174,7 @@ static void pnv_shutdown(void)opal_shutdown (); } -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE static void pnv_kexec_wait_secondaries_down (void ) {int my_cpu, i, notified =-1 ;
@@ -245,7 +245,7 @@ static void pnv_kexec_cpu_down(int crash_shutdown, int secondary) opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE); } } -#endif /* CONFIG_KEXEC */ +#endif /* CONFIG_KEXEC_CORE */ #ifdef CONFIG_MEMORY_HOTPLUG_SPARSE static unsigned long pnv_memory_block_size (void )
@@ -311,7 +311,7 @@ define_machine(powernv) { .machine_shutdown = pnv_shutdown, .power_save = NULL, .calibrate_decr = generic_calibrate_decr, -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE .kexec_cpu_down = pnv_kexec_cpu_down,#endif #ifdef CONFIG_MEMORY_HOTPLUG_SPARSE
arch/powerpc/platforms/ps3/setup.c +2 -2
@@ -250,7 +250,7 @@ static int __init ps3_probe(void)return 1 ; } -#if defined(CONFIG_KEXEC ) +#if defined(CONFIG_KEXEC_CORE )static void ps3_kexec_cpu_down (int crash_shutdown,int secondary) {int cpu =smp_processor_id ();
@@ -276,7 +276,7 @@ define_machine(ps3) { .progress = ps3_progress, .restart = ps3_restart, .halt = ps3_halt, -#if defined(CONFIG_KEXEC ) +#if defined(CONFIG_KEXEC_CORE ) .kexec_cpu_down = ps3_kexec_cpu_down,#endif };
arch/powerpc/platforms/pseries/Makefile +1 -1
@@ -8,7 +8,7 @@ obj-y := lpar.o hvCall.o nvram.o reconfig.o \ pci.o pci_dlpar.o eeh_pseries.o msi.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SCANLOG) += scanlog.o -obj-$(CONFIG_KEXEC) += kexec.o +obj-$(CONFIG_KEXEC_CORE) += kexec.o obj-$(CONFIG_PSERIES_ENERGY) += pseries_energy.o obj-$(CONFIG_HOTPLUG_CPU) += hotplug-cpu.o
arch/powerpc/platforms/pseries/setup.c +2 -2
@@ -367,7 +367,7 @@ void pseries_disable_reloc_on_exc(void) }EXPORT_SYMBOL (pseries_disable_reloc_on_exc); -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE static void pSeries_machine_kexec (struct kimage *image) {if (firmware_has_feature (FW_FEATURE_SET_MODE ))
@@ -725,7 +725,7 @@ define_machine(pseries) { .progress = rtas_progress, .system_reset_exception = pSeries_system_reset_exception, .machine_check_exception = pSeries_machine_check_exception, -#ifdef CONFIG_KEXEC +#ifdef CONFIG_KEXEC_CORE .machine_kexec = pSeries_machine_kexec, .kexec_cpu_down = pseries_kexec_cpu_down, #endif
Signature · 1 line
2.7.4
PATCH v9 5/10 powerpc: Factor out relocation code in module_64.c
In reply to Thiago Jung BauermannThe kexec_file_load system call needs to relocate the purgatory, so factor out the module relocation code so that it can be shared.
This patch's purpose is to move the ELF relocation logic from apply_relocate_add to the new function elf64_apply_relocate_add_item with as few changes as possible. The following changes were needed:
elf64_apply_relocate_add_item takes a my_r2 argument because the kexec code can't use the my_r2 function since it doesn't have a struct module to pass to it. For the same reason, it also takes an obj_name argument to use in error messages. It still takes a pointer to struct module argument, but kexec code can just pass NULL because except for the TOC symbol, the purgatory doesn't have undefined symbols so the module pointer isn't used.
Apart from what is described in the paragraph above, the code has no functional changes.
--- arch/powerpc/kernel/module_64.c | 344 +++++++++++++++++++++------------------- 1 file changed, 182 insertions(+), 162 deletions(-)
arch/powerpc/kernel/module_64.c +182 -162
@@ -507,6 +507,181 @@ static int restore_r2(u32 *instruction, struct module *me)return 1 ; } +static int elf64_apply_relocate_add_item (const Elf64_Shdr *sechdrs, +const char *strtab, +const Elf64_Rela *rela, +const Elf64_Sym *sym, +unsigned long *location, +unsigned long value, +unsigned long my_r2, +const char *obj_name, +struct module *me) +{ +switch (ELF64_R_TYPE (rela->r_info)) { +case R_PPC64_ADDR32 : +/* Simply set it */ + *(u32 *)location = value; +break ; + +case R_PPC64_ADDR64 : +/* Simply set it */ + *(unsigned long *)location = value; +break ; + +case R_PPC64_TOC : + *(unsigned long *)location = my_r2; +break ; + +case R_PPC64_TOC16 : +/* Subtract TOC pointer */ + value -= my_r2; +if (value +0x8000 >0xffff ) { +pr_err ("%s: bad TOC16 relocation (0x%lx)\n" , + obj_name, value); +return -ENOEXEC ; + } + *((uint16_t *) location) + = (*((uint16_t *) location) & ~0xffff ) + | (value &0xffff ); +break ; + +case R_PPC64_TOC16_LO : +/* Subtract TOC pointer */ + value -= my_r2; + *((uint16_t *) location) + = (*((uint16_t *) location) & ~0xffff ) + | (value &0xffff ); +break ; + +case R_PPC64_TOC16_DS : +/* Subtract TOC pointer */ + value -= my_r2; +if ((value &3 ) !=0 || value +0x8000 >0xffff ) { +pr_err ("%s: bad TOC16_DS relocation (0x%lx)\n" , + obj_name, value); +return -ENOEXEC ; + } + *((uint16_t *) location) + = (*((uint16_t *) location) & ~0xfffc ) + | (value &0xfffc ); +break ; + +case R_PPC64_TOC16_LO_DS : +/* Subtract TOC pointer */ + value -= my_r2; +if ((value &3 ) !=0 ) { +pr_err ("%s: bad TOC16_LO_DS relocation (0x%lx)\n" , + obj_name, value); +return -ENOEXEC ; + } + *((uint16_t *) location) + = (*((uint16_t *) location) & ~0xfffc ) + | (value &0xfffc ); +break ; + +case R_PPC64_TOC16_HA : +/* Subtract TOC pointer */ + value -= my_r2; + value = ((value +0x8000 ) >>16 ); + *((uint16_t *) location) + = (*((uint16_t *) location) & ~0xffff ) + | (value &0xffff ); +break ; + +case R_PPC_REL24 : +/* FIXME: Handle weak symbols here --RR */ +if (sym->st_shndx ==SHN_UNDEF ) { +/* External: go via stub */ + value =stub_for_addr (sechdrs, value, me); +if (!value) +return -ENOENT ; +if (!restore_r2 ((u32 *)location +1 , me)) +return -ENOEXEC ; + +squash_toc_save_inst (strtab + sym->st_name, value); + }else + value +=local_entry_offset (sym); + +/* Convert value to relative */ + value -= (unsigned long )location; +if (value +0x2000000 >0x3ffffff || (value &3 ) !=0 ) { +pr_err ("%s: REL24 %li out of range!\n" , + obj_name, (long int )value); +return -ENOEXEC ; + } + +/* Only replace bits 2 through 26 */ + *(uint32_t *)location + = (*(uint32_t *)location & ~0x03fffffc ) + | (value &0x03fffffc ); +break ; + +case R_PPC64_REL64 : +/* 64 bits relative (used by features fixups) */ + *location = value - (unsigned long )location; +break ; + +case R_PPC64_TOCSAVE : +/* +* Marker reloc indicates we don't have to save r2. +* That would only save us one instruction, so ignore +* it. +*/ +break ; + +case R_PPC64_ENTRY : +/* +* Optimize ELFv2 large code model entry point if +* the TOC is within 2GB range of current location. +*/ + value = my_r2 - (unsigned long )location; +if (value +0x80008000 >0xffffffff ) +break ; +/* +* Check for the large code model prolog sequence: +* ld r2, ...(r12) +* add r2, r2, r12 +*/ +if ((((uint32_t *)location)[0 ] & ~0xfffc ) + !=0xe84c0000 ) +break ; +if (((uint32_t *)location)[1 ] !=0x7c426214 ) +break ; +/* +* If found, replace it with: +* addis r2, r12, (.TOC.-func)@ha +* addi r2, r12, (.TOC.-func)@l +*/ + ((uint32_t *)location)[0 ] =0x3c4c0000 +PPC_HA (value); + ((uint32_t *)location)[1 ] =0x38420000 +PPC_LO (value); +break ; + +case R_PPC64_REL16_HA : +/* Subtract location pointer */ + value -= (unsigned long )location; + value = ((value +0x8000 ) >>16 ); + *((uint16_t *) location) + = (*((uint16_t *) location) & ~0xffff ) + | (value &0xffff ); +break ; + +case R_PPC64_REL16_LO : +/* Subtract location pointer */ + value -= (unsigned long )location; + *((uint16_t *) location) + = (*((uint16_t *) location) & ~0xffff ) + | (value &0xffff ); +break ; + +default : +pr_err ("%s: Unknown ADD relocation: %lu\n" , obj_name, + (unsigned long )ELF64_R_TYPE (rela->r_info)); +return -ENOEXEC ; + } + +return 0 ; +} + int apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab, unsigned int symindex,
@@ -514,6 +689,7 @@ int apply_relocate_add(Elf64_Shdr *sechdrs, struct module *me) {unsigned int i; +int ret;Elf64_Rela *rela = (void *)sechdrs[relsec].sh_addr;Elf64_Sym *sym;unsigned long *location;
@@ -548,168 +724,12 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,/* `Everything is relative'. */ value = sym->st_value + rela[i].r_addend; -switch (ELF64_R_TYPE (rela[i].r_info)) { -case R_PPC64_ADDR32 : -/* Simply set it */ - *(u32 *)location = value; -break ; - -case R_PPC64_ADDR64 : -/* Simply set it */ - *(unsigned long *)location = value; -break ; - -case R_PPC64_TOC : - *(unsigned long *)location =my_r2 (sechdrs, me); -break ; - -case R_PPC64_TOC16 : -/* Subtract TOC pointer */ - value -=my_r2 (sechdrs, me); -if (value +0x8000 >0xffff ) { -pr_err ("%s: bad TOC16 relocation (0x%lx)\n" , - me->name, value); -return -ENOEXEC ; - } - *((uint16_t *) location) - = (*((uint16_t *) location) & ~0xffff ) - | (value &0xffff ); -break ; - -case R_PPC64_TOC16_LO : -/* Subtract TOC pointer */ - value -=my_r2 (sechdrs, me); - *((uint16_t *) location) - = (*((uint16_t *) location) & ~0xffff ) - | (value &0xffff ); -break ; - -case R_PPC64_TOC16_DS : -/* Subtract TOC pointer */ - value -=my_r2 (sechdrs, me); -if ((value &3 ) !=0 || value +0x8000 >0xffff ) { -pr_err ("%s: bad TOC16_DS relocation (0x%lx)\n" , - me->name, value); -return -ENOEXEC ; - } - *((uint16_t *) location) - = (*((uint16_t *) location) & ~0xfffc ) - | (value &0xfffc ); -break ; - -case R_PPC64_TOC16_LO_DS : -/* Subtract TOC pointer */ - value -=my_r2 (sechdrs, me); -if ((value &3 ) !=0 ) { -pr_err ("%s: bad TOC16_LO_DS relocation (0x%lx)\n" , - me->name, value); -return -ENOEXEC ; - } - *((uint16_t *) location) - = (*((uint16_t *) location) & ~0xfffc ) - | (value &0xfffc ); -break ; - -case R_PPC64_TOC16_HA : -/* Subtract TOC pointer */ - value -=my_r2 (sechdrs, me); - value = ((value +0x8000 ) >>16 ); - *((uint16_t *) location) - = (*((uint16_t *) location) & ~0xffff ) - | (value &0xffff ); -break ; - -case R_PPC_REL24 : -/* FIXME: Handle weak symbols here --RR */ -if (sym->st_shndx ==SHN_UNDEF ) { -/* External: go via stub */ - value =stub_for_addr (sechdrs, value, me); -if (!value) -return -ENOENT ; -if (!restore_r2 ((u32 *)location +1 , me)) -return -ENOEXEC ; - -squash_toc_save_inst (strtab + sym->st_name, value); - }else - value +=local_entry_offset (sym); - -/* Convert value to relative */ - value -= (unsigned long )location; -if (value +0x2000000 >0x3ffffff || (value &3 ) !=0 ){ -pr_err ("%s: REL24 %li out of range!\n" , - me->name, (long int )value); -return -ENOEXEC ; - } - -/* Only replace bits 2 through 26 */ - *(uint32_t *)location - = (*(uint32_t *)location & ~0x03fffffc ) - | (value &0x03fffffc ); -break ; - -case R_PPC64_REL64 : -/* 64 bits relative (used by features fixups) */ - *location = value - (unsigned long )location; -break ; - -case R_PPC64_TOCSAVE : -/* -* Marker reloc indicates we don't have to save r2. -* That would only save us one instruction, so ignore -* it. -*/ -break ; - -case R_PPC64_ENTRY : -/* -* Optimize ELFv2 large code model entry point if -* the TOC is within 2GB range of current location. -*/ - value =my_r2 (sechdrs, me) - (unsigned long )location; -if (value +0x80008000 >0xffffffff ) -break ; -/* -* Check for the large code model prolog sequence: -* ld r2, ...(r12) -* add r2, r2, r12 -*/ -if ((((uint32_t *)location)[0 ] & ~0xfffc ) - !=0xe84c0000 ) -break ; -if (((uint32_t *)location)[1 ] !=0x7c426214 ) -break ; -/* -* If found, replace it with: -* addis r2, r12, (.TOC.-func)@ha -* addi r2, r12, (.TOC.-func)@l -*/ - ((uint32_t *)location)[0 ] =0x3c4c0000 +PPC_HA (value); - ((uint32_t *)location)[1 ] =0x38420000 +PPC_LO (value); -break ; - -case R_PPC64_REL16_HA : -/* Subtract location pointer */ - value -= (unsigned long )location; - value = ((value +0x8000 ) >>16 ); - *((uint16_t *) location) - = (*((uint16_t *) location) & ~0xffff ) - | (value &0xffff ); -break ; - -case R_PPC64_REL16_LO : -/* Subtract location pointer */ - value -= (unsigned long )location; - *((uint16_t *) location) - = (*((uint16_t *) location) & ~0xffff ) - | (value &0xffff ); -break ; - -default : -pr_err ("%s: Unknown ADD relocation: %lu\n" , - me->name, - (unsigned long )ELF64_R_TYPE (rela[i].r_info)); -return -ENOEXEC ; - } + ret =elf64_apply_relocate_add_item (sechdrs, strtab, &rela[i], + sym, location, value, +my_r2 (sechdrs, me), + me->name, me); +if (ret) +return ret; }return 0 ;
Signature · 1 line
2.7.4
PATCH v9 6/10 powerpc: Implement kexec_file_load.
In reply to Thiago Jung BauermannAdd arch-specific functions needed by generic kexec_file code.
Also, module_64.c's apply_relocate_add and kexec_file's arch_kexec_apply_relocations_add have slightly different needs, so elf64_apply_relocate_add_item needs to be adapted to accommodate both:
When apply_relocate_add is called, the module is already loaded at its final location in memory so the place where the relocation needs to be applied and its address in the module's memory are the same.
This is not the case for kexec's purgatory, because it is stored in a buffer and will only be copied to its final location in memory right before being executed. Therefore, it needs to be relocated while still in its buffer. In this case, the place where the relocation needs to be applied is different from its address in the purgatory's memory.
So we add an address argument to elf64_apply_relocate_add_item to specify the final address of the relocation in memory. We also add more relocation types that are used by the purgatory.
--- arch/powerpc/Kconfig | 13 ++ arch/powerpc/include/asm/elf_util.h | 43 +++++ arch/powerpc/include/asm/systbl.h | 1 + arch/powerpc/include/asm/unistd.h | 2 +- arch/powerpc/include/uapi/asm/unistd.h | 1 + arch/powerpc/kernel/Makefile | 1 + arch/powerpc/kernel/elf_util.c | 46 ++++++ arch/powerpc/kernel/machine_kexec_file_64.c | 245 ++++++++++++++++++++++++++++ arch/powerpc/kernel/module_64.c | 71 ++++++-- 9 files changed, 406 insertions(+), 17 deletions(-)
arch/powerpc/Kconfig +13 -0
@@ -455,6 +455,19 @@ config KEXEC interface is strongly in flux, so no good recommendation can be made. +config KEXEC_FILE + bool "kexec file based system call" + select KEXEC_CORE + select BUILD_BIN2C + depends on PPC64 + depends on CRYPTO=y + depends on CRYPTO_SHA256=y + help + This is a new version of the kexec system call. This call is + file based and takes in file descriptors as system call arguments + for kernel and initramfs as opposed to a list of segments as is the + case for the older kexec call. + config RELOCATABLE bool "Build a relocatable kernel" depends on (PPC64 && !COMPILE_TEST) || (FLATMEM && (44x || FSL_BOOKE))
arch/powerpc/include/asm/elf_util.h new file +43 -0
43 lines not on this page · raw message
arch/powerpc/include/asm/systbl.h +1 -0
@@ -386,3 +386,4 @@ SYSCALL(mlock2) SYSCALL(copy_file_range) COMPAT_SYS_SPU(preadv2) COMPAT_SYS_SPU(pwritev2) +SYSCALL(kexec_file_load)
arch/powerpc/include/asm/unistd.h +1 -1
@@ -12,7 +12,7 @@#include <uapi/asm/unistd.h> -#define NR_syscalls 382 +#define NR_syscalls 383#define __NR__exit __NR_exit
arch/powerpc/include/uapi/asm/unistd.h +1 -0
@@ -392,5 +392,6 @@#define __NR_copy_file_range 379#define __NR_preadv2 380#define __NR_pwritev2 381 +#define __NR_kexec_file_load 382#endif /* _UAPI_ASM_POWERPC_UNISTD_H_ */
arch/powerpc/kernel/Makefile +1 -0
@@ -109,6 +109,7 @@ obj-$(CONFIG_PCI) += pci_$(BITS).o $(pci64-y) \ obj-$(CONFIG_PCI_MSI) += msi.o obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o crash.o \ machine_kexec_$(BITS).o +obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file_$(BITS).o elf_util.o obj-$(CONFIG_AUDIT) += audit.o obj64-$(CONFIG_AUDIT) += compat_audit.o
arch/powerpc/kernel/elf_util.c new file +46 -0
46 lines not on this page · raw message
arch/powerpc/kernel/machine_kexec_file_64.c new file +245 -0
245 lines not on this page · raw message
arch/powerpc/kernel/module_64.c +55 -16
124 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v9 7/10 powerpc: Add functions to read ELF files of any endianness.
In reply to Thiago Jung BauermannA little endian kernel might need to kexec a big endian kernel (the opposite is less likely but could happen as well), so we can't just cast the buffer with the binary to ELF structs and use them as is done elsewhere.
This patch adds functions which do byte-swapping as necessary when populating the ELF structs. These functions will be used in the next patch in the series.
--- arch/powerpc/include/asm/elf_util.h | 21 ++ arch/powerpc/kernel/elf_util.c | 418 ++++++++++++++++++++++++++++++++++++ 2 files changed, 439 insertions(+)
arch/powerpc/include/asm/elf_util.h +21 -0
@@ -19,6 +19,18 @@#include <linux/elf.h> +struct elf_info { +/* +* Where the ELF binary contents are kept. +* Memory managed by the user of the struct. +*/ +const char *buffer; + +const struct elfhdr *ehdr; +const struct elf_phdr *proghdrs; +struct elf_shdr *sechdrs; +}; +/* * r2 is the TOC pointer: it actually points 0x8000 into the TOC (this * gives the value maximum span in an instruction which uses a signed
@@ -40,4 +52,13 @@ int elf64_apply_relocate_add_item(const Elf64_Shdr *sechdrs, const char *strtab, unsigned long my_r2, const char *obj_name, struct module *me); +static inline bool elf_is_elf_file (const struct elfhdr *ehdr) +{ +return memcmp (ehdr->e_ident,ELFMAG ,SELFMAG ) ==0 ; +} + +int elf_read_from_buffer (const char *buf,size_t len,struct elfhdr *ehdr, +struct elf_info *elf_info); +void elf_free_info (struct elf_info *elf_info); +#endif /* _ASM_POWERPC_ELF_UTIL_H */
arch/powerpc/kernel/elf_util.c +418 -0
428 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v9 8/10 powerpc: Add support for loading ELF kernels with kexec_file_load.
In reply to Thiago Jung BauermannThis uses all the infrastructure built up by the previous patches in the series to load an ELF vmlinux file and an initrd. It uses the flattened device tree at initial_boot_params as a base and adjusts memory reservations and its /chosen node for the next kernel.
--- arch/powerpc/include/asm/kexec.h | 12 + arch/powerpc/kernel/Makefile | 3 +- arch/powerpc/kernel/kexec_elf_64.c | 280 +++++++++++++++++++++++ arch/powerpc/kernel/machine_kexec_file_64.c | 338 +++++++++++++++++++++++++++- 4 files changed, 630 insertions(+), 3 deletions(-)
arch/powerpc/include/asm/kexec.h +12 -0
@@ -91,6 +91,18 @@ static inline bool kdump_in_progress(void) return crashing_cpu >= 0; } +#ifdef CONFIG_KEXEC_FILE +extern struct kexec_file_ops kexec_elf64_ops; + +int setup_purgatory (struct kimage *image,const void *slave_code, +const void *fdt,unsigned long kernel_load_addr, +unsigned long fdt_load_addr,unsigned long stack_top, +int debug); +int setup_new_fdt (void *fdt,unsigned long initrd_load_addr, +unsigned long initrd_len,const char *cmdline); +bool find_debug_console (const void *fdt); +#endif /* CONFIG_KEXEC_FILE */ +#else /* !CONFIG_KEXEC_CORE */ static inline void crash_kexec_secondary (struct pt_regs *regs) { }
arch/powerpc/kernel/Makefile +2 -1
@@ -109,7 +109,8 @@ obj-$(CONFIG_PCI) += pci_$(BITS).o $(pci64-y) \ obj-$(CONFIG_PCI_MSI) += msi.o obj-$(CONFIG_KEXEC_CORE) += machine_kexec.o crash.o \ machine_kexec_$(BITS).o -obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file_$(BITS).o elf_util.o +obj-$(CONFIG_KEXEC_FILE) += machine_kexec_file_$(BITS).o elf_util.o \ + kexec_elf_$(BITS).o obj-$(CONFIG_AUDIT) += audit.o obj64-$(CONFIG_AUDIT) += compat_audit.o
arch/powerpc/kernel/kexec_elf_64.c new file +280 -0
280 lines not on this page · raw message
arch/powerpc/kernel/machine_kexec_file_64.c +336 -2
362 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v9 9/10 powerpc: Add purgatory for kexec_file_load implementation.
In reply to Thiago Jung BauermannThis purgatory implementation comes from kexec-tools, almost unchanged.
In order to use boot/string.S in ppc64 big endian mode, the functions defined in it need to have dot symbols so that they can be called from C code. Therefore, change the file to use a DOTSYM macro if one is defined, so that the purgatory can add those dot symbols.
The changes made to the purgatory code relative to the version in kexec-tools were:
The sha256_regions global variable was renamed to sha_regions to match what kexec_file_load expects, and to use the sha256.c file from x86's purgatory (this avoids adding yet another SHA-256 implementation).
The global variables in purgatory.c and purgatory-ppc64.c now use a __section attribute to put them in the .data section instead of being initialized to zero. It doesn't matter what their initial value is, because they will be set by the kernel when preparing the kexec image.
Also, since we don't support loading a crashdump kernel via kexec_file_load yet, the code related to that functionality has been removed.
Finally, some checkpatch.pl warnings were fixed.
--- arch/powerpc/Makefile | 1 + arch/powerpc/boot/string.S | 67 +++++++------ arch/powerpc/purgatory/.gitignore | 2 + arch/powerpc/purgatory/Makefile | 33 +++++++ arch/powerpc/purgatory/console-ppc64.c | 37 +++++++ arch/powerpc/purgatory/crtsavres.S | 5 + arch/powerpc/purgatory/hvCall.S | 27 +++++ arch/powerpc/purgatory/hvCall.h | 8 ++ arch/powerpc/purgatory/kexec-sha256.h | 11 +++ arch/powerpc/purgatory/ppc64_asm.h | 20 ++++ arch/powerpc/purgatory/printf.c | 164 +++++++++++++++++++++++++++++++ arch/powerpc/purgatory/purgatory-ppc64.c | 36 +++++++ arch/powerpc/purgatory/purgatory.c | 62 ++++++++++++ arch/powerpc/purgatory/purgatory.h | 14 +++ arch/powerpc/purgatory/sha256.c | 6 ++ arch/powerpc/purgatory/sha256.h | 1 + arch/powerpc/purgatory/string.S | 2 + arch/powerpc/purgatory/v2wrap.S | 134 +++++++++++++++++++++++++ 18 files changed, 601 insertions(+), 29 deletions(-)
arch/powerpc/Makefile +1 -0
@@ -249,6 +249,7 @@ core-y += arch/powerpc/kernel/ \ core-$(CONFIG_XMON) += arch/powerpc/xmon/ core-$(CONFIG_KVM) += arch/powerpc/kvm/ core-$(CONFIG_PERF_EVENTS) += arch/powerpc/perf/ +core-$(CONFIG_KEXEC_FILE) += arch/powerpc/purgatory/ drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
arch/powerpc/boot/string.S +38 -29
149 lines not on this page · raw message
arch/powerpc/purgatory/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +kexec-purgatory.c +purgatory.ro
arch/powerpc/purgatory/Makefile new file +33 -0
@@ -0,0 +1,33 @@ +OBJECT_FILES_NON_STANDARD := y + +purgatory-y := purgatory.o printf.o string.o v2wrap.o hvCall.o \ + purgatory-ppc64.o console-ppc64.o crtsavres.o sha256.o + +targets += $(purgatory-y) +PURGATORY_OBJS = $(addprefix $(obj)/,$(purgatory-y)) + +LDFLAGS_purgatory.ro := -e purgatory_start -r --no-undefined -nostartfiles \ + -nostdlib -nodefaultlibs +targets += purgatory.ro + +KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_FTRACE), $(KBUILD_CFLAGS)) + +KBUILD_CFLAGS += -fno-zero-initialized-in-bss -fno-builtin -ffreestanding \ + -fno-stack-protector -fno-exceptions -fpie +KBUILD_AFLAGS += -fno-exceptions -msoft-float -fpie + +$(obj)/purgatory.ro: $(PURGATORY_OBJS) FORCE + $(call if_changed,ld) + +targets += kexec-purgatory.c + +CMD_BIN2C = $(objtree)/scripts/basic/bin2c +quiet_cmd_bin2c = BIN2C $@ + cmd_bin2c = $(CMD_BIN2C) kexec_purgatory < $< > $@ + +$(obj)/kexec-purgatory.c: $(obj)/purgatory.ro FORCE + $(call if_changed,bin2c) + @: + + +obj-$(CONFIG_KEXEC_FILE) += kexec-purgatory.o
arch/powerpc/purgatory/console-ppc64.c new file +37 -0
@@ -0,0 +1,37 @@ +/* +* kexec: Linux boots Linux +* +* Created by: Mohan Kumar M ([email protected]) +* +* Copyright (C) IBM Corporation, 2005. All rights reserved +* +* Code taken from kexec-tools. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation (version 2 of the License). +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include "hvCall.h" +#include <asm/byteorder.h> +#include "purgatory.h" + +void putchar (int c) +{ +char buff[8 ]; +unsigned long *lbuf = (unsigned long *)buff; + +if (!debug)/* running on non pseries */ +return ; + +if (c =='\n' ) +putchar ('\r' ); + + buff[0 ] = c; +plpar_hcall_norets (H_PUT_TERM_CHAR ,0 ,1 ,__cpu_to_be64 (*lbuf),0 ); +}
arch/powerpc/purgatory/crtsavres.S new file +5 -0
@@ -0,0 +1,5 @@ +#ifndef CONFIG_CC_OPTIMIZE_FOR_SIZE +#define CONFIG_CC_OPTIMIZE_FOR_SIZE 1 +#endif + +#include "../lib/crtsavres.S"
arch/powerpc/purgatory/hvCall.S new file +27 -0
@@ -0,0 +1,27 @@ +/* + * This file contains the generic function to perform a call to the + * pSeries LPAR hypervisor. + * + * Taken from linux/arch/powerpc/platforms/pseries/hvCall.S + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version + * 2 of the License, or (at your option) any later version. + */ +#include "ppc64_asm.h" + +#define HVSC .long 0x44000022 +.text + .machine ppc64 +.globl DOTSYM(plpar_hcall_norets) +DOTSYM(plpar_hcall_norets): + or 6,6,6 # medium low priority + mfcr 0 + stw 0,8(1) + + HVSC /* invoke the hypervisor */ + + lwz 0,8(1) + mtcrf 0xff,0 + blr /* return r3 = status */
arch/powerpc/purgatory/hvCall.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef HVCALL_H +#define HVCALL_H + +#define H_PUT_TERM_CHAR 0x58 + +long plpar_hcall_norets (unsigned long opcode, ...); + +#endif
arch/powerpc/purgatory/kexec-sha256.h new file +11 -0
@@ -0,0 +1,11 @@ +#ifndef KEXEC_SHA256_H +#define KEXEC_SHA256_H + +struct kexec_sha_region { +unsigned long start; +unsigned long len; +}; + +#define SHA256_REGIONS 16 + +#endif /* KEXEC_SHA256_H */
arch/powerpc/purgatory/ppc64_asm.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* ppc64_asm.h - common defines for PPC64 assembly parts +* +* Code taken from kexec-tools. +* +* This source code is licensed under the GNU General Public License, +* Version 2. See the file COPYING for more details. +*/ + +#include <asm/types.h> + +/* +* ABIv1 requires dot symbol while ABIv2 does not. +*/ +#ifdef PPC64_ELF_ABI_v2 +#define DOTSYM (a) a +#else +#define GLUE (a, b) a##b +#define DOTSYM (a) GLUE(., a) +#endif
arch/powerpc/purgatory/printf.c new file +164 -0
164 lines not on this page · raw message
arch/powerpc/purgatory/purgatory-ppc64.c new file +36 -0
@@ -0,0 +1,36 @@ +/* +* kexec: Linux boots Linux +* +* Created by: Mohan Kumar M ([email protected]) +* +* Copyright (C) IBM Corporation, 2005. All rights reserved +* +* Code taken from kexec-tools. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation (version 2 of the License). +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include "purgatory.h" + +unsigned long stack __section(".data"); +unsigned long dt_offset __section(".data"); +unsigned long my_toc __section(".data"); +unsigned long kernel __section(".data"); +int debug __section(".data"); +unsigned long opal_base __section(".data"); +unsigned long opal_entry __section(".data"); + +void setup_arch (void ) +{ +} + +void post_verification_setup_arch (void ) +{ +}
arch/powerpc/purgatory/purgatory.c new file +62 -0
62 lines not on this page · raw message
arch/powerpc/purgatory/purgatory.h new file +14 -0
@@ -0,0 +1,14 @@ +#ifndef PURGATORY_H +#define PURGATORY_H + +#include <linux/compiler.h> + +extern int debug; + +void putchar (int ch); +void sprintf(char *buffer, const char *fmt, ...) __printf(2, 3); +void printf(const char *fmt, ...) __printf(1, 2); +void setup_arch (void ); +void post_verification_setup_arch (void ); + +#endif /* PURGATORY_H */
arch/powerpc/purgatory/sha256.c new file +6 -0
@@ -0,0 +1,6 @@ +#include "../boot/string.h" + +/* Avoid including x86's boot/string.h in sha256.c. */ +#define BOOT_STRING_H + +#include "../../x86/purgatory/sha256.c"
arch/powerpc/purgatory/sha256.h new file +1 -0
@@ -0,0 +1 @@ +#include "../../x86/purgatory/sha256.h"
arch/powerpc/purgatory/string.S new file +2 -0
@@ -0,0 +1,2 @@ +#include "ppc64_asm.h" +#include "../boot/string.S"
arch/powerpc/purgatory/v2wrap.S new file +134 -0
134 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v9 10/10 powerpc: Enable CONFIG_KEXEC_FILE in powerpc server defconfigs.
In reply to Thiago Jung BauermannEnable CONFIG_KEXEC_FILE in powernv_defconfig, ppc64_defconfig and pseries_defconfig.
It depends on CONFIG_CRYPTO_SHA256=y, so add that as well.
--- arch/powerpc/configs/powernv_defconfig | 2 ++ arch/powerpc/configs/ppc64_defconfig | 2 ++ arch/powerpc/configs/pseries_defconfig | 2 ++ 3 files changed, 6 insertions(+)
arch/powerpc/configs/powernv_defconfig +2 -0
@@ -49,6 +49,7 @@ CONFIG_BINFMT_MISC=m CONFIG_PPC_TRANSACTIONAL_MEM=y CONFIG_HOTPLUG_CPU=y CONFIG_KEXEC=y +CONFIG_KEXEC_FILE=y CONFIG_IRQ_ALL_CPUS=y CONFIG_NUMA=y CONFIG_MEMORY_HOTPLUG=y
@@ -301,6 +302,7 @@ CONFIG_CRYPTO_CCM=m CONFIG_CRYPTO_PCBC=m CONFIG_CRYPTO_HMAC=y CONFIG_CRYPTO_MICHAEL_MIC=m +CONFIG_CRYPTO_SHA256=y CONFIG_CRYPTO_TGR192=m CONFIG_CRYPTO_WP512=m CONFIG_CRYPTO_ANUBIS=m
arch/powerpc/configs/ppc64_defconfig +2 -0
@@ -46,6 +46,7 @@ CONFIG_HZ_100=y CONFIG_BINFMT_MISC=m CONFIG_PPC_TRANSACTIONAL_MEM=y CONFIG_KEXEC=y +CONFIG_KEXEC_FILE=y CONFIG_CRASH_DUMP=y CONFIG_IRQ_ALL_CPUS=y CONFIG_MEMORY_HOTREMOVE=y
@@ -336,6 +337,7 @@ CONFIG_CRYPTO_TEST=m CONFIG_CRYPTO_PCBC=m CONFIG_CRYPTO_HMAC=y CONFIG_CRYPTO_MICHAEL_MIC=m +CONFIG_CRYPTO_SHA256=y CONFIG_CRYPTO_TGR192=m CONFIG_CRYPTO_WP512=m CONFIG_CRYPTO_ANUBIS=m
arch/powerpc/configs/pseries_defconfig +2 -0
@@ -52,6 +52,7 @@ CONFIG_HZ_100=y CONFIG_BINFMT_MISC=m CONFIG_PPC_TRANSACTIONAL_MEM=y CONFIG_KEXEC=y +CONFIG_KEXEC_FILE=y CONFIG_IRQ_ALL_CPUS=y CONFIG_MEMORY_HOTPLUG=y CONFIG_MEMORY_HOTREMOVE=y
@@ -303,6 +304,7 @@ CONFIG_CRYPTO_TEST=m CONFIG_CRYPTO_PCBC=m CONFIG_CRYPTO_HMAC=y CONFIG_CRYPTO_MICHAEL_MIC=m +CONFIG_CRYPTO_SHA256=y CONFIG_CRYPTO_TGR192=m CONFIG_CRYPTO_WP512=m CONFIG_CRYPTO_ANUBIS=m
Signature · 1 line
2.7.4