aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorXunlei Pang <xlpang@redhat.com>2016-05-23 19:24:22 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-05-23 20:04:14 -0400
commit7a0058ec78602da02b34fa2ae3afc523e90d1ab2 (patch)
tree46268819bc7000ca50afd55941d2e130016e6fd9 /kernel
parent0eea08678ebe9f7d8ef98fed974a5bf1a0dd2dd2 (diff)
s390/kexec: consolidate crash_map/unmap_reserved_pages() and arch_kexec_protect(unprotect)_crashkres()
Commit 3f625002581b ("kexec: introduce a protection mechanism for the crashkernel reserved memory") is a similar mechanism for protecting the crash kernel reserved memory to previous crash_map/unmap_reserved_pages() implementation, the new one is more generic in name and cleaner in code (besides, some arch may not be allowed to unmap the pgtable). Therefore, this patch consolidates them, and uses the new arch_kexec_protect(unprotect)_crashkres() to replace former crash_map/unmap_reserved_pages() which by now has been only used by S390. The consolidation work needs the crash memory to be mapped initially, this is done in machine_kdump_pm_init() which is after reserve_crashkernel(). Once kdump kernel is loaded, the new arch_kexec_protect_crashkres() implemented for S390 will actually unmap the pgtable like before. Signed-off-by: Xunlei Pang <xlpang@redhat.com> Signed-off-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Acked-by: Michael Holzheu <holzheu@linux.vnet.ibm.com> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: "Eric W. Biederman" <ebiederm@xmission.com> Cc: Minfei Huang <mhuang@redhat.com> Cc: Vivek Goyal <vgoyal@redhat.com> Cc: Dave Young <dyoung@redhat.com> Cc: Baoquan He <bhe@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/kexec.c12
-rw-r--r--kernel/kexec_core.c11
2 files changed, 2 insertions, 21 deletions
diff --git a/kernel/kexec.c b/kernel/kexec.c
index b73dc211fcfd..4384672d3245 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -136,9 +136,6 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,
136 if (ret) 136 if (ret)
137 return ret; 137 return ret;
138 138
139 if (flags & KEXEC_ON_CRASH)
140 crash_map_reserved_pages();
141
142 if (flags & KEXEC_PRESERVE_CONTEXT) 139 if (flags & KEXEC_PRESERVE_CONTEXT)
143 image->preserve_context = 1; 140 image->preserve_context = 1;
144 141
@@ -161,12 +158,6 @@ out:
161 if ((flags & KEXEC_ON_CRASH) && kexec_crash_image) 158 if ((flags & KEXEC_ON_CRASH) && kexec_crash_image)
162 arch_kexec_protect_crashkres(); 159 arch_kexec_protect_crashkres();
163 160
164 /*
165 * Once the reserved memory is mapped, we should unmap this memory
166 * before returning
167 */
168 if (flags & KEXEC_ON_CRASH)
169 crash_unmap_reserved_pages();
170 kimage_free(image); 161 kimage_free(image);
171 return ret; 162 return ret;
172} 163}
@@ -232,9 +223,6 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
232 223
233 result = do_kexec_load(entry, nr_segments, segments, flags); 224 result = do_kexec_load(entry, nr_segments, segments, flags);
234 225
235 if ((flags & KEXEC_ON_CRASH) && kexec_crash_image)
236 arch_kexec_protect_crashkres();
237
238 mutex_unlock(&kexec_mutex); 226 mutex_unlock(&kexec_mutex);
239 227
240 return result; 228 return result;
diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
index 48b73cc8e425..56b3ed0927b0 100644
--- a/kernel/kexec_core.c
+++ b/kernel/kexec_core.c
@@ -954,7 +954,6 @@ int crash_shrink_memory(unsigned long new_size)
954 start = roundup(start, KEXEC_CRASH_MEM_ALIGN); 954 start = roundup(start, KEXEC_CRASH_MEM_ALIGN);
955 end = roundup(start + new_size, KEXEC_CRASH_MEM_ALIGN); 955 end = roundup(start + new_size, KEXEC_CRASH_MEM_ALIGN);
956 956
957 crash_map_reserved_pages();
958 crash_free_reserved_phys_range(end, crashk_res.end); 957 crash_free_reserved_phys_range(end, crashk_res.end);
959 958
960 if ((start == end) && (crashk_res.parent != NULL)) 959 if ((start == end) && (crashk_res.parent != NULL))
@@ -968,7 +967,6 @@ int crash_shrink_memory(unsigned long new_size)
968 crashk_res.end = end - 1; 967 crashk_res.end = end - 1;
969 968
970 insert_resource(&iomem_resource, ram_res); 969 insert_resource(&iomem_resource, ram_res);
971 crash_unmap_reserved_pages();
972 970
973unlock: 971unlock:
974 mutex_unlock(&kexec_mutex); 972 mutex_unlock(&kexec_mutex);
@@ -1553,17 +1551,12 @@ int kernel_kexec(void)
1553} 1551}
1554 1552
1555/* 1553/*
1556 * Add and remove page tables for crashkernel memory 1554 * Protection mechanism for crashkernel reserved memory after
1555 * the kdump kernel is loaded.
1557 * 1556 *
1558 * Provide an empty default implementation here -- architecture 1557 * Provide an empty default implementation here -- architecture
1559 * code may override this 1558 * code may override this
1560 */ 1559 */
1561void __weak crash_map_reserved_pages(void)
1562{}
1563
1564void __weak crash_unmap_reserved_pages(void)
1565{}
1566
1567void __weak arch_kexec_protect_crashkres(void) 1560void __weak arch_kexec_protect_crashkres(void)
1568{} 1561{}
1569 1562