From 40135bb739610c4ec3dfc55d5798606dde976b35 Mon Sep 17 00:00:00 2001 From: Dave Kleikamp Date: Fri, 23 May 2014 16:25:51 -0500 Subject: [PATCH] kexec: Add kimage_arch_load_normal_segment to generic code original patch by Bob Picco Signed-off-by: Dave Kleikamp Cc: Bob Picco --- include/linux/kexec.h | 6 ++++++ kernel/kexec.c | 19 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/include/linux/kexec.h b/include/linux/kexec.h index e804306ef5e8..bd21485dafd6 100644 --- a/include/linux/kexec.h +++ b/include/linux/kexec.h @@ -222,6 +222,12 @@ extern asmlinkage long sys_kexec_load(unsigned long entry, struct kexec_segment __user *segments, unsigned long flags); extern int kernel_kexec(void); +extern int kimage_arch_load_normal_segment(struct kimage *image, + struct kexec_segment *segment, + int *arch_status, + int (*add_phys_addr)(struct kimage *image, + unsigned long page)); + extern int kexec_add_buffer(struct kimage *image, char *buffer, unsigned long bufsz, unsigned long memsz, unsigned long buf_align, unsigned long buf_min, diff --git a/kernel/kexec.c b/kernel/kexec.c index 7a36fdcca5bf..c8f1c829a759 100644 --- a/kernel/kexec.c +++ b/kernel/kexec.c @@ -1062,12 +1062,21 @@ static struct page *kimage_alloc_page(struct kimage *image, return page; } +int __weak kimage_arch_load_normal_segment(struct kimage *image, + struct kexec_segment *segment, + int *arch_status, + int (*add_phys_addr)(struct kimage *image, + unsigned long page)) +{ + return -ENOENT; +} + static int kimage_load_normal_segment(struct kimage *image, struct kexec_segment *segment) { unsigned long maddr; size_t ubytes, mbytes; - int result; + int result, arch_status; unsigned char __user *buf = NULL; unsigned char *kbuf = NULL; @@ -1084,6 +1093,14 @@ static int kimage_load_normal_segment(struct kimage *image, if (result < 0) goto out; + /* Should the arch handle this segment load, then use the arch status.*/ + result = kimage_arch_load_normal_segment(image, segment, &arch_status, + kimage_add_page); + if (!result) { + result = arch_status; + goto out; + } + while (mbytes) { struct page *page; char *ptr; -- 2.50.1