aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinfei Huang <mnfhuang@gmail.com>2016-05-23 16:24:16 -0700
committerAlex Shi <alex.shi@linaro.org>2017-10-25 11:25:42 +0800
commitb67152e919ade82f38a8d7b78861afece5c98caa (patch)
treeb927c0aa0923d6f2c023d052b98929d6194b18cc
parentcb24e1e5cf7bc66b31fe20be82e5c35ad300fc2e (diff)
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> (cherry picked from commit 917a35605f09c0d16aeb2e92c7fbff562e19a116) Signed-off-by: Alex Shi <alex.shi@linaro.org>
-rw-r--r--kernel/kexec.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/kernel/kexec.c b/kernel/kexec.c
index 3680f9ca893f..b8d875f6c753 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -194,22 +194,25 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
segments, flags);
}
if (result)
- goto out;
+ goto unmap_page;
if (flags & KEXEC_PRESERVE_CONTEXT)
image->preserve_context = 1;
result = machine_kexec_prepare(image);
if (result)
- goto out;
+ goto unmap_page;
for (i = 0; i < nr_segments; i++) {
result = kimage_load_segment(image, &image->segment[i]);
if (result)
- goto out;
+ goto unmap_page;
}
kimage_terminate(image);
+unmap_page:
if (flags & KEXEC_ON_CRASH)
crash_unmap_reserved_pages();
+ if (result)
+ goto out;
}
/* Install the new kernel, and Uninstall the old */
image = xchg(dest_image, image);