Skip to content

Commit

Permalink
kexec: make a pair of map/unmap reserved pages in error path
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Vivek Goyal <[email protected]>
Cc: "Eric W. Biederman" <[email protected]>
Cc: Xunlei Pang <[email protected]>
Cc: Baoquan He <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Minfei Huang authored and torvalds committed May 24, 2016
1 parent 1e5768a commit 917a356
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions kernel/kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 917a356

Please sign in to comment.