kexec: add machine_kexec_post_load()
authorPavel Tatashin <pasha.tatashin@soleen.com>
Wed, 4 Dec 2019 15:59:15 +0000 (10:59 -0500)
committerWill Deacon <will@kernel.org>
Wed, 8 Jan 2020 16:32:55 +0000 (16:32 +0000)
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 <pasha.tatashin@soleen.com>
Acked-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Will Deacon <will@kernel.org>
kernel/kexec.c
kernel/kexec_core.c
kernel/kexec_file.c
kernel/kexec_internal.h

index bc933c0db9bf019aefa7c5bc7061bc2541fb2a00..f977786fe498fb7241337c6da0e94e3a0ad85d34 100644 (file)
@@ -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);
 
index f7ae04b8de6f3152061acd503f686426273242cb..c19c0dad1ebef9def30f749a0a5cb13fac609a3f 100644 (file)
@@ -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)
index a2df939486655ed22b811a6a311744f2c1c61113..faa74d5f69411b420c7ea47cc58f1476ca0eafe7 100644 (file)
@@ -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
index 48aaf2ac0d0d15d7cd1dca3c42fa9b2f00313c9e..39d30ccf8d8798c1113ea70889ea106ecb25ad1f 100644 (file)
@@ -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