Skip to content

Commit

Permalink
kexec: add machine_kexec_post_load()
Browse files Browse the repository at this point in the history
It is the same as machine_kexec_prepare(), but is called after segments are
loaded. This way, can do processing work with already loaded relocation
segments. One such example is arm64: it has to have segments loaded in
order to create a page table, but it cannot do it during kexec time,
because at that time allocations won't be possible anymore.

Signed-off-by: Pavel Tatashin <[email protected]>
Acked-by: Dave Young <[email protected]>
Signed-off-by: Will Deacon <[email protected]>
  • Loading branch information
soleen authored and willdeacon committed Jan 8, 2020
1 parent d42cc53 commit de68e4d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions kernel/kexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ static int do_kexec_load(unsigned long entry, unsigned long nr_segments,

kimage_terminate(image);

ret = machine_kexec_post_load(image);
if (ret)
goto out;

/* Install the new kernel and uninstall the old */
image = xchg(dest_image, image);

Expand Down
6 changes: 6 additions & 0 deletions kernel/kexec_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,12 @@ static void kimage_free_extra_pages(struct kimage *image)
kimage_free_page_list(&image->unusable_pages);

}

int __weak machine_kexec_post_load(struct kimage *image)
{
return 0;
}

void kimage_terminate(struct kimage *image)
{
if (*image->entry != 0)
Expand Down
4 changes: 4 additions & 0 deletions kernel/kexec_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,10 @@ SYSCALL_DEFINE5(kexec_file_load, int, kernel_fd, int, initrd_fd,

kimage_terminate(image);

ret = machine_kexec_post_load(image);
if (ret)
goto out;

/*
* Free up any temporary buffers allocated which are not needed
* after image has been loaded
Expand Down
2 changes: 2 additions & 0 deletions kernel/kexec_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ void kimage_terminate(struct kimage *image);
int kimage_is_destination_range(struct kimage *image,
unsigned long start, unsigned long end);

int machine_kexec_post_load(struct kimage *image);

extern struct mutex kexec_mutex;

#ifdef CONFIG_KEXEC_FILE
Expand Down

0 comments on commit de68e4d

Please sign in to comment.