diff options
author | Philipp Rudo <prudo@linux.ibm.com> | 2019-03-07 12:48:03 +0100 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2019-04-29 10:43:59 +0200 |
commit | 8e4964261374aaec9f4a83de076ceb11c8cdc044 (patch) | |
tree | 8df575c5d36b1ecf3188151787bfddd080738f56 /arch/s390/kernel/kexec_elf.c | |
parent | d0d249d75dda1b101624316a52d117be07b8ccff (diff) | |
download | linux-stable-8e4964261374aaec9f4a83de076ceb11c8cdc044.tar.gz linux-stable-8e4964261374aaec9f4a83de076ceb11c8cdc044.tar.bz2 linux-stable-8e4964261374aaec9f4a83de076ceb11c8cdc044.zip |
s390/kexec_file: Unify loader code
s390_image_load and s390_elf_load have the same code to load the different
components. Combine this functionality in one shared function.
While at it move kexec_file_update_kernel into the new function as well.
Signed-off-by: Philipp Rudo <prudo@linux.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'arch/s390/kernel/kexec_elf.c')
-rw-r--r-- | arch/s390/kernel/kexec_elf.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/arch/s390/kernel/kexec_elf.c b/arch/s390/kernel/kexec_elf.c index 1cdf90767cba..c74ff6b54344 100644 --- a/arch/s390/kernel/kexec_elf.c +++ b/arch/s390/kernel/kexec_elf.c @@ -12,16 +12,17 @@ #include <linux/kexec.h> #include <asm/setup.h> -static int kexec_file_add_elf_kernel(struct kimage *image, - struct s390_load_data *data, - char *kernel, unsigned long kernel_len) +static int kexec_file_add_kernel_elf(struct kimage *image, + struct s390_load_data *data) { struct kexec_buf buf; const Elf_Ehdr *ehdr; const Elf_Phdr *phdr; Elf_Addr entry; + void *kernel; int i, ret; + kernel = image->kernel_buf; ehdr = (Elf_Ehdr *)kernel; buf.image = image; if (image->type == KEXEC_TYPE_CRASH) @@ -62,7 +63,7 @@ static int kexec_file_add_elf_kernel(struct kimage *image, data->memsz = ALIGN(data->memsz, phdr->p_align) + buf.memsz; } - return 0; + return data->memsz ? 0 : -EINVAL; } static void *s390_elf_load(struct kimage *image, @@ -70,11 +71,10 @@ static void *s390_elf_load(struct kimage *image, char *initrd, unsigned long initrd_len, char *cmdline, unsigned long cmdline_len) { - struct s390_load_data data = {0}; const Elf_Ehdr *ehdr; const Elf_Phdr *phdr; size_t size; - int i, ret; + int i; /* image->fobs->probe already checked for valid ELF magic number. */ ehdr = (Elf_Ehdr *)kernel; @@ -107,24 +107,7 @@ static void *s390_elf_load(struct kimage *image, if (size > kernel_len) return ERR_PTR(-EINVAL); - ret = kexec_file_add_elf_kernel(image, &data, kernel, kernel_len); - if (ret) - return ERR_PTR(ret); - - if (!data.memsz) - return ERR_PTR(-EINVAL); - - if (initrd) { - ret = kexec_file_add_initrd(image, &data, initrd, initrd_len); - if (ret) - return ERR_PTR(ret); - } - - ret = kexec_file_add_purgatory(image, &data); - if (ret) - return ERR_PTR(ret); - - return kexec_file_update_kernel(image, &data); + return kexec_file_add_components(image, kexec_file_add_kernel_elf); } static int s390_elf_probe(const char *buf, unsigned long len) |