1 // SPDX-License-Identifier: GPL-2.0
3 * Image loader for kexec_file_load system call.
5 * Copyright IBM Corp. 2018
7 * Author(s): Philipp Rudo <prudo@linux.vnet.ibm.com>
10 #include <linux/errno.h>
11 #include <linux/kernel.h>
12 #include <linux/kexec.h>
13 #include <asm/setup.h>
15 static int kexec_file_add_image_kernel(struct kimage
*image
,
16 struct s390_load_data
*data
,
17 char *kernel
, unsigned long kernel_len
)
24 buf
.buffer
= kernel
+ STARTUP_NORMAL_OFFSET
;
25 buf
.bufsz
= kernel_len
- STARTUP_NORMAL_OFFSET
;
27 buf
.mem
= STARTUP_NORMAL_OFFSET
;
28 if (image
->type
== KEXEC_TYPE_CRASH
)
29 buf
.mem
+= crashk_res
.start
;
30 buf
.memsz
= buf
.bufsz
;
32 ret
= kexec_add_buffer(&buf
);
34 data
->kernel_buf
= kernel
;
35 data
->memsz
+= buf
.memsz
+ STARTUP_NORMAL_OFFSET
;
40 static void *s390_image_load(struct kimage
*image
,
41 char *kernel
, unsigned long kernel_len
,
42 char *initrd
, unsigned long initrd_len
,
43 char *cmdline
, unsigned long cmdline_len
)
45 struct s390_load_data data
= {0};
48 ret
= kexec_file_add_image_kernel(image
, &data
, kernel
, kernel_len
);
53 ret
= kexec_file_add_initrd(image
, &data
, initrd
, initrd_len
);
58 ret
= kexec_file_add_purgatory(image
, &data
);
62 return kexec_file_update_kernel(image
, &data
);
65 static int s390_image_probe(const char *buf
, unsigned long len
)
67 /* Can't reliably tell if an image is valid. Therefore give the
68 * user whatever he wants.
73 const struct kexec_file_ops s390_kexec_image_ops
= {
74 .probe
= s390_image_probe
,
75 .load
= s390_image_load
,