[PATCH V2 1/2] kexec: Make a pair of map/unmap reserved pages in error path
Minfei Huang
mnfhuang at gmail.com
Tue Mar 1 00:02:28 PST 2016
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.
Signed-off-by: Minfei Huang <mnfhuang at gmail.com>
---
kernel/kexec.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/kernel/kexec.c b/kernel/kexec.c
index ee70aef..5cd60c4 100644
--- a/kernel/kexec.c
+++ b/kernel/kexec.c
@@ -169,6 +169,7 @@ SYSCALL_DEFINE4(kexec_load, unsigned long, entry, unsigned long, nr_segments,
dest_image = &kexec_image;
if (flags & KEXEC_ON_CRASH)
dest_image = &kexec_crash_image;
+
if (nr_segments > 0) {
unsigned long i;
@@ -190,22 +191,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);
--
1.9.1
More information about the kexec
mailing list