Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | /* |
| 3 | * Image loader for kexec_file_load system call. |
| 4 | * |
| 5 | * Copyright IBM Corp. 2018 |
| 6 | * |
| 7 | * Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com> |
| 8 | */ |
| 9 | |
| 10 | #include <linux/errno.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/kexec.h> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 13 | #include <asm/ipl.h> |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 14 | #include <asm/setup.h> |
| 15 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 16 | static int kexec_file_add_kernel_image(struct kimage *image, |
| 17 | struct s390_load_data *data) |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 18 | { |
| 19 | struct kexec_buf buf; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 20 | |
| 21 | buf.image = image; |
| 22 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 23 | buf.buffer = image->kernel_buf; |
| 24 | buf.bufsz = image->kernel_buf_len; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 25 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 26 | buf.mem = 0; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 27 | if (image->type == KEXEC_TYPE_CRASH) |
| 28 | buf.mem += crashk_res.start; |
| 29 | buf.memsz = buf.bufsz; |
| 30 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 31 | data->kernel_buf = image->kernel_buf; |
| 32 | data->kernel_mem = buf.mem; |
| 33 | data->parm = image->kernel_buf + PARMAREA; |
| 34 | data->memsz += buf.memsz; |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 35 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 36 | ipl_report_add_component(data->report, &buf, |
| 37 | IPL_RB_COMPONENT_FLAG_SIGNED | |
| 38 | IPL_RB_COMPONENT_FLAG_VERIFIED, |
| 39 | IPL_RB_CERT_UNKNOWN); |
| 40 | return kexec_add_buffer(&buf); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 41 | } |
| 42 | |
| 43 | static void *s390_image_load(struct kimage *image, |
| 44 | char *kernel, unsigned long kernel_len, |
| 45 | char *initrd, unsigned long initrd_len, |
| 46 | char *cmdline, unsigned long cmdline_len) |
| 47 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 48 | return kexec_file_add_components(image, kexec_file_add_kernel_image); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | static int s390_image_probe(const char *buf, unsigned long len) |
| 52 | { |
| 53 | /* Can't reliably tell if an image is valid. Therefore give the |
| 54 | * user whatever he wants. |
| 55 | */ |
| 56 | return 0; |
| 57 | } |
| 58 | |
| 59 | const struct kexec_file_ops s390_kexec_image_ops = { |
| 60 | .probe = s390_image_probe, |
| 61 | .load = s390_image_load, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 62 | #ifdef CONFIG_KEXEC_SIG |
| 63 | .verify_sig = s390_verify_sig, |
| 64 | #endif /* CONFIG_KEXEC_SIG */ |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 65 | }; |