]>
Commit | Line | Data |
---|---|---|
ff6b8ea6 MH |
1 | /* |
2 | * arch/s390/kernel/ipl.c | |
3 | * ipl/reipl/dump support for Linux on s390. | |
4 | * | |
99ca4e58 | 5 | * Copyright IBM Corp. 2005,2007 |
ff6b8ea6 MH |
6 | * Author(s): Michael Holzheu <holzheu@de.ibm.com> |
7 | * Heiko Carstens <heiko.carstens@de.ibm.com> | |
8 | * Volker Sameske <sameske@de.ibm.com> | |
9 | */ | |
10 | ||
11 | #include <linux/types.h> | |
12 | #include <linux/module.h> | |
13 | #include <linux/device.h> | |
14 | #include <linux/delay.h> | |
15 | #include <linux/reboot.h> | |
03a4d208 | 16 | #include <linux/ctype.h> |
46b05d26 | 17 | #include <asm/ipl.h> |
ff6b8ea6 MH |
18 | #include <asm/smp.h> |
19 | #include <asm/setup.h> | |
20 | #include <asm/cpcmd.h> | |
21 | #include <asm/cio.h> | |
03a4d208 | 22 | #include <asm/ebcdic.h> |
15e9b586 | 23 | #include <asm/reset.h> |
ab14de6c | 24 | #include <asm/sclp.h> |
ff6b8ea6 MH |
25 | |
26 | #define IPL_PARM_BLOCK_VERSION 0 | |
03a4d208 | 27 | |
411ed322 MH |
28 | #define IPL_UNKNOWN_STR "unknown" |
29 | #define IPL_CCW_STR "ccw" | |
30 | #define IPL_FCP_STR "fcp" | |
31 | #define IPL_FCP_DUMP_STR "fcp_dump" | |
32 | #define IPL_NSS_STR "nss" | |
615b04b3 | 33 | |
99ca4e58 MH |
34 | #define DUMP_CCW_STR "ccw" |
35 | #define DUMP_FCP_STR "fcp" | |
36 | #define DUMP_NONE_STR "none" | |
37 | ||
38 | /* | |
39 | * Four shutdown trigger types are supported: | |
40 | * - panic | |
41 | * - halt | |
42 | * - power off | |
43 | * - reipl | |
44 | */ | |
45 | #define ON_PANIC_STR "on_panic" | |
46 | #define ON_HALT_STR "on_halt" | |
47 | #define ON_POFF_STR "on_poff" | |
48 | #define ON_REIPL_STR "on_reboot" | |
49 | ||
50 | struct shutdown_action; | |
51 | struct shutdown_trigger { | |
52 | char *name; | |
53 | struct shutdown_action *action; | |
54 | }; | |
55 | ||
56 | /* | |
57 | * Five shutdown action types are supported: | |
58 | */ | |
59 | #define SHUTDOWN_ACTION_IPL_STR "ipl" | |
60 | #define SHUTDOWN_ACTION_REIPL_STR "reipl" | |
61 | #define SHUTDOWN_ACTION_DUMP_STR "dump" | |
62 | #define SHUTDOWN_ACTION_VMCMD_STR "vmcmd" | |
63 | #define SHUTDOWN_ACTION_STOP_STR "stop" | |
64 | ||
65 | struct shutdown_action { | |
66 | char *name; | |
67 | void (*fn) (struct shutdown_trigger *trigger); | |
68 | int (*init) (void); | |
69 | }; | |
70 | ||
ff6b8ea6 MH |
71 | static char *ipl_type_str(enum ipl_type type) |
72 | { | |
73 | switch (type) { | |
ff6b8ea6 MH |
74 | case IPL_TYPE_CCW: |
75 | return IPL_CCW_STR; | |
76 | case IPL_TYPE_FCP: | |
77 | return IPL_FCP_STR; | |
411ed322 MH |
78 | case IPL_TYPE_FCP_DUMP: |
79 | return IPL_FCP_DUMP_STR; | |
fe355b7f HY |
80 | case IPL_TYPE_NSS: |
81 | return IPL_NSS_STR; | |
ff6b8ea6 MH |
82 | case IPL_TYPE_UNKNOWN: |
83 | default: | |
84 | return IPL_UNKNOWN_STR; | |
85 | } | |
86 | } | |
87 | ||
411ed322 MH |
88 | enum dump_type { |
89 | DUMP_TYPE_NONE = 1, | |
90 | DUMP_TYPE_CCW = 2, | |
91 | DUMP_TYPE_FCP = 4, | |
92 | }; | |
93 | ||
411ed322 MH |
94 | static char *dump_type_str(enum dump_type type) |
95 | { | |
96 | switch (type) { | |
97 | case DUMP_TYPE_NONE: | |
98 | return DUMP_NONE_STR; | |
99 | case DUMP_TYPE_CCW: | |
100 | return DUMP_CCW_STR; | |
101 | case DUMP_TYPE_FCP: | |
102 | return DUMP_FCP_STR; | |
103 | default: | |
104 | return NULL; | |
105 | } | |
106 | } | |
107 | ||
108 | /* | |
109 | * Must be in data section since the bss section | |
110 | * is not cleared when these are accessed. | |
111 | */ | |
112 | static u16 ipl_devno __attribute__((__section__(".data"))) = 0; | |
113 | u32 ipl_flags __attribute__((__section__(".data"))) = 0; | |
114 | ||
ff6b8ea6 | 115 | enum ipl_method { |
411ed322 MH |
116 | REIPL_METHOD_CCW_CIO, |
117 | REIPL_METHOD_CCW_DIAG, | |
118 | REIPL_METHOD_CCW_VM, | |
119 | REIPL_METHOD_FCP_RO_DIAG, | |
120 | REIPL_METHOD_FCP_RW_DIAG, | |
121 | REIPL_METHOD_FCP_RO_VM, | |
122 | REIPL_METHOD_FCP_DUMP, | |
123 | REIPL_METHOD_NSS, | |
124 | REIPL_METHOD_DEFAULT, | |
125 | }; | |
126 | ||
127 | enum dump_method { | |
128 | DUMP_METHOD_NONE, | |
129 | DUMP_METHOD_CCW_CIO, | |
130 | DUMP_METHOD_CCW_DIAG, | |
131 | DUMP_METHOD_CCW_VM, | |
132 | DUMP_METHOD_FCP_DIAG, | |
ff6b8ea6 MH |
133 | }; |
134 | ||
ff6b8ea6 MH |
135 | static int diag308_set_works = 0; |
136 | ||
137 | static int reipl_capabilities = IPL_TYPE_UNKNOWN; | |
fe355b7f | 138 | |
ff6b8ea6 | 139 | static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN; |
411ed322 | 140 | static enum ipl_method reipl_method = REIPL_METHOD_DEFAULT; |
ff6b8ea6 MH |
141 | static struct ipl_parameter_block *reipl_block_fcp; |
142 | static struct ipl_parameter_block *reipl_block_ccw; | |
143 | ||
fe355b7f HY |
144 | static char reipl_nss_name[NSS_NAME_SIZE + 1]; |
145 | ||
411ed322 MH |
146 | static int dump_capabilities = DUMP_TYPE_NONE; |
147 | static enum dump_type dump_type = DUMP_TYPE_NONE; | |
148 | static enum dump_method dump_method = DUMP_METHOD_NONE; | |
ff6b8ea6 MH |
149 | static struct ipl_parameter_block *dump_block_fcp; |
150 | static struct ipl_parameter_block *dump_block_ccw; | |
151 | ||
05dd2530 HC |
152 | static struct sclp_ipl_info sclp_ipl_info; |
153 | ||
46b05d26 | 154 | int diag308(unsigned long subcode, void *addr) |
ff6b8ea6 | 155 | { |
94c12cc7 | 156 | register unsigned long _addr asm("0") = (unsigned long) addr; |
ff6b8ea6 MH |
157 | register unsigned long _rc asm("1") = 0; |
158 | ||
94c12cc7 MS |
159 | asm volatile( |
160 | " diag %0,%2,0x308\n" | |
161 | "0:\n" | |
162 | EX_TABLE(0b,0b) | |
ff6b8ea6 | 163 | : "+d" (_addr), "+d" (_rc) |
94c12cc7 | 164 | : "d" (subcode) : "cc", "memory"); |
ff6b8ea6 MH |
165 | return _rc; |
166 | } | |
411ed322 | 167 | EXPORT_SYMBOL_GPL(diag308); |
ff6b8ea6 MH |
168 | |
169 | /* SYSFS */ | |
170 | ||
171 | #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \ | |
9b949165 GKH |
172 | static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \ |
173 | struct kobj_attribute *attr, \ | |
ff6b8ea6 MH |
174 | char *page) \ |
175 | { \ | |
176 | return sprintf(page, _format, _value); \ | |
177 | } \ | |
9b949165 | 178 | static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ |
ff6b8ea6 MH |
179 | __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL); |
180 | ||
181 | #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \ | |
9b949165 GKH |
182 | static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \ |
183 | struct kobj_attribute *attr, \ | |
ff6b8ea6 MH |
184 | char *page) \ |
185 | { \ | |
186 | return sprintf(page, _fmt_out, \ | |
187 | (unsigned long long) _value); \ | |
188 | } \ | |
9b949165 GKH |
189 | static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \ |
190 | struct kobj_attribute *attr, \ | |
ff6b8ea6 MH |
191 | const char *buf, size_t len) \ |
192 | { \ | |
193 | unsigned long long value; \ | |
194 | if (sscanf(buf, _fmt_in, &value) != 1) \ | |
195 | return -EINVAL; \ | |
196 | _value = value; \ | |
197 | return len; \ | |
198 | } \ | |
9b949165 | 199 | static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ |
ff6b8ea6 MH |
200 | __ATTR(_name,(S_IRUGO | S_IWUSR), \ |
201 | sys_##_prefix##_##_name##_show, \ | |
202 | sys_##_prefix##_##_name##_store); | |
203 | ||
fe355b7f | 204 | #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\ |
9b949165 GKH |
205 | static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \ |
206 | struct kobj_attribute *attr, \ | |
fe355b7f HY |
207 | char *page) \ |
208 | { \ | |
209 | return sprintf(page, _fmt_out, _value); \ | |
210 | } \ | |
9b949165 GKH |
211 | static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \ |
212 | struct kobj_attribute *attr, \ | |
fe355b7f HY |
213 | const char *buf, size_t len) \ |
214 | { \ | |
99ca4e58 MH |
215 | strncpy(_value, buf, sizeof(_value) - 1); \ |
216 | strstrip(_value); \ | |
fe355b7f HY |
217 | return len; \ |
218 | } \ | |
9b949165 | 219 | static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ |
fe355b7f HY |
220 | __ATTR(_name,(S_IRUGO | S_IWUSR), \ |
221 | sys_##_prefix##_##_name##_show, \ | |
222 | sys_##_prefix##_##_name##_store); | |
223 | ||
ff6b8ea6 MH |
224 | static void make_attrs_ro(struct attribute **attrs) |
225 | { | |
226 | while (*attrs) { | |
227 | (*attrs)->mode = S_IRUGO; | |
228 | attrs++; | |
229 | } | |
230 | } | |
231 | ||
232 | /* | |
233 | * ipl section | |
234 | */ | |
235 | ||
411ed322 | 236 | static __init enum ipl_type get_ipl_type(void) |
ff6b8ea6 MH |
237 | { |
238 | struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START; | |
239 | ||
fe355b7f HY |
240 | if (ipl_flags & IPL_NSS_VALID) |
241 | return IPL_TYPE_NSS; | |
e87bfe51 | 242 | if (!(ipl_flags & IPL_DEVNO_VALID)) |
ff6b8ea6 | 243 | return IPL_TYPE_UNKNOWN; |
e87bfe51 | 244 | if (!(ipl_flags & IPL_PARMBLOCK_VALID)) |
ff6b8ea6 MH |
245 | return IPL_TYPE_CCW; |
246 | if (ipl->hdr.version > IPL_MAX_SUPPORTED_VERSION) | |
247 | return IPL_TYPE_UNKNOWN; | |
248 | if (ipl->hdr.pbt != DIAG308_IPL_TYPE_FCP) | |
249 | return IPL_TYPE_UNKNOWN; | |
411ed322 MH |
250 | if (ipl->ipl_info.fcp.opt == DIAG308_IPL_OPT_DUMP) |
251 | return IPL_TYPE_FCP_DUMP; | |
ff6b8ea6 MH |
252 | return IPL_TYPE_FCP; |
253 | } | |
254 | ||
411ed322 MH |
255 | struct ipl_info ipl_info; |
256 | EXPORT_SYMBOL_GPL(ipl_info); | |
257 | ||
9b949165 GKH |
258 | static ssize_t ipl_type_show(struct kobject *kobj, struct kobj_attribute *attr, |
259 | char *page) | |
ff6b8ea6 | 260 | { |
411ed322 | 261 | return sprintf(page, "%s\n", ipl_type_str(ipl_info.type)); |
ff6b8ea6 MH |
262 | } |
263 | ||
9b949165 | 264 | static struct kobj_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type); |
ff6b8ea6 | 265 | |
9b949165 GKH |
266 | static ssize_t sys_ipl_device_show(struct kobject *kobj, |
267 | struct kobj_attribute *attr, char *page) | |
ff6b8ea6 MH |
268 | { |
269 | struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START; | |
270 | ||
411ed322 | 271 | switch (ipl_info.type) { |
ff6b8ea6 MH |
272 | case IPL_TYPE_CCW: |
273 | return sprintf(page, "0.0.%04x\n", ipl_devno); | |
274 | case IPL_TYPE_FCP: | |
411ed322 | 275 | case IPL_TYPE_FCP_DUMP: |
ff6b8ea6 MH |
276 | return sprintf(page, "0.0.%04x\n", ipl->ipl_info.fcp.devno); |
277 | default: | |
278 | return 0; | |
279 | } | |
280 | } | |
281 | ||
9b949165 | 282 | static struct kobj_attribute sys_ipl_device_attr = |
ff6b8ea6 MH |
283 | __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL); |
284 | ||
05bd711e AV |
285 | static ssize_t ipl_parameter_read(struct kobject *kobj, struct bin_attribute *attr, |
286 | char *buf, loff_t off, size_t count) | |
ff6b8ea6 MH |
287 | { |
288 | unsigned int size = IPL_PARMBLOCK_SIZE; | |
289 | ||
290 | if (off > size) | |
291 | return 0; | |
292 | if (off + count > size) | |
293 | count = size - off; | |
294 | memcpy(buf, (void *)IPL_PARMBLOCK_START + off, count); | |
295 | return count; | |
296 | } | |
297 | ||
298 | static struct bin_attribute ipl_parameter_attr = { | |
299 | .attr = { | |
300 | .name = "binary_parameter", | |
301 | .mode = S_IRUGO, | |
ff6b8ea6 MH |
302 | }, |
303 | .size = PAGE_SIZE, | |
304 | .read = &ipl_parameter_read, | |
305 | }; | |
306 | ||
05bd711e AV |
307 | static ssize_t ipl_scp_data_read(struct kobject *kobj, struct bin_attribute *attr, |
308 | char *buf, loff_t off, size_t count) | |
ff6b8ea6 MH |
309 | { |
310 | unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len; | |
311 | void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data; | |
312 | ||
313 | if (off > size) | |
314 | return 0; | |
315 | if (off + count > size) | |
316 | count = size - off; | |
317 | memcpy(buf, scp_data + off, count); | |
318 | return count; | |
319 | } | |
320 | ||
321 | static struct bin_attribute ipl_scp_data_attr = { | |
322 | .attr = { | |
323 | .name = "scp_data", | |
324 | .mode = S_IRUGO, | |
ff6b8ea6 MH |
325 | }, |
326 | .size = PAGE_SIZE, | |
05bd711e | 327 | .read = ipl_scp_data_read, |
ff6b8ea6 MH |
328 | }; |
329 | ||
330 | /* FCP ipl device attributes */ | |
331 | ||
332 | DEFINE_IPL_ATTR_RO(ipl_fcp, wwpn, "0x%016llx\n", (unsigned long long) | |
333 | IPL_PARMBLOCK_START->ipl_info.fcp.wwpn); | |
334 | DEFINE_IPL_ATTR_RO(ipl_fcp, lun, "0x%016llx\n", (unsigned long long) | |
335 | IPL_PARMBLOCK_START->ipl_info.fcp.lun); | |
336 | DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n", (unsigned long long) | |
337 | IPL_PARMBLOCK_START->ipl_info.fcp.bootprog); | |
338 | DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n", (unsigned long long) | |
339 | IPL_PARMBLOCK_START->ipl_info.fcp.br_lba); | |
340 | ||
341 | static struct attribute *ipl_fcp_attrs[] = { | |
342 | &sys_ipl_type_attr.attr, | |
343 | &sys_ipl_device_attr.attr, | |
344 | &sys_ipl_fcp_wwpn_attr.attr, | |
345 | &sys_ipl_fcp_lun_attr.attr, | |
346 | &sys_ipl_fcp_bootprog_attr.attr, | |
347 | &sys_ipl_fcp_br_lba_attr.attr, | |
348 | NULL, | |
349 | }; | |
350 | ||
351 | static struct attribute_group ipl_fcp_attr_group = { | |
352 | .attrs = ipl_fcp_attrs, | |
353 | }; | |
354 | ||
355 | /* CCW ipl device attributes */ | |
356 | ||
9b949165 GKH |
357 | static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj, |
358 | struct kobj_attribute *attr, char *page) | |
03a4d208 MH |
359 | { |
360 | char loadparm[LOADPARM_LEN + 1] = {}; | |
361 | ||
05dd2530 | 362 | if (!sclp_ipl_info.is_valid) |
03a4d208 | 363 | return sprintf(page, "#unknown#\n"); |
05dd2530 | 364 | memcpy(loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN); |
03a4d208 MH |
365 | EBCASC(loadparm, LOADPARM_LEN); |
366 | strstrip(loadparm); | |
367 | return sprintf(page, "%s\n", loadparm); | |
368 | } | |
369 | ||
9b949165 | 370 | static struct kobj_attribute sys_ipl_ccw_loadparm_attr = |
03a4d208 MH |
371 | __ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL); |
372 | ||
ff6b8ea6 MH |
373 | static struct attribute *ipl_ccw_attrs[] = { |
374 | &sys_ipl_type_attr.attr, | |
375 | &sys_ipl_device_attr.attr, | |
03a4d208 | 376 | &sys_ipl_ccw_loadparm_attr.attr, |
ff6b8ea6 MH |
377 | NULL, |
378 | }; | |
379 | ||
380 | static struct attribute_group ipl_ccw_attr_group = { | |
381 | .attrs = ipl_ccw_attrs, | |
382 | }; | |
383 | ||
fe355b7f HY |
384 | /* NSS ipl device attributes */ |
385 | ||
386 | DEFINE_IPL_ATTR_RO(ipl_nss, name, "%s\n", kernel_nss_name); | |
387 | ||
388 | static struct attribute *ipl_nss_attrs[] = { | |
389 | &sys_ipl_type_attr.attr, | |
390 | &sys_ipl_nss_name_attr.attr, | |
391 | NULL, | |
392 | }; | |
393 | ||
394 | static struct attribute_group ipl_nss_attr_group = { | |
395 | .attrs = ipl_nss_attrs, | |
396 | }; | |
397 | ||
ff6b8ea6 MH |
398 | /* UNKNOWN ipl device attributes */ |
399 | ||
400 | static struct attribute *ipl_unknown_attrs[] = { | |
401 | &sys_ipl_type_attr.attr, | |
402 | NULL, | |
403 | }; | |
404 | ||
405 | static struct attribute_group ipl_unknown_attr_group = { | |
406 | .attrs = ipl_unknown_attrs, | |
407 | }; | |
408 | ||
d91885be | 409 | static struct kset *ipl_kset; |
ff6b8ea6 | 410 | |
99ca4e58 MH |
411 | static int __init ipl_register_fcp_files(void) |
412 | { | |
413 | int rc; | |
414 | ||
415 | rc = sysfs_create_group(&ipl_kset->kobj, &ipl_fcp_attr_group); | |
416 | if (rc) | |
417 | goto out; | |
418 | rc = sysfs_create_bin_file(&ipl_kset->kobj, &ipl_parameter_attr); | |
419 | if (rc) | |
420 | goto out_ipl_parm; | |
421 | rc = sysfs_create_bin_file(&ipl_kset->kobj, &ipl_scp_data_attr); | |
422 | if (!rc) | |
423 | goto out; | |
424 | ||
425 | sysfs_remove_bin_file(&ipl_kset->kobj, &ipl_parameter_attr); | |
426 | ||
427 | out_ipl_parm: | |
428 | sysfs_remove_group(&ipl_kset->kobj, &ipl_fcp_attr_group); | |
429 | out: | |
430 | return rc; | |
431 | } | |
432 | ||
433 | static void ipl_run(struct shutdown_trigger *trigger) | |
434 | { | |
435 | diag308(DIAG308_IPL, NULL); | |
436 | if (MACHINE_IS_VM) | |
437 | __cpcmd("IPL", NULL, 0, NULL); | |
438 | else if (ipl_info.type == IPL_TYPE_CCW) | |
439 | reipl_ccw_dev(&ipl_info.data.ccw.dev_id); | |
440 | } | |
441 | ||
442 | static int ipl_init(void) | |
443 | { | |
444 | int rc; | |
445 | ||
446 | ipl_kset = kset_create_and_add("ipl", NULL, firmware_kobj); | |
447 | if (!ipl_kset) { | |
448 | rc = -ENOMEM; | |
449 | goto out; | |
450 | } | |
451 | switch (ipl_info.type) { | |
452 | case IPL_TYPE_CCW: | |
453 | rc = sysfs_create_group(&ipl_kset->kobj, &ipl_ccw_attr_group); | |
454 | break; | |
455 | case IPL_TYPE_FCP: | |
456 | case IPL_TYPE_FCP_DUMP: | |
457 | rc = ipl_register_fcp_files(); | |
458 | break; | |
459 | case IPL_TYPE_NSS: | |
460 | rc = sysfs_create_group(&ipl_kset->kobj, &ipl_nss_attr_group); | |
461 | break; | |
462 | default: | |
463 | rc = sysfs_create_group(&ipl_kset->kobj, | |
464 | &ipl_unknown_attr_group); | |
465 | break; | |
466 | } | |
467 | out: | |
468 | if (rc) | |
469 | panic("ipl_init failed: rc = %i\n", rc); | |
470 | ||
471 | return 0; | |
472 | } | |
473 | ||
474 | static struct shutdown_action ipl_action = {SHUTDOWN_ACTION_IPL_STR, ipl_run, | |
475 | ipl_init}; | |
476 | ||
ff6b8ea6 | 477 | /* |
99ca4e58 | 478 | * reipl shutdown action: Reboot Linux on shutdown. |
ff6b8ea6 MH |
479 | */ |
480 | ||
481 | /* FCP reipl device attributes */ | |
482 | ||
483 | DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%016llx\n", | |
484 | reipl_block_fcp->ipl_info.fcp.wwpn); | |
485 | DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%016llx\n", | |
486 | reipl_block_fcp->ipl_info.fcp.lun); | |
487 | DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n", | |
488 | reipl_block_fcp->ipl_info.fcp.bootprog); | |
489 | DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n", | |
490 | reipl_block_fcp->ipl_info.fcp.br_lba); | |
491 | DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n", | |
492 | reipl_block_fcp->ipl_info.fcp.devno); | |
493 | ||
494 | static struct attribute *reipl_fcp_attrs[] = { | |
495 | &sys_reipl_fcp_device_attr.attr, | |
496 | &sys_reipl_fcp_wwpn_attr.attr, | |
497 | &sys_reipl_fcp_lun_attr.attr, | |
498 | &sys_reipl_fcp_bootprog_attr.attr, | |
499 | &sys_reipl_fcp_br_lba_attr.attr, | |
500 | NULL, | |
501 | }; | |
502 | ||
503 | static struct attribute_group reipl_fcp_attr_group = { | |
504 | .name = IPL_FCP_STR, | |
505 | .attrs = reipl_fcp_attrs, | |
506 | }; | |
507 | ||
508 | /* CCW reipl device attributes */ | |
509 | ||
510 | DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n", | |
511 | reipl_block_ccw->ipl_info.ccw.devno); | |
512 | ||
03a4d208 MH |
513 | static void reipl_get_ascii_loadparm(char *loadparm) |
514 | { | |
515 | memcpy(loadparm, &reipl_block_ccw->ipl_info.ccw.load_param, | |
516 | LOADPARM_LEN); | |
517 | EBCASC(loadparm, LOADPARM_LEN); | |
518 | loadparm[LOADPARM_LEN] = 0; | |
519 | strstrip(loadparm); | |
520 | } | |
521 | ||
9b949165 GKH |
522 | static ssize_t reipl_ccw_loadparm_show(struct kobject *kobj, |
523 | struct kobj_attribute *attr, char *page) | |
03a4d208 MH |
524 | { |
525 | char buf[LOADPARM_LEN + 1]; | |
526 | ||
527 | reipl_get_ascii_loadparm(buf); | |
528 | return sprintf(page, "%s\n", buf); | |
529 | } | |
530 | ||
9b949165 GKH |
531 | static ssize_t reipl_ccw_loadparm_store(struct kobject *kobj, |
532 | struct kobj_attribute *attr, | |
03a4d208 MH |
533 | const char *buf, size_t len) |
534 | { | |
535 | int i, lp_len; | |
536 | ||
537 | /* ignore trailing newline */ | |
538 | lp_len = len; | |
539 | if ((len > 0) && (buf[len - 1] == '\n')) | |
540 | lp_len--; | |
541 | /* loadparm can have max 8 characters and must not start with a blank */ | |
542 | if ((lp_len > LOADPARM_LEN) || ((lp_len > 0) && (buf[0] == ' '))) | |
543 | return -EINVAL; | |
544 | /* loadparm can only contain "a-z,A-Z,0-9,SP,." */ | |
545 | for (i = 0; i < lp_len; i++) { | |
546 | if (isalpha(buf[i]) || isdigit(buf[i]) || (buf[i] == ' ') || | |
547 | (buf[i] == '.')) | |
548 | continue; | |
549 | return -EINVAL; | |
550 | } | |
551 | /* initialize loadparm with blanks */ | |
552 | memset(&reipl_block_ccw->ipl_info.ccw.load_param, ' ', LOADPARM_LEN); | |
553 | /* copy and convert to ebcdic */ | |
554 | memcpy(&reipl_block_ccw->ipl_info.ccw.load_param, buf, lp_len); | |
555 | ASCEBC(reipl_block_ccw->ipl_info.ccw.load_param, LOADPARM_LEN); | |
556 | return len; | |
557 | } | |
558 | ||
9b949165 | 559 | static struct kobj_attribute sys_reipl_ccw_loadparm_attr = |
03a4d208 MH |
560 | __ATTR(loadparm, 0644, reipl_ccw_loadparm_show, |
561 | reipl_ccw_loadparm_store); | |
562 | ||
ff6b8ea6 MH |
563 | static struct attribute *reipl_ccw_attrs[] = { |
564 | &sys_reipl_ccw_device_attr.attr, | |
03a4d208 | 565 | &sys_reipl_ccw_loadparm_attr.attr, |
ff6b8ea6 MH |
566 | NULL, |
567 | }; | |
568 | ||
569 | static struct attribute_group reipl_ccw_attr_group = { | |
570 | .name = IPL_CCW_STR, | |
571 | .attrs = reipl_ccw_attrs, | |
572 | }; | |
573 | ||
fe355b7f HY |
574 | |
575 | /* NSS reipl device attributes */ | |
576 | ||
577 | DEFINE_IPL_ATTR_STR_RW(reipl_nss, name, "%s\n", "%s\n", reipl_nss_name); | |
578 | ||
579 | static struct attribute *reipl_nss_attrs[] = { | |
580 | &sys_reipl_nss_name_attr.attr, | |
581 | NULL, | |
582 | }; | |
583 | ||
584 | static struct attribute_group reipl_nss_attr_group = { | |
585 | .name = IPL_NSS_STR, | |
586 | .attrs = reipl_nss_attrs, | |
587 | }; | |
588 | ||
ff6b8ea6 MH |
589 | /* reipl type */ |
590 | ||
591 | static int reipl_set_type(enum ipl_type type) | |
592 | { | |
593 | if (!(reipl_capabilities & type)) | |
594 | return -EINVAL; | |
595 | ||
596 | switch(type) { | |
597 | case IPL_TYPE_CCW: | |
598 | if (MACHINE_IS_VM) | |
411ed322 | 599 | reipl_method = REIPL_METHOD_CCW_VM; |
ff6b8ea6 | 600 | else |
411ed322 | 601 | reipl_method = REIPL_METHOD_CCW_CIO; |
ff6b8ea6 MH |
602 | break; |
603 | case IPL_TYPE_FCP: | |
604 | if (diag308_set_works) | |
411ed322 | 605 | reipl_method = REIPL_METHOD_FCP_RW_DIAG; |
ff6b8ea6 | 606 | else if (MACHINE_IS_VM) |
411ed322 | 607 | reipl_method = REIPL_METHOD_FCP_RO_VM; |
ff6b8ea6 | 608 | else |
411ed322 MH |
609 | reipl_method = REIPL_METHOD_FCP_RO_DIAG; |
610 | break; | |
611 | case IPL_TYPE_FCP_DUMP: | |
612 | reipl_method = REIPL_METHOD_FCP_DUMP; | |
ff6b8ea6 | 613 | break; |
fe355b7f | 614 | case IPL_TYPE_NSS: |
411ed322 MH |
615 | reipl_method = REIPL_METHOD_NSS; |
616 | break; | |
617 | case IPL_TYPE_UNKNOWN: | |
618 | reipl_method = REIPL_METHOD_DEFAULT; | |
fe355b7f | 619 | break; |
ff6b8ea6 | 620 | default: |
411ed322 | 621 | BUG(); |
ff6b8ea6 MH |
622 | } |
623 | reipl_type = type; | |
624 | return 0; | |
625 | } | |
626 | ||
9b949165 GKH |
627 | static ssize_t reipl_type_show(struct kobject *kobj, |
628 | struct kobj_attribute *attr, char *page) | |
ff6b8ea6 MH |
629 | { |
630 | return sprintf(page, "%s\n", ipl_type_str(reipl_type)); | |
631 | } | |
632 | ||
9b949165 GKH |
633 | static ssize_t reipl_type_store(struct kobject *kobj, |
634 | struct kobj_attribute *attr, | |
635 | const char *buf, size_t len) | |
ff6b8ea6 MH |
636 | { |
637 | int rc = -EINVAL; | |
638 | ||
639 | if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0) | |
640 | rc = reipl_set_type(IPL_TYPE_CCW); | |
641 | else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0) | |
642 | rc = reipl_set_type(IPL_TYPE_FCP); | |
fe355b7f HY |
643 | else if (strncmp(buf, IPL_NSS_STR, strlen(IPL_NSS_STR)) == 0) |
644 | rc = reipl_set_type(IPL_TYPE_NSS); | |
ff6b8ea6 MH |
645 | return (rc != 0) ? rc : len; |
646 | } | |
647 | ||
9b949165 | 648 | static struct kobj_attribute reipl_type_attr = |
99ca4e58 | 649 | __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store); |
ff6b8ea6 | 650 | |
d91885be | 651 | static struct kset *reipl_kset; |
ff6b8ea6 | 652 | |
99ca4e58 | 653 | void reipl_run(struct shutdown_trigger *trigger) |
ff6b8ea6 MH |
654 | { |
655 | struct ccw_dev_id devid; | |
656 | static char buf[100]; | |
03a4d208 | 657 | char loadparm[LOADPARM_LEN + 1]; |
ff6b8ea6 | 658 | |
ff6b8ea6 | 659 | switch (reipl_method) { |
411ed322 | 660 | case REIPL_METHOD_CCW_CIO: |
ff6b8ea6 | 661 | devid.devno = reipl_block_ccw->ipl_info.ccw.devno; |
411ed322 | 662 | if (ipl_info.type == IPL_TYPE_CCW && devid.devno == ipl_devno) |
5986b0e8 | 663 | diag308(DIAG308_IPL, NULL); |
ff6b8ea6 MH |
664 | devid.ssid = 0; |
665 | reipl_ccw_dev(&devid); | |
666 | break; | |
411ed322 | 667 | case REIPL_METHOD_CCW_VM: |
58be9441 | 668 | reipl_get_ascii_loadparm(loadparm); |
03a4d208 | 669 | if (strlen(loadparm) == 0) |
6517156c | 670 | sprintf(buf, "IPL %X CLEAR", |
03a4d208 MH |
671 | reipl_block_ccw->ipl_info.ccw.devno); |
672 | else | |
6517156c | 673 | sprintf(buf, "IPL %X CLEAR LOADPARM '%s'", |
03a4d208 | 674 | reipl_block_ccw->ipl_info.ccw.devno, loadparm); |
740b5706 | 675 | __cpcmd(buf, NULL, 0, NULL); |
ff6b8ea6 | 676 | break; |
411ed322 | 677 | case REIPL_METHOD_CCW_DIAG: |
ff6b8ea6 MH |
678 | diag308(DIAG308_SET, reipl_block_ccw); |
679 | diag308(DIAG308_IPL, NULL); | |
680 | break; | |
411ed322 | 681 | case REIPL_METHOD_FCP_RW_DIAG: |
ff6b8ea6 MH |
682 | diag308(DIAG308_SET, reipl_block_fcp); |
683 | diag308(DIAG308_IPL, NULL); | |
684 | break; | |
411ed322 | 685 | case REIPL_METHOD_FCP_RO_DIAG: |
ff6b8ea6 MH |
686 | diag308(DIAG308_IPL, NULL); |
687 | break; | |
411ed322 | 688 | case REIPL_METHOD_FCP_RO_VM: |
740b5706 | 689 | __cpcmd("IPL", NULL, 0, NULL); |
ff6b8ea6 | 690 | break; |
411ed322 | 691 | case REIPL_METHOD_NSS: |
fe355b7f HY |
692 | sprintf(buf, "IPL %s", reipl_nss_name); |
693 | __cpcmd(buf, NULL, 0, NULL); | |
694 | break; | |
411ed322 | 695 | case REIPL_METHOD_DEFAULT: |
ff6b8ea6 | 696 | if (MACHINE_IS_VM) |
740b5706 | 697 | __cpcmd("IPL", NULL, 0, NULL); |
ff6b8ea6 MH |
698 | diag308(DIAG308_IPL, NULL); |
699 | break; | |
411ed322 MH |
700 | case REIPL_METHOD_FCP_DUMP: |
701 | default: | |
702 | break; | |
ff6b8ea6 | 703 | } |
ff6b8ea6 MH |
704 | } |
705 | ||
99ca4e58 | 706 | static void __init reipl_probe(void) |
ff6b8ea6 | 707 | { |
99ca4e58 | 708 | void *buffer; |
ff6b8ea6 | 709 | |
99ca4e58 MH |
710 | buffer = (void *) get_zeroed_page(GFP_KERNEL); |
711 | if (!buffer) | |
ff6b8ea6 | 712 | return; |
99ca4e58 MH |
713 | if (diag308(DIAG308_STORE, buffer) == DIAG308_RC_OK) |
714 | diag308_set_works = 1; | |
715 | free_page((unsigned long)buffer); | |
ff6b8ea6 MH |
716 | } |
717 | ||
99ca4e58 | 718 | static int __init reipl_nss_init(void) |
ff6b8ea6 MH |
719 | { |
720 | int rc; | |
721 | ||
99ca4e58 MH |
722 | if (!MACHINE_IS_VM) |
723 | return 0; | |
724 | rc = sysfs_create_group(&reipl_kset->kobj, &reipl_nss_attr_group); | |
fe355b7f HY |
725 | if (rc) |
726 | return rc; | |
727 | strncpy(reipl_nss_name, kernel_nss_name, NSS_NAME_SIZE + 1); | |
728 | reipl_capabilities |= IPL_TYPE_NSS; | |
729 | return 0; | |
730 | } | |
731 | ||
ff6b8ea6 MH |
732 | static int __init reipl_ccw_init(void) |
733 | { | |
734 | int rc; | |
735 | ||
736 | reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL); | |
737 | if (!reipl_block_ccw) | |
738 | return -ENOMEM; | |
d91885be | 739 | rc = sysfs_create_group(&reipl_kset->kobj, &reipl_ccw_attr_group); |
ff6b8ea6 MH |
740 | if (rc) { |
741 | free_page((unsigned long)reipl_block_ccw); | |
742 | return rc; | |
743 | } | |
744 | reipl_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN; | |
745 | reipl_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION; | |
fbb04f38 | 746 | reipl_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN; |
ff6b8ea6 | 747 | reipl_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW; |
03a4d208 | 748 | /* check if read scp info worked and set loadparm */ |
05dd2530 | 749 | if (sclp_ipl_info.is_valid) |
03a4d208 | 750 | memcpy(reipl_block_ccw->ipl_info.ccw.load_param, |
05dd2530 | 751 | &sclp_ipl_info.loadparm, LOADPARM_LEN); |
03a4d208 MH |
752 | else |
753 | /* read scp info failed: set empty loadparm (EBCDIC blanks) */ | |
754 | memset(reipl_block_ccw->ipl_info.ccw.load_param, 0x40, | |
755 | LOADPARM_LEN); | |
756 | /* FIXME: check for diag308_set_works when enabling diag ccw reipl */ | |
757 | if (!MACHINE_IS_VM) | |
758 | sys_reipl_ccw_loadparm_attr.attr.mode = S_IRUGO; | |
411ed322 | 759 | if (ipl_info.type == IPL_TYPE_CCW) |
ff6b8ea6 MH |
760 | reipl_block_ccw->ipl_info.ccw.devno = ipl_devno; |
761 | reipl_capabilities |= IPL_TYPE_CCW; | |
762 | return 0; | |
763 | } | |
764 | ||
765 | static int __init reipl_fcp_init(void) | |
766 | { | |
767 | int rc; | |
768 | ||
411ed322 | 769 | if ((!diag308_set_works) && (ipl_info.type != IPL_TYPE_FCP)) |
ff6b8ea6 | 770 | return 0; |
411ed322 | 771 | if ((!diag308_set_works) && (ipl_info.type == IPL_TYPE_FCP)) |
ff6b8ea6 MH |
772 | make_attrs_ro(reipl_fcp_attrs); |
773 | ||
774 | reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL); | |
775 | if (!reipl_block_fcp) | |
776 | return -ENOMEM; | |
d91885be | 777 | rc = sysfs_create_group(&reipl_kset->kobj, &reipl_fcp_attr_group); |
ff6b8ea6 MH |
778 | if (rc) { |
779 | free_page((unsigned long)reipl_block_fcp); | |
780 | return rc; | |
781 | } | |
411ed322 | 782 | if (ipl_info.type == IPL_TYPE_FCP) { |
ff6b8ea6 MH |
783 | memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE); |
784 | } else { | |
785 | reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN; | |
786 | reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION; | |
fbb04f38 | 787 | reipl_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN; |
ff6b8ea6 MH |
788 | reipl_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP; |
789 | reipl_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_IPL; | |
790 | } | |
791 | reipl_capabilities |= IPL_TYPE_FCP; | |
792 | return 0; | |
793 | } | |
794 | ||
99ca4e58 | 795 | static int reipl_init(void) |
ff6b8ea6 MH |
796 | { |
797 | int rc; | |
798 | ||
f62ed9e3 | 799 | reipl_kset = kset_create_and_add("reipl", NULL, firmware_kobj); |
d91885be GKH |
800 | if (!reipl_kset) |
801 | return -ENOMEM; | |
802 | rc = sysfs_create_file(&reipl_kset->kobj, &reipl_type_attr.attr); | |
ff6b8ea6 | 803 | if (rc) { |
d91885be | 804 | kset_unregister(reipl_kset); |
ff6b8ea6 MH |
805 | return rc; |
806 | } | |
807 | rc = reipl_ccw_init(); | |
808 | if (rc) | |
809 | return rc; | |
810 | rc = reipl_fcp_init(); | |
fe355b7f HY |
811 | if (rc) |
812 | return rc; | |
813 | rc = reipl_nss_init(); | |
ff6b8ea6 MH |
814 | if (rc) |
815 | return rc; | |
411ed322 | 816 | rc = reipl_set_type(ipl_info.type); |
ff6b8ea6 MH |
817 | if (rc) |
818 | return rc; | |
819 | return 0; | |
820 | } | |
821 | ||
99ca4e58 MH |
822 | static struct shutdown_action reipl_action = {SHUTDOWN_ACTION_REIPL_STR, |
823 | reipl_run, reipl_init}; | |
824 | ||
825 | /* | |
826 | * dump shutdown action: Dump Linux on shutdown. | |
827 | */ | |
828 | ||
829 | /* FCP dump device attributes */ | |
830 | ||
831 | DEFINE_IPL_ATTR_RW(dump_fcp, wwpn, "0x%016llx\n", "%016llx\n", | |
832 | dump_block_fcp->ipl_info.fcp.wwpn); | |
833 | DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%016llx\n", | |
834 | dump_block_fcp->ipl_info.fcp.lun); | |
835 | DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n", | |
836 | dump_block_fcp->ipl_info.fcp.bootprog); | |
837 | DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n", | |
838 | dump_block_fcp->ipl_info.fcp.br_lba); | |
839 | DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n", | |
840 | dump_block_fcp->ipl_info.fcp.devno); | |
841 | ||
842 | static struct attribute *dump_fcp_attrs[] = { | |
843 | &sys_dump_fcp_device_attr.attr, | |
844 | &sys_dump_fcp_wwpn_attr.attr, | |
845 | &sys_dump_fcp_lun_attr.attr, | |
846 | &sys_dump_fcp_bootprog_attr.attr, | |
847 | &sys_dump_fcp_br_lba_attr.attr, | |
848 | NULL, | |
849 | }; | |
850 | ||
851 | static struct attribute_group dump_fcp_attr_group = { | |
852 | .name = IPL_FCP_STR, | |
853 | .attrs = dump_fcp_attrs, | |
854 | }; | |
855 | ||
856 | /* CCW dump device attributes */ | |
857 | ||
858 | DEFINE_IPL_ATTR_RW(dump_ccw, device, "0.0.%04llx\n", "0.0.%llx\n", | |
859 | dump_block_ccw->ipl_info.ccw.devno); | |
860 | ||
861 | static struct attribute *dump_ccw_attrs[] = { | |
862 | &sys_dump_ccw_device_attr.attr, | |
863 | NULL, | |
864 | }; | |
865 | ||
866 | static struct attribute_group dump_ccw_attr_group = { | |
867 | .name = IPL_CCW_STR, | |
868 | .attrs = dump_ccw_attrs, | |
869 | }; | |
870 | ||
871 | /* dump type */ | |
872 | ||
873 | static int dump_set_type(enum dump_type type) | |
874 | { | |
875 | if (!(dump_capabilities & type)) | |
876 | return -EINVAL; | |
877 | switch (type) { | |
878 | case DUMP_TYPE_CCW: | |
879 | if (MACHINE_IS_VM) | |
880 | dump_method = DUMP_METHOD_CCW_VM; | |
881 | else | |
882 | dump_method = DUMP_METHOD_CCW_CIO; | |
883 | break; | |
884 | case DUMP_TYPE_FCP: | |
885 | dump_method = DUMP_METHOD_FCP_DIAG; | |
886 | break; | |
887 | default: | |
888 | dump_method = DUMP_METHOD_NONE; | |
889 | } | |
890 | dump_type = type; | |
891 | return 0; | |
892 | } | |
893 | ||
894 | static ssize_t dump_type_show(struct kobject *kobj, | |
895 | struct kobj_attribute *attr, char *page) | |
896 | { | |
897 | return sprintf(page, "%s\n", dump_type_str(dump_type)); | |
898 | } | |
899 | ||
900 | static ssize_t dump_type_store(struct kobject *kobj, | |
901 | struct kobj_attribute *attr, | |
902 | const char *buf, size_t len) | |
903 | { | |
904 | int rc = -EINVAL; | |
905 | ||
906 | if (strncmp(buf, DUMP_NONE_STR, strlen(DUMP_NONE_STR)) == 0) | |
907 | rc = dump_set_type(DUMP_TYPE_NONE); | |
908 | else if (strncmp(buf, DUMP_CCW_STR, strlen(DUMP_CCW_STR)) == 0) | |
909 | rc = dump_set_type(DUMP_TYPE_CCW); | |
910 | else if (strncmp(buf, DUMP_FCP_STR, strlen(DUMP_FCP_STR)) == 0) | |
911 | rc = dump_set_type(DUMP_TYPE_FCP); | |
912 | return (rc != 0) ? rc : len; | |
913 | } | |
914 | ||
915 | static struct kobj_attribute dump_type_attr = | |
916 | __ATTR(dump_type, 0644, dump_type_show, dump_type_store); | |
917 | ||
918 | static struct kset *dump_kset; | |
919 | ||
920 | static void dump_run(struct shutdown_trigger *trigger) | |
921 | { | |
922 | struct ccw_dev_id devid; | |
923 | static char buf[100]; | |
924 | ||
925 | switch (dump_method) { | |
926 | case DUMP_METHOD_CCW_CIO: | |
927 | smp_send_stop(); | |
928 | devid.devno = dump_block_ccw->ipl_info.ccw.devno; | |
929 | devid.ssid = 0; | |
930 | reipl_ccw_dev(&devid); | |
931 | break; | |
932 | case DUMP_METHOD_CCW_VM: | |
933 | smp_send_stop(); | |
934 | sprintf(buf, "STORE STATUS"); | |
935 | __cpcmd(buf, NULL, 0, NULL); | |
936 | sprintf(buf, "IPL %X", dump_block_ccw->ipl_info.ccw.devno); | |
937 | __cpcmd(buf, NULL, 0, NULL); | |
938 | break; | |
939 | case DUMP_METHOD_CCW_DIAG: | |
940 | diag308(DIAG308_SET, dump_block_ccw); | |
941 | diag308(DIAG308_DUMP, NULL); | |
942 | break; | |
943 | case DUMP_METHOD_FCP_DIAG: | |
944 | diag308(DIAG308_SET, dump_block_fcp); | |
945 | diag308(DIAG308_DUMP, NULL); | |
946 | break; | |
947 | case DUMP_METHOD_NONE: | |
948 | default: | |
949 | return; | |
950 | } | |
951 | printk(KERN_EMERG "Dump failed!\n"); | |
952 | } | |
953 | ||
ff6b8ea6 MH |
954 | static int __init dump_ccw_init(void) |
955 | { | |
956 | int rc; | |
957 | ||
958 | dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL); | |
959 | if (!dump_block_ccw) | |
960 | return -ENOMEM; | |
d91885be | 961 | rc = sysfs_create_group(&dump_kset->kobj, &dump_ccw_attr_group); |
ff6b8ea6 MH |
962 | if (rc) { |
963 | free_page((unsigned long)dump_block_ccw); | |
964 | return rc; | |
965 | } | |
966 | dump_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN; | |
967 | dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION; | |
fbb04f38 | 968 | dump_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN; |
ff6b8ea6 | 969 | dump_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW; |
411ed322 | 970 | dump_capabilities |= DUMP_TYPE_CCW; |
ff6b8ea6 MH |
971 | return 0; |
972 | } | |
973 | ||
ff6b8ea6 MH |
974 | static int __init dump_fcp_init(void) |
975 | { | |
976 | int rc; | |
977 | ||
05dd2530 | 978 | if (!sclp_ipl_info.has_dump) |
ff6b8ea6 MH |
979 | return 0; /* LDIPL DUMP is not installed */ |
980 | if (!diag308_set_works) | |
981 | return 0; | |
982 | dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL); | |
983 | if (!dump_block_fcp) | |
984 | return -ENOMEM; | |
d91885be | 985 | rc = sysfs_create_group(&dump_kset->kobj, &dump_fcp_attr_group); |
ff6b8ea6 MH |
986 | if (rc) { |
987 | free_page((unsigned long)dump_block_fcp); | |
988 | return rc; | |
989 | } | |
990 | dump_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN; | |
991 | dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION; | |
fbb04f38 | 992 | dump_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN; |
ff6b8ea6 MH |
993 | dump_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP; |
994 | dump_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_DUMP; | |
411ed322 | 995 | dump_capabilities |= DUMP_TYPE_FCP; |
ff6b8ea6 MH |
996 | return 0; |
997 | } | |
998 | ||
99ca4e58 | 999 | static int dump_init(void) |
ff6b8ea6 MH |
1000 | { |
1001 | int rc; | |
1002 | ||
f62ed9e3 | 1003 | dump_kset = kset_create_and_add("dump", NULL, firmware_kobj); |
d91885be GKH |
1004 | if (!dump_kset) |
1005 | return -ENOMEM; | |
99ca4e58 | 1006 | rc = sysfs_create_file(&dump_kset->kobj, &dump_type_attr.attr); |
ff6b8ea6 | 1007 | if (rc) { |
d91885be | 1008 | kset_unregister(dump_kset); |
ff6b8ea6 MH |
1009 | return rc; |
1010 | } | |
1011 | rc = dump_ccw_init(); | |
1012 | if (rc) | |
1013 | return rc; | |
1014 | rc = dump_fcp_init(); | |
1015 | if (rc) | |
1016 | return rc; | |
411ed322 | 1017 | dump_set_type(DUMP_TYPE_NONE); |
ff6b8ea6 MH |
1018 | return 0; |
1019 | } | |
1020 | ||
99ca4e58 MH |
1021 | static struct shutdown_action dump_action = {SHUTDOWN_ACTION_DUMP_STR, |
1022 | dump_run, dump_init}; | |
1023 | ||
1024 | /* | |
1025 | * vmcmd shutdown action: Trigger vm command on shutdown. | |
1026 | */ | |
1027 | ||
1028 | static char vmcmd_on_reboot[128]; | |
1029 | static char vmcmd_on_panic[128]; | |
1030 | static char vmcmd_on_halt[128]; | |
1031 | static char vmcmd_on_poff[128]; | |
1032 | ||
1033 | DEFINE_IPL_ATTR_STR_RW(vmcmd, on_reboot, "%s\n", "%s\n", vmcmd_on_reboot); | |
1034 | DEFINE_IPL_ATTR_STR_RW(vmcmd, on_panic, "%s\n", "%s\n", vmcmd_on_panic); | |
1035 | DEFINE_IPL_ATTR_STR_RW(vmcmd, on_halt, "%s\n", "%s\n", vmcmd_on_halt); | |
1036 | DEFINE_IPL_ATTR_STR_RW(vmcmd, on_poff, "%s\n", "%s\n", vmcmd_on_poff); | |
1037 | ||
1038 | static struct attribute *vmcmd_attrs[] = { | |
1039 | &sys_vmcmd_on_reboot_attr.attr, | |
1040 | &sys_vmcmd_on_panic_attr.attr, | |
1041 | &sys_vmcmd_on_halt_attr.attr, | |
1042 | &sys_vmcmd_on_poff_attr.attr, | |
1043 | NULL, | |
1044 | }; | |
1045 | ||
1046 | static struct attribute_group vmcmd_attr_group = { | |
1047 | .attrs = vmcmd_attrs, | |
1048 | }; | |
1049 | ||
1050 | static struct kset *vmcmd_kset; | |
1051 | ||
1052 | static void vmcmd_run(struct shutdown_trigger *trigger) | |
ff6b8ea6 | 1053 | { |
99ca4e58 MH |
1054 | char *cmd, *next_cmd; |
1055 | ||
1056 | if (strcmp(trigger->name, ON_REIPL_STR) == 0) | |
1057 | cmd = vmcmd_on_reboot; | |
1058 | else if (strcmp(trigger->name, ON_PANIC_STR) == 0) | |
1059 | cmd = vmcmd_on_panic; | |
1060 | else if (strcmp(trigger->name, ON_HALT_STR) == 0) | |
1061 | cmd = vmcmd_on_halt; | |
1062 | else if (strcmp(trigger->name, ON_POFF_STR) == 0) | |
1063 | cmd = vmcmd_on_poff; | |
1064 | else | |
1065 | return; | |
1066 | ||
1067 | if (strlen(cmd) == 0) | |
1068 | return; | |
1069 | do { | |
1070 | next_cmd = strchr(cmd, '\n'); | |
1071 | if (next_cmd) { | |
1072 | next_cmd[0] = 0; | |
1073 | next_cmd += 1; | |
1074 | } | |
1075 | __cpcmd(cmd, NULL, 0, NULL); | |
1076 | cmd = next_cmd; | |
1077 | } while (cmd != NULL); | |
1078 | } | |
1079 | ||
1080 | static int vmcmd_init(void) | |
1081 | { | |
1082 | if (!MACHINE_IS_VM) | |
1083 | return -ENOTSUPP; | |
1084 | vmcmd_kset = kset_create_and_add("vmcmd", NULL, firmware_kobj); | |
1085 | if (!vmcmd_kset) | |
1086 | return -ENOMEM; | |
1087 | return sysfs_create_group(&vmcmd_kset->kobj, &vmcmd_attr_group); | |
1088 | } | |
1089 | ||
1090 | static struct shutdown_action vmcmd_action = {SHUTDOWN_ACTION_VMCMD_STR, | |
1091 | vmcmd_run, vmcmd_init}; | |
1092 | ||
1093 | /* | |
1094 | * stop shutdown action: Stop Linux on shutdown. | |
1095 | */ | |
1096 | ||
1097 | static void stop_run(struct shutdown_trigger *trigger) | |
1098 | { | |
c6547497 MH |
1099 | if (strcmp(trigger->name, ON_PANIC_STR) == 0) |
1100 | disabled_wait((unsigned long) __builtin_return_address(0)); | |
1101 | else { | |
1102 | signal_processor(smp_processor_id(), sigp_stop); | |
1103 | for (;;); | |
1104 | } | |
99ca4e58 MH |
1105 | } |
1106 | ||
1107 | static struct shutdown_action stop_action = {SHUTDOWN_ACTION_STOP_STR, | |
1108 | stop_run, NULL}; | |
1109 | ||
1110 | /* action list */ | |
1111 | ||
1112 | static struct shutdown_action *shutdown_actions_list[] = { | |
1113 | &ipl_action, &reipl_action, &dump_action, &vmcmd_action, &stop_action}; | |
1114 | #define SHUTDOWN_ACTIONS_COUNT (sizeof(shutdown_actions_list) / sizeof(void *)) | |
1115 | ||
1116 | /* | |
1117 | * Trigger section | |
1118 | */ | |
1119 | ||
1120 | static struct kset *shutdown_actions_kset; | |
1121 | ||
1122 | static int set_trigger(const char *buf, struct shutdown_trigger *trigger, | |
1123 | size_t len) | |
1124 | { | |
1125 | int i; | |
1126 | for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) { | |
1127 | if (!shutdown_actions_list[i]) | |
1128 | continue; | |
1129 | if (strncmp(buf, shutdown_actions_list[i]->name, | |
1130 | strlen(shutdown_actions_list[i]->name)) == 0) { | |
1131 | trigger->action = shutdown_actions_list[i]; | |
1132 | return len; | |
1133 | } | |
1134 | } | |
1135 | return -EINVAL; | |
1136 | } | |
1137 | ||
1138 | /* on reipl */ | |
1139 | ||
1140 | static struct shutdown_trigger on_reboot_trigger = {ON_REIPL_STR, | |
1141 | &reipl_action}; | |
1142 | ||
1143 | static ssize_t on_reboot_show(struct kobject *kobj, | |
1144 | struct kobj_attribute *attr, char *page) | |
1145 | { | |
1146 | return sprintf(page, "%s\n", on_reboot_trigger.action->name); | |
1147 | } | |
1148 | ||
1149 | static ssize_t on_reboot_store(struct kobject *kobj, | |
1150 | struct kobj_attribute *attr, | |
1151 | const char *buf, size_t len) | |
1152 | { | |
1153 | return set_trigger(buf, &on_reboot_trigger, len); | |
1154 | } | |
1155 | ||
1156 | static struct kobj_attribute on_reboot_attr = | |
1157 | __ATTR(on_reboot, 0644, on_reboot_show, on_reboot_store); | |
1158 | ||
1159 | static void do_machine_restart(char *__unused) | |
1160 | { | |
1161 | smp_send_stop(); | |
1162 | on_reboot_trigger.action->fn(&on_reboot_trigger); | |
1163 | reipl_run(NULL); | |
1164 | } | |
1165 | void (*_machine_restart)(char *command) = do_machine_restart; | |
1166 | ||
1167 | /* on panic */ | |
1168 | ||
1169 | static struct shutdown_trigger on_panic_trigger = {ON_PANIC_STR, &stop_action}; | |
1170 | ||
1171 | static ssize_t on_panic_show(struct kobject *kobj, | |
1172 | struct kobj_attribute *attr, char *page) | |
1173 | { | |
1174 | return sprintf(page, "%s\n", on_panic_trigger.action->name); | |
1175 | } | |
1176 | ||
1177 | static ssize_t on_panic_store(struct kobject *kobj, | |
1178 | struct kobj_attribute *attr, | |
1179 | const char *buf, size_t len) | |
1180 | { | |
1181 | return set_trigger(buf, &on_panic_trigger, len); | |
1182 | } | |
1183 | ||
1184 | static struct kobj_attribute on_panic_attr = | |
1185 | __ATTR(on_panic, 0644, on_panic_show, on_panic_store); | |
1186 | ||
1187 | static void do_panic(void) | |
1188 | { | |
1189 | on_panic_trigger.action->fn(&on_panic_trigger); | |
1190 | stop_run(&on_panic_trigger); | |
1191 | } | |
1192 | ||
1193 | /* on halt */ | |
1194 | ||
1195 | static struct shutdown_trigger on_halt_trigger = {ON_HALT_STR, &stop_action}; | |
1196 | ||
1197 | static ssize_t on_halt_show(struct kobject *kobj, | |
1198 | struct kobj_attribute *attr, char *page) | |
1199 | { | |
1200 | return sprintf(page, "%s\n", on_halt_trigger.action->name); | |
1201 | } | |
1202 | ||
1203 | static ssize_t on_halt_store(struct kobject *kobj, | |
1204 | struct kobj_attribute *attr, | |
1205 | const char *buf, size_t len) | |
1206 | { | |
1207 | return set_trigger(buf, &on_halt_trigger, len); | |
1208 | } | |
1209 | ||
1210 | static struct kobj_attribute on_halt_attr = | |
1211 | __ATTR(on_halt, 0644, on_halt_show, on_halt_store); | |
ff6b8ea6 | 1212 | |
99ca4e58 MH |
1213 | |
1214 | static void do_machine_halt(void) | |
1215 | { | |
1216 | smp_send_stop(); | |
1217 | on_halt_trigger.action->fn(&on_halt_trigger); | |
1218 | stop_run(&on_halt_trigger); | |
1219 | } | |
1220 | void (*_machine_halt)(void) = do_machine_halt; | |
1221 | ||
1222 | /* on power off */ | |
1223 | ||
1224 | static struct shutdown_trigger on_poff_trigger = {ON_POFF_STR, &stop_action}; | |
1225 | ||
1226 | static ssize_t on_poff_show(struct kobject *kobj, | |
1227 | struct kobj_attribute *attr, char *page) | |
1228 | { | |
1229 | return sprintf(page, "%s\n", on_poff_trigger.action->name); | |
1230 | } | |
1231 | ||
1232 | static ssize_t on_poff_store(struct kobject *kobj, | |
1233 | struct kobj_attribute *attr, | |
1234 | const char *buf, size_t len) | |
1235 | { | |
1236 | return set_trigger(buf, &on_poff_trigger, len); | |
1237 | } | |
1238 | ||
1239 | static struct kobj_attribute on_poff_attr = | |
1240 | __ATTR(on_poff, 0644, on_poff_show, on_poff_store); | |
1241 | ||
1242 | ||
1243 | static void do_machine_power_off(void) | |
1244 | { | |
1245 | smp_send_stop(); | |
1246 | on_poff_trigger.action->fn(&on_poff_trigger); | |
1247 | stop_run(&on_poff_trigger); | |
1248 | } | |
1249 | void (*_machine_power_off)(void) = do_machine_power_off; | |
1250 | ||
1251 | static void __init shutdown_triggers_init(void) | |
1252 | { | |
d91885be | 1253 | shutdown_actions_kset = kset_create_and_add("shutdown_actions", NULL, |
f62ed9e3 | 1254 | firmware_kobj); |
d91885be | 1255 | if (!shutdown_actions_kset) |
99ca4e58 MH |
1256 | goto fail; |
1257 | if (sysfs_create_file(&shutdown_actions_kset->kobj, | |
1258 | &on_reboot_attr.attr)) | |
1259 | goto fail; | |
1260 | if (sysfs_create_file(&shutdown_actions_kset->kobj, | |
1261 | &on_panic_attr.attr)) | |
1262 | goto fail; | |
1263 | if (sysfs_create_file(&shutdown_actions_kset->kobj, | |
1264 | &on_halt_attr.attr)) | |
1265 | goto fail; | |
1266 | if (sysfs_create_file(&shutdown_actions_kset->kobj, | |
1267 | &on_poff_attr.attr)) | |
1268 | goto fail; | |
1269 | ||
1270 | return; | |
1271 | fail: | |
1272 | panic("shutdown_triggers_init failed\n"); | |
1273 | } | |
1274 | ||
1275 | static void __init shutdown_actions_init(void) | |
1276 | { | |
1277 | int i; | |
1278 | ||
1279 | for (i = 0; i < SHUTDOWN_ACTIONS_COUNT; i++) { | |
1280 | if (!shutdown_actions_list[i]->init) | |
1281 | continue; | |
1282 | if (shutdown_actions_list[i]->init()) | |
1283 | shutdown_actions_list[i] = NULL; | |
ff6b8ea6 | 1284 | } |
ff6b8ea6 MH |
1285 | } |
1286 | ||
1287 | static int __init s390_ipl_init(void) | |
1288 | { | |
ff6b8ea6 | 1289 | reipl_probe(); |
99ca4e58 MH |
1290 | shutdown_actions_init(); |
1291 | shutdown_triggers_init(); | |
ff6b8ea6 MH |
1292 | return 0; |
1293 | } | |
1294 | ||
1295 | __initcall(s390_ipl_init); | |
15e9b586 | 1296 | |
99ca4e58 MH |
1297 | static void __init strncpy_skip_quote(char *dst, char *src, int n) |
1298 | { | |
1299 | int sx, dx; | |
1300 | ||
1301 | dx = 0; | |
1302 | for (sx = 0; src[sx] != 0; sx++) { | |
1303 | if (src[sx] == '"') | |
1304 | continue; | |
1305 | dst[dx++] = src[sx]; | |
1306 | if (dx >= n) | |
1307 | break; | |
1308 | } | |
1309 | } | |
1310 | ||
1311 | static int __init vmcmd_on_reboot_setup(char *str) | |
1312 | { | |
1313 | if (!MACHINE_IS_VM) | |
1314 | return 1; | |
1315 | strncpy_skip_quote(vmcmd_on_reboot, str, 127); | |
1316 | vmcmd_on_reboot[127] = 0; | |
1317 | on_reboot_trigger.action = &vmcmd_action; | |
1318 | return 1; | |
1319 | } | |
1320 | __setup("vmreboot=", vmcmd_on_reboot_setup); | |
1321 | ||
1322 | static int __init vmcmd_on_panic_setup(char *str) | |
1323 | { | |
1324 | if (!MACHINE_IS_VM) | |
1325 | return 1; | |
1326 | strncpy_skip_quote(vmcmd_on_panic, str, 127); | |
1327 | vmcmd_on_panic[127] = 0; | |
1328 | on_panic_trigger.action = &vmcmd_action; | |
1329 | return 1; | |
1330 | } | |
1331 | __setup("vmpanic=", vmcmd_on_panic_setup); | |
1332 | ||
1333 | static int __init vmcmd_on_halt_setup(char *str) | |
1334 | { | |
1335 | if (!MACHINE_IS_VM) | |
1336 | return 1; | |
1337 | strncpy_skip_quote(vmcmd_on_halt, str, 127); | |
1338 | vmcmd_on_halt[127] = 0; | |
1339 | on_halt_trigger.action = &vmcmd_action; | |
1340 | return 1; | |
1341 | } | |
1342 | __setup("vmhalt=", vmcmd_on_halt_setup); | |
1343 | ||
1344 | static int __init vmcmd_on_poff_setup(char *str) | |
1345 | { | |
1346 | if (!MACHINE_IS_VM) | |
1347 | return 1; | |
1348 | strncpy_skip_quote(vmcmd_on_poff, str, 127); | |
1349 | vmcmd_on_poff[127] = 0; | |
1350 | on_poff_trigger.action = &vmcmd_action; | |
1351 | return 1; | |
1352 | } | |
1353 | __setup("vmpoff=", vmcmd_on_poff_setup); | |
1354 | ||
1355 | static int on_panic_notify(struct notifier_block *self, | |
1356 | unsigned long event, void *data) | |
1357 | { | |
1358 | do_panic(); | |
1359 | return NOTIFY_OK; | |
1360 | } | |
1361 | ||
1362 | static struct notifier_block on_panic_nb = { | |
1363 | .notifier_call = on_panic_notify, | |
1364 | .priority = 0, | |
1365 | }; | |
1366 | ||
1367 | void __init setup_ipl(void) | |
1368 | { | |
1369 | ipl_info.type = get_ipl_type(); | |
1370 | switch (ipl_info.type) { | |
1371 | case IPL_TYPE_CCW: | |
1372 | ipl_info.data.ccw.dev_id.devno = ipl_devno; | |
1373 | ipl_info.data.ccw.dev_id.ssid = 0; | |
1374 | break; | |
1375 | case IPL_TYPE_FCP: | |
1376 | case IPL_TYPE_FCP_DUMP: | |
1377 | ipl_info.data.fcp.dev_id.devno = | |
1378 | IPL_PARMBLOCK_START->ipl_info.fcp.devno; | |
1379 | ipl_info.data.fcp.dev_id.ssid = 0; | |
1380 | ipl_info.data.fcp.wwpn = IPL_PARMBLOCK_START->ipl_info.fcp.wwpn; | |
1381 | ipl_info.data.fcp.lun = IPL_PARMBLOCK_START->ipl_info.fcp.lun; | |
1382 | break; | |
1383 | case IPL_TYPE_NSS: | |
1384 | strncpy(ipl_info.data.nss.name, kernel_nss_name, | |
1385 | sizeof(ipl_info.data.nss.name)); | |
1386 | break; | |
1387 | case IPL_TYPE_UNKNOWN: | |
1388 | default: | |
1389 | /* We have no info to copy */ | |
1390 | break; | |
1391 | } | |
1392 | atomic_notifier_chain_register(&panic_notifier_list, &on_panic_nb); | |
1393 | } | |
1394 | ||
6fc321fd HC |
1395 | void __init ipl_save_parameters(void) |
1396 | { | |
1397 | struct cio_iplinfo iplinfo; | |
1398 | unsigned int *ipl_ptr; | |
1399 | void *src, *dst; | |
1400 | ||
1401 | if (cio_get_iplinfo(&iplinfo)) | |
1402 | return; | |
1403 | ||
1404 | ipl_devno = iplinfo.devno; | |
1405 | ipl_flags |= IPL_DEVNO_VALID; | |
1406 | if (!iplinfo.is_qdio) | |
1407 | return; | |
1408 | ipl_flags |= IPL_PARMBLOCK_VALID; | |
1409 | ipl_ptr = (unsigned int *)__LC_IPL_PARMBLOCK_PTR; | |
1410 | src = (void *)(unsigned long)*ipl_ptr; | |
1411 | dst = (void *)IPL_PARMBLOCK_ORIGIN; | |
1412 | memmove(dst, src, PAGE_SIZE); | |
1413 | *ipl_ptr = IPL_PARMBLOCK_ORIGIN; | |
1414 | } | |
1415 | ||
15e9b586 HC |
1416 | static LIST_HEAD(rcall); |
1417 | static DEFINE_MUTEX(rcall_mutex); | |
1418 | ||
1419 | void register_reset_call(struct reset_call *reset) | |
1420 | { | |
1421 | mutex_lock(&rcall_mutex); | |
1422 | list_add(&reset->list, &rcall); | |
1423 | mutex_unlock(&rcall_mutex); | |
1424 | } | |
1425 | EXPORT_SYMBOL_GPL(register_reset_call); | |
1426 | ||
1427 | void unregister_reset_call(struct reset_call *reset) | |
1428 | { | |
1429 | mutex_lock(&rcall_mutex); | |
1430 | list_del(&reset->list); | |
1431 | mutex_unlock(&rcall_mutex); | |
1432 | } | |
1433 | EXPORT_SYMBOL_GPL(unregister_reset_call); | |
1434 | ||
1435 | static void do_reset_calls(void) | |
1436 | { | |
1437 | struct reset_call *reset; | |
1438 | ||
1439 | list_for_each_entry(reset, &rcall, list) | |
1440 | reset->fn(); | |
1441 | } | |
1442 | ||
c5dd8586 | 1443 | u32 dump_prefix_page; |
15e9b586 HC |
1444 | |
1445 | void s390_reset_system(void) | |
1446 | { | |
1447 | struct _lowcore *lc; | |
1448 | ||
15e9b586 | 1449 | lc = (struct _lowcore *)(unsigned long) store_prefix(); |
a45e1414 MH |
1450 | |
1451 | /* Stack for interrupt/machine check handler */ | |
15e9b586 HC |
1452 | lc->panic_stack = S390_lowcore.panic_stack; |
1453 | ||
da1cf23e | 1454 | /* Save prefix page address for dump case */ |
c5dd8586 | 1455 | dump_prefix_page = (u32)(unsigned long) lc; |
da1cf23e | 1456 | |
15e9b586 HC |
1457 | /* Disable prefixing */ |
1458 | set_prefix(0); | |
1459 | ||
1460 | /* Disable lowcore protection */ | |
1461 | __ctl_clear_bit(0,28); | |
1462 | ||
1463 | /* Set new machine check handler */ | |
c1821c2e | 1464 | S390_lowcore.mcck_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK; |
15e9b586 | 1465 | S390_lowcore.mcck_new_psw.addr = |
ab14de6c | 1466 | PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler; |
a45e1414 MH |
1467 | |
1468 | /* Set new program check handler */ | |
c1821c2e | 1469 | S390_lowcore.program_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK; |
a45e1414 | 1470 | S390_lowcore.program_new_psw.addr = |
ab14de6c | 1471 | PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler; |
a45e1414 | 1472 | |
15e9b586 HC |
1473 | do_reset_calls(); |
1474 | } | |
99ca4e58 | 1475 |