summaryrefslogtreecommitdiffstats
path: root/meta/recipes-kernel/kexec
diff options
context:
space:
mode:
authorzhengrq <zhengrq.fnst@cn.fujitsu.com>2017-11-08 17:56:02 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-11-21 13:06:11 +0000
commitaab72188198cda66226f7afacba02e3f3bfe235c (patch)
tree1a1b11e24275f80cffa389ce944bc444514245e3 /meta/recipes-kernel/kexec
parentc3f3a04f71d0dfe3d92dd3fff99bee61b99e78ae (diff)
downloadpoky-aab72188198cda66226f7afacba02e3f3bfe235c.tar.gz
kexec-tools: 2.0.14 -> 2.0.15
1) Upgrade kexec-tools from 2.0.14 to 2.0.15. 2) Remove patches that are included in 2.0.15. kexec-tools/0001-arm64-Disable-PIC.patch kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch kexec-tools/0001-vmcore-dmesg-Define-_GNU_SOURCE.patch kexec-tools/0001-x86-x86_64-Fix-format-warning-with-die.patch kexec-tools/0002-kexec-generalize-and-rename-get_kernel_stext_sym.patch kexec-tools/0002-ppc-Fix-format-warning-with-die.patch kexec-tools/0003-arm64-identify-PHYS_OFFSET-correctly.patch kexec-tools/0004-arm64-kdump-identify-memory-regions.patch kexec-tools/0005-arm64-kdump-add-elf-core-header-segment.patch kexec-tools/0006-arm64-kdump-set-up-kernel-image-segment.patch kexec-tools/0007-arm64-kdump-set-up-other-segments.patch kexec-tools/0008-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch kexec-tools/0009-arm64-kdump-Add-support-for-binary-image-files.patch (From OE-Core rev: d2f196351a8e30542d5fb1561cb7960b6673c5ab) Signed-off-by: Zheng Ruoqin <zhengrq.fnst@cn.fujitsu.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-kernel/kexec')
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0001-arm64-Disable-PIC.patch31
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch78
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0001-vmcore-dmesg-Define-_GNU_SOURCE.patch31
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0001-x86-x86_64-Fix-format-warning-with-die.patch78
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0002-kexec-generalize-and-rename-get_kernel_stext_sym.patch194
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0002-ppc-Fix-format-warning-with-die.patch43
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0003-arm64-identify-PHYS_OFFSET-correctly.patch76
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0004-arm64-kdump-identify-memory-regions.patch202
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0005-arm64-kdump-add-elf-core-header-segment.patch191
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0006-arm64-kdump-set-up-kernel-image-segment.patch137
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0007-arm64-kdump-set-up-other-segments.patch35
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0008-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch150
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools/0009-arm64-kdump-Add-support-for-binary-image-files.patch52
-rw-r--r--meta/recipes-kernel/kexec/kexec-tools_2.0.15.bb (renamed from meta/recipes-kernel/kexec/kexec-tools_2.0.14.bb)17
14 files changed, 2 insertions, 1313 deletions
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0001-arm64-Disable-PIC.patch b/meta/recipes-kernel/kexec/kexec-tools/0001-arm64-Disable-PIC.patch
deleted file mode 100644
index 84e94d7d93..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0001-arm64-Disable-PIC.patch
+++ /dev/null
@@ -1,31 +0,0 @@
1From 3bb73e5e5649b455e15d5ca3a7ad1a90c4960972 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 10 Jun 2017 11:54:36 -0700
4Subject: [PATCH] arm64: Disable PIC
5
6Fix
7| cc1: sorry, unimplemented: code model 'large' with -fPIC
8| make: *** [Makefile:118: purgatory/arch/arm64/entry.o] Error 1
9
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12Upstream-Status: Pending
13
14 purgatory/arch/arm64/Makefile | 1 +
15 1 file changed, 1 insertion(+)
16
17diff --git a/purgatory/arch/arm64/Makefile b/purgatory/arch/arm64/Makefile
18index 636abea..80068ca 100644
19--- a/purgatory/arch/arm64/Makefile
20+++ b/purgatory/arch/arm64/Makefile
21@@ -1,6 +1,7 @@
22
23 arm64_PURGATORY_EXTRA_CFLAGS = \
24 -mcmodel=large \
25+ -fno-PIC \
26 -fno-stack-protector \
27 -fno-asynchronous-unwind-tables \
28 -Wundef \
29--
302.13.1
31
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch b/meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch
deleted file mode 100644
index 822f28c44b..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch
+++ /dev/null
@@ -1,78 +0,0 @@
1From 02eed0f8f2748fd7579f69e5373445b52b2b8754 Mon Sep 17 00:00:00 2001
2From: AKASHI Takahiro <takahiro.akashi@linaro.org>
3Date: Mon, 17 Oct 2016 13:56:58 +0900
4Subject: [PATCH 1/9] kexec: exntend the semantics of kexec_iomem_for_each_line
5
6The current kexec_iomem_for_each_line() counts up all the lines for which
7a callback function returns zero(0) or positive, and otherwise it stops
8further scanning.
9This behavior is incovenient in some cases. For instance, on arm64, we want
10to count up "System RAM" entries, but need to skip "reserved" entries.
11
12So this patch extends the semantics so that we will continue to scan
13succeeding entries but not count lines for which a callback function
14returns positive.
15
16The current users of kexec_iomem_for_each_line(), arm, sh and x86, will not
17be affected by this change because
18* arm
19 The callback function only returns -1 or 0, and the return value of
20 kexec_iomem_for_each_line() will never be used.
21* sh, x86
22 The callback function may return (-1 for sh,) 0 or 1, but always returns
23 1 once we have reached the maximum number of entries allowed.
24 Even so the current kexec_iomem_for_each_line() counts them up.
25 This change actually fixes this bug.
26
27Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
28
29Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
30Signed-off-by: He Zhe <zhe.he@windriver.com>
31---
32 kexec/kexec-iomem.c | 15 ++++++++++-----
33 1 file changed, 10 insertions(+), 5 deletions(-)
34
35diff --git a/kexec/kexec-iomem.c b/kexec/kexec-iomem.c
36index 485a2e8..0a0277a 100644
37--- a/kexec/kexec-iomem.c
38+++ b/kexec/kexec-iomem.c
39@@ -18,6 +18,9 @@
40 * Iterate over each line in the file returned by proc_iomem(). If match is
41 * NULL or if the line matches with our match-pattern then call the
42 * callback if non-NULL.
43+ * If match is NULL, callback should return a negative if error.
44+ * Otherwise the interation goes on, incrementing nr but only if callback
45+ * returns 0 (matched).
46 *
47 * Return the number of lines matched.
48 */
49@@ -37,7 +40,7 @@ int kexec_iomem_for_each_line(char *match,
50 char *str;
51 int consumed;
52 int count;
53- int nr = 0;
54+ int nr = 0, ret;
55
56 fp = fopen(iomem, "r");
57 if (!fp)
58@@ -50,11 +53,13 @@ int kexec_iomem_for_each_line(char *match,
59 str = line + consumed;
60 size = end - start + 1;
61 if (!match || memcmp(str, match, strlen(match)) == 0) {
62- if (callback
63- && callback(data, nr, str, start, size) < 0) {
64- break;
65+ if (callback) {
66+ ret = callback(data, nr, str, start, size);
67+ if (ret < 0)
68+ break;
69+ else if (ret == 0)
70+ nr++;
71 }
72- nr++;
73 }
74 }
75
76--
771.9.1
78
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0001-vmcore-dmesg-Define-_GNU_SOURCE.patch b/meta/recipes-kernel/kexec/kexec-tools/0001-vmcore-dmesg-Define-_GNU_SOURCE.patch
deleted file mode 100644
index 90c2f6e0ec..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0001-vmcore-dmesg-Define-_GNU_SOURCE.patch
+++ /dev/null
@@ -1,31 +0,0 @@
1From d811875a41b4628040abaada3da29b7b9592e757 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 9 Jan 2016 17:16:16 -0800
4Subject: [PATCH] vmcore-dmesg: Define _GNU_SOURCE
5
6loff_t is guarded with _GNU_SOURCE on some C library implementations
7e.g. musl since this type is not defined by POSIX. Define _GNU_SOURCE to
8include this define, it should help compiling on musl while nothing
9changes for glibc based systems since there _GNU_SOURCE is already
10defined
11
12Signed-off-by: Khem Raj <raj.khem@gmail.com>
13---
14Upstream-Status: Submitted
15
16 vmcore-dmesg/vmcore-dmesg.c | 1 +
17 1 file changed, 1 insertion(+)
18
19diff --git a/vmcore-dmesg/vmcore-dmesg.c b/vmcore-dmesg/vmcore-dmesg.c
20index 0364636..a8f56df 100644
21--- a/vmcore-dmesg/vmcore-dmesg.c
22+++ b/vmcore-dmesg/vmcore-dmesg.c
23@@ -1,4 +1,5 @@
24 #define _XOPEN_SOURCE 600
25+#define _GNU_SOURCE
26 #define _LARGEFILE_SOURCE 1
27 #define _FILE_OFFSET_BITS 64
28 #include <endian.h>
29--
302.7.0
31
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0001-x86-x86_64-Fix-format-warning-with-die.patch b/meta/recipes-kernel/kexec/kexec-tools/0001-x86-x86_64-Fix-format-warning-with-die.patch
deleted file mode 100644
index e601f52757..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0001-x86-x86_64-Fix-format-warning-with-die.patch
+++ /dev/null
@@ -1,78 +0,0 @@
1Upstream-Status: Backport
2Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
3
4
5From 1550f81bf1886aa0520da0b6181cd61c1a75d4ad Mon Sep 17 00:00:00 2001
6From: Pratyush Anand <panand@redhat.com>
7Date: Tue, 14 Mar 2017 17:59:22 +0530
8Subject: [PATCH 1/2] x86/x86_64: Fix format warning with die()
9
10Fedora koji uses gcc version 7.0.1-0.12.fc27, and it generates a build
11warning
12
13 kexec/arch/i386/kexec-elf-x86.c:299:3: error: format not a string
14 literal and no format arguments [-Werror=format-security]
15 die(error_msg);
16 ^~~
17 cc1: some warnings being treated as errors
18
19error_msg can have a format specifier as well in string. In such cases,
20if there is no other arguments for the format variable then code will
21try to access a non existing argument. Therefore, use 1st argument as
22format specifier for string print and pass error_msg as the string to be
23printed.
24
25While doing that,also use const qualifier before "char *error_msg".
26
27Signed-off-by: Pratyush Anand <panand@redhat.com>
28Signed-off-by: Simon Horman <horms@verge.net.au>
29---
30 kexec/arch/i386/kexec-elf-x86.c | 4 ++--
31 kexec/arch/x86_64/kexec-elf-x86_64.c | 4 ++--
32 2 files changed, 4 insertions(+), 4 deletions(-)
33
34diff --git a/kexec/arch/i386/kexec-elf-x86.c b/kexec/arch/i386/kexec-elf-x86.c
35index de00dcb..fedf031 100644
36--- a/kexec/arch/i386/kexec-elf-x86.c
37+++ b/kexec/arch/i386/kexec-elf-x86.c
38@@ -91,7 +91,7 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
39 char *command_line = NULL, *modified_cmdline = NULL;
40 const char *append = NULL;
41 char *tmp_cmdline = NULL;
42- char *error_msg = NULL;
43+ const char *error_msg = NULL;
44 int result;
45 int command_line_len;
46 const char *ramdisk;
47@@ -296,6 +296,6 @@ out:
48 free(command_line);
49 free(modified_cmdline);
50 if (error_msg)
51- die(error_msg);
52+ die("%s", error_msg);
53 return result;
54 }
55diff --git a/kexec/arch/x86_64/kexec-elf-x86_64.c b/kexec/arch/x86_64/kexec-elf-x86_64.c
56index ae65692..ad22311 100644
57--- a/kexec/arch/x86_64/kexec-elf-x86_64.c
58+++ b/kexec/arch/x86_64/kexec-elf-x86_64.c
59@@ -99,7 +99,7 @@ int elf_x86_64_load(int argc, char **argv, const char *buf, off_t len,
60 #define ARG_STYLE_NONE 2
61 int opt;
62 int result = 0;
63- char *error_msg = NULL;
64+ const char *error_msg = NULL;
65
66 /* See options.h and add any new options there too! */
67 static const struct option options[] = {
68@@ -276,6 +276,6 @@ out:
69 free(command_line);
70 free(modified_cmdline);
71 if (error_msg)
72- die(error_msg);
73+ die("%s", error_msg);
74 return result;
75 }
76--
772.11.0
78
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0002-kexec-generalize-and-rename-get_kernel_stext_sym.patch b/meta/recipes-kernel/kexec/kexec-tools/0002-kexec-generalize-and-rename-get_kernel_stext_sym.patch
deleted file mode 100644
index 953f13bd0a..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0002-kexec-generalize-and-rename-get_kernel_stext_sym.patch
+++ /dev/null
@@ -1,194 +0,0 @@
1From d29f37bb6e9114aba96c606103b110f511bee9a1 Mon Sep 17 00:00:00 2001
2From: Pratyush Anand <panand@redhat.com>
3Date: Wed, 2 Nov 2016 15:05:25 +0530
4Subject: [PATCH 2/9] kexec: generalize and rename get_kernel_stext_sym()
5
6get_kernel_stext_sym() has been defined for both arm and i386. Other
7architecture might need some other kernel symbol address. Therefore rewrite
8this function as generic function to get any kernel symbol address.
9
10More over, kallsyms is not arch specific representation, therefore have
11common function for all arches.
12
13Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
14
15Signed-off-by: Pratyush Anand <panand@redhat.com>
16[created symbols.c]
17Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
18Signed-off-by: He Zhe <zhe.he@windriver.com>
19---
20 kexec/Makefile | 1 +
21 kexec/arch/arm/crashdump-arm.c | 40 +---------------------------------------
22 kexec/arch/i386/crashdump-x86.c | 29 -----------------------------
23 kexec/kexec.h | 2 ++
24 kexec/symbols.c | 41 +++++++++++++++++++++++++++++++++++++++++
25 5 files changed, 45 insertions(+), 68 deletions(-)
26 create mode 100644 kexec/symbols.c
27
28diff --git a/kexec/Makefile b/kexec/Makefile
29index 39f365f..2b4fb3d 100644
30--- a/kexec/Makefile
31+++ b/kexec/Makefile
32@@ -26,6 +26,7 @@ KEXEC_SRCS_base += kexec/kernel_version.c
33 KEXEC_SRCS_base += kexec/lzma.c
34 KEXEC_SRCS_base += kexec/zlib.c
35 KEXEC_SRCS_base += kexec/kexec-xen.c
36+KEXEC_SRCS_base += kexec/symbols.c
37
38 KEXEC_GENERATED_SRCS += $(PURGATORY_HEX_C)
39
40diff --git a/kexec/arch/arm/crashdump-arm.c b/kexec/arch/arm/crashdump-arm.c
41index 4a89b5e..245c21a 100644
42--- a/kexec/arch/arm/crashdump-arm.c
43+++ b/kexec/arch/arm/crashdump-arm.c
44@@ -73,48 +73,10 @@ static struct crash_elf_info elf_info = {
45
46 extern unsigned long long user_page_offset;
47
48-/* Retrieve kernel _stext symbol virtual address from /proc/kallsyms */
49-static unsigned long long get_kernel_stext_sym(void)
50-{
51- const char *kallsyms = "/proc/kallsyms";
52- const char *stext = "_stext";
53- char sym[128];
54- char line[128];
55- FILE *fp;
56- unsigned long long vaddr = 0;
57- char type;
58-
59- fp = fopen(kallsyms, "r");
60- if (!fp) {
61- fprintf(stderr, "Cannot open %s\n", kallsyms);
62- return 0;
63- }
64-
65- while(fgets(line, sizeof(line), fp) != NULL) {
66- unsigned long long addr;
67-
68- if (sscanf(line, "%Lx %c %s", &addr, &type, sym) != 3)
69- continue;
70-
71- if (strcmp(sym, stext) == 0) {
72- dbgprintf("kernel symbol %s vaddr = %#llx\n", stext, addr);
73- vaddr = addr;
74- break;
75- }
76- }
77-
78- fclose(fp);
79-
80- if (vaddr == 0)
81- fprintf(stderr, "Cannot get kernel %s symbol address\n", stext);
82-
83- return vaddr;
84-}
85-
86 static int get_kernel_page_offset(struct kexec_info *info,
87 struct crash_elf_info *elf_info)
88 {
89- unsigned long long stext_sym_addr = get_kernel_stext_sym();
90+ unsigned long long stext_sym_addr = get_kernel_sym("_stext");
91 if (stext_sym_addr == 0) {
92 if (user_page_offset != (-1ULL)) {
93 elf_info->page_offset = user_page_offset;
94diff --git a/kexec/arch/i386/crashdump-x86.c b/kexec/arch/i386/crashdump-x86.c
95index ab833d4..abf82a5 100644
96--- a/kexec/arch/i386/crashdump-x86.c
97+++ b/kexec/arch/i386/crashdump-x86.c
98@@ -102,35 +102,6 @@ static int get_kernel_paddr(struct kexec_info *UNUSED(info),
99 return -1;
100 }
101
102-/* Retrieve kernel symbol virtual address from /proc/kallsyms */
103-static unsigned long long get_kernel_sym(const char *symbol)
104-{
105- const char *kallsyms = "/proc/kallsyms";
106- char sym[128];
107- char line[128];
108- FILE *fp;
109- unsigned long long vaddr;
110- char type;
111-
112- fp = fopen(kallsyms, "r");
113- if (!fp) {
114- fprintf(stderr, "Cannot open %s\n", kallsyms);
115- return 0;
116- }
117-
118- while(fgets(line, sizeof(line), fp) != NULL) {
119- if (sscanf(line, "%Lx %c %s", &vaddr, &type, sym) != 3)
120- continue;
121- if (strcmp(sym, symbol) == 0) {
122- dbgprintf("kernel symbol %s vaddr = %16llx\n", symbol, vaddr);
123- return vaddr;
124- }
125- }
126-
127- fprintf(stderr, "Cannot get kernel %s symbol address\n", symbol);
128- return 0;
129-}
130-
131 /* Retrieve info regarding virtual address kernel has been compiled for and
132 * size of the kernel from /proc/kcore. Current /proc/kcore parsing from
133 * from kexec-tools fails because of malformed elf notes. A kernel patch has
134diff --git a/kexec/kexec.h b/kexec/kexec.h
135index 9194f1c..b4fafad 100644
136--- a/kexec/kexec.h
137+++ b/kexec/kexec.h
138@@ -312,4 +312,6 @@ int xen_kexec_load(struct kexec_info *info);
139 int xen_kexec_unload(uint64_t kexec_flags);
140 void xen_kexec_exec(void);
141
142+extern unsigned long long get_kernel_sym(const char *text);
143+
144 #endif /* KEXEC_H */
145diff --git a/kexec/symbols.c b/kexec/symbols.c
146new file mode 100644
147index 0000000..ea6e327
148--- /dev/null
149+++ b/kexec/symbols.c
150@@ -0,0 +1,41 @@
151+#include <stdio.h>
152+#include <string.h>
153+#include "kexec.h"
154+
155+/* Retrieve kernel symbol virtual address from /proc/kallsyms */
156+unsigned long long get_kernel_sym(const char *text)
157+{
158+ const char *kallsyms = "/proc/kallsyms";
159+ char sym[128];
160+ char line[128];
161+ FILE *fp;
162+ unsigned long long vaddr = 0;
163+ char type;
164+
165+ fp = fopen(kallsyms, "r");
166+ if (!fp) {
167+ fprintf(stderr, "Cannot open %s\n", kallsyms);
168+ return 0;
169+ }
170+
171+ while (fgets(line, sizeof(line), fp) != NULL) {
172+ unsigned long long addr;
173+
174+ if (sscanf(line, "%Lx %c %s", &addr, &type, sym) != 3)
175+ continue;
176+
177+ if (strcmp(sym, text) == 0) {
178+ dbgprintf("kernel symbol %s vaddr = %#llx\n",
179+ text, addr);
180+ vaddr = addr;
181+ break;
182+ }
183+ }
184+
185+ fclose(fp);
186+
187+ if (vaddr == 0)
188+ fprintf(stderr, "Cannot get kernel %s symbol address\n", text);
189+
190+ return vaddr;
191+}
192--
1931.9.1
194
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0002-ppc-Fix-format-warning-with-die.patch b/meta/recipes-kernel/kexec/kexec-tools/0002-ppc-Fix-format-warning-with-die.patch
deleted file mode 100644
index 6a1c06df99..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0002-ppc-Fix-format-warning-with-die.patch
+++ /dev/null
@@ -1,43 +0,0 @@
1From 1c956fc8c6b6324d8d38bba5f9e60a018051c6f5 Mon Sep 17 00:00:00 2001
2From: Jussi Kukkonen <jussi.kukkonen@intel.com>
3Date: Thu, 16 Mar 2017 15:39:06 +0200
4Subject: [PATCH 2/2] ppc: Fix format warning with die()
5
6Enable compiling kexec-tools for ppc with -Werror=format-security.
7
8Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
9Upstream-Status: Submitted [Mailing list]
10---
11 kexec/arch/ppc/kexec-elf-ppc.c | 2 +-
12 kexec/arch/ppc/kexec-uImage-ppc.c | 2 +-
13 2 files changed, 2 insertions(+), 2 deletions(-)
14
15diff --git a/kexec/arch/ppc/kexec-elf-ppc.c b/kexec/arch/ppc/kexec-elf-ppc.c
16index 291f06d..ad43ad1 100644
17--- a/kexec/arch/ppc/kexec-elf-ppc.c
18+++ b/kexec/arch/ppc/kexec-elf-ppc.c
19@@ -453,7 +453,7 @@ out:
20 if (!tmp_cmdline)
21 free(command_line);
22 if (error_msg)
23- die(error_msg);
24+ die("%s", error_msg);
25
26 return result;
27 }
28diff --git a/kexec/arch/ppc/kexec-uImage-ppc.c b/kexec/arch/ppc/kexec-uImage-ppc.c
29index 5eec6e4..e8f7adc 100644
30--- a/kexec/arch/ppc/kexec-uImage-ppc.c
31+++ b/kexec/arch/ppc/kexec-uImage-ppc.c
32@@ -306,7 +306,7 @@ out:
33 if (!tmp_cmdline)
34 free(command_line);
35 if (error_msg)
36- die(error_msg);
37+ die("%s", error_msg);
38 return ret;
39 }
40
41--
422.11.0
43
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0003-arm64-identify-PHYS_OFFSET-correctly.patch b/meta/recipes-kernel/kexec/kexec-tools/0003-arm64-identify-PHYS_OFFSET-correctly.patch
deleted file mode 100644
index 1a1c317436..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0003-arm64-identify-PHYS_OFFSET-correctly.patch
+++ /dev/null
@@ -1,76 +0,0 @@
1From 16df170ad4808d12acd5e919ac4f6e7f33a247b3 Mon Sep 17 00:00:00 2001
2From: AKASHI Takahiro <takahiro.akashi@linaro.org>
3Date: Thu, 1 Sep 2016 10:57:42 +0900
4Subject: [PATCH 3/9] arm64: identify PHYS_OFFSET correctly
5
6Due to the kernel patch, commit e7cd190385d1 ("arm64: mark reserved
7memblock regions explicitly in iomem"), the current code will not be able
8to identify the correct value of PHYS_OFFSET if some "reserved" memory
9region, which is likely to be UEFI runtime services code/data, exists at
10an address below the first "System RAM" regions.
11
12This patch fixes this issue.
13
14Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
15
16Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
17Signed-off-by: He Zhe <zhe.he@windriver.com>
18---
19 kexec/arch/arm64/iomem.h | 7 +++++++
20 kexec/arch/arm64/kexec-arm64.c | 12 ++++++++++--
21 2 files changed, 17 insertions(+), 2 deletions(-)
22 create mode 100644 kexec/arch/arm64/iomem.h
23
24diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h
25new file mode 100644
26index 0000000..7fd66eb
27--- /dev/null
28+++ b/kexec/arch/arm64/iomem.h
29@@ -0,0 +1,7 @@
30+#ifndef IOMEM_H
31+#define IOMEM_H
32+
33+#define SYSTEM_RAM "System RAM\n"
34+#define IOMEM_RESERVED "reserved\n"
35+
36+#endif
37diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
38index 2e8839a..8ac811d 100644
39--- a/kexec/arch/arm64/kexec-arm64.c
40+++ b/kexec/arch/arm64/kexec-arm64.c
41@@ -21,6 +21,7 @@
42 #include "crashdump-arm64.h"
43 #include "dt-ops.h"
44 #include "fs2dt.h"
45+#include "iomem.h"
46 #include "kexec-syscall.h"
47 #include "arch/options.h"
48
49@@ -475,7 +476,14 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
50 return -1;
51
52 r = (struct memory_range *)data + nr;
53- r->type = RANGE_RAM;
54+
55+ if (!strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)))
56+ r->type = RANGE_RAM;
57+ else if (!strncmp(str, IOMEM_RESERVED, strlen(IOMEM_RESERVED)))
58+ r->type = RANGE_RESERVED;
59+ else
60+ return 1;
61+
62 r->start = base;
63 r->end = base + length - 1;
64
65@@ -494,7 +502,7 @@ static int get_memory_ranges_iomem_cb(void *data, int nr, char *str,
66 static int get_memory_ranges_iomem(struct memory_range *array,
67 unsigned int *count)
68 {
69- *count = kexec_iomem_for_each_line("System RAM\n",
70+ *count = kexec_iomem_for_each_line(NULL,
71 get_memory_ranges_iomem_cb, array);
72
73 if (!*count) {
74--
751.9.1
76
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0004-arm64-kdump-identify-memory-regions.patch b/meta/recipes-kernel/kexec/kexec-tools/0004-arm64-kdump-identify-memory-regions.patch
deleted file mode 100644
index 66600f3070..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0004-arm64-kdump-identify-memory-regions.patch
+++ /dev/null
@@ -1,202 +0,0 @@
1From 48a4c7874d8264ddbfaec2e9858d7866a2d2eb60 Mon Sep 17 00:00:00 2001
2From: AKASHI Takahiro <takahiro.akashi@linaro.org>
3Date: Wed, 5 Aug 2015 13:16:30 +0900
4Subject: [PATCH 4/9] arm64: kdump: identify memory regions
5
6The following regions need to be identified for later use:
7 a) memory regions which belong to the 1st kernel
8 b) usable memory reserved for crash dump kernel
9
10We go through /proc/iomem to find out a) and b) which are marked
11as "System RAM" and "Crash kernel", respectively.
12
13Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
14
15Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
16Signed-off-by: He Zhe <zhe.he@windriver.com>
17---
18 kexec/arch/arm64/Makefile | 2 +
19 kexec/arch/arm64/crashdump-arm64.c | 100 ++++++++++++++++++++++++++++++++++++-
20 kexec/arch/arm64/crashdump-arm64.h | 14 +++++-
21 kexec/arch/arm64/iomem.h | 1 +
22 4 files changed, 114 insertions(+), 3 deletions(-)
23
24diff --git a/kexec/arch/arm64/Makefile b/kexec/arch/arm64/Makefile
25index 74b677f..2d4ae0e 100644
26--- a/kexec/arch/arm64/Makefile
27+++ b/kexec/arch/arm64/Makefile
28@@ -6,6 +6,8 @@ arm64_FS2DT_INCLUDE += \
29
30 arm64_DT_OPS += kexec/dt-ops.c
31
32+arm64_MEM_REGIONS = kexec/mem_regions.c
33+
34 arm64_CPPFLAGS += -I $(srcdir)/kexec/
35
36 arm64_KEXEC_SRCS += \
37diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
38index d2272c8..dcaca43 100644
39--- a/kexec/arch/arm64/crashdump-arm64.c
40+++ b/kexec/arch/arm64/crashdump-arm64.c
41@@ -1,5 +1,13 @@
42 /*
43 * ARM64 crashdump.
44+ * partly derived from arm implementation
45+ *
46+ * Copyright (c) 2014-2016 Linaro Limited
47+ * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
48+ *
49+ * This program is free software; you can redistribute it and/or modify
50+ * it under the terms of the GNU General Public License version 2 as
51+ * published by the Free Software Foundation.
52 */
53
54 #define _GNU_SOURCE
55@@ -10,12 +18,102 @@
56 #include "kexec.h"
57 #include "crashdump.h"
58 #include "crashdump-arm64.h"
59+#include "iomem.h"
60 #include "kexec-arm64.h"
61 #include "kexec-elf.h"
62+#include "mem_regions.h"
63
64-struct memory_ranges usablemem_rgns = {};
65+/* memory ranges on crashed kernel */
66+static struct memory_range crash_memory_ranges[CRASH_MAX_MEMORY_RANGES];
67+static struct memory_ranges crash_memory_rgns = {
68+ .size = 0,
69+ .max_size = CRASH_MAX_MEMORY_RANGES,
70+ .ranges = crash_memory_ranges,
71+};
72+
73+/* memory range reserved for crashkernel */
74+struct memory_range crash_reserved_mem;
75+struct memory_ranges usablemem_rgns = {
76+ .size = 0,
77+ .max_size = 1,
78+ .ranges = &crash_reserved_mem,
79+};
80+
81+/*
82+ * iomem_range_callback() - callback called for each iomem region
83+ * @data: not used
84+ * @nr: not used
85+ * @str: name of the memory region
86+ * @base: start address of the memory region
87+ * @length: size of the memory region
88+ *
89+ * This function is called once for each memory region found in /proc/iomem.
90+ * It locates system RAM and crashkernel reserved memory and places these to
91+ * variables, respectively, crash_memory_ranges and crash_reserved_mem.
92+ */
93+
94+static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
95+ char *str, unsigned long long base,
96+ unsigned long long length)
97+{
98+ if (strncmp(str, CRASH_KERNEL, strlen(CRASH_KERNEL)) == 0)
99+ return mem_regions_add(&usablemem_rgns,
100+ base, length, RANGE_RAM);
101+ else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0)
102+ return mem_regions_add(&crash_memory_rgns,
103+ base, length, RANGE_RAM);
104+
105+ return 0;
106+}
107
108 int is_crashkernel_mem_reserved(void)
109 {
110+ if (!crash_reserved_mem.end)
111+ kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL);
112+
113+ return crash_reserved_mem.start != crash_reserved_mem.end;
114+}
115+
116+/*
117+ * crash_get_memory_ranges() - read system physical memory
118+ *
119+ * Function reads through system physical memory and stores found memory
120+ * regions in crash_memory_ranges.
121+ * Regions are sorted in ascending order.
122+ *
123+ * Returns 0 in case of success and -1 otherwise (errno is set).
124+ */
125+static int crash_get_memory_ranges(void)
126+{
127+ /*
128+ * First read all memory regions that can be considered as
129+ * system memory including the crash area.
130+ */
131+ if (!usablemem_rgns.size)
132+ kexec_iomem_for_each_line(NULL, iomem_range_callback, NULL);
133+
134+ /* allow only a single region for crash dump kernel */
135+ if (usablemem_rgns.size != 1) {
136+ errno = EINVAL;
137+ return -1;
138+ }
139+
140+ dbgprint_mem_range("Reserved memory range", &crash_reserved_mem, 1);
141+
142+ if (mem_regions_exclude(&crash_memory_rgns, &crash_reserved_mem)) {
143+ fprintf(stderr,
144+ "Error: Number of crash memory ranges excedeed the max limit\n");
145+ errno = ENOMEM;
146+ return -1;
147+ }
148+
149+ /*
150+ * Make sure that the memory regions are sorted.
151+ */
152+ mem_regions_sort(&crash_memory_rgns);
153+
154+ dbgprint_mem_range("Coredump memory ranges",
155+ crash_memory_rgns.ranges, crash_memory_rgns.size);
156+
157 return 0;
158 }
159diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h
160index f33c7a2..07a0ed0 100644
161--- a/kexec/arch/arm64/crashdump-arm64.h
162+++ b/kexec/arch/arm64/crashdump-arm64.h
163@@ -1,12 +1,22 @@
164 /*
165 * ARM64 crashdump.
166+ *
167+ * Copyright (c) 2014-2016 Linaro Limited
168+ * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
169+ *
170+ * This program is free software; you can redistribute it and/or modify
171+ * it under the terms of the GNU General Public License version 2 as
172+ * published by the Free Software Foundation.
173 */
174
175-#if !defined(CRASHDUMP_ARM64_H)
176+#ifndef CRASHDUMP_ARM64_H
177 #define CRASHDUMP_ARM64_H
178
179 #include "kexec.h"
180
181+#define CRASH_MAX_MEMORY_RANGES 32
182+
183 extern struct memory_ranges usablemem_rgns;
184+extern struct memory_range crash_reserved_mem;
185
186-#endif
187+#endif /* CRASHDUMP_ARM64_H */
188diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h
189index 7fd66eb..20cda87 100644
190--- a/kexec/arch/arm64/iomem.h
191+++ b/kexec/arch/arm64/iomem.h
192@@ -2,6 +2,7 @@
193 #define IOMEM_H
194
195 #define SYSTEM_RAM "System RAM\n"
196+#define CRASH_KERNEL "Crash kernel\n"
197 #define IOMEM_RESERVED "reserved\n"
198
199 #endif
200--
2011.9.1
202
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0005-arm64-kdump-add-elf-core-header-segment.patch b/meta/recipes-kernel/kexec/kexec-tools/0005-arm64-kdump-add-elf-core-header-segment.patch
deleted file mode 100644
index fe535b6070..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0005-arm64-kdump-add-elf-core-header-segment.patch
+++ /dev/null
@@ -1,191 +0,0 @@
1From 769da25627cebb2a53caee5d5be78a32d376adc1 Mon Sep 17 00:00:00 2001
2From: AKASHI Takahiro <takahiro.akashi@linaro.org>
3Date: Wed, 5 Aug 2015 13:45:15 +0900
4Subject: [PATCH 5/9] arm64: kdump: add elf core header segment
5
6Elf core header contains the information necessary for the coredump of
7the 1st kernel, including its physcal memory layout as well as cpu register
8states at the panic.
9The segment is allocated inside the reserved memory of crash dump kernel.
10
11Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
12
13Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
14Signed-off-by: He Zhe <zhe.he@windriver.com>
15---
16 kexec/arch/arm64/crashdump-arm64.c | 96 ++++++++++++++++++++++++++++++++++++++
17 kexec/arch/arm64/crashdump-arm64.h | 3 ++
18 kexec/arch/arm64/iomem.h | 2 +
19 kexec/arch/arm64/kexec-elf-arm64.c | 10 ++++
20 4 files changed, 111 insertions(+)
21
22diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
23index dcaca43..8346131 100644
24--- a/kexec/arch/arm64/crashdump-arm64.c
25+++ b/kexec/arch/arm64/crashdump-arm64.c
26@@ -39,6 +39,39 @@ struct memory_ranges usablemem_rgns = {
27 .ranges = &crash_reserved_mem,
28 };
29
30+struct memory_range elfcorehdr_mem;
31+
32+static struct crash_elf_info elf_info = {
33+ .class = ELFCLASS64,
34+#if (__BYTE_ORDER == __LITTLE_ENDIAN)
35+ .data = ELFDATA2LSB,
36+#else
37+ .data = ELFDATA2MSB,
38+#endif
39+ .machine = EM_AARCH64,
40+};
41+
42+/*
43+ * Note: The returned value is correct only if !CONFIG_RANDOMIZE_BASE.
44+ */
45+static uint64_t get_kernel_page_offset(void)
46+{
47+ int i;
48+
49+ if (elf_info.kern_vaddr_start == UINT64_MAX)
50+ return UINT64_MAX;
51+
52+ /* Current max virtual memory range is 48-bits. */
53+ for (i = 48; i > 0; i--)
54+ if (!(elf_info.kern_vaddr_start & (1UL << i)))
55+ break;
56+
57+ if (i <= 0)
58+ return UINT64_MAX;
59+ else
60+ return UINT64_MAX << i;
61+}
62+
63 /*
64 * iomem_range_callback() - callback called for each iomem region
65 * @data: not used
66@@ -62,6 +95,10 @@ static int iomem_range_callback(void *UNUSED(data), int UNUSED(nr),
67 else if (strncmp(str, SYSTEM_RAM, strlen(SYSTEM_RAM)) == 0)
68 return mem_regions_add(&crash_memory_rgns,
69 base, length, RANGE_RAM);
70+ else if (strncmp(str, KERNEL_CODE, strlen(KERNEL_CODE)) == 0)
71+ elf_info.kern_paddr_start = base;
72+ else if (strncmp(str, KERNEL_DATA, strlen(KERNEL_DATA)) == 0)
73+ elf_info.kern_size = base + length - elf_info.kern_paddr_start;
74
75 return 0;
76 }
77@@ -115,5 +152,64 @@ static int crash_get_memory_ranges(void)
78 dbgprint_mem_range("Coredump memory ranges",
79 crash_memory_rgns.ranges, crash_memory_rgns.size);
80
81+ /*
82+ * For additional kernel code/data segment.
83+ * kern_paddr_start/kern_size are determined in iomem_range_callback
84+ */
85+ elf_info.kern_vaddr_start = get_kernel_sym("_text");
86+ if (!elf_info.kern_vaddr_start)
87+ elf_info.kern_vaddr_start = UINT64_MAX;
88+
89+ return 0;
90+}
91+
92+/*
93+ * load_crashdump_segments() - load the elf core header
94+ * @info: kexec info structure
95+ *
96+ * This function creates and loads an additional segment of elf core header
97+ : which is used to construct /proc/vmcore on crash dump kernel.
98+ *
99+ * Return 0 in case of success and -1 in case of error.
100+ */
101+
102+int load_crashdump_segments(struct kexec_info *info)
103+{
104+ unsigned long elfcorehdr;
105+ unsigned long bufsz;
106+ void *buf;
107+ int err;
108+
109+ /*
110+ * First fetch all the memory (RAM) ranges that we are going to
111+ * pass to the crash dump kernel during panic.
112+ */
113+
114+ err = crash_get_memory_ranges();
115+
116+ if (err)
117+ return err;
118+
119+ elf_info.page_offset = get_kernel_page_offset();
120+ dbgprintf("%s: page_offset: %016llx\n", __func__,
121+ elf_info.page_offset);
122+
123+ err = crash_create_elf64_headers(info, &elf_info,
124+ crash_memory_rgns.ranges, crash_memory_rgns.size,
125+ &buf, &bufsz, ELF_CORE_HEADER_ALIGN);
126+
127+ if (err)
128+ return err;
129+
130+ elfcorehdr = add_buffer_phys_virt(info, buf, bufsz, bufsz, 0,
131+ crash_reserved_mem.start, crash_reserved_mem.end,
132+ -1, 0);
133+
134+ elfcorehdr_mem.start = elfcorehdr;
135+ elfcorehdr_mem.end = elfcorehdr + bufsz - 1;
136+
137+ dbgprintf("%s: elfcorehdr 0x%llx-0x%llx\n", __func__,
138+ elfcorehdr_mem.start, elfcorehdr_mem.end);
139+
140 return 0;
141 }
142diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h
143index 07a0ed0..da75a2d 100644
144--- a/kexec/arch/arm64/crashdump-arm64.h
145+++ b/kexec/arch/arm64/crashdump-arm64.h
146@@ -18,5 +18,8 @@
147
148 extern struct memory_ranges usablemem_rgns;
149 extern struct memory_range crash_reserved_mem;
150+extern struct memory_range elfcorehdr_mem;
151+
152+extern int load_crashdump_segments(struct kexec_info *info);
153
154 #endif /* CRASHDUMP_ARM64_H */
155diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h
156index 20cda87..d4864bb 100644
157--- a/kexec/arch/arm64/iomem.h
158+++ b/kexec/arch/arm64/iomem.h
159@@ -2,6 +2,8 @@
160 #define IOMEM_H
161
162 #define SYSTEM_RAM "System RAM\n"
163+#define KERNEL_CODE "Kernel code\n"
164+#define KERNEL_DATA "Kernel data\n"
165 #define CRASH_KERNEL "Crash kernel\n"
166 #define IOMEM_RESERVED "reserved\n"
167
168diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c
169index daf8bf0..c70a37a 100644
170--- a/kexec/arch/arm64/kexec-elf-arm64.c
171+++ b/kexec/arch/arm64/kexec-elf-arm64.c
172@@ -119,6 +119,16 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
173 dbgprintf("%s: PE format: %s\n", __func__,
174 (arm64_header_check_pe_sig(header) ? "yes" : "no"));
175
176+ if (info->kexec_flags & KEXEC_ON_CRASH) {
177+ /* create and initialize elf core header segment */
178+ result = load_crashdump_segments(info);
179+ if (result) {
180+ dbgprintf("%s: Creating eflcorehdr failed.\n",
181+ __func__);
182+ goto exit;
183+ }
184+ }
185+
186 /* load the kernel */
187 result = elf_exec_load(&ehdr, info);
188
189--
1901.9.1
191
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0006-arm64-kdump-set-up-kernel-image-segment.patch b/meta/recipes-kernel/kexec/kexec-tools/0006-arm64-kdump-set-up-kernel-image-segment.patch
deleted file mode 100644
index 414955107a..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0006-arm64-kdump-set-up-kernel-image-segment.patch
+++ /dev/null
@@ -1,137 +0,0 @@
1From 4079c93ac5453ef5f7889ab64920c1e9427690ef Mon Sep 17 00:00:00 2001
2From: AKASHI Takahiro <takahiro.akashi@linaro.org>
3Date: Tue, 17 Feb 2015 16:06:55 +0900
4Subject: [PATCH 6/9] arm64: kdump: set up kernel image segment
5
6On arm64, we can use the same kernel image as 1st kernel, but
7we have to modify the entry point as well as segments' addresses
8in the kernel's elf header in order to load them into correct places.
9
10Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
11
12Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
13Signed-off-by: He Zhe <zhe.he@windriver.com>
14---
15 kexec/arch/arm64/crashdump-arm64.c | 23 +++++++++++++++++++++++
16 kexec/arch/arm64/crashdump-arm64.h | 1 +
17 kexec/arch/arm64/kexec-arm64.c | 25 ++++++++++++++++++++-----
18 kexec/arch/arm64/kexec-elf-arm64.c | 10 +++++++++-
19 4 files changed, 53 insertions(+), 6 deletions(-)
20
21diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c
22index 8346131..9517329 100644
23--- a/kexec/arch/arm64/crashdump-arm64.c
24+++ b/kexec/arch/arm64/crashdump-arm64.c
25@@ -213,3 +213,26 @@ int load_crashdump_segments(struct kexec_info *info)
26
27 return 0;
28 }
29+
30+/*
31+ * e_entry and p_paddr are actually in virtual address space.
32+ * Those values will be translated to physcal addresses by
33+ * using virt_to_phys().
34+ * So let's get ready for later use so the memory base (phys_offset)
35+ * will be correctly replaced with crash_reserved_mem.start.
36+ */
37+void modify_ehdr_for_crashdump(struct mem_ehdr *ehdr)
38+{
39+ struct mem_phdr *phdr;
40+ int i;
41+
42+ ehdr->e_entry += - arm64_mem.phys_offset + crash_reserved_mem.start;
43+
44+ for (i = 0; i < ehdr->e_phnum; i++) {
45+ phdr = &ehdr->e_phdr[i];
46+ if (phdr->p_type != PT_LOAD)
47+ continue;
48+ phdr->p_paddr +=
49+ (-arm64_mem.phys_offset + crash_reserved_mem.start);
50+ }
51+}
52diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h
53index da75a2d..382f571 100644
54--- a/kexec/arch/arm64/crashdump-arm64.h
55+++ b/kexec/arch/arm64/crashdump-arm64.h
56@@ -21,5 +21,6 @@ extern struct memory_range crash_reserved_mem;
57 extern struct memory_range elfcorehdr_mem;
58
59 extern int load_crashdump_segments(struct kexec_info *info);
60+extern void modify_ehdr_for_crashdump(struct mem_ehdr *ehdr);
61
62 #endif /* CRASHDUMP_ARM64_H */
63diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
64index 8ac811d..cec4e41 100644
65--- a/kexec/arch/arm64/kexec-arm64.c
66+++ b/kexec/arch/arm64/kexec-arm64.c
67@@ -307,12 +307,27 @@ unsigned long arm64_locate_kernel_segment(struct kexec_info *info)
68 {
69 unsigned long hole;
70
71- hole = locate_hole(info,
72- arm64_mem.text_offset + arm64_mem.image_size,
73- MiB(2), 0, ULONG_MAX, 1);
74+ if (info->kexec_flags & KEXEC_ON_CRASH) {
75+ unsigned long hole_end;
76+
77+ hole = (crash_reserved_mem.start < mem_min ?
78+ mem_min : crash_reserved_mem.start);
79+ hole = _ALIGN_UP(hole, MiB(2));
80+ hole_end = hole + arm64_mem.text_offset + arm64_mem.image_size;
81+
82+ if ((hole_end > mem_max) ||
83+ (hole_end > crash_reserved_mem.end)) {
84+ dbgprintf("%s: Crash kernel out of range\n", __func__);
85+ hole = ULONG_MAX;
86+ }
87+ } else {
88+ hole = locate_hole(info,
89+ arm64_mem.text_offset + arm64_mem.image_size,
90+ MiB(2), 0, ULONG_MAX, 1);
91
92- if (hole == ULONG_MAX)
93- dbgprintf("%s: locate_hole failed\n", __func__);
94+ if (hole == ULONG_MAX)
95+ dbgprintf("%s: locate_hole failed\n", __func__);
96+ }
97
98 return hole;
99 }
100diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c
101index c70a37a..842ce21 100644
102--- a/kexec/arch/arm64/kexec-elf-arm64.c
103+++ b/kexec/arch/arm64/kexec-elf-arm64.c
104@@ -9,6 +9,7 @@
105 #include <stdlib.h>
106 #include <linux/elf.h>
107
108+#include "crashdump-arm64.h"
109 #include "kexec-arm64.h"
110 #include "kexec-elf.h"
111 #include "kexec-syscall.h"
112@@ -105,7 +106,8 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
113 }
114
115 arm64_mem.vp_offset = _ALIGN_DOWN(ehdr.e_entry, MiB(2));
116- arm64_mem.vp_offset -= kernel_segment - get_phys_offset();
117+ if (!(info->kexec_flags & KEXEC_ON_CRASH))
118+ arm64_mem.vp_offset -= kernel_segment - get_phys_offset();
119
120 dbgprintf("%s: kernel_segment: %016lx\n", __func__, kernel_segment);
121 dbgprintf("%s: text_offset: %016lx\n", __func__,
122@@ -127,6 +129,12 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
123 __func__);
124 goto exit;
125 }
126+
127+ /*
128+ * offset addresses in order to fit vmlinux
129+ * (elf_exec) into crash kernel's memory
130+ */
131+ modify_ehdr_for_crashdump(&ehdr);
132 }
133
134 /* load the kernel */
135--
1361.9.1
137
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0007-arm64-kdump-set-up-other-segments.patch b/meta/recipes-kernel/kexec/kexec-tools/0007-arm64-kdump-set-up-other-segments.patch
deleted file mode 100644
index 2745466dbe..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0007-arm64-kdump-set-up-other-segments.patch
+++ /dev/null
@@ -1,35 +0,0 @@
1From 07ad14e12665221d754fde8e47c32ac18c24586a Mon Sep 17 00:00:00 2001
2From: AKASHI Takahiro <takahiro.akashi@linaro.org>
3Date: Fri, 31 Jul 2015 20:01:39 +0900
4Subject: [PATCH 7/9] arm64: kdump: set up other segments
5
6We make sure that all the other segments, initrd and device-tree blob,
7also be loaded into the reserved memory of crash dump kernel.
8
9Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
10
11Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
12Signed-off-by: He Zhe <zhe.he@windriver.com>
13---
14 kexec/arch/arm64/kexec-arm64.c | 5 ++++-
15 1 file changed, 4 insertions(+), 1 deletion(-)
16
17diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
18index cec4e41..78a0035 100644
19--- a/kexec/arch/arm64/kexec-arm64.c
20+++ b/kexec/arch/arm64/kexec-arm64.c
21@@ -374,7 +374,10 @@ int arm64_load_other_segments(struct kexec_info *info,
22 /* Put the other segments after the image. */
23
24 hole_min = image_base + arm64_mem.image_size;
25- hole_max = ULONG_MAX;
26+ if (info->kexec_flags & KEXEC_ON_CRASH)
27+ hole_max = crash_reserved_mem.end;
28+ else
29+ hole_max = ULONG_MAX;
30
31 if (arm64_opts.initrd) {
32 initrd_buf = slurp_file(arm64_opts.initrd, &initrd_size);
33--
341.9.1
35
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0008-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch b/meta/recipes-kernel/kexec/kexec-tools/0008-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch
deleted file mode 100644
index 31c3d8510a..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0008-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch
+++ /dev/null
@@ -1,150 +0,0 @@
1From 23bf7ac189cc3b87ceb9d1d3b69b5c4815354add Mon Sep 17 00:00:00 2001
2From: AKASHI Takahiro <takahiro.akashi@linaro.org>
3Date: Wed, 27 Jan 2016 13:38:39 +0900
4Subject: [PATCH 8/9] arm64: kdump: add DT properties to crash dump kernel's
5 dtb
6
7We pass the following properties to crash dump kernel:
8linux,elfcorehdr: elf core header segment,
9 same as "elfcorehdr=" kernel parameter on other archs
10linux,usable-memory-range: usable memory reserved for crash dump kernel
11
12Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
13
14Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
15Signed-off-by: He Zhe <zhe.he@windriver.com>
16---
17 kexec/arch/arm64/kexec-arm64.c | 76 +++++++++++++++++++++++++++++++++++---
18 kexec/arch/arm64/kexec-elf-arm64.c | 5 ---
19 2 files changed, 71 insertions(+), 10 deletions(-)
20
21diff --git a/kexec/arch/arm64/kexec-arm64.c b/kexec/arch/arm64/kexec-arm64.c
22index 78a0035..a8fb64f 100644
23--- a/kexec/arch/arm64/kexec-arm64.c
24+++ b/kexec/arch/arm64/kexec-arm64.c
25@@ -128,9 +128,6 @@ int arch_process_options(int argc, char **argv)
26 case OPT_INITRD:
27 arm64_opts.initrd = optarg;
28 break;
29- case OPT_PANIC:
30- die("load-panic (-p) not supported");
31- break;
32 default:
33 break; /* Ignore core and unknown options. */
34 }
35@@ -285,8 +282,12 @@ on_success:
36 * setup_2nd_dtb - Setup the 2nd stage kernel's dtb.
37 */
38
39-static int setup_2nd_dtb(struct dtb *dtb, char *command_line)
40+static int setup_2nd_dtb(struct dtb *dtb, char *command_line, int on_crash)
41 {
42+ char *new_buf;
43+ int new_size;
44+ int nodeoffset;
45+ uint64_t range[2];
46 int result;
47
48 result = fdt_check_header(dtb->buf);
49@@ -298,8 +299,72 @@ static int setup_2nd_dtb(struct dtb *dtb, char *command_line)
50
51 result = set_bootargs(dtb, command_line);
52
53+ /* remove those anyway */
54+ nodeoffset = fdt_path_offset(dtb->buf, "/chosen");
55+ fdt_delprop(dtb->buf, nodeoffset, "linux,crashkernel-base");
56+ fdt_delprop(dtb->buf, nodeoffset, "linux,crashkernel-size");
57+
58+ if (on_crash) {
59+ nodeoffset = fdt_path_offset(dtb->buf, "/chosen");
60+ fdt_delprop(dtb->buf, nodeoffset, "linux,elfcorehdr");
61+ fdt_delprop(dtb->buf, nodeoffset, "linux,usable-memory-range");
62+ new_size = fdt_totalsize(dtb->buf)
63+ + 2 * (sizeof(struct fdt_property)
64+ + FDT_TAGALIGN(sizeof(range)))
65+ + strlen("linux,elfcorehdr") + 1
66+ + strlen("linux,usable-memory-range") + 1;
67+
68+ new_buf = xmalloc(new_size);
69+ result = fdt_open_into(dtb->buf, new_buf, new_size);
70+ if (result) {
71+ dbgprintf("%s: fdt_open_into failed: %s\n", __func__,
72+ fdt_strerror(result));
73+ result = -ENOSPC;
74+ goto on_error;
75+ }
76+
77+ range[0] = cpu_to_be64(elfcorehdr_mem.start);
78+ range[1] = cpu_to_be64(elfcorehdr_mem.end
79+ - elfcorehdr_mem.start + 1);
80+ nodeoffset = fdt_path_offset(new_buf, "/chosen");
81+ result = fdt_setprop(new_buf, nodeoffset, "linux,elfcorehdr",
82+ (void *)range, sizeof(range));
83+ if (result) {
84+ dbgprintf("%s: fdt_setprop failed: %s\n", __func__,
85+ fdt_strerror(result));
86+ result = -EINVAL;
87+ goto on_error;
88+ }
89+
90+ range[0] = cpu_to_be64(crash_reserved_mem.start);
91+ range[1] = cpu_to_be64(crash_reserved_mem.end
92+ - crash_reserved_mem.start + 1);
93+ nodeoffset = fdt_path_offset(new_buf, "/chosen");
94+ result = fdt_setprop(new_buf, nodeoffset,
95+ "linux,usable-memory-range",
96+ (void *)range, sizeof(range));
97+ if (result) {
98+ dbgprintf("%s: fdt_setprop failed: %s\n", __func__,
99+ fdt_strerror(result));
100+ result = -EINVAL;
101+ goto on_error;
102+ }
103+
104+ fdt_pack(new_buf);
105+ dtb->buf = new_buf;
106+ dtb->size = fdt_totalsize(new_buf);
107+ }
108+
109 dump_reservemap(dtb);
110
111+
112+ return result;
113+
114+on_error:
115+ fprintf(stderr, "kexec: %s failed.\n", __func__);
116+ if (new_buf)
117+ free(new_buf);
118+
119 return result;
120 }
121
122@@ -366,7 +431,8 @@ int arm64_load_other_segments(struct kexec_info *info,
123 }
124 }
125
126- result = setup_2nd_dtb(&dtb, command_line);
127+ result = setup_2nd_dtb(&dtb, command_line,
128+ info->kexec_flags & KEXEC_ON_CRASH);
129
130 if (result)
131 return -EFAILED;
132diff --git a/kexec/arch/arm64/kexec-elf-arm64.c b/kexec/arch/arm64/kexec-elf-arm64.c
133index 842ce21..b17a31a 100644
134--- a/kexec/arch/arm64/kexec-elf-arm64.c
135+++ b/kexec/arch/arm64/kexec-elf-arm64.c
136@@ -47,11 +47,6 @@ int elf_arm64_load(int argc, char **argv, const char *kernel_buf,
137 int result;
138 int i;
139
140- if (info->kexec_flags & KEXEC_ON_CRASH) {
141- fprintf(stderr, "kexec: kdump not yet supported on arm64\n");
142- return -EFAILED;
143- }
144-
145 result = build_elf_exec_info(kernel_buf, kernel_size, &ehdr, 0);
146
147 if (result < 0) {
148--
1491.9.1
150
diff --git a/meta/recipes-kernel/kexec/kexec-tools/0009-arm64-kdump-Add-support-for-binary-image-files.patch b/meta/recipes-kernel/kexec/kexec-tools/0009-arm64-kdump-Add-support-for-binary-image-files.patch
deleted file mode 100644
index 8b1c0183e0..0000000000
--- a/meta/recipes-kernel/kexec/kexec-tools/0009-arm64-kdump-Add-support-for-binary-image-files.patch
+++ /dev/null
@@ -1,52 +0,0 @@
1From 5a4958f01a793c3e7f440f5bae75666a4349cc50 Mon Sep 17 00:00:00 2001
2From: Pratyush Anand <panand@redhat.com>
3Date: Thu, 14 May 2015 11:25:37 +0530
4Subject: [PATCH 9/9] arm64: kdump: Add support for binary image files
5
6This patch adds support to use binary image ie arch/arm64/boot/Image with
7kdump.
8
9Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git]
10
11Signed-off-by: Pratyush Anand <panand@redhat.com>
12[takahiro.akashi@linaro.org: a bit reworked]
13Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
14Signed-off-by: He Zhe <zhe.he@windriver.com>
15---
16 kexec/arch/arm64/kexec-image-arm64.c | 12 ++++++++++++
17 1 file changed, 12 insertions(+)
18
19diff --git a/kexec/arch/arm64/kexec-image-arm64.c b/kexec/arch/arm64/kexec-image-arm64.c
20index 960ed96..982e431 100644
21--- a/kexec/arch/arm64/kexec-image-arm64.c
22+++ b/kexec/arch/arm64/kexec-image-arm64.c
23@@ -4,7 +4,9 @@
24
25 #define _GNU_SOURCE
26
27+#include "crashdump-arm64.h"
28 #include "kexec-arm64.h"
29+#include "kexec-syscall.h"
30 #include <limits.h>
31
32 int image_arm64_probe(const char *kernel_buf, off_t kernel_size)
33@@ -58,6 +60,16 @@ int image_arm64_load(int argc, char **argv, const char *kernel_buf,
34 dbgprintf("%s: PE format: %s\n", __func__,
35 (arm64_header_check_pe_sig(header) ? "yes" : "no"));
36
37+ if (info->kexec_flags & KEXEC_ON_CRASH) {
38+ /* create and initialize elf core header segment */
39+ result = load_crashdump_segments(info);
40+ if (result) {
41+ dbgprintf("%s: Creating eflcorehdr failed.\n",
42+ __func__);
43+ goto exit;
44+ }
45+ }
46+
47 /* load the kernel */
48 add_segment_phys_virt(info, kernel_buf, kernel_size,
49 kernel_segment + arm64_mem.text_offset,
50--
511.9.1
52
diff --git a/meta/recipes-kernel/kexec/kexec-tools_2.0.14.bb b/meta/recipes-kernel/kexec/kexec-tools_2.0.15.bb
index 0f6398f13e..6bd9025e6f 100644
--- a/meta/recipes-kernel/kexec/kexec-tools_2.0.14.bb
+++ b/meta/recipes-kernel/kexec/kexec-tools_2.0.15.bb
@@ -5,26 +5,13 @@ EXTRA_OECONF = " --with-zlib=yes"
5SRC_URI += "${KERNELORG_MIRROR}/linux/utils/kernel/kexec/kexec-tools-${PV}.tar.gz \ 5SRC_URI += "${KERNELORG_MIRROR}/linux/utils/kernel/kexec/kexec-tools-${PV}.tar.gz \
6 file://0002-powerpc-change-the-memory-size-limit.patch \ 6 file://0002-powerpc-change-the-memory-size-limit.patch \
7 file://0001-purgatory-Pass-r-directly-to-linker.patch \ 7 file://0001-purgatory-Pass-r-directly-to-linker.patch \
8 file://0001-vmcore-dmesg-Define-_GNU_SOURCE.patch \
9 file://0001-kexec-exntend-the-semantics-of-kexec_iomem_for_each_.patch \
10 file://0002-kexec-generalize-and-rename-get_kernel_stext_sym.patch \
11 file://0003-arm64-identify-PHYS_OFFSET-correctly.patch \
12 file://0004-arm64-kdump-identify-memory-regions.patch \
13 file://0005-arm64-kdump-add-elf-core-header-segment.patch \
14 file://0006-arm64-kdump-set-up-kernel-image-segment.patch \
15 file://0007-arm64-kdump-set-up-other-segments.patch \
16 file://0008-arm64-kdump-add-DT-properties-to-crash-dump-kernel-s.patch \
17 file://0009-arm64-kdump-Add-support-for-binary-image-files.patch \
18 file://0010-kexec-ARM-Fix-add_buffer_phys_virt-align-issue.patch \ 8 file://0010-kexec-ARM-Fix-add_buffer_phys_virt-align-issue.patch \
19 file://0001-x86-x86_64-Fix-format-warning-with-die.patch \
20 file://0002-ppc-Fix-format-warning-with-die.patch \
21 file://kexec-x32.patch \ 9 file://kexec-x32.patch \
22 file://0001-Disable-PIE-during-link.patch \ 10 file://0001-Disable-PIE-during-link.patch \
23 file://0001-arm64-Disable-PIC.patch \
24 " 11 "
25 12
26SRC_URI[md5sum] = "b2b2c5e6b29d467d6e99d587fb6b7cf5" 13SRC_URI[md5sum] = "78906fdc255656fa2b9996c8acb3ef62"
27SRC_URI[sha256sum] = "b3e69519d2acced256843b1e8f1ecfa00d9b54fa07449ed78f05b9193f239370" 14SRC_URI[sha256sum] = "42dbd0dab9964cd1ed89fa4571c8d13191eb7132b361ade5ac44517c91ecb97e"
28 15
29SECURITY_PIE_CFLAGS_remove = "-fPIE -pie" 16SECURITY_PIE_CFLAGS_remove = "-fPIE -pie"
30 17