diff options
Diffstat (limited to 'meta/recipes-kernel/kexec/kexec-tools/0004-arm64-kdump-identify-memory-regions.patch')
-rw-r--r-- | meta/recipes-kernel/kexec/kexec-tools/0004-arm64-kdump-identify-memory-regions.patch | 202 |
1 files changed, 0 insertions, 202 deletions
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 @@ | |||
1 | From 48a4c7874d8264ddbfaec2e9858d7866a2d2eb60 Mon Sep 17 00:00:00 2001 | ||
2 | From: AKASHI Takahiro <takahiro.akashi@linaro.org> | ||
3 | Date: Wed, 5 Aug 2015 13:16:30 +0900 | ||
4 | Subject: [PATCH 4/9] arm64: kdump: identify memory regions | ||
5 | |||
6 | The 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 | |||
10 | We go through /proc/iomem to find out a) and b) which are marked | ||
11 | as "System RAM" and "Crash kernel", respectively. | ||
12 | |||
13 | Upstream-Status: Backport [https://git.linaro.org/people/takahiro.akashi/kexec-tools.git] | ||
14 | |||
15 | Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org> | ||
16 | Signed-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 | |||
24 | diff --git a/kexec/arch/arm64/Makefile b/kexec/arch/arm64/Makefile | ||
25 | index 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 += \ | ||
37 | diff --git a/kexec/arch/arm64/crashdump-arm64.c b/kexec/arch/arm64/crashdump-arm64.c | ||
38 | index 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 | } | ||
159 | diff --git a/kexec/arch/arm64/crashdump-arm64.h b/kexec/arch/arm64/crashdump-arm64.h | ||
160 | index 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 */ | ||
188 | diff --git a/kexec/arch/arm64/iomem.h b/kexec/arch/arm64/iomem.h | ||
189 | index 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 | -- | ||
201 | 1.9.1 | ||
202 | |||