Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 /*
0003  * Image loader for kexec_file_load system call.
0004  *
0005  * Copyright IBM Corp. 2018
0006  *
0007  * Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com>
0008  */
0009 
0010 #include <linux/errno.h>
0011 #include <linux/kernel.h>
0012 #include <linux/kexec.h>
0013 #include <asm/ipl.h>
0014 #include <asm/setup.h>
0015 
0016 static int kexec_file_add_kernel_image(struct kimage *image,
0017                        struct s390_load_data *data)
0018 {
0019     struct kexec_buf buf;
0020 
0021     buf.image = image;
0022 
0023     buf.buffer = image->kernel_buf;
0024     buf.bufsz = image->kernel_buf_len;
0025 
0026     buf.mem = 0;
0027     if (image->type == KEXEC_TYPE_CRASH)
0028         buf.mem += crashk_res.start;
0029     buf.memsz = buf.bufsz;
0030 
0031     data->kernel_buf = image->kernel_buf;
0032     data->kernel_mem = buf.mem;
0033     data->parm = image->kernel_buf + PARMAREA;
0034     data->memsz += buf.memsz;
0035 
0036     ipl_report_add_component(data->report, &buf,
0037                  IPL_RB_COMPONENT_FLAG_SIGNED |
0038                  IPL_RB_COMPONENT_FLAG_VERIFIED,
0039                  IPL_RB_CERT_UNKNOWN);
0040     return kexec_add_buffer(&buf);
0041 }
0042 
0043 static void *s390_image_load(struct kimage *image,
0044                  char *kernel, unsigned long kernel_len,
0045                  char *initrd, unsigned long initrd_len,
0046                  char *cmdline, unsigned long cmdline_len)
0047 {
0048     return kexec_file_add_components(image, kexec_file_add_kernel_image);
0049 }
0050 
0051 static int s390_image_probe(const char *buf, unsigned long len)
0052 {
0053     /* Can't reliably tell if an image is valid.  Therefore give the
0054      * user whatever he wants.
0055      */
0056     return 0;
0057 }
0058 
0059 const struct kexec_file_ops s390_kexec_image_ops = {
0060     .probe = s390_image_probe,
0061     .load = s390_image_load,
0062 #ifdef CONFIG_KEXEC_SIG
0063     .verify_sig = s390_verify_sig,
0064 #endif /* CONFIG_KEXEC_SIG */
0065 };