Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

kexec: make a pair of map/unmap reserved pages in error path

For some arch, kexec shall map the reserved pages, then use them, when
we try to start the kdump service.

kexec may return directly, without unmaping the reserved pages, if it
fails during starting service. To fix it, we make a pair of map/unmap
reserved pages both in generic path and error path.

This patch only affects s390. Other architecturess don't implement the
interface of crash_unmap_reserved_pages and crash_map_reserved_pages.

It isn't a urgent patch. Kernel can work well without any risk,
although the reserved pages are not unmapped before returning in error
path.

Signed-off-by: Minfei Huang <mnfhuang@gmail.com>
Cc: Vivek Goyal <vgoyal@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Xunlei Pang <xlpang@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>

authored by

Minfei Huang and committed by
Linus Torvalds
917a3560 1e5768ae

+6 -3
+6 -3
kernel/kexec.c
··· 194 194 segments, flags); 195 195 } 196 196 if (result) 197 - goto out; 197 + goto unmap_page; 198 198 199 199 if (flags & KEXEC_PRESERVE_CONTEXT) 200 200 image->preserve_context = 1; 201 201 result = machine_kexec_prepare(image); 202 202 if (result) 203 - goto out; 203 + goto unmap_page; 204 204 205 205 for (i = 0; i < nr_segments; i++) { 206 206 result = kimage_load_segment(image, &image->segment[i]); 207 207 if (result) 208 - goto out; 208 + goto unmap_page; 209 209 } 210 210 kimage_terminate(image); 211 + unmap_page: 211 212 if (flags & KEXEC_ON_CRASH) 212 213 crash_unmap_reserved_pages(); 214 + if (result) 215 + goto out; 213 216 } 214 217 /* Install the new kernel, and Uninstall the old */ 215 218 image = xchg(dest_image, image);