forked from pool/kexec-tools
080f64dafa
- Update to version 2.0.14 (bsc#1039937, FATE#320672, FATE#320671) Changelog: http://git.kernel.org/cgit/utils/kernel/kexec/kexec-tools.git/log/?id=refs/tags/v2.0.13..v2.0.14 - Backport upstream fixes (bsc#1039937, FATE#320672, FATE#320671) 0001-kexec-tools-2.0.14.git.patch 0002-ppc64-Reduce-number-of-ELF-LOAD-segments.patch 0003-kexec-Increase-the-upper-limit-for-RAM-segments.patch 0004-alpha-add-missing-__NR_kexec_load-definition.patch 0005-kexec-implemented-XEN-KEXEC-STATUS-to-determine-if-a.patch 0006-kexec-Remove-redundant-space-from-help-message.patch 0007-purgatory-Add-purgatory.map-and-purgatory.ro.sym-to-.patch 0008-kexec-Add-option-to-get-crash-kernel-region-size.patch 0009-crashdump-arm-Add-get_crash_kernel_load_range-functi.patch 0010-crashdump-arm64-Add-get_crash_kernel_load_range-func.patch 0011-crashdump-cris-Add-get_crash_kernel_load_range-funct.patch 0012-crashdump-ia64-Add-get_crash_kernel_load_range-funct.patch 0013-crashdump-m68k-Add-get_crash_kernel_load_range-funct.patch 0014-crashdump-mips-Add-get_crash_kernel_load_range-funct.patch 0015-crashdump-ppc-Add-get_crash_kernel_load_range-functi.patch 0016-crashdump-ppc64-Add-get_crash_kernel_load_range-func.patch 0017-crashdump-s390-Add-get_crash_kernel_load_range-funct.patch 0018-crashdump-sh-Add-get_crash_kernel_load_range-functio.patch 0019-gitignore-add-two-generated-files-in-purgatory.patch 0020-Only-print-debug-message-when-failed-to-serach-for-k.patch 0021-build_mem_phdrs-check-if-p_paddr-is-invalid.patch 0022-uImage-fix-realloc-pointer-confusion.patch 0023-uImage-Fix-uImage_load-for-little-endian-machines.patch 0024-uImage-Add-new-IH_ARCH_xxx-definitions.patch 0025-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch 0026-uImage-use-char-instead-of-unsigned-char-for-uImage_.patch 0027-arm64-add-uImage-support.patch OBS-URL: https://build.opensuse.org/request/show/500203 OBS-URL: https://build.opensuse.org/package/show/Kernel:kdump/kexec-tools?expand=0&rev=83
143 lines
4.7 KiB
Diff
143 lines
4.7 KiB
Diff
From 1591926df5a602ffcbf55e99aa8a96fbebd0bafe Mon Sep 17 00:00:00 2001
|
|
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
|
|
Date: Wed, 17 May 2017 14:51:47 +0900
|
|
Subject: [PATCH 41/45] arm64: kdump: set up kernel image segment
|
|
|
|
On arm64, we can use the same kernel image as 1st kernel, but
|
|
we have to modify the entry point as well as segments' addresses
|
|
in the kernel's elf header in order to load them into correct places.
|
|
|
|
Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
|
|
Tested-by: David Woodhouse <dwmw@amazon.co.uk>
|
|
Tested-by: Pratyush Anand <panand@redhat.com>
|
|
Signed-off-by: Simon Horman <horms@verge.net.au>
|
|
---
|
|
kexec/arch/arm64/crashdump-arm64.c | 24 ++++++++++++++++++++++++
|
|
kexec/arch/arm64/crashdump-arm64.h | 1 +
|
|
kexec/arch/arm64/kexec-arm64.c | 25 ++++++++++++++++++++-----
|
|
kexec/arch/arm64/kexec-elf-arm64.c | 11 ++++++++++-
|
|
4 files changed, 55 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
|
|
index d142435fa933..4fd7aa8fd43c 100644
|
|
--- a/kexec/arch/arm64/crashdump-arm64.c
|
|
+++ b/kexec/arch/arm64/crashdump-arm64.c
|
|
@@ -211,6 +211,30 @@ int load_crashdump_segments(struct kexec_info *info)
|
|
return 0;
|
|
}
|
|
|
|
+/*
|
|
+ * e_entry and p_paddr are actually in virtual address space.
|
|
+ * Those values will be translated to physcal addresses by using
|
|
+ * virt_to_phys() in add_segment().
|
|
+ * So let's fix up those values for later use so the memory base
|
|
+ * (arm64_mm.phys_offset) will be correctly replaced with
|
|
+ * crash_reserved_mem.start.
|
|
+ */
|
|
+void fixup_elf_addrs(struct mem_ehdr *ehdr)
|
|
+{
|
|
+ struct mem_phdr *phdr;
|
|
+ int i;
|
|
+
|
|
+ ehdr->e_entry += - arm64_mem.phys_offset + crash_reserved_mem.start;
|
|
+
|
|
+ for (i = 0; i < ehdr->e_phnum; i++) {
|
|
+ phdr = &ehdr->e_phdr[i];
|
|
+ if (phdr->p_type != PT_LOAD)
|
|
+ continue;
|
|
+ phdr->p_paddr +=
|
|
+ (-arm64_mem.phys_offset + crash_reserved_mem.start);
|
|
+ }
|
|
+}
|
|
+
|
|
int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
|
|
{
|
|
if (!usablemem_rgns.size)
|
|
diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h
|
|
index 64c677d2fce1..880b83aa3d0f 100644
|
|
--- a/kexec/arch/arm64/crashdump-arm64.h
|
|
+++ b/kexec/arch/arm64/crashdump-arm64.h
|
|
@@ -21,5 +21,6 @@ extern struct memory_range crash_reserved_mem;
|
|
extern struct memory_range elfcorehdr_mem;
|
|
|
|
extern int load_crashdump_segments(struct kexec_info *info);
|
|
+extern void fixup_elf_addrs(struct mem_ehdr *ehdr);
|
|
|
|
#endif /* CRASHDUMP_ARM64_H */
|
|
diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
|
|
index 153c96f73b3d..6c2175672305 100644
|
|
--- a/kexec/arch/arm64/kexec-arm64.c
|
|
+++ b/kexec/arch/arm64/kexec-arm64.c
|
|
@@ -308,12 +308,27 @@ unsigned long arm64_locate_kernel_segment(struct kexec_info *info)
|
|
{
|
|
unsigned long hole;
|
|
|
|
- hole = locate_hole(info,
|
|
- arm64_mem.text_offset + arm64_mem.image_size,
|
|
- MiB(2), 0, ULONG_MAX, 1);
|
|
+ if (info->kexec_flags & KEXEC_ON_CRASH) {
|
|
+ unsigned long hole_end;
|
|
+
|
|
+ hole = (crash_reserved_mem.start < mem_min ?
|
|
+ mem_min : crash_reserved_mem.start);
|
|
+ hole = _ALIGN_UP(hole, MiB(2));
|
|
+ hole_end = hole + arm64_mem.text_offset + arm64_mem.image_size;
|
|
+
|
|
+ if ((hole_end > mem_max) ||
|
|
+ (hole_end > crash_reserved_mem.end)) {
|
|
+ dbgprintf("%s: Crash kernel out of range\n", __func__);
|
|
+ hole = ULONG_MAX;
|
|
+ }
|
|
+ } else {
|
|
+ hole = locate_hole(info,
|
|
+ arm64_mem.text_offset + arm64_mem.image_size,
|
|
+ MiB(2), 0, ULONG_MAX, 1);
|
|
|
|
- if (hole == ULONG_MAX)
|
|
- dbgprintf("%s: locate_hole failed\n", __func__);
|
|
+ if (hole == ULONG_MAX)
|
|
+ dbgprintf("%s: locate_hole failed\n", __func__);
|
|
+ }
|
|
|
|
return hole;
|
|
}
|
|
diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c
|
|
index 900c6939ab62..a9611474ef51 100644
|
|
--- a/kexec/arch/arm64/kexec-elf-arm64.c
|
|
+++ b/kexec/arch/arm64/kexec-elf-arm64.c
|
|
@@ -9,6 +9,7 @@
|
|
#include <stdlib.h>
|
|
#include <linux/elf.h>
|
|
|
|
+#include "crashdump-arm64.h"
|
|
#include "kexec-arm64.h"
|
|
#include "kexec-elf.h"
|
|
#include "kexec-syscall.h"
|
|
@@ -105,7 +106,8 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
|
|
}
|
|
|
|
arm64_mem.vp_offset = _ALIGN_DOWN(ehdr.e_entry, MiB(2));
|
|
- arm64_mem.vp_offset -= kernel_segment - get_phys_offset();
|
|
+ if (!(info->kexec_flags & KEXEC_ON_CRASH))
|
|
+ arm64_mem.vp_offset -= kernel_segment - get_phys_offset();
|
|
|
|
dbgprintf("%s: kernel_segment: %016lx\n", __func__, kernel_segment);
|
|
dbgprintf("%s: text_offset: %016lx\n", __func__,
|
|
@@ -130,6 +132,13 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
|
|
}
|
|
|
|
/* load the kernel */
|
|
+ if (info->kexec_flags & KEXEC_ON_CRASH)
|
|
+ /*
|
|
+ * offset addresses in elf header in order to load
|
|
+ * vmlinux (elf_exec) into crash kernel's memory
|
|
+ */
|
|
+ fixup_elf_addrs(&ehdr);
|
|
+
|
|
result = elf_exec_load(&ehdr, info);
|
|
|
|
if (result) {
|
|
--
|
|
2.13.0
|
|
|