1 // SPDX-License-Identifier: GPL-2.0
3 * ipl/reipl/dump support for Linux on s390.
5 * Copyright IBM Corp. 2005, 2012
6 * Author(s): Michael Holzheu <holzheu@de.ibm.com>
7 * Heiko Carstens <heiko.carstens@de.ibm.com>
8 * Volker Sameske <sameske@de.ibm.com>
11 #include <linux/types.h>
12 #include <linux/export.h>
13 #include <linux/init.h>
14 #include <linux/device.h>
15 #include <linux/delay.h>
16 #include <linux/reboot.h>
17 #include <linux/ctype.h>
19 #include <linux/gfp.h>
20 #include <linux/crash_dump.h>
21 #include <linux/debug_locks.h>
25 #include <asm/setup.h>
26 #include <asm/cpcmd.h>
27 #include <asm/ebcdic.h>
29 #include <asm/checksum.h>
30 #include <asm/debug.h>
31 #include <asm/os_info.h>
32 #include <asm/sections.h>
33 #include <asm/boot_data.h>
36 #define IPL_PARM_BLOCK_VERSION 0
38 #define IPL_UNKNOWN_STR "unknown"
39 #define IPL_CCW_STR "ccw"
40 #define IPL_FCP_STR "fcp"
41 #define IPL_FCP_DUMP_STR "fcp_dump"
42 #define IPL_NVME_STR "nvme"
43 #define IPL_NVME_DUMP_STR "nvme_dump"
44 #define IPL_NSS_STR "nss"
46 #define DUMP_CCW_STR "ccw"
47 #define DUMP_FCP_STR "fcp"
48 #define DUMP_NVME_STR "nvme"
49 #define DUMP_NONE_STR "none"
52 * Four shutdown trigger types are supported:
59 #define ON_PANIC_STR "on_panic"
60 #define ON_HALT_STR "on_halt"
61 #define ON_POFF_STR "on_poff"
62 #define ON_REIPL_STR "on_reboot"
63 #define ON_RESTART_STR "on_restart"
65 struct shutdown_action
;
66 struct shutdown_trigger
{
68 struct shutdown_action
*action
;
72 * The following shutdown action types are supported:
74 #define SHUTDOWN_ACTION_IPL_STR "ipl"
75 #define SHUTDOWN_ACTION_REIPL_STR "reipl"
76 #define SHUTDOWN_ACTION_DUMP_STR "dump"
77 #define SHUTDOWN_ACTION_VMCMD_STR "vmcmd"
78 #define SHUTDOWN_ACTION_STOP_STR "stop"
79 #define SHUTDOWN_ACTION_DUMP_REIPL_STR "dump_reipl"
81 struct shutdown_action
{
83 void (*fn
) (struct shutdown_trigger
*trigger
);
88 static char *ipl_type_str(enum ipl_type type
)
95 case IPL_TYPE_FCP_DUMP
:
96 return IPL_FCP_DUMP_STR
;
101 case IPL_TYPE_NVME_DUMP
:
102 return IPL_NVME_DUMP_STR
;
103 case IPL_TYPE_UNKNOWN
:
105 return IPL_UNKNOWN_STR
;
116 static char *dump_type_str(enum dump_type type
)
120 return DUMP_NONE_STR
;
126 return DUMP_NVME_STR
;
132 int __bootdata_preserved(ipl_block_valid
);
133 struct ipl_parameter_block
__bootdata_preserved(ipl_block
);
134 int __bootdata_preserved(ipl_secure_flag
);
136 unsigned long __bootdata_preserved(ipl_cert_list_addr
);
137 unsigned long __bootdata_preserved(ipl_cert_list_size
);
139 unsigned long __bootdata(early_ipl_comp_list_addr
);
140 unsigned long __bootdata(early_ipl_comp_list_size
);
142 static int reipl_capabilities
= IPL_TYPE_UNKNOWN
;
144 static enum ipl_type reipl_type
= IPL_TYPE_UNKNOWN
;
145 static struct ipl_parameter_block
*reipl_block_fcp
;
146 static struct ipl_parameter_block
*reipl_block_nvme
;
147 static struct ipl_parameter_block
*reipl_block_ccw
;
148 static struct ipl_parameter_block
*reipl_block_nss
;
149 static struct ipl_parameter_block
*reipl_block_actual
;
151 static int dump_capabilities
= DUMP_TYPE_NONE
;
152 static enum dump_type dump_type
= DUMP_TYPE_NONE
;
153 static struct ipl_parameter_block
*dump_block_fcp
;
154 static struct ipl_parameter_block
*dump_block_nvme
;
155 static struct ipl_parameter_block
*dump_block_ccw
;
157 static struct sclp_ipl_info sclp_ipl_info
;
159 static bool reipl_nvme_clear
;
160 static bool reipl_fcp_clear
;
161 static bool reipl_ccw_clear
;
163 static inline int __diag308(unsigned long subcode
, void *addr
)
165 register unsigned long _addr
asm("0") = (unsigned long) addr
;
166 register unsigned long _rc
asm("1") = 0;
169 " diag %0,%2,0x308\n"
172 : "+d" (_addr
), "+d" (_rc
)
173 : "d" (subcode
) : "cc", "memory");
177 int diag308(unsigned long subcode
, void *addr
)
179 if (IS_ENABLED(CONFIG_KASAN
))
180 __arch_local_irq_stosm(0x04); /* enable DAT */
181 diag_stat_inc(DIAG_STAT_X308
);
182 return __diag308(subcode
, addr
);
184 EXPORT_SYMBOL_GPL(diag308
);
188 #define IPL_ATTR_SHOW_FN(_prefix, _name, _format, args...) \
189 static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
190 struct kobj_attribute *attr, \
193 return scnprintf(page, PAGE_SIZE, _format, ##args); \
196 #define IPL_ATTR_CCW_STORE_FN(_prefix, _name, _ipl_blk) \
197 static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
198 struct kobj_attribute *attr, \
199 const char *buf, size_t len) \
201 unsigned long long ssid, devno; \
203 if (sscanf(buf, "0.%llx.%llx\n", &ssid, &devno) != 2) \
206 if (ssid > __MAX_SSID || devno > __MAX_SUBCHANNEL) \
209 _ipl_blk.ssid = ssid; \
210 _ipl_blk.devno = devno; \
214 #define DEFINE_IPL_CCW_ATTR_RW(_prefix, _name, _ipl_blk) \
215 IPL_ATTR_SHOW_FN(_prefix, _name, "0.%x.%04x\n", \
216 _ipl_blk.ssid, _ipl_blk.devno); \
217 IPL_ATTR_CCW_STORE_FN(_prefix, _name, _ipl_blk); \
218 static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
219 __ATTR(_name, (S_IRUGO | S_IWUSR), \
220 sys_##_prefix##_##_name##_show, \
221 sys_##_prefix##_##_name##_store) \
223 #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
224 IPL_ATTR_SHOW_FN(_prefix, _name, _format, _value) \
225 static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
226 __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL)
228 #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
229 IPL_ATTR_SHOW_FN(_prefix, _name, _fmt_out, (unsigned long long) _value) \
230 static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
231 struct kobj_attribute *attr, \
232 const char *buf, size_t len) \
234 unsigned long long value; \
235 if (sscanf(buf, _fmt_in, &value) != 1) \
240 static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
241 __ATTR(_name,(S_IRUGO | S_IWUSR), \
242 sys_##_prefix##_##_name##_show, \
243 sys_##_prefix##_##_name##_store)
245 #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
246 IPL_ATTR_SHOW_FN(_prefix, _name, _fmt_out, _value) \
247 static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
248 struct kobj_attribute *attr, \
249 const char *buf, size_t len) \
251 strncpy(_value, buf, sizeof(_value) - 1); \
255 static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
256 __ATTR(_name,(S_IRUGO | S_IWUSR), \
257 sys_##_prefix##_##_name##_show, \
258 sys_##_prefix##_##_name##_store)
264 static __init
enum ipl_type
get_ipl_type(void)
266 if (!ipl_block_valid
)
267 return IPL_TYPE_UNKNOWN
;
269 switch (ipl_block
.pb0_hdr
.pbt
) {
273 if (ipl_block
.fcp
.opt
== IPL_PB0_FCP_OPT_DUMP
)
274 return IPL_TYPE_FCP_DUMP
;
278 if (ipl_block
.nvme
.opt
== IPL_PB0_NVME_OPT_DUMP
)
279 return IPL_TYPE_NVME_DUMP
;
281 return IPL_TYPE_NVME
;
283 return IPL_TYPE_UNKNOWN
;
286 struct ipl_info ipl_info
;
287 EXPORT_SYMBOL_GPL(ipl_info
);
289 static ssize_t
ipl_type_show(struct kobject
*kobj
, struct kobj_attribute
*attr
,
292 return sprintf(page
, "%s\n", ipl_type_str(ipl_info
.type
));
295 static struct kobj_attribute sys_ipl_type_attr
= __ATTR_RO(ipl_type
);
297 static ssize_t
ipl_secure_show(struct kobject
*kobj
,
298 struct kobj_attribute
*attr
, char *page
)
300 return sprintf(page
, "%i\n", !!ipl_secure_flag
);
303 static struct kobj_attribute sys_ipl_secure_attr
=
304 __ATTR(secure
, 0444, ipl_secure_show
, NULL
);
306 static ssize_t
ipl_has_secure_show(struct kobject
*kobj
,
307 struct kobj_attribute
*attr
, char *page
)
309 return sprintf(page
, "%i\n", !!sclp
.has_sipl
);
312 static struct kobj_attribute sys_ipl_has_secure_attr
=
313 __ATTR(has_secure
, 0444, ipl_has_secure_show
, NULL
);
315 static ssize_t
ipl_vm_parm_show(struct kobject
*kobj
,
316 struct kobj_attribute
*attr
, char *page
)
318 char parm
[DIAG308_VMPARM_SIZE
+ 1] = {};
320 if (ipl_block_valid
&& (ipl_block
.pb0_hdr
.pbt
== IPL_PBT_CCW
))
321 ipl_block_get_ascii_vmparm(parm
, sizeof(parm
), &ipl_block
);
322 return sprintf(page
, "%s\n", parm
);
325 static struct kobj_attribute sys_ipl_vm_parm_attr
=
326 __ATTR(parm
, S_IRUGO
, ipl_vm_parm_show
, NULL
);
328 static ssize_t
sys_ipl_device_show(struct kobject
*kobj
,
329 struct kobj_attribute
*attr
, char *page
)
331 switch (ipl_info
.type
) {
333 return sprintf(page
, "0.%x.%04x\n", ipl_block
.ccw
.ssid
,
334 ipl_block
.ccw
.devno
);
336 case IPL_TYPE_FCP_DUMP
:
337 return sprintf(page
, "0.0.%04x\n", ipl_block
.fcp
.devno
);
339 case IPL_TYPE_NVME_DUMP
:
340 return sprintf(page
, "%08ux\n", ipl_block
.nvme
.fid
);
346 static struct kobj_attribute sys_ipl_device_attr
=
347 __ATTR(device
, S_IRUGO
, sys_ipl_device_show
, NULL
);
349 static ssize_t
ipl_parameter_read(struct file
*filp
, struct kobject
*kobj
,
350 struct bin_attribute
*attr
, char *buf
,
351 loff_t off
, size_t count
)
353 return memory_read_from_buffer(buf
, count
, &off
, &ipl_block
,
356 static struct bin_attribute ipl_parameter_attr
=
357 __BIN_ATTR(binary_parameter
, S_IRUGO
, ipl_parameter_read
, NULL
,
360 static ssize_t
ipl_scp_data_read(struct file
*filp
, struct kobject
*kobj
,
361 struct bin_attribute
*attr
, char *buf
,
362 loff_t off
, size_t count
)
364 unsigned int size
= ipl_block
.fcp
.scp_data_len
;
365 void *scp_data
= &ipl_block
.fcp
.scp_data
;
367 return memory_read_from_buffer(buf
, count
, &off
, scp_data
, size
);
370 static ssize_t
ipl_nvme_scp_data_read(struct file
*filp
, struct kobject
*kobj
,
371 struct bin_attribute
*attr
, char *buf
,
372 loff_t off
, size_t count
)
374 unsigned int size
= ipl_block
.nvme
.scp_data_len
;
375 void *scp_data
= &ipl_block
.nvme
.scp_data
;
377 return memory_read_from_buffer(buf
, count
, &off
, scp_data
, size
);
380 static struct bin_attribute ipl_scp_data_attr
=
381 __BIN_ATTR(scp_data
, S_IRUGO
, ipl_scp_data_read
, NULL
, PAGE_SIZE
);
383 static struct bin_attribute ipl_nvme_scp_data_attr
=
384 __BIN_ATTR(scp_data
, S_IRUGO
, ipl_nvme_scp_data_read
, NULL
, PAGE_SIZE
);
386 static struct bin_attribute
*ipl_fcp_bin_attrs
[] = {
392 static struct bin_attribute
*ipl_nvme_bin_attrs
[] = {
394 &ipl_nvme_scp_data_attr
,
398 /* FCP ipl device attributes */
400 DEFINE_IPL_ATTR_RO(ipl_fcp
, wwpn
, "0x%016llx\n",
401 (unsigned long long)ipl_block
.fcp
.wwpn
);
402 DEFINE_IPL_ATTR_RO(ipl_fcp
, lun
, "0x%016llx\n",
403 (unsigned long long)ipl_block
.fcp
.lun
);
404 DEFINE_IPL_ATTR_RO(ipl_fcp
, bootprog
, "%lld\n",
405 (unsigned long long)ipl_block
.fcp
.bootprog
);
406 DEFINE_IPL_ATTR_RO(ipl_fcp
, br_lba
, "%lld\n",
407 (unsigned long long)ipl_block
.fcp
.br_lba
);
409 /* NVMe ipl device attributes */
410 DEFINE_IPL_ATTR_RO(ipl_nvme
, fid
, "0x%08llx\n",
411 (unsigned long long)ipl_block
.nvme
.fid
);
412 DEFINE_IPL_ATTR_RO(ipl_nvme
, nsid
, "0x%08llx\n",
413 (unsigned long long)ipl_block
.nvme
.nsid
);
414 DEFINE_IPL_ATTR_RO(ipl_nvme
, bootprog
, "%lld\n",
415 (unsigned long long)ipl_block
.nvme
.bootprog
);
416 DEFINE_IPL_ATTR_RO(ipl_nvme
, br_lba
, "%lld\n",
417 (unsigned long long)ipl_block
.nvme
.br_lba
);
419 static ssize_t
ipl_ccw_loadparm_show(struct kobject
*kobj
,
420 struct kobj_attribute
*attr
, char *page
)
422 char loadparm
[LOADPARM_LEN
+ 1] = {};
424 if (!sclp_ipl_info
.is_valid
)
425 return sprintf(page
, "#unknown#\n");
426 memcpy(loadparm
, &sclp_ipl_info
.loadparm
, LOADPARM_LEN
);
427 EBCASC(loadparm
, LOADPARM_LEN
);
429 return sprintf(page
, "%s\n", loadparm
);
432 static struct kobj_attribute sys_ipl_ccw_loadparm_attr
=
433 __ATTR(loadparm
, 0444, ipl_ccw_loadparm_show
, NULL
);
435 static struct attribute
*ipl_fcp_attrs
[] = {
436 &sys_ipl_type_attr
.attr
,
437 &sys_ipl_device_attr
.attr
,
438 &sys_ipl_fcp_wwpn_attr
.attr
,
439 &sys_ipl_fcp_lun_attr
.attr
,
440 &sys_ipl_fcp_bootprog_attr
.attr
,
441 &sys_ipl_fcp_br_lba_attr
.attr
,
442 &sys_ipl_ccw_loadparm_attr
.attr
,
443 &sys_ipl_secure_attr
.attr
,
444 &sys_ipl_has_secure_attr
.attr
,
448 static struct attribute_group ipl_fcp_attr_group
= {
449 .attrs
= ipl_fcp_attrs
,
450 .bin_attrs
= ipl_fcp_bin_attrs
,
453 static struct attribute
*ipl_nvme_attrs
[] = {
454 &sys_ipl_type_attr
.attr
,
455 &sys_ipl_nvme_fid_attr
.attr
,
456 &sys_ipl_nvme_nsid_attr
.attr
,
457 &sys_ipl_nvme_bootprog_attr
.attr
,
458 &sys_ipl_nvme_br_lba_attr
.attr
,
459 &sys_ipl_ccw_loadparm_attr
.attr
,
460 &sys_ipl_secure_attr
.attr
,
461 &sys_ipl_has_secure_attr
.attr
,
465 static struct attribute_group ipl_nvme_attr_group
= {
466 .attrs
= ipl_nvme_attrs
,
467 .bin_attrs
= ipl_nvme_bin_attrs
,
471 /* CCW ipl device attributes */
473 static struct attribute
*ipl_ccw_attrs_vm
[] = {
474 &sys_ipl_type_attr
.attr
,
475 &sys_ipl_device_attr
.attr
,
476 &sys_ipl_ccw_loadparm_attr
.attr
,
477 &sys_ipl_vm_parm_attr
.attr
,
478 &sys_ipl_secure_attr
.attr
,
479 &sys_ipl_has_secure_attr
.attr
,
483 static struct attribute
*ipl_ccw_attrs_lpar
[] = {
484 &sys_ipl_type_attr
.attr
,
485 &sys_ipl_device_attr
.attr
,
486 &sys_ipl_ccw_loadparm_attr
.attr
,
487 &sys_ipl_secure_attr
.attr
,
488 &sys_ipl_has_secure_attr
.attr
,
492 static struct attribute_group ipl_ccw_attr_group_vm
= {
493 .attrs
= ipl_ccw_attrs_vm
,
496 static struct attribute_group ipl_ccw_attr_group_lpar
= {
497 .attrs
= ipl_ccw_attrs_lpar
500 /* UNKNOWN ipl device attributes */
502 static struct attribute
*ipl_unknown_attrs
[] = {
503 &sys_ipl_type_attr
.attr
,
507 static struct attribute_group ipl_unknown_attr_group
= {
508 .attrs
= ipl_unknown_attrs
,
511 static struct kset
*ipl_kset
;
513 static void __ipl_run(void *unused
)
516 diag308(DIAG308_LOAD_CLEAR
, NULL
);
519 static void ipl_run(struct shutdown_trigger
*trigger
)
521 smp_call_ipl_cpu(__ipl_run
, NULL
);
524 static int __init
ipl_init(void)
528 ipl_kset
= kset_create_and_add("ipl", NULL
, firmware_kobj
);
533 switch (ipl_info
.type
) {
536 rc
= sysfs_create_group(&ipl_kset
->kobj
,
537 &ipl_ccw_attr_group_vm
);
539 rc
= sysfs_create_group(&ipl_kset
->kobj
,
540 &ipl_ccw_attr_group_lpar
);
543 case IPL_TYPE_FCP_DUMP
:
544 rc
= sysfs_create_group(&ipl_kset
->kobj
, &ipl_fcp_attr_group
);
547 case IPL_TYPE_NVME_DUMP
:
548 rc
= sysfs_create_group(&ipl_kset
->kobj
, &ipl_nvme_attr_group
);
551 rc
= sysfs_create_group(&ipl_kset
->kobj
,
552 &ipl_unknown_attr_group
);
557 panic("ipl_init failed: rc = %i\n", rc
);
562 static struct shutdown_action __refdata ipl_action
= {
563 .name
= SHUTDOWN_ACTION_IPL_STR
,
569 * reipl shutdown action: Reboot Linux on shutdown.
572 /* VM IPL PARM attributes */
573 static ssize_t
reipl_generic_vmparm_show(struct ipl_parameter_block
*ipb
,
576 char vmparm
[DIAG308_VMPARM_SIZE
+ 1] = {};
578 ipl_block_get_ascii_vmparm(vmparm
, sizeof(vmparm
), ipb
);
579 return sprintf(page
, "%s\n", vmparm
);
582 static ssize_t
reipl_generic_vmparm_store(struct ipl_parameter_block
*ipb
,
584 const char *buf
, size_t len
)
588 /* ignore trailing newline */
590 if ((len
> 0) && (buf
[len
- 1] == '\n'))
593 if (ip_len
> vmparm_max
)
596 /* parm is used to store kernel options, check for common chars */
597 for (i
= 0; i
< ip_len
; i
++)
598 if (!(isalnum(buf
[i
]) || isascii(buf
[i
]) || isprint(buf
[i
])))
601 memset(ipb
->ccw
.vm_parm
, 0, DIAG308_VMPARM_SIZE
);
602 ipb
->ccw
.vm_parm_len
= ip_len
;
604 ipb
->ccw
.vm_flags
|= IPL_PB0_CCW_VM_FLAG_VP
;
605 memcpy(ipb
->ccw
.vm_parm
, buf
, ip_len
);
606 ASCEBC(ipb
->ccw
.vm_parm
, ip_len
);
608 ipb
->ccw
.vm_flags
&= ~IPL_PB0_CCW_VM_FLAG_VP
;
615 static ssize_t
reipl_nss_vmparm_show(struct kobject
*kobj
,
616 struct kobj_attribute
*attr
, char *page
)
618 return reipl_generic_vmparm_show(reipl_block_nss
, page
);
621 static ssize_t
reipl_nss_vmparm_store(struct kobject
*kobj
,
622 struct kobj_attribute
*attr
,
623 const char *buf
, size_t len
)
625 return reipl_generic_vmparm_store(reipl_block_nss
, 56, buf
, len
);
629 static ssize_t
reipl_ccw_vmparm_show(struct kobject
*kobj
,
630 struct kobj_attribute
*attr
, char *page
)
632 return reipl_generic_vmparm_show(reipl_block_ccw
, page
);
635 static ssize_t
reipl_ccw_vmparm_store(struct kobject
*kobj
,
636 struct kobj_attribute
*attr
,
637 const char *buf
, size_t len
)
639 return reipl_generic_vmparm_store(reipl_block_ccw
, 64, buf
, len
);
642 static struct kobj_attribute sys_reipl_nss_vmparm_attr
=
643 __ATTR(parm
, S_IRUGO
| S_IWUSR
, reipl_nss_vmparm_show
,
644 reipl_nss_vmparm_store
);
645 static struct kobj_attribute sys_reipl_ccw_vmparm_attr
=
646 __ATTR(parm
, S_IRUGO
| S_IWUSR
, reipl_ccw_vmparm_show
,
647 reipl_ccw_vmparm_store
);
649 /* FCP reipl device attributes */
651 static ssize_t
reipl_fcp_scpdata_read(struct file
*filp
, struct kobject
*kobj
,
652 struct bin_attribute
*attr
,
653 char *buf
, loff_t off
, size_t count
)
655 size_t size
= reipl_block_fcp
->fcp
.scp_data_len
;
656 void *scp_data
= reipl_block_fcp
->fcp
.scp_data
;
658 return memory_read_from_buffer(buf
, count
, &off
, scp_data
, size
);
661 static ssize_t
reipl_fcp_scpdata_write(struct file
*filp
, struct kobject
*kobj
,
662 struct bin_attribute
*attr
,
663 char *buf
, loff_t off
, size_t count
)
665 size_t scpdata_len
= count
;
672 memcpy(reipl_block_fcp
->fcp
.scp_data
, buf
, count
);
673 if (scpdata_len
% 8) {
674 padding
= 8 - (scpdata_len
% 8);
675 memset(reipl_block_fcp
->fcp
.scp_data
+ scpdata_len
,
677 scpdata_len
+= padding
;
680 reipl_block_fcp
->hdr
.len
= IPL_BP_FCP_LEN
+ scpdata_len
;
681 reipl_block_fcp
->fcp
.len
= IPL_BP0_FCP_LEN
+ scpdata_len
;
682 reipl_block_fcp
->fcp
.scp_data_len
= scpdata_len
;
686 static struct bin_attribute sys_reipl_fcp_scp_data_attr
=
687 __BIN_ATTR(scp_data
, (S_IRUGO
| S_IWUSR
), reipl_fcp_scpdata_read
,
688 reipl_fcp_scpdata_write
, DIAG308_SCPDATA_SIZE
);
690 static struct bin_attribute
*reipl_fcp_bin_attrs
[] = {
691 &sys_reipl_fcp_scp_data_attr
,
695 DEFINE_IPL_ATTR_RW(reipl_fcp
, wwpn
, "0x%016llx\n", "%llx\n",
696 reipl_block_fcp
->fcp
.wwpn
);
697 DEFINE_IPL_ATTR_RW(reipl_fcp
, lun
, "0x%016llx\n", "%llx\n",
698 reipl_block_fcp
->fcp
.lun
);
699 DEFINE_IPL_ATTR_RW(reipl_fcp
, bootprog
, "%lld\n", "%lld\n",
700 reipl_block_fcp
->fcp
.bootprog
);
701 DEFINE_IPL_ATTR_RW(reipl_fcp
, br_lba
, "%lld\n", "%lld\n",
702 reipl_block_fcp
->fcp
.br_lba
);
703 DEFINE_IPL_ATTR_RW(reipl_fcp
, device
, "0.0.%04llx\n", "0.0.%llx\n",
704 reipl_block_fcp
->fcp
.devno
);
706 static void reipl_get_ascii_loadparm(char *loadparm
,
707 struct ipl_parameter_block
*ibp
)
709 memcpy(loadparm
, ibp
->common
.loadparm
, LOADPARM_LEN
);
710 EBCASC(loadparm
, LOADPARM_LEN
);
711 loadparm
[LOADPARM_LEN
] = 0;
715 static ssize_t
reipl_generic_loadparm_show(struct ipl_parameter_block
*ipb
,
718 char buf
[LOADPARM_LEN
+ 1];
720 reipl_get_ascii_loadparm(buf
, ipb
);
721 return sprintf(page
, "%s\n", buf
);
724 static ssize_t
reipl_generic_loadparm_store(struct ipl_parameter_block
*ipb
,
725 const char *buf
, size_t len
)
729 /* ignore trailing newline */
731 if ((len
> 0) && (buf
[len
- 1] == '\n'))
733 /* loadparm can have max 8 characters and must not start with a blank */
734 if ((lp_len
> LOADPARM_LEN
) || ((lp_len
> 0) && (buf
[0] == ' ')))
736 /* loadparm can only contain "a-z,A-Z,0-9,SP,." */
737 for (i
= 0; i
< lp_len
; i
++) {
738 if (isalpha(buf
[i
]) || isdigit(buf
[i
]) || (buf
[i
] == ' ') ||
743 /* initialize loadparm with blanks */
744 memset(ipb
->common
.loadparm
, ' ', LOADPARM_LEN
);
745 /* copy and convert to ebcdic */
746 memcpy(ipb
->common
.loadparm
, buf
, lp_len
);
747 ASCEBC(ipb
->common
.loadparm
, LOADPARM_LEN
);
748 ipb
->common
.flags
|= IPL_PB0_FLAG_LOADPARM
;
753 static ssize_t
reipl_fcp_loadparm_show(struct kobject
*kobj
,
754 struct kobj_attribute
*attr
, char *page
)
756 return reipl_generic_loadparm_show(reipl_block_fcp
, page
);
759 static ssize_t
reipl_fcp_loadparm_store(struct kobject
*kobj
,
760 struct kobj_attribute
*attr
,
761 const char *buf
, size_t len
)
763 return reipl_generic_loadparm_store(reipl_block_fcp
, buf
, len
);
766 static struct kobj_attribute sys_reipl_fcp_loadparm_attr
=
767 __ATTR(loadparm
, S_IRUGO
| S_IWUSR
, reipl_fcp_loadparm_show
,
768 reipl_fcp_loadparm_store
);
770 static ssize_t
reipl_fcp_clear_show(struct kobject
*kobj
,
771 struct kobj_attribute
*attr
, char *page
)
773 return sprintf(page
, "%u\n", reipl_fcp_clear
);
776 static ssize_t
reipl_fcp_clear_store(struct kobject
*kobj
,
777 struct kobj_attribute
*attr
,
778 const char *buf
, size_t len
)
780 if (strtobool(buf
, &reipl_fcp_clear
) < 0)
785 static struct attribute
*reipl_fcp_attrs
[] = {
786 &sys_reipl_fcp_device_attr
.attr
,
787 &sys_reipl_fcp_wwpn_attr
.attr
,
788 &sys_reipl_fcp_lun_attr
.attr
,
789 &sys_reipl_fcp_bootprog_attr
.attr
,
790 &sys_reipl_fcp_br_lba_attr
.attr
,
791 &sys_reipl_fcp_loadparm_attr
.attr
,
795 static struct attribute_group reipl_fcp_attr_group
= {
796 .attrs
= reipl_fcp_attrs
,
797 .bin_attrs
= reipl_fcp_bin_attrs
,
800 static struct kobj_attribute sys_reipl_fcp_clear_attr
=
801 __ATTR(clear
, 0644, reipl_fcp_clear_show
, reipl_fcp_clear_store
);
803 /* NVME reipl device attributes */
805 static ssize_t
reipl_nvme_scpdata_read(struct file
*filp
, struct kobject
*kobj
,
806 struct bin_attribute
*attr
,
807 char *buf
, loff_t off
, size_t count
)
809 size_t size
= reipl_block_nvme
->nvme
.scp_data_len
;
810 void *scp_data
= reipl_block_nvme
->nvme
.scp_data
;
812 return memory_read_from_buffer(buf
, count
, &off
, scp_data
, size
);
815 static ssize_t
reipl_nvme_scpdata_write(struct file
*filp
, struct kobject
*kobj
,
816 struct bin_attribute
*attr
,
817 char *buf
, loff_t off
, size_t count
)
819 size_t scpdata_len
= count
;
825 memcpy(reipl_block_nvme
->nvme
.scp_data
, buf
, count
);
826 if (scpdata_len
% 8) {
827 padding
= 8 - (scpdata_len
% 8);
828 memset(reipl_block_nvme
->nvme
.scp_data
+ scpdata_len
,
830 scpdata_len
+= padding
;
833 reipl_block_nvme
->hdr
.len
= IPL_BP_FCP_LEN
+ scpdata_len
;
834 reipl_block_nvme
->nvme
.len
= IPL_BP0_FCP_LEN
+ scpdata_len
;
835 reipl_block_nvme
->nvme
.scp_data_len
= scpdata_len
;
840 static struct bin_attribute sys_reipl_nvme_scp_data_attr
=
841 __BIN_ATTR(scp_data
, (S_IRUGO
| S_IWUSR
), reipl_nvme_scpdata_read
,
842 reipl_nvme_scpdata_write
, DIAG308_SCPDATA_SIZE
);
844 static struct bin_attribute
*reipl_nvme_bin_attrs
[] = {
845 &sys_reipl_nvme_scp_data_attr
,
849 DEFINE_IPL_ATTR_RW(reipl_nvme
, fid
, "0x%08llx\n", "%llx\n",
850 reipl_block_nvme
->nvme
.fid
);
851 DEFINE_IPL_ATTR_RW(reipl_nvme
, nsid
, "0x%08llx\n", "%llx\n",
852 reipl_block_nvme
->nvme
.nsid
);
853 DEFINE_IPL_ATTR_RW(reipl_nvme
, bootprog
, "%lld\n", "%lld\n",
854 reipl_block_nvme
->nvme
.bootprog
);
855 DEFINE_IPL_ATTR_RW(reipl_nvme
, br_lba
, "%lld\n", "%lld\n",
856 reipl_block_nvme
->nvme
.br_lba
);
859 static ssize_t
reipl_nvme_loadparm_show(struct kobject
*kobj
,
860 struct kobj_attribute
*attr
, char *page
)
862 return reipl_generic_loadparm_show(reipl_block_nvme
, page
);
865 static ssize_t
reipl_nvme_loadparm_store(struct kobject
*kobj
,
866 struct kobj_attribute
*attr
,
867 const char *buf
, size_t len
)
869 return reipl_generic_loadparm_store(reipl_block_nvme
, buf
, len
);
872 static struct kobj_attribute sys_reipl_nvme_loadparm_attr
=
873 __ATTR(loadparm
, S_IRUGO
| S_IWUSR
, reipl_nvme_loadparm_show
,
874 reipl_nvme_loadparm_store
);
876 static struct attribute
*reipl_nvme_attrs
[] = {
877 &sys_reipl_nvme_fid_attr
.attr
,
878 &sys_reipl_nvme_nsid_attr
.attr
,
879 &sys_reipl_nvme_bootprog_attr
.attr
,
880 &sys_reipl_nvme_br_lba_attr
.attr
,
881 &sys_reipl_nvme_loadparm_attr
.attr
,
885 static struct attribute_group reipl_nvme_attr_group
= {
886 .attrs
= reipl_nvme_attrs
,
887 .bin_attrs
= reipl_nvme_bin_attrs
890 static ssize_t
reipl_nvme_clear_show(struct kobject
*kobj
,
891 struct kobj_attribute
*attr
, char *page
)
893 return sprintf(page
, "%u\n", reipl_nvme_clear
);
896 static ssize_t
reipl_nvme_clear_store(struct kobject
*kobj
,
897 struct kobj_attribute
*attr
,
898 const char *buf
, size_t len
)
900 if (strtobool(buf
, &reipl_nvme_clear
) < 0)
905 static struct kobj_attribute sys_reipl_nvme_clear_attr
=
906 __ATTR(clear
, 0644, reipl_nvme_clear_show
, reipl_nvme_clear_store
);
908 /* CCW reipl device attributes */
909 DEFINE_IPL_CCW_ATTR_RW(reipl_ccw
, device
, reipl_block_ccw
->ccw
);
912 static ssize_t
reipl_nss_loadparm_show(struct kobject
*kobj
,
913 struct kobj_attribute
*attr
, char *page
)
915 return reipl_generic_loadparm_show(reipl_block_nss
, page
);
918 static ssize_t
reipl_nss_loadparm_store(struct kobject
*kobj
,
919 struct kobj_attribute
*attr
,
920 const char *buf
, size_t len
)
922 return reipl_generic_loadparm_store(reipl_block_nss
, buf
, len
);
926 static ssize_t
reipl_ccw_loadparm_show(struct kobject
*kobj
,
927 struct kobj_attribute
*attr
, char *page
)
929 return reipl_generic_loadparm_show(reipl_block_ccw
, page
);
932 static ssize_t
reipl_ccw_loadparm_store(struct kobject
*kobj
,
933 struct kobj_attribute
*attr
,
934 const char *buf
, size_t len
)
936 return reipl_generic_loadparm_store(reipl_block_ccw
, buf
, len
);
939 static struct kobj_attribute sys_reipl_ccw_loadparm_attr
=
940 __ATTR(loadparm
, S_IRUGO
| S_IWUSR
, reipl_ccw_loadparm_show
,
941 reipl_ccw_loadparm_store
);
943 static ssize_t
reipl_ccw_clear_show(struct kobject
*kobj
,
944 struct kobj_attribute
*attr
, char *page
)
946 return sprintf(page
, "%u\n", reipl_ccw_clear
);
949 static ssize_t
reipl_ccw_clear_store(struct kobject
*kobj
,
950 struct kobj_attribute
*attr
,
951 const char *buf
, size_t len
)
953 if (strtobool(buf
, &reipl_ccw_clear
) < 0)
958 static struct kobj_attribute sys_reipl_ccw_clear_attr
=
959 __ATTR(clear
, 0644, reipl_ccw_clear_show
, reipl_ccw_clear_store
);
961 static struct attribute
*reipl_ccw_attrs_vm
[] = {
962 &sys_reipl_ccw_device_attr
.attr
,
963 &sys_reipl_ccw_loadparm_attr
.attr
,
964 &sys_reipl_ccw_vmparm_attr
.attr
,
965 &sys_reipl_ccw_clear_attr
.attr
,
969 static struct attribute
*reipl_ccw_attrs_lpar
[] = {
970 &sys_reipl_ccw_device_attr
.attr
,
971 &sys_reipl_ccw_loadparm_attr
.attr
,
972 &sys_reipl_ccw_clear_attr
.attr
,
976 static struct attribute_group reipl_ccw_attr_group_vm
= {
978 .attrs
= reipl_ccw_attrs_vm
,
981 static struct attribute_group reipl_ccw_attr_group_lpar
= {
983 .attrs
= reipl_ccw_attrs_lpar
,
987 /* NSS reipl device attributes */
988 static void reipl_get_ascii_nss_name(char *dst
,
989 struct ipl_parameter_block
*ipb
)
991 memcpy(dst
, ipb
->ccw
.nss_name
, NSS_NAME_SIZE
);
992 EBCASC(dst
, NSS_NAME_SIZE
);
993 dst
[NSS_NAME_SIZE
] = 0;
996 static ssize_t
reipl_nss_name_show(struct kobject
*kobj
,
997 struct kobj_attribute
*attr
, char *page
)
999 char nss_name
[NSS_NAME_SIZE
+ 1] = {};
1001 reipl_get_ascii_nss_name(nss_name
, reipl_block_nss
);
1002 return sprintf(page
, "%s\n", nss_name
);
1005 static ssize_t
reipl_nss_name_store(struct kobject
*kobj
,
1006 struct kobj_attribute
*attr
,
1007 const char *buf
, size_t len
)
1011 /* ignore trailing newline */
1013 if ((len
> 0) && (buf
[len
- 1] == '\n'))
1016 if (nss_len
> NSS_NAME_SIZE
)
1019 memset(reipl_block_nss
->ccw
.nss_name
, 0x40, NSS_NAME_SIZE
);
1021 reipl_block_nss
->ccw
.vm_flags
|= IPL_PB0_CCW_VM_FLAG_NSS
;
1022 memcpy(reipl_block_nss
->ccw
.nss_name
, buf
, nss_len
);
1023 ASCEBC(reipl_block_nss
->ccw
.nss_name
, nss_len
);
1024 EBC_TOUPPER(reipl_block_nss
->ccw
.nss_name
, nss_len
);
1026 reipl_block_nss
->ccw
.vm_flags
&= ~IPL_PB0_CCW_VM_FLAG_NSS
;
1032 static struct kobj_attribute sys_reipl_nss_name_attr
=
1033 __ATTR(name
, S_IRUGO
| S_IWUSR
, reipl_nss_name_show
,
1034 reipl_nss_name_store
);
1036 static struct kobj_attribute sys_reipl_nss_loadparm_attr
=
1037 __ATTR(loadparm
, S_IRUGO
| S_IWUSR
, reipl_nss_loadparm_show
,
1038 reipl_nss_loadparm_store
);
1040 static struct attribute
*reipl_nss_attrs
[] = {
1041 &sys_reipl_nss_name_attr
.attr
,
1042 &sys_reipl_nss_loadparm_attr
.attr
,
1043 &sys_reipl_nss_vmparm_attr
.attr
,
1047 static struct attribute_group reipl_nss_attr_group
= {
1048 .name
= IPL_NSS_STR
,
1049 .attrs
= reipl_nss_attrs
,
1052 void set_os_info_reipl_block(void)
1054 os_info_entry_add(OS_INFO_REIPL_BLOCK
, reipl_block_actual
,
1055 reipl_block_actual
->hdr
.len
);
1060 static int reipl_set_type(enum ipl_type type
)
1062 if (!(reipl_capabilities
& type
))
1067 reipl_block_actual
= reipl_block_ccw
;
1070 reipl_block_actual
= reipl_block_fcp
;
1073 reipl_block_actual
= reipl_block_nvme
;
1076 reipl_block_actual
= reipl_block_nss
;
1085 static ssize_t
reipl_type_show(struct kobject
*kobj
,
1086 struct kobj_attribute
*attr
, char *page
)
1088 return sprintf(page
, "%s\n", ipl_type_str(reipl_type
));
1091 static ssize_t
reipl_type_store(struct kobject
*kobj
,
1092 struct kobj_attribute
*attr
,
1093 const char *buf
, size_t len
)
1097 if (strncmp(buf
, IPL_CCW_STR
, strlen(IPL_CCW_STR
)) == 0)
1098 rc
= reipl_set_type(IPL_TYPE_CCW
);
1099 else if (strncmp(buf
, IPL_FCP_STR
, strlen(IPL_FCP_STR
)) == 0)
1100 rc
= reipl_set_type(IPL_TYPE_FCP
);
1101 else if (strncmp(buf
, IPL_NVME_STR
, strlen(IPL_NVME_STR
)) == 0)
1102 rc
= reipl_set_type(IPL_TYPE_NVME
);
1103 else if (strncmp(buf
, IPL_NSS_STR
, strlen(IPL_NSS_STR
)) == 0)
1104 rc
= reipl_set_type(IPL_TYPE_NSS
);
1105 return (rc
!= 0) ? rc
: len
;
1108 static struct kobj_attribute reipl_type_attr
=
1109 __ATTR(reipl_type
, 0644, reipl_type_show
, reipl_type_store
);
1111 static struct kset
*reipl_kset
;
1112 static struct kset
*reipl_fcp_kset
;
1113 static struct kset
*reipl_nvme_kset
;
1115 static void __reipl_run(void *unused
)
1117 switch (reipl_type
) {
1119 diag308(DIAG308_SET
, reipl_block_ccw
);
1120 if (reipl_ccw_clear
)
1121 diag308(DIAG308_LOAD_CLEAR
, NULL
);
1123 diag308(DIAG308_LOAD_NORMAL_DUMP
, NULL
);
1126 diag308(DIAG308_SET
, reipl_block_fcp
);
1127 if (reipl_fcp_clear
)
1128 diag308(DIAG308_LOAD_CLEAR
, NULL
);
1130 diag308(DIAG308_LOAD_NORMAL
, NULL
);
1133 diag308(DIAG308_SET
, reipl_block_nvme
);
1134 if (reipl_nvme_clear
)
1135 diag308(DIAG308_LOAD_CLEAR
, NULL
);
1137 diag308(DIAG308_LOAD_NORMAL
, NULL
);
1140 diag308(DIAG308_SET
, reipl_block_nss
);
1141 diag308(DIAG308_LOAD_CLEAR
, NULL
);
1143 case IPL_TYPE_UNKNOWN
:
1144 diag308(DIAG308_LOAD_CLEAR
, NULL
);
1146 case IPL_TYPE_FCP_DUMP
:
1147 case IPL_TYPE_NVME_DUMP
:
1153 static void reipl_run(struct shutdown_trigger
*trigger
)
1155 smp_call_ipl_cpu(__reipl_run
, NULL
);
1158 static void reipl_block_ccw_init(struct ipl_parameter_block
*ipb
)
1160 ipb
->hdr
.len
= IPL_BP_CCW_LEN
;
1161 ipb
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
1162 ipb
->pb0_hdr
.len
= IPL_BP0_CCW_LEN
;
1163 ipb
->pb0_hdr
.pbt
= IPL_PBT_CCW
;
1166 static void reipl_block_ccw_fill_parms(struct ipl_parameter_block
*ipb
)
1169 /* check if read scp info worked and set loadparm */
1170 if (sclp_ipl_info
.is_valid
)
1171 memcpy(ipb
->ccw
.loadparm
, &sclp_ipl_info
.loadparm
, LOADPARM_LEN
);
1173 /* read scp info failed: set empty loadparm (EBCDIC blanks) */
1174 memset(ipb
->ccw
.loadparm
, 0x40, LOADPARM_LEN
);
1175 ipb
->ccw
.flags
= IPL_PB0_FLAG_LOADPARM
;
1178 if (MACHINE_IS_VM
&& ipl_block_valid
&&
1179 (ipl_block
.ccw
.vm_flags
& IPL_PB0_CCW_VM_FLAG_VP
)) {
1181 ipb
->ccw
.vm_flags
|= IPL_PB0_CCW_VM_FLAG_VP
;
1182 ipb
->ccw
.vm_parm_len
= ipl_block
.ccw
.vm_parm_len
;
1183 memcpy(ipb
->ccw
.vm_parm
,
1184 ipl_block
.ccw
.vm_parm
, DIAG308_VMPARM_SIZE
);
1188 static int __init
reipl_nss_init(void)
1195 reipl_block_nss
= (void *) get_zeroed_page(GFP_KERNEL
);
1196 if (!reipl_block_nss
)
1199 rc
= sysfs_create_group(&reipl_kset
->kobj
, &reipl_nss_attr_group
);
1203 reipl_block_ccw_init(reipl_block_nss
);
1204 reipl_capabilities
|= IPL_TYPE_NSS
;
1208 static int __init
reipl_ccw_init(void)
1212 reipl_block_ccw
= (void *) get_zeroed_page(GFP_KERNEL
);
1213 if (!reipl_block_ccw
)
1216 rc
= sysfs_create_group(&reipl_kset
->kobj
,
1217 MACHINE_IS_VM
? &reipl_ccw_attr_group_vm
1218 : &reipl_ccw_attr_group_lpar
);
1222 reipl_block_ccw_init(reipl_block_ccw
);
1223 if (ipl_info
.type
== IPL_TYPE_CCW
) {
1224 reipl_block_ccw
->ccw
.ssid
= ipl_block
.ccw
.ssid
;
1225 reipl_block_ccw
->ccw
.devno
= ipl_block
.ccw
.devno
;
1226 reipl_block_ccw_fill_parms(reipl_block_ccw
);
1229 reipl_capabilities
|= IPL_TYPE_CCW
;
1233 static int __init
reipl_fcp_init(void)
1237 reipl_block_fcp
= (void *) get_zeroed_page(GFP_KERNEL
);
1238 if (!reipl_block_fcp
)
1241 /* sysfs: create fcp kset for mixing attr group and bin attrs */
1242 reipl_fcp_kset
= kset_create_and_add(IPL_FCP_STR
, NULL
,
1244 if (!reipl_fcp_kset
) {
1245 free_page((unsigned long) reipl_block_fcp
);
1249 rc
= sysfs_create_group(&reipl_fcp_kset
->kobj
, &reipl_fcp_attr_group
);
1253 if (test_facility(141)) {
1254 rc
= sysfs_create_file(&reipl_fcp_kset
->kobj
,
1255 &sys_reipl_fcp_clear_attr
.attr
);
1259 reipl_fcp_clear
= true;
1262 if (ipl_info
.type
== IPL_TYPE_FCP
) {
1263 memcpy(reipl_block_fcp
, &ipl_block
, sizeof(ipl_block
));
1265 * Fix loadparm: There are systems where the (SCSI) LOADPARM
1266 * is invalid in the SCSI IPL parameter block, so take it
1267 * always from sclp_ipl_info.
1269 memcpy(reipl_block_fcp
->fcp
.loadparm
, sclp_ipl_info
.loadparm
,
1272 reipl_block_fcp
->hdr
.len
= IPL_BP_FCP_LEN
;
1273 reipl_block_fcp
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
1274 reipl_block_fcp
->fcp
.len
= IPL_BP0_FCP_LEN
;
1275 reipl_block_fcp
->fcp
.pbt
= IPL_PBT_FCP
;
1276 reipl_block_fcp
->fcp
.opt
= IPL_PB0_FCP_OPT_IPL
;
1278 reipl_capabilities
|= IPL_TYPE_FCP
;
1282 sysfs_remove_group(&reipl_fcp_kset
->kobj
, &reipl_fcp_attr_group
);
1284 kset_unregister(reipl_fcp_kset
);
1285 free_page((unsigned long) reipl_block_fcp
);
1289 static int __init
reipl_nvme_init(void)
1293 reipl_block_nvme
= (void *) get_zeroed_page(GFP_KERNEL
);
1294 if (!reipl_block_nvme
)
1297 /* sysfs: create kset for mixing attr group and bin attrs */
1298 reipl_nvme_kset
= kset_create_and_add(IPL_NVME_STR
, NULL
,
1300 if (!reipl_nvme_kset
) {
1301 free_page((unsigned long) reipl_block_nvme
);
1305 rc
= sysfs_create_group(&reipl_nvme_kset
->kobj
, &reipl_nvme_attr_group
);
1309 if (test_facility(141)) {
1310 rc
= sysfs_create_file(&reipl_nvme_kset
->kobj
,
1311 &sys_reipl_nvme_clear_attr
.attr
);
1315 reipl_nvme_clear
= true;
1318 if (ipl_info
.type
== IPL_TYPE_NVME
) {
1319 memcpy(reipl_block_nvme
, &ipl_block
, sizeof(ipl_block
));
1321 * Fix loadparm: There are systems where the (SCSI) LOADPARM
1322 * is invalid in the IPL parameter block, so take it
1323 * always from sclp_ipl_info.
1325 memcpy(reipl_block_nvme
->nvme
.loadparm
, sclp_ipl_info
.loadparm
,
1328 reipl_block_nvme
->hdr
.len
= IPL_BP_NVME_LEN
;
1329 reipl_block_nvme
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
1330 reipl_block_nvme
->nvme
.len
= IPL_BP0_NVME_LEN
;
1331 reipl_block_nvme
->nvme
.pbt
= IPL_PBT_NVME
;
1332 reipl_block_nvme
->nvme
.opt
= IPL_PB0_NVME_OPT_IPL
;
1334 reipl_capabilities
|= IPL_TYPE_NVME
;
1338 sysfs_remove_group(&reipl_nvme_kset
->kobj
, &reipl_nvme_attr_group
);
1340 kset_unregister(reipl_nvme_kset
);
1341 free_page((unsigned long) reipl_block_nvme
);
1345 static int __init
reipl_type_init(void)
1347 enum ipl_type reipl_type
= ipl_info
.type
;
1348 struct ipl_parameter_block
*reipl_block
;
1351 reipl_block
= os_info_old_entry(OS_INFO_REIPL_BLOCK
, &size
);
1355 * If we have an OS info reipl block, this will be used
1357 if (reipl_block
->pb0_hdr
.pbt
== IPL_PBT_FCP
) {
1358 memcpy(reipl_block_fcp
, reipl_block
, size
);
1359 reipl_type
= IPL_TYPE_FCP
;
1360 } else if (reipl_block
->pb0_hdr
.pbt
== IPL_PBT_NVME
) {
1361 memcpy(reipl_block_nvme
, reipl_block
, size
);
1362 reipl_type
= IPL_TYPE_NVME
;
1363 } else if (reipl_block
->pb0_hdr
.pbt
== IPL_PBT_CCW
) {
1364 memcpy(reipl_block_ccw
, reipl_block
, size
);
1365 reipl_type
= IPL_TYPE_CCW
;
1368 return reipl_set_type(reipl_type
);
1371 static int __init
reipl_init(void)
1375 reipl_kset
= kset_create_and_add("reipl", NULL
, firmware_kobj
);
1378 rc
= sysfs_create_file(&reipl_kset
->kobj
, &reipl_type_attr
.attr
);
1380 kset_unregister(reipl_kset
);
1383 rc
= reipl_ccw_init();
1386 rc
= reipl_fcp_init();
1389 rc
= reipl_nvme_init();
1392 rc
= reipl_nss_init();
1395 return reipl_type_init();
1398 static struct shutdown_action __refdata reipl_action
= {
1399 .name
= SHUTDOWN_ACTION_REIPL_STR
,
1405 * dump shutdown action: Dump Linux on shutdown.
1408 /* FCP dump device attributes */
1410 DEFINE_IPL_ATTR_RW(dump_fcp
, wwpn
, "0x%016llx\n", "%llx\n",
1411 dump_block_fcp
->fcp
.wwpn
);
1412 DEFINE_IPL_ATTR_RW(dump_fcp
, lun
, "0x%016llx\n", "%llx\n",
1413 dump_block_fcp
->fcp
.lun
);
1414 DEFINE_IPL_ATTR_RW(dump_fcp
, bootprog
, "%lld\n", "%lld\n",
1415 dump_block_fcp
->fcp
.bootprog
);
1416 DEFINE_IPL_ATTR_RW(dump_fcp
, br_lba
, "%lld\n", "%lld\n",
1417 dump_block_fcp
->fcp
.br_lba
);
1418 DEFINE_IPL_ATTR_RW(dump_fcp
, device
, "0.0.%04llx\n", "0.0.%llx\n",
1419 dump_block_fcp
->fcp
.devno
);
1421 static struct attribute
*dump_fcp_attrs
[] = {
1422 &sys_dump_fcp_device_attr
.attr
,
1423 &sys_dump_fcp_wwpn_attr
.attr
,
1424 &sys_dump_fcp_lun_attr
.attr
,
1425 &sys_dump_fcp_bootprog_attr
.attr
,
1426 &sys_dump_fcp_br_lba_attr
.attr
,
1430 static struct attribute_group dump_fcp_attr_group
= {
1431 .name
= IPL_FCP_STR
,
1432 .attrs
= dump_fcp_attrs
,
1435 /* NVME dump device attributes */
1436 DEFINE_IPL_ATTR_RW(dump_nvme
, fid
, "0x%08llx\n", "%llx\n",
1437 dump_block_nvme
->nvme
.fid
);
1438 DEFINE_IPL_ATTR_RW(dump_nvme
, nsid
, "0x%08llx\n", "%llx\n",
1439 dump_block_nvme
->nvme
.nsid
);
1440 DEFINE_IPL_ATTR_RW(dump_nvme
, bootprog
, "%lld\n", "%llx\n",
1441 dump_block_nvme
->nvme
.bootprog
);
1442 DEFINE_IPL_ATTR_RW(dump_nvme
, br_lba
, "%lld\n", "%llx\n",
1443 dump_block_nvme
->nvme
.br_lba
);
1445 static struct attribute
*dump_nvme_attrs
[] = {
1446 &sys_dump_nvme_fid_attr
.attr
,
1447 &sys_dump_nvme_nsid_attr
.attr
,
1448 &sys_dump_nvme_bootprog_attr
.attr
,
1449 &sys_dump_nvme_br_lba_attr
.attr
,
1453 static struct attribute_group dump_nvme_attr_group
= {
1454 .name
= IPL_NVME_STR
,
1455 .attrs
= dump_nvme_attrs
,
1458 /* CCW dump device attributes */
1459 DEFINE_IPL_CCW_ATTR_RW(dump_ccw
, device
, dump_block_ccw
->ccw
);
1461 static struct attribute
*dump_ccw_attrs
[] = {
1462 &sys_dump_ccw_device_attr
.attr
,
1466 static struct attribute_group dump_ccw_attr_group
= {
1467 .name
= IPL_CCW_STR
,
1468 .attrs
= dump_ccw_attrs
,
1473 static int dump_set_type(enum dump_type type
)
1475 if (!(dump_capabilities
& type
))
1481 static ssize_t
dump_type_show(struct kobject
*kobj
,
1482 struct kobj_attribute
*attr
, char *page
)
1484 return sprintf(page
, "%s\n", dump_type_str(dump_type
));
1487 static ssize_t
dump_type_store(struct kobject
*kobj
,
1488 struct kobj_attribute
*attr
,
1489 const char *buf
, size_t len
)
1493 if (strncmp(buf
, DUMP_NONE_STR
, strlen(DUMP_NONE_STR
)) == 0)
1494 rc
= dump_set_type(DUMP_TYPE_NONE
);
1495 else if (strncmp(buf
, DUMP_CCW_STR
, strlen(DUMP_CCW_STR
)) == 0)
1496 rc
= dump_set_type(DUMP_TYPE_CCW
);
1497 else if (strncmp(buf
, DUMP_FCP_STR
, strlen(DUMP_FCP_STR
)) == 0)
1498 rc
= dump_set_type(DUMP_TYPE_FCP
);
1499 else if (strncmp(buf
, DUMP_NVME_STR
, strlen(DUMP_NVME_STR
)) == 0)
1500 rc
= dump_set_type(DUMP_TYPE_NVME
);
1501 return (rc
!= 0) ? rc
: len
;
1504 static struct kobj_attribute dump_type_attr
=
1505 __ATTR(dump_type
, 0644, dump_type_show
, dump_type_store
);
1507 static struct kset
*dump_kset
;
1509 static void diag308_dump(void *dump_block
)
1511 diag308(DIAG308_SET
, dump_block
);
1513 if (diag308(DIAG308_LOAD_NORMAL_DUMP
, NULL
) != 0x302)
1515 udelay(USEC_PER_SEC
);
1519 static void __dump_run(void *unused
)
1521 switch (dump_type
) {
1523 diag308_dump(dump_block_ccw
);
1526 diag308_dump(dump_block_fcp
);
1528 case DUMP_TYPE_NVME
:
1529 diag308_dump(dump_block_nvme
);
1536 static void dump_run(struct shutdown_trigger
*trigger
)
1538 if (dump_type
== DUMP_TYPE_NONE
)
1541 smp_call_ipl_cpu(__dump_run
, NULL
);
1544 static int __init
dump_ccw_init(void)
1548 dump_block_ccw
= (void *) get_zeroed_page(GFP_KERNEL
);
1549 if (!dump_block_ccw
)
1551 rc
= sysfs_create_group(&dump_kset
->kobj
, &dump_ccw_attr_group
);
1553 free_page((unsigned long)dump_block_ccw
);
1556 dump_block_ccw
->hdr
.len
= IPL_BP_CCW_LEN
;
1557 dump_block_ccw
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
1558 dump_block_ccw
->ccw
.len
= IPL_BP0_CCW_LEN
;
1559 dump_block_ccw
->ccw
.pbt
= IPL_PBT_CCW
;
1560 dump_capabilities
|= DUMP_TYPE_CCW
;
1564 static int __init
dump_fcp_init(void)
1568 if (!sclp_ipl_info
.has_dump
)
1569 return 0; /* LDIPL DUMP is not installed */
1570 dump_block_fcp
= (void *) get_zeroed_page(GFP_KERNEL
);
1571 if (!dump_block_fcp
)
1573 rc
= sysfs_create_group(&dump_kset
->kobj
, &dump_fcp_attr_group
);
1575 free_page((unsigned long)dump_block_fcp
);
1578 dump_block_fcp
->hdr
.len
= IPL_BP_FCP_LEN
;
1579 dump_block_fcp
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
1580 dump_block_fcp
->fcp
.len
= IPL_BP0_FCP_LEN
;
1581 dump_block_fcp
->fcp
.pbt
= IPL_PBT_FCP
;
1582 dump_block_fcp
->fcp
.opt
= IPL_PB0_FCP_OPT_DUMP
;
1583 dump_capabilities
|= DUMP_TYPE_FCP
;
1587 static int __init
dump_nvme_init(void)
1591 if (!sclp_ipl_info
.has_dump
)
1592 return 0; /* LDIPL DUMP is not installed */
1593 dump_block_nvme
= (void *) get_zeroed_page(GFP_KERNEL
);
1594 if (!dump_block_nvme
)
1596 rc
= sysfs_create_group(&dump_kset
->kobj
, &dump_nvme_attr_group
);
1598 free_page((unsigned long)dump_block_nvme
);
1601 dump_block_nvme
->hdr
.len
= IPL_BP_NVME_LEN
;
1602 dump_block_nvme
->hdr
.version
= IPL_PARM_BLOCK_VERSION
;
1603 dump_block_nvme
->fcp
.len
= IPL_BP0_NVME_LEN
;
1604 dump_block_nvme
->fcp
.pbt
= IPL_PBT_NVME
;
1605 dump_block_nvme
->fcp
.opt
= IPL_PB0_NVME_OPT_DUMP
;
1606 dump_capabilities
|= DUMP_TYPE_NVME
;
1610 static int __init
dump_init(void)
1614 dump_kset
= kset_create_and_add("dump", NULL
, firmware_kobj
);
1617 rc
= sysfs_create_file(&dump_kset
->kobj
, &dump_type_attr
.attr
);
1619 kset_unregister(dump_kset
);
1622 rc
= dump_ccw_init();
1625 rc
= dump_fcp_init();
1628 rc
= dump_nvme_init();
1631 dump_set_type(DUMP_TYPE_NONE
);
1635 static struct shutdown_action __refdata dump_action
= {
1636 .name
= SHUTDOWN_ACTION_DUMP_STR
,
1641 static void dump_reipl_run(struct shutdown_trigger
*trigger
)
1643 unsigned long ipib
= (unsigned long) reipl_block_actual
;
1646 csum
= (__force
unsigned int)
1647 csum_partial(reipl_block_actual
, reipl_block_actual
->hdr
.len
, 0);
1648 mem_assign_absolute(S390_lowcore
.ipib
, ipib
);
1649 mem_assign_absolute(S390_lowcore
.ipib_checksum
, csum
);
1653 static struct shutdown_action __refdata dump_reipl_action
= {
1654 .name
= SHUTDOWN_ACTION_DUMP_REIPL_STR
,
1655 .fn
= dump_reipl_run
,
1659 * vmcmd shutdown action: Trigger vm command on shutdown.
1662 static char vmcmd_on_reboot
[128];
1663 static char vmcmd_on_panic
[128];
1664 static char vmcmd_on_halt
[128];
1665 static char vmcmd_on_poff
[128];
1666 static char vmcmd_on_restart
[128];
1668 DEFINE_IPL_ATTR_STR_RW(vmcmd
, on_reboot
, "%s\n", "%s\n", vmcmd_on_reboot
);
1669 DEFINE_IPL_ATTR_STR_RW(vmcmd
, on_panic
, "%s\n", "%s\n", vmcmd_on_panic
);
1670 DEFINE_IPL_ATTR_STR_RW(vmcmd
, on_halt
, "%s\n", "%s\n", vmcmd_on_halt
);
1671 DEFINE_IPL_ATTR_STR_RW(vmcmd
, on_poff
, "%s\n", "%s\n", vmcmd_on_poff
);
1672 DEFINE_IPL_ATTR_STR_RW(vmcmd
, on_restart
, "%s\n", "%s\n", vmcmd_on_restart
);
1674 static struct attribute
*vmcmd_attrs
[] = {
1675 &sys_vmcmd_on_reboot_attr
.attr
,
1676 &sys_vmcmd_on_panic_attr
.attr
,
1677 &sys_vmcmd_on_halt_attr
.attr
,
1678 &sys_vmcmd_on_poff_attr
.attr
,
1679 &sys_vmcmd_on_restart_attr
.attr
,
1683 static struct attribute_group vmcmd_attr_group
= {
1684 .attrs
= vmcmd_attrs
,
1687 static struct kset
*vmcmd_kset
;
1689 static void vmcmd_run(struct shutdown_trigger
*trigger
)
1693 if (strcmp(trigger
->name
, ON_REIPL_STR
) == 0)
1694 cmd
= vmcmd_on_reboot
;
1695 else if (strcmp(trigger
->name
, ON_PANIC_STR
) == 0)
1696 cmd
= vmcmd_on_panic
;
1697 else if (strcmp(trigger
->name
, ON_HALT_STR
) == 0)
1698 cmd
= vmcmd_on_halt
;
1699 else if (strcmp(trigger
->name
, ON_POFF_STR
) == 0)
1700 cmd
= vmcmd_on_poff
;
1701 else if (strcmp(trigger
->name
, ON_RESTART_STR
) == 0)
1702 cmd
= vmcmd_on_restart
;
1706 if (strlen(cmd
) == 0)
1708 __cpcmd(cmd
, NULL
, 0, NULL
);
1711 static int vmcmd_init(void)
1715 vmcmd_kset
= kset_create_and_add("vmcmd", NULL
, firmware_kobj
);
1718 return sysfs_create_group(&vmcmd_kset
->kobj
, &vmcmd_attr_group
);
1721 static struct shutdown_action vmcmd_action
= {SHUTDOWN_ACTION_VMCMD_STR
,
1722 vmcmd_run
, vmcmd_init
};
1725 * stop shutdown action: Stop Linux on shutdown.
1728 static void stop_run(struct shutdown_trigger
*trigger
)
1730 if (strcmp(trigger
->name
, ON_PANIC_STR
) == 0 ||
1731 strcmp(trigger
->name
, ON_RESTART_STR
) == 0)
1736 static struct shutdown_action stop_action
= {SHUTDOWN_ACTION_STOP_STR
,
1741 static struct shutdown_action
*shutdown_actions_list
[] = {
1742 &ipl_action
, &reipl_action
, &dump_reipl_action
, &dump_action
,
1743 &vmcmd_action
, &stop_action
};
1744 #define SHUTDOWN_ACTIONS_COUNT (sizeof(shutdown_actions_list) / sizeof(void *))
1750 static struct kset
*shutdown_actions_kset
;
1752 static int set_trigger(const char *buf
, struct shutdown_trigger
*trigger
,
1757 for (i
= 0; i
< SHUTDOWN_ACTIONS_COUNT
; i
++) {
1758 if (sysfs_streq(buf
, shutdown_actions_list
[i
]->name
)) {
1759 if (shutdown_actions_list
[i
]->init_rc
) {
1760 return shutdown_actions_list
[i
]->init_rc
;
1762 trigger
->action
= shutdown_actions_list
[i
];
1772 static struct shutdown_trigger on_reboot_trigger
= {ON_REIPL_STR
,
1775 static ssize_t
on_reboot_show(struct kobject
*kobj
,
1776 struct kobj_attribute
*attr
, char *page
)
1778 return sprintf(page
, "%s\n", on_reboot_trigger
.action
->name
);
1781 static ssize_t
on_reboot_store(struct kobject
*kobj
,
1782 struct kobj_attribute
*attr
,
1783 const char *buf
, size_t len
)
1785 return set_trigger(buf
, &on_reboot_trigger
, len
);
1787 static struct kobj_attribute on_reboot_attr
= __ATTR_RW(on_reboot
);
1789 static void do_machine_restart(char *__unused
)
1792 on_reboot_trigger
.action
->fn(&on_reboot_trigger
);
1795 void (*_machine_restart
)(char *command
) = do_machine_restart
;
1799 static struct shutdown_trigger on_panic_trigger
= {ON_PANIC_STR
, &stop_action
};
1801 static ssize_t
on_panic_show(struct kobject
*kobj
,
1802 struct kobj_attribute
*attr
, char *page
)
1804 return sprintf(page
, "%s\n", on_panic_trigger
.action
->name
);
1807 static ssize_t
on_panic_store(struct kobject
*kobj
,
1808 struct kobj_attribute
*attr
,
1809 const char *buf
, size_t len
)
1811 return set_trigger(buf
, &on_panic_trigger
, len
);
1813 static struct kobj_attribute on_panic_attr
= __ATTR_RW(on_panic
);
1815 static void do_panic(void)
1818 on_panic_trigger
.action
->fn(&on_panic_trigger
);
1819 stop_run(&on_panic_trigger
);
1824 static struct shutdown_trigger on_restart_trigger
= {ON_RESTART_STR
,
1827 static ssize_t
on_restart_show(struct kobject
*kobj
,
1828 struct kobj_attribute
*attr
, char *page
)
1830 return sprintf(page
, "%s\n", on_restart_trigger
.action
->name
);
1833 static ssize_t
on_restart_store(struct kobject
*kobj
,
1834 struct kobj_attribute
*attr
,
1835 const char *buf
, size_t len
)
1837 return set_trigger(buf
, &on_restart_trigger
, len
);
1839 static struct kobj_attribute on_restart_attr
= __ATTR_RW(on_restart
);
1841 static void __do_restart(void *ignore
)
1843 __arch_local_irq_stosm(0x04); /* enable DAT */
1845 #ifdef CONFIG_CRASH_DUMP
1848 on_restart_trigger
.action
->fn(&on_restart_trigger
);
1849 stop_run(&on_restart_trigger
);
1852 void do_restart(void)
1857 smp_call_online_cpu(__do_restart
, NULL
);
1862 static struct shutdown_trigger on_halt_trigger
= {ON_HALT_STR
, &stop_action
};
1864 static ssize_t
on_halt_show(struct kobject
*kobj
,
1865 struct kobj_attribute
*attr
, char *page
)
1867 return sprintf(page
, "%s\n", on_halt_trigger
.action
->name
);
1870 static ssize_t
on_halt_store(struct kobject
*kobj
,
1871 struct kobj_attribute
*attr
,
1872 const char *buf
, size_t len
)
1874 return set_trigger(buf
, &on_halt_trigger
, len
);
1876 static struct kobj_attribute on_halt_attr
= __ATTR_RW(on_halt
);
1878 static void do_machine_halt(void)
1881 on_halt_trigger
.action
->fn(&on_halt_trigger
);
1882 stop_run(&on_halt_trigger
);
1884 void (*_machine_halt
)(void) = do_machine_halt
;
1888 static struct shutdown_trigger on_poff_trigger
= {ON_POFF_STR
, &stop_action
};
1890 static ssize_t
on_poff_show(struct kobject
*kobj
,
1891 struct kobj_attribute
*attr
, char *page
)
1893 return sprintf(page
, "%s\n", on_poff_trigger
.action
->name
);
1896 static ssize_t
on_poff_store(struct kobject
*kobj
,
1897 struct kobj_attribute
*attr
,
1898 const char *buf
, size_t len
)
1900 return set_trigger(buf
, &on_poff_trigger
, len
);
1902 static struct kobj_attribute on_poff_attr
= __ATTR_RW(on_poff
);
1904 static void do_machine_power_off(void)
1907 on_poff_trigger
.action
->fn(&on_poff_trigger
);
1908 stop_run(&on_poff_trigger
);
1910 void (*_machine_power_off
)(void) = do_machine_power_off
;
1912 static struct attribute
*shutdown_action_attrs
[] = {
1913 &on_restart_attr
.attr
,
1914 &on_reboot_attr
.attr
,
1915 &on_panic_attr
.attr
,
1921 static struct attribute_group shutdown_action_attr_group
= {
1922 .attrs
= shutdown_action_attrs
,
1925 static void __init
shutdown_triggers_init(void)
1927 shutdown_actions_kset
= kset_create_and_add("shutdown_actions", NULL
,
1929 if (!shutdown_actions_kset
)
1931 if (sysfs_create_group(&shutdown_actions_kset
->kobj
,
1932 &shutdown_action_attr_group
))
1936 panic("shutdown_triggers_init failed\n");
1939 static void __init
shutdown_actions_init(void)
1943 for (i
= 0; i
< SHUTDOWN_ACTIONS_COUNT
; i
++) {
1944 if (!shutdown_actions_list
[i
]->init
)
1946 shutdown_actions_list
[i
]->init_rc
=
1947 shutdown_actions_list
[i
]->init();
1951 static int __init
s390_ipl_init(void)
1953 char str
[8] = {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40};
1955 sclp_early_get_ipl_info(&sclp_ipl_info
);
1957 * Fix loadparm: There are systems where the (SCSI) LOADPARM
1958 * returned by read SCP info is invalid (contains EBCDIC blanks)
1959 * when the system has been booted via diag308. In that case we use
1960 * the value from diag308, if available.
1962 * There are also systems where diag308 store does not work in
1963 * case the system is booted from HMC. Fortunately in this case
1964 * READ SCP info provides the correct value.
1966 if (memcmp(sclp_ipl_info
.loadparm
, str
, sizeof(str
)) == 0 && ipl_block_valid
)
1967 memcpy(sclp_ipl_info
.loadparm
, ipl_block
.ccw
.loadparm
, LOADPARM_LEN
);
1968 shutdown_actions_init();
1969 shutdown_triggers_init();
1973 __initcall(s390_ipl_init
);
1975 static void __init
strncpy_skip_quote(char *dst
, char *src
, int n
)
1980 for (sx
= 0; src
[sx
] != 0; sx
++) {
1983 dst
[dx
++] = src
[sx
];
1989 static int __init
vmcmd_on_reboot_setup(char *str
)
1993 strncpy_skip_quote(vmcmd_on_reboot
, str
, 127);
1994 vmcmd_on_reboot
[127] = 0;
1995 on_reboot_trigger
.action
= &vmcmd_action
;
1998 __setup("vmreboot=", vmcmd_on_reboot_setup
);
2000 static int __init
vmcmd_on_panic_setup(char *str
)
2004 strncpy_skip_quote(vmcmd_on_panic
, str
, 127);
2005 vmcmd_on_panic
[127] = 0;
2006 on_panic_trigger
.action
= &vmcmd_action
;
2009 __setup("vmpanic=", vmcmd_on_panic_setup
);
2011 static int __init
vmcmd_on_halt_setup(char *str
)
2015 strncpy_skip_quote(vmcmd_on_halt
, str
, 127);
2016 vmcmd_on_halt
[127] = 0;
2017 on_halt_trigger
.action
= &vmcmd_action
;
2020 __setup("vmhalt=", vmcmd_on_halt_setup
);
2022 static int __init
vmcmd_on_poff_setup(char *str
)
2026 strncpy_skip_quote(vmcmd_on_poff
, str
, 127);
2027 vmcmd_on_poff
[127] = 0;
2028 on_poff_trigger
.action
= &vmcmd_action
;
2031 __setup("vmpoff=", vmcmd_on_poff_setup
);
2033 static int on_panic_notify(struct notifier_block
*self
,
2034 unsigned long event
, void *data
)
2040 static struct notifier_block on_panic_nb
= {
2041 .notifier_call
= on_panic_notify
,
2042 .priority
= INT_MIN
,
2045 void __init
setup_ipl(void)
2047 BUILD_BUG_ON(sizeof(struct ipl_parameter_block
) != PAGE_SIZE
);
2049 ipl_info
.type
= get_ipl_type();
2050 switch (ipl_info
.type
) {
2052 ipl_info
.data
.ccw
.dev_id
.ssid
= ipl_block
.ccw
.ssid
;
2053 ipl_info
.data
.ccw
.dev_id
.devno
= ipl_block
.ccw
.devno
;
2056 case IPL_TYPE_FCP_DUMP
:
2057 ipl_info
.data
.fcp
.dev_id
.ssid
= 0;
2058 ipl_info
.data
.fcp
.dev_id
.devno
= ipl_block
.fcp
.devno
;
2059 ipl_info
.data
.fcp
.wwpn
= ipl_block
.fcp
.wwpn
;
2060 ipl_info
.data
.fcp
.lun
= ipl_block
.fcp
.lun
;
2063 case IPL_TYPE_NVME_DUMP
:
2064 ipl_info
.data
.nvme
.fid
= ipl_block
.nvme
.fid
;
2065 ipl_info
.data
.nvme
.nsid
= ipl_block
.nvme
.nsid
;
2068 case IPL_TYPE_UNKNOWN
:
2069 /* We have no info to copy */
2072 atomic_notifier_chain_register(&panic_notifier_list
, &on_panic_nb
);
2075 void s390_reset_system(void)
2077 /* Disable prefixing */
2080 /* Disable lowcore protection */
2081 __ctl_clear_bit(0, 28);
2082 diag_dma_ops
.diag308_reset();
2085 #ifdef CONFIG_KEXEC_FILE
2087 int ipl_report_add_component(struct ipl_report
*report
, struct kexec_buf
*kbuf
,
2088 unsigned char flags
, unsigned short cert
)
2090 struct ipl_report_component
*comp
;
2092 comp
= vzalloc(sizeof(*comp
));
2095 list_add_tail(&comp
->list
, &report
->components
);
2097 comp
->entry
.addr
= kbuf
->mem
;
2098 comp
->entry
.len
= kbuf
->memsz
;
2099 comp
->entry
.flags
= flags
;
2100 comp
->entry
.certificate_index
= cert
;
2102 report
->size
+= sizeof(comp
->entry
);
2107 int ipl_report_add_certificate(struct ipl_report
*report
, void *key
,
2108 unsigned long addr
, unsigned long len
)
2110 struct ipl_report_certificate
*cert
;
2112 cert
= vzalloc(sizeof(*cert
));
2115 list_add_tail(&cert
->list
, &report
->certificates
);
2117 cert
->entry
.addr
= addr
;
2118 cert
->entry
.len
= len
;
2121 report
->size
+= sizeof(cert
->entry
);
2122 report
->size
+= cert
->entry
.len
;
2127 struct ipl_report
*ipl_report_init(struct ipl_parameter_block
*ipib
)
2129 struct ipl_report
*report
;
2131 report
= vzalloc(sizeof(*report
));
2133 return ERR_PTR(-ENOMEM
);
2135 report
->ipib
= ipib
;
2136 INIT_LIST_HEAD(&report
->components
);
2137 INIT_LIST_HEAD(&report
->certificates
);
2139 report
->size
= ALIGN(ipib
->hdr
.len
, 8);
2140 report
->size
+= sizeof(struct ipl_rl_hdr
);
2141 report
->size
+= sizeof(struct ipl_rb_components
);
2142 report
->size
+= sizeof(struct ipl_rb_certificates
);
2147 void *ipl_report_finish(struct ipl_report
*report
)
2149 struct ipl_report_certificate
*cert
;
2150 struct ipl_report_component
*comp
;
2151 struct ipl_rb_certificates
*certs
;
2152 struct ipl_parameter_block
*ipib
;
2153 struct ipl_rb_components
*comps
;
2154 struct ipl_rl_hdr
*rl_hdr
;
2157 buf
= vzalloc(report
->size
);
2159 return ERR_PTR(-ENOMEM
);
2162 memcpy(ptr
, report
->ipib
, report
->ipib
->hdr
.len
);
2164 if (ipl_secure_flag
)
2165 ipib
->hdr
.flags
|= IPL_PL_FLAG_SIPL
;
2166 ipib
->hdr
.flags
|= IPL_PL_FLAG_IPLSR
;
2167 ptr
+= report
->ipib
->hdr
.len
;
2168 ptr
= PTR_ALIGN(ptr
, 8);
2171 ptr
+= sizeof(*rl_hdr
);
2174 comps
->rbt
= IPL_RBT_COMPONENTS
;
2175 ptr
+= sizeof(*comps
);
2176 list_for_each_entry(comp
, &report
->components
, list
) {
2177 memcpy(ptr
, &comp
->entry
, sizeof(comp
->entry
));
2178 ptr
+= sizeof(comp
->entry
);
2180 comps
->len
= ptr
- (void *)comps
;
2183 certs
->rbt
= IPL_RBT_CERTIFICATES
;
2184 ptr
+= sizeof(*certs
);
2185 list_for_each_entry(cert
, &report
->certificates
, list
) {
2186 memcpy(ptr
, &cert
->entry
, sizeof(cert
->entry
));
2187 ptr
+= sizeof(cert
->entry
);
2189 certs
->len
= ptr
- (void *)certs
;
2190 rl_hdr
->len
= ptr
- (void *)rl_hdr
;
2192 list_for_each_entry(cert
, &report
->certificates
, list
) {
2193 memcpy(ptr
, cert
->key
, cert
->entry
.len
);
2194 ptr
+= cert
->entry
.len
;
2197 BUG_ON(ptr
> buf
+ report
->size
);
2201 int ipl_report_free(struct ipl_report
*report
)
2203 struct ipl_report_component
*comp
, *ncomp
;
2204 struct ipl_report_certificate
*cert
, *ncert
;
2206 list_for_each_entry_safe(comp
, ncomp
, &report
->components
, list
)
2209 list_for_each_entry_safe(cert
, ncert
, &report
->certificates
, list
)