Merge tag 'hyperv-next-signed-20230902' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / arch / s390 / kernel / kexec_image.c
CommitLineData
e49bb0a2
PR
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>
99feaa71 13#include <asm/ipl.h>
e49bb0a2
PR
14#include <asm/setup.h>
15
8e496426
PR
16static int kexec_file_add_kernel_image(struct kimage *image,
17 struct s390_load_data *data)
e49bb0a2
PR
18{
19 struct kexec_buf buf;
e49bb0a2
PR
20
21 buf.image = image;
22
653beba2
PR
23 buf.buffer = image->kernel_buf;
24 buf.bufsz = image->kernel_buf_len;
e49bb0a2 25
653beba2 26 buf.mem = 0;
ee337f54
PR
27 if (image->type == KEXEC_TYPE_CRASH)
28 buf.mem += crashk_res.start;
e49bb0a2
PR
29 buf.memsz = buf.bufsz;
30
8e496426 31 data->kernel_buf = image->kernel_buf;
653beba2 32 data->kernel_mem = buf.mem;
8e496426 33 data->parm = image->kernel_buf + PARMAREA;
653beba2 34 data->memsz += buf.memsz;
e49bb0a2 35
99feaa71
PR
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);
8e496426 40 return kexec_add_buffer(&buf);
e49bb0a2
PR
41}
42
43static 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{
8e496426 48 return kexec_file_add_components(image, kexec_file_add_kernel_image);
e49bb0a2
PR
49}
50
51static 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
59const struct kexec_file_ops s390_kexec_image_ops = {
60 .probe = s390_image_probe,
61 .load = s390_image_load,
99d5cadf 62#ifdef CONFIG_KEXEC_SIG
e23a8020 63 .verify_sig = s390_verify_sig,
99d5cadf 64#endif /* CONFIG_KEXEC_SIG */
e49bb0a2 65};