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
215 lines
6.3 KiB
Diff
215 lines
6.3 KiB
Diff
From c0672c93edcb5bb32800f8d48afa05861ef32a79 Mon Sep 17 00:00:00 2001
|
|
From: AKASHI Takahiro <takahiro.akashi@linaro.org>
|
|
Date: Wed, 17 May 2017 14:51:45 +0900
|
|
Subject: [PATCH 39/45] arm64: kdump: identify memory regions
|
|
|
|
The following regions need to be identified for later use:
|
|
a) memory regions which belong to the 1st kernel
|
|
b) usable memory reserved for crash dump kernel
|
|
|
|
We go through /proc/iomem to find out a) and b) which are marked
|
|
as "System RAM" and "Crash kernel", respectively.
|
|
|
|
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/Makefile | 2 +
|
|
kexec/arch/arm64/crashdump-arm64.c | 109 +++++++++++++++++++++++++++++++++++--
|
|
kexec/arch/arm64/crashdump-arm64.h | 14 ++++-
|
|
kexec/arch/arm64/iomem.h | 1 +
|
|
4 files changed, 120 insertions(+), 6 deletions(-)
|
|
|
|
diff --git a/kexec/arch/arm64/Makefile b/kexec/arch/arm64/Makefile
|
|
index 91f6388e46a3..9d9111caa8ed 100644
|
|
--- a/kexec/arch/arm64/Makefile
|
|
+++ b/kexec/arch/arm64/Makefile
|
|
@@ -6,6 +6,8 @@ arm64_FS2DT_INCLUDE += \
|
|
|
|
arm64_DT_OPS += kexec/dt-ops.c
|
|
|
|
+arm64_MEM_REGIONS = kexec/mem_regions.c
|
|
+
|
|
arm64_CPPFLAGS += -I $(srcdir)/kexec/
|
|
|
|
arm64_KEXEC_SRCS += \
|
|
diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
|
|
index b0e4713f12c6..9267c9add291 100644
|
|
--- a/kexec/arch/arm64/crashdump-arm64.c
|
|
+++ b/kexec/arch/arm64/crashdump-arm64.c
|
|
@@ -1,5 +1,13 @@
|
|
/*
|
|
* ARM64 crashdump.
|
|
+ * partly derived from arm implementation
|
|
+ *
|
|
+ * Copyright (c) 2014-2017 Linaro Limited
|
|
+ * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
+ * it under the terms of the GNU General Public License version 2 as
|
|
+ * published by the Free Software Foundation.
|
|
*/
|
|
|
|
#define _GNU_SOURCE
|
|
@@ -10,18 +18,111 @@
|
|
#include "kexec.h"
|
|
#include "crashdump.h"
|
|
#include "crashdump-arm64.h"
|
|
+#include "iomem.h"
|
|
#include "kexec-arm64.h"
|
|
#include "kexec-elf.h"
|
|
+#include "mem_regions.h"
|
|
|
|
-struct memory_ranges usablemem_rgns = {};
|
|
+/* memory ranges on crashed kernel */
|
|
+static struct memory_range system_memory_ranges[CRASH_MAX_MEMORY_RANGES];
|
|
+static struct memory_ranges system_memory_rgns = {
|
|
+ .size = 0,
|
|
+ .max_size = CRASH_MAX_MEMORY_RANGES,
|
|
+ .ranges = system_memory_ranges,
|
|
+};
|
|
|
|
-int is_crashkernel_mem_reserved(void)
|
|
+/* memory range reserved for crashkernel */
|
|
+struct memory_range crash_reserved_mem;
|
|
+struct memory_ranges usablemem_rgns = {
|
|
+ .size = 0,
|
|
+ .max_size = 1,
|
|
+ .ranges = &crash_reserved_mem,
|
|
+};
|
|
+
|
|
+/*
|
|
+ * iomem_range_callback() - callback called for each iomem region
|
|
+ * @data: not used
|
|
+ * @nr: not used
|
|
+ * @str: name of the memory region
|
|
+ * @base: start address of the memory region
|
|
+ * @length: size of the memory region
|
|
+ *
|
|
+ * This function is called once for each memory region found in /proc/iomem.
|
|
+ * It locates system RAM and crashkernel reserved memory and places these to
|
|
+ * variables, respectively, system_memory_ranges and crash_reserved_mem.
|
|
+ */
|
|
+
|
|
+static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
|
|
+ char *str, unsigned long long base,
|
|
+ unsigned long long length)
|
|
{
|
|
+ if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0)
|
|
+ return mem_regions_add(&usablemem_rgns,
|
|
+ base, length, RANGE_RAM);
|
|
+ else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0)
|
|
+ return mem_regions_add(&system_memory_rgns,
|
|
+ base, length, RANGE_RAM);
|
|
+
|
|
return 0;
|
|
}
|
|
|
|
+int is_crashkernel_mem_reserved(void)
|
|
+{
|
|
+ if (!usablemem_rgns.size)
|
|
+ kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL);
|
|
+
|
|
+ return crash_reserved_mem.start != crash_reserved_mem.end;
|
|
+}
|
|
+
|
|
+/*
|
|
+ * crash_get_memory_ranges() - read system physical memory
|
|
+ *
|
|
+ * Function reads through system physical memory and stores found memory
|
|
+ * regions in system_memory_ranges.
|
|
+ * Regions are sorted in ascending order.
|
|
+ *
|
|
+ * Returns 0 in case of success and a negative value otherwise.
|
|
+ */
|
|
+static int crash_get_memory_ranges(void)
|
|
+{
|
|
+ /*
|
|
+ * First read all memory regions that can be considered as
|
|
+ * system memory including the crash area.
|
|
+ */
|
|
+ if (!usablemem_rgns.size)
|
|
+ kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL);
|
|
+
|
|
+ /* allow only a single region for crash dump kernel */
|
|
+ if (usablemem_rgns.size != 1)
|
|
+ return -EINVAL;
|
|
+
|
|
+ dbgprint_mem_range("Reserved memory range", &crash_reserved_mem, 1);
|
|
+
|
|
+ if (mem_regions_exclude(&system_memory_rgns, &crash_reserved_mem)) {
|
|
+ fprintf(stderr,
|
|
+ "Error: Number of crash memory ranges excedeed the max limit\n");
|
|
+ return -ENOMEM;
|
|
+ }
|
|
+
|
|
+ /*
|
|
+ * Make sure that the memory regions are sorted.
|
|
+ */
|
|
+ mem_regions_sort(&system_memory_rgns);
|
|
+
|
|
+ dbgprint_mem_range("Coredump memory ranges",
|
|
+ system_memory_rgns.ranges, system_memory_rgns.size);
|
|
+}
|
|
+
|
|
int get_crash_kernel_load_range(uint64_t *start, uint64_t *end)
|
|
{
|
|
- /* Crash kernel region size is not exposed by the system */
|
|
- return -1;
|
|
+ if (!usablemem_rgns.size)
|
|
+ kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL);
|
|
+
|
|
+ if (!crash_reserved_mem.end)
|
|
+ return -1;
|
|
+
|
|
+ *start = crash_reserved_mem.start;
|
|
+ *end = crash_reserved_mem.end;
|
|
+
|
|
+ return 0;
|
|
}
|
|
diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h
|
|
index f33c7a25b454..ce9881eba67e 100644
|
|
--- a/kexec/arch/arm64/crashdump-arm64.h
|
|
+++ b/kexec/arch/arm64/crashdump-arm64.h
|
|
@@ -1,12 +1,22 @@
|
|
/*
|
|
* ARM64 crashdump.
|
|
+ *
|
|
+ * Copyright (c) 2014-2017 Linaro Limited
|
|
+ * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
|
|
+ *
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
+ * it under the terms of the GNU General Public License version 2 as
|
|
+ * published by the Free Software Foundation.
|
|
*/
|
|
|
|
-#if !defined(CRASHDUMP_ARM64_H)
|
|
+#ifndef CRASHDUMP_ARM64_H
|
|
#define CRASHDUMP_ARM64_H
|
|
|
|
#include "kexec.h"
|
|
|
|
+#define CRASH_MAX_MEMORY_RANGES 32
|
|
+
|
|
extern struct memory_ranges usablemem_rgns;
|
|
+extern struct memory_range crash_reserved_mem;
|
|
|
|
-#endif
|
|
+#endif /* CRASHDUMP_ARM64_H */
|
|
diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h
|
|
index 7fd66eb063e1..20cda87dbd02 100644
|
|
--- a/kexec/arch/arm64/iomem.h
|
|
+++ b/kexec/arch/arm64/iomem.h
|
|
@@ -2,6 +2,7 @@
|
|
#define IOMEM_H
|
|
|
|
#define SYSTEM_RAM "System RAM\n"
|
|
+#define CRASH_KERNEL "Crash kernel\n"
|
|
#define IOMEM_RESERVED "reserved\n"
|
|
|
|
#endif
|
|
--
|
|
2.13.0
|
|
|