2017-08-30 20:03:38 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
/*
|
|
|
|
* Image loader for kexec_file_load system call.
|
|
|
|
*
|
|
|
|
* Copyright IBM Corp. 2018
|
|
|
|
*
|
|
|
|
* Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kexec.h>
|
2019-03-18 19:53:47 +08:00
|
|
|
#include <asm/ipl.h>
|
2017-08-30 20:03:38 +08:00
|
|
|
#include <asm/setup.h>
|
|
|
|
|
2019-03-07 19:48:03 +08:00
|
|
|
static int kexec_file_add_kernel_image(struct kimage *image,
|
|
|
|
struct s390_load_data *data)
|
2017-08-30 20:03:38 +08:00
|
|
|
{
|
|
|
|
struct kexec_buf buf;
|
|
|
|
|
|
|
|
buf.image = image;
|
|
|
|
|
2019-03-07 22:56:34 +08:00
|
|
|
buf.buffer = image->kernel_buf;
|
|
|
|
buf.bufsz = image->kernel_buf_len;
|
2017-08-30 20:03:38 +08:00
|
|
|
|
2019-03-07 22:56:34 +08:00
|
|
|
buf.mem = 0;
|
2017-09-05 17:55:23 +08:00
|
|
|
if (image->type == KEXEC_TYPE_CRASH)
|
|
|
|
buf.mem += crashk_res.start;
|
2017-08-30 20:03:38 +08:00
|
|
|
buf.memsz = buf.bufsz;
|
|
|
|
|
2019-03-07 19:48:03 +08:00
|
|
|
data->kernel_buf = image->kernel_buf;
|
2019-03-07 22:56:34 +08:00
|
|
|
data->kernel_mem = buf.mem;
|
2019-03-07 19:48:03 +08:00
|
|
|
data->parm = image->kernel_buf + PARMAREA;
|
2019-03-07 22:56:34 +08:00
|
|
|
data->memsz += buf.memsz;
|
2017-08-30 20:03:38 +08:00
|
|
|
|
2019-03-18 19:53:47 +08:00
|
|
|
ipl_report_add_component(data->report, &buf,
|
|
|
|
IPL_RB_COMPONENT_FLAG_SIGNED |
|
|
|
|
IPL_RB_COMPONENT_FLAG_VERIFIED,
|
|
|
|
IPL_RB_CERT_UNKNOWN);
|
2019-03-07 19:48:03 +08:00
|
|
|
return kexec_add_buffer(&buf);
|
2017-08-30 20:03:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *s390_image_load(struct kimage *image,
|
|
|
|
char *kernel, unsigned long kernel_len,
|
|
|
|
char *initrd, unsigned long initrd_len,
|
|
|
|
char *cmdline, unsigned long cmdline_len)
|
|
|
|
{
|
2019-03-07 19:48:03 +08:00
|
|
|
return kexec_file_add_components(image, kexec_file_add_kernel_image);
|
2017-08-30 20:03:38 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int s390_image_probe(const char *buf, unsigned long len)
|
|
|
|
{
|
|
|
|
/* Can't reliably tell if an image is valid. Therefore give the
|
|
|
|
* user whatever he wants.
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const struct kexec_file_ops s390_kexec_image_ops = {
|
|
|
|
.probe = s390_image_probe,
|
|
|
|
.load = s390_image_load,
|
2019-08-20 08:17:44 +08:00
|
|
|
#ifdef CONFIG_KEXEC_SIG
|
2019-02-26 17:50:39 +08:00
|
|
|
.verify_sig = s390_verify_sig,
|
2019-08-20 08:17:44 +08:00
|
|
|
#endif /* CONFIG_KEXEC_SIG */
|
2017-08-30 20:03:38 +08:00
|
|
|
};
|