ipl.c 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204
  1. /*
  2. * arch/s390/kernel/ipl.c
  3. * ipl/reipl/dump support for Linux on s390.
  4. *
  5. * Copyright (C) IBM Corp. 2005,2006
  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. #include <linux/types.h>
  11. #include <linux/module.h>
  12. #include <linux/device.h>
  13. #include <linux/delay.h>
  14. #include <linux/reboot.h>
  15. #include <linux/ctype.h>
  16. #include <asm/ipl.h>
  17. #include <asm/smp.h>
  18. #include <asm/setup.h>
  19. #include <asm/cpcmd.h>
  20. #include <asm/cio.h>
  21. #include <asm/ebcdic.h>
  22. #include <asm/reset.h>
  23. #include <asm/sclp.h>
  24. #define IPL_PARM_BLOCK_VERSION 0
  25. #define IPL_UNKNOWN_STR "unknown"
  26. #define IPL_CCW_STR "ccw"
  27. #define IPL_FCP_STR "fcp"
  28. #define IPL_FCP_DUMP_STR "fcp_dump"
  29. #define IPL_NSS_STR "nss"
  30. static char *ipl_type_str(enum ipl_type type)
  31. {
  32. switch (type) {
  33. case IPL_TYPE_CCW:
  34. return IPL_CCW_STR;
  35. case IPL_TYPE_FCP:
  36. return IPL_FCP_STR;
  37. case IPL_TYPE_FCP_DUMP:
  38. return IPL_FCP_DUMP_STR;
  39. case IPL_TYPE_NSS:
  40. return IPL_NSS_STR;
  41. case IPL_TYPE_UNKNOWN:
  42. default:
  43. return IPL_UNKNOWN_STR;
  44. }
  45. }
  46. enum dump_type {
  47. DUMP_TYPE_NONE = 1,
  48. DUMP_TYPE_CCW = 2,
  49. DUMP_TYPE_FCP = 4,
  50. };
  51. #define DUMP_NONE_STR "none"
  52. #define DUMP_CCW_STR "ccw"
  53. #define DUMP_FCP_STR "fcp"
  54. static char *dump_type_str(enum dump_type type)
  55. {
  56. switch (type) {
  57. case DUMP_TYPE_NONE:
  58. return DUMP_NONE_STR;
  59. case DUMP_TYPE_CCW:
  60. return DUMP_CCW_STR;
  61. case DUMP_TYPE_FCP:
  62. return DUMP_FCP_STR;
  63. default:
  64. return NULL;
  65. }
  66. }
  67. /*
  68. * Must be in data section since the bss section
  69. * is not cleared when these are accessed.
  70. */
  71. static u16 ipl_devno __attribute__((__section__(".data"))) = 0;
  72. u32 ipl_flags __attribute__((__section__(".data"))) = 0;
  73. enum ipl_method {
  74. REIPL_METHOD_CCW_CIO,
  75. REIPL_METHOD_CCW_DIAG,
  76. REIPL_METHOD_CCW_VM,
  77. REIPL_METHOD_FCP_RO_DIAG,
  78. REIPL_METHOD_FCP_RW_DIAG,
  79. REIPL_METHOD_FCP_RO_VM,
  80. REIPL_METHOD_FCP_DUMP,
  81. REIPL_METHOD_NSS,
  82. REIPL_METHOD_DEFAULT,
  83. };
  84. enum dump_method {
  85. DUMP_METHOD_NONE,
  86. DUMP_METHOD_CCW_CIO,
  87. DUMP_METHOD_CCW_DIAG,
  88. DUMP_METHOD_CCW_VM,
  89. DUMP_METHOD_FCP_DIAG,
  90. };
  91. enum shutdown_action {
  92. SHUTDOWN_REIPL,
  93. SHUTDOWN_DUMP,
  94. SHUTDOWN_STOP,
  95. };
  96. #define SHUTDOWN_REIPL_STR "reipl"
  97. #define SHUTDOWN_DUMP_STR "dump"
  98. #define SHUTDOWN_STOP_STR "stop"
  99. static char *shutdown_action_str(enum shutdown_action action)
  100. {
  101. switch (action) {
  102. case SHUTDOWN_REIPL:
  103. return SHUTDOWN_REIPL_STR;
  104. case SHUTDOWN_DUMP:
  105. return SHUTDOWN_DUMP_STR;
  106. case SHUTDOWN_STOP:
  107. return SHUTDOWN_STOP_STR;
  108. default:
  109. return NULL;
  110. }
  111. }
  112. static int diag308_set_works = 0;
  113. static int reipl_capabilities = IPL_TYPE_UNKNOWN;
  114. static enum ipl_type reipl_type = IPL_TYPE_UNKNOWN;
  115. static enum ipl_method reipl_method = REIPL_METHOD_DEFAULT;
  116. static struct ipl_parameter_block *reipl_block_fcp;
  117. static struct ipl_parameter_block *reipl_block_ccw;
  118. static char reipl_nss_name[NSS_NAME_SIZE + 1];
  119. static int dump_capabilities = DUMP_TYPE_NONE;
  120. static enum dump_type dump_type = DUMP_TYPE_NONE;
  121. static enum dump_method dump_method = DUMP_METHOD_NONE;
  122. static struct ipl_parameter_block *dump_block_fcp;
  123. static struct ipl_parameter_block *dump_block_ccw;
  124. static enum shutdown_action on_panic_action = SHUTDOWN_STOP;
  125. static struct sclp_ipl_info sclp_ipl_info;
  126. int diag308(unsigned long subcode, void *addr)
  127. {
  128. register unsigned long _addr asm("0") = (unsigned long) addr;
  129. register unsigned long _rc asm("1") = 0;
  130. asm volatile(
  131. " diag %0,%2,0x308\n"
  132. "0:\n"
  133. EX_TABLE(0b,0b)
  134. : "+d" (_addr), "+d" (_rc)
  135. : "d" (subcode) : "cc", "memory");
  136. return _rc;
  137. }
  138. EXPORT_SYMBOL_GPL(diag308);
  139. /* SYSFS */
  140. #define DEFINE_IPL_ATTR_RO(_prefix, _name, _format, _value) \
  141. static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
  142. struct kobj_attribute *attr, \
  143. char *page) \
  144. { \
  145. return sprintf(page, _format, _value); \
  146. } \
  147. static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
  148. __ATTR(_name, S_IRUGO, sys_##_prefix##_##_name##_show, NULL);
  149. #define DEFINE_IPL_ATTR_RW(_prefix, _name, _fmt_out, _fmt_in, _value) \
  150. static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
  151. struct kobj_attribute *attr, \
  152. char *page) \
  153. { \
  154. return sprintf(page, _fmt_out, \
  155. (unsigned long long) _value); \
  156. } \
  157. static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
  158. struct kobj_attribute *attr, \
  159. const char *buf, size_t len) \
  160. { \
  161. unsigned long long value; \
  162. if (sscanf(buf, _fmt_in, &value) != 1) \
  163. return -EINVAL; \
  164. _value = value; \
  165. return len; \
  166. } \
  167. static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
  168. __ATTR(_name,(S_IRUGO | S_IWUSR), \
  169. sys_##_prefix##_##_name##_show, \
  170. sys_##_prefix##_##_name##_store);
  171. #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\
  172. static ssize_t sys_##_prefix##_##_name##_show(struct kobject *kobj, \
  173. struct kobj_attribute *attr, \
  174. char *page) \
  175. { \
  176. return sprintf(page, _fmt_out, _value); \
  177. } \
  178. static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \
  179. struct kobj_attribute *attr, \
  180. const char *buf, size_t len) \
  181. { \
  182. if (sscanf(buf, _fmt_in, _value) != 1) \
  183. return -EINVAL; \
  184. return len; \
  185. } \
  186. static struct kobj_attribute sys_##_prefix##_##_name##_attr = \
  187. __ATTR(_name,(S_IRUGO | S_IWUSR), \
  188. sys_##_prefix##_##_name##_show, \
  189. sys_##_prefix##_##_name##_store);
  190. static void make_attrs_ro(struct attribute **attrs)
  191. {
  192. while (*attrs) {
  193. (*attrs)->mode = S_IRUGO;
  194. attrs++;
  195. }
  196. }
  197. /*
  198. * ipl section
  199. */
  200. static __init enum ipl_type get_ipl_type(void)
  201. {
  202. struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
  203. if (ipl_flags & IPL_NSS_VALID)
  204. return IPL_TYPE_NSS;
  205. if (!(ipl_flags & IPL_DEVNO_VALID))
  206. return IPL_TYPE_UNKNOWN;
  207. if (!(ipl_flags & IPL_PARMBLOCK_VALID))
  208. return IPL_TYPE_CCW;
  209. if (ipl->hdr.version > IPL_MAX_SUPPORTED_VERSION)
  210. return IPL_TYPE_UNKNOWN;
  211. if (ipl->hdr.pbt != DIAG308_IPL_TYPE_FCP)
  212. return IPL_TYPE_UNKNOWN;
  213. if (ipl->ipl_info.fcp.opt == DIAG308_IPL_OPT_DUMP)
  214. return IPL_TYPE_FCP_DUMP;
  215. return IPL_TYPE_FCP;
  216. }
  217. void __init setup_ipl_info(void)
  218. {
  219. ipl_info.type = get_ipl_type();
  220. switch (ipl_info.type) {
  221. case IPL_TYPE_CCW:
  222. ipl_info.data.ccw.dev_id.devno = ipl_devno;
  223. ipl_info.data.ccw.dev_id.ssid = 0;
  224. break;
  225. case IPL_TYPE_FCP:
  226. case IPL_TYPE_FCP_DUMP:
  227. ipl_info.data.fcp.dev_id.devno =
  228. IPL_PARMBLOCK_START->ipl_info.fcp.devno;
  229. ipl_info.data.fcp.dev_id.ssid = 0;
  230. ipl_info.data.fcp.wwpn = IPL_PARMBLOCK_START->ipl_info.fcp.wwpn;
  231. ipl_info.data.fcp.lun = IPL_PARMBLOCK_START->ipl_info.fcp.lun;
  232. break;
  233. case IPL_TYPE_NSS:
  234. strncpy(ipl_info.data.nss.name, kernel_nss_name,
  235. sizeof(ipl_info.data.nss.name));
  236. break;
  237. case IPL_TYPE_UNKNOWN:
  238. default:
  239. /* We have no info to copy */
  240. break;
  241. }
  242. }
  243. struct ipl_info ipl_info;
  244. EXPORT_SYMBOL_GPL(ipl_info);
  245. static ssize_t ipl_type_show(struct kobject *kobj, struct kobj_attribute *attr,
  246. char *page)
  247. {
  248. return sprintf(page, "%s\n", ipl_type_str(ipl_info.type));
  249. }
  250. static struct kobj_attribute sys_ipl_type_attr = __ATTR_RO(ipl_type);
  251. static ssize_t sys_ipl_device_show(struct kobject *kobj,
  252. struct kobj_attribute *attr, char *page)
  253. {
  254. struct ipl_parameter_block *ipl = IPL_PARMBLOCK_START;
  255. switch (ipl_info.type) {
  256. case IPL_TYPE_CCW:
  257. return sprintf(page, "0.0.%04x\n", ipl_devno);
  258. case IPL_TYPE_FCP:
  259. case IPL_TYPE_FCP_DUMP:
  260. return sprintf(page, "0.0.%04x\n", ipl->ipl_info.fcp.devno);
  261. default:
  262. return 0;
  263. }
  264. }
  265. static struct kobj_attribute sys_ipl_device_attr =
  266. __ATTR(device, S_IRUGO, sys_ipl_device_show, NULL);
  267. static ssize_t ipl_parameter_read(struct kobject *kobj, struct bin_attribute *attr,
  268. char *buf, loff_t off, size_t count)
  269. {
  270. unsigned int size = IPL_PARMBLOCK_SIZE;
  271. if (off > size)
  272. return 0;
  273. if (off + count > size)
  274. count = size - off;
  275. memcpy(buf, (void *)IPL_PARMBLOCK_START + off, count);
  276. return count;
  277. }
  278. static struct bin_attribute ipl_parameter_attr = {
  279. .attr = {
  280. .name = "binary_parameter",
  281. .mode = S_IRUGO,
  282. },
  283. .size = PAGE_SIZE,
  284. .read = &ipl_parameter_read,
  285. };
  286. static ssize_t ipl_scp_data_read(struct kobject *kobj, struct bin_attribute *attr,
  287. char *buf, loff_t off, size_t count)
  288. {
  289. unsigned int size = IPL_PARMBLOCK_START->ipl_info.fcp.scp_data_len;
  290. void *scp_data = &IPL_PARMBLOCK_START->ipl_info.fcp.scp_data;
  291. if (off > size)
  292. return 0;
  293. if (off + count > size)
  294. count = size - off;
  295. memcpy(buf, scp_data + off, count);
  296. return count;
  297. }
  298. static struct bin_attribute ipl_scp_data_attr = {
  299. .attr = {
  300. .name = "scp_data",
  301. .mode = S_IRUGO,
  302. },
  303. .size = PAGE_SIZE,
  304. .read = ipl_scp_data_read,
  305. };
  306. /* FCP ipl device attributes */
  307. DEFINE_IPL_ATTR_RO(ipl_fcp, wwpn, "0x%016llx\n", (unsigned long long)
  308. IPL_PARMBLOCK_START->ipl_info.fcp.wwpn);
  309. DEFINE_IPL_ATTR_RO(ipl_fcp, lun, "0x%016llx\n", (unsigned long long)
  310. IPL_PARMBLOCK_START->ipl_info.fcp.lun);
  311. DEFINE_IPL_ATTR_RO(ipl_fcp, bootprog, "%lld\n", (unsigned long long)
  312. IPL_PARMBLOCK_START->ipl_info.fcp.bootprog);
  313. DEFINE_IPL_ATTR_RO(ipl_fcp, br_lba, "%lld\n", (unsigned long long)
  314. IPL_PARMBLOCK_START->ipl_info.fcp.br_lba);
  315. static struct attribute *ipl_fcp_attrs[] = {
  316. &sys_ipl_type_attr.attr,
  317. &sys_ipl_device_attr.attr,
  318. &sys_ipl_fcp_wwpn_attr.attr,
  319. &sys_ipl_fcp_lun_attr.attr,
  320. &sys_ipl_fcp_bootprog_attr.attr,
  321. &sys_ipl_fcp_br_lba_attr.attr,
  322. NULL,
  323. };
  324. static struct attribute_group ipl_fcp_attr_group = {
  325. .attrs = ipl_fcp_attrs,
  326. };
  327. /* CCW ipl device attributes */
  328. static ssize_t ipl_ccw_loadparm_show(struct kobject *kobj,
  329. struct kobj_attribute *attr, char *page)
  330. {
  331. char loadparm[LOADPARM_LEN + 1] = {};
  332. if (!sclp_ipl_info.is_valid)
  333. return sprintf(page, "#unknown#\n");
  334. memcpy(loadparm, &sclp_ipl_info.loadparm, LOADPARM_LEN);
  335. EBCASC(loadparm, LOADPARM_LEN);
  336. strstrip(loadparm);
  337. return sprintf(page, "%s\n", loadparm);
  338. }
  339. static struct kobj_attribute sys_ipl_ccw_loadparm_attr =
  340. __ATTR(loadparm, 0444, ipl_ccw_loadparm_show, NULL);
  341. static struct attribute *ipl_ccw_attrs[] = {
  342. &sys_ipl_type_attr.attr,
  343. &sys_ipl_device_attr.attr,
  344. &sys_ipl_ccw_loadparm_attr.attr,
  345. NULL,
  346. };
  347. static struct attribute_group ipl_ccw_attr_group = {
  348. .attrs = ipl_ccw_attrs,
  349. };
  350. /* NSS ipl device attributes */
  351. DEFINE_IPL_ATTR_RO(ipl_nss, name, "%s\n", kernel_nss_name);
  352. static struct attribute *ipl_nss_attrs[] = {
  353. &sys_ipl_type_attr.attr,
  354. &sys_ipl_nss_name_attr.attr,
  355. NULL,
  356. };
  357. static struct attribute_group ipl_nss_attr_group = {
  358. .attrs = ipl_nss_attrs,
  359. };
  360. /* UNKNOWN ipl device attributes */
  361. static struct attribute *ipl_unknown_attrs[] = {
  362. &sys_ipl_type_attr.attr,
  363. NULL,
  364. };
  365. static struct attribute_group ipl_unknown_attr_group = {
  366. .attrs = ipl_unknown_attrs,
  367. };
  368. static struct kset *ipl_kset;
  369. /*
  370. * reipl section
  371. */
  372. /* FCP reipl device attributes */
  373. DEFINE_IPL_ATTR_RW(reipl_fcp, wwpn, "0x%016llx\n", "%016llx\n",
  374. reipl_block_fcp->ipl_info.fcp.wwpn);
  375. DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%016llx\n",
  376. reipl_block_fcp->ipl_info.fcp.lun);
  377. DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n",
  378. reipl_block_fcp->ipl_info.fcp.bootprog);
  379. DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n",
  380. reipl_block_fcp->ipl_info.fcp.br_lba);
  381. DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
  382. reipl_block_fcp->ipl_info.fcp.devno);
  383. static struct attribute *reipl_fcp_attrs[] = {
  384. &sys_reipl_fcp_device_attr.attr,
  385. &sys_reipl_fcp_wwpn_attr.attr,
  386. &sys_reipl_fcp_lun_attr.attr,
  387. &sys_reipl_fcp_bootprog_attr.attr,
  388. &sys_reipl_fcp_br_lba_attr.attr,
  389. NULL,
  390. };
  391. static struct attribute_group reipl_fcp_attr_group = {
  392. .name = IPL_FCP_STR,
  393. .attrs = reipl_fcp_attrs,
  394. };
  395. /* CCW reipl device attributes */
  396. DEFINE_IPL_ATTR_RW(reipl_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
  397. reipl_block_ccw->ipl_info.ccw.devno);
  398. static void reipl_get_ascii_loadparm(char *loadparm)
  399. {
  400. memcpy(loadparm, &reipl_block_ccw->ipl_info.ccw.load_param,
  401. LOADPARM_LEN);
  402. EBCASC(loadparm, LOADPARM_LEN);
  403. loadparm[LOADPARM_LEN] = 0;
  404. strstrip(loadparm);
  405. }
  406. static ssize_t reipl_ccw_loadparm_show(struct kobject *kobj,
  407. struct kobj_attribute *attr, char *page)
  408. {
  409. char buf[LOADPARM_LEN + 1];
  410. reipl_get_ascii_loadparm(buf);
  411. return sprintf(page, "%s\n", buf);
  412. }
  413. static ssize_t reipl_ccw_loadparm_store(struct kobject *kobj,
  414. struct kobj_attribute *attr,
  415. const char *buf, size_t len)
  416. {
  417. int i, lp_len;
  418. /* ignore trailing newline */
  419. lp_len = len;
  420. if ((len > 0) && (buf[len - 1] == '\n'))
  421. lp_len--;
  422. /* loadparm can have max 8 characters and must not start with a blank */
  423. if ((lp_len > LOADPARM_LEN) || ((lp_len > 0) && (buf[0] == ' ')))
  424. return -EINVAL;
  425. /* loadparm can only contain "a-z,A-Z,0-9,SP,." */
  426. for (i = 0; i < lp_len; i++) {
  427. if (isalpha(buf[i]) || isdigit(buf[i]) || (buf[i] == ' ') ||
  428. (buf[i] == '.'))
  429. continue;
  430. return -EINVAL;
  431. }
  432. /* initialize loadparm with blanks */
  433. memset(&reipl_block_ccw->ipl_info.ccw.load_param, ' ', LOADPARM_LEN);
  434. /* copy and convert to ebcdic */
  435. memcpy(&reipl_block_ccw->ipl_info.ccw.load_param, buf, lp_len);
  436. ASCEBC(reipl_block_ccw->ipl_info.ccw.load_param, LOADPARM_LEN);
  437. return len;
  438. }
  439. static struct kobj_attribute sys_reipl_ccw_loadparm_attr =
  440. __ATTR(loadparm, 0644, reipl_ccw_loadparm_show,
  441. reipl_ccw_loadparm_store);
  442. static struct attribute *reipl_ccw_attrs[] = {
  443. &sys_reipl_ccw_device_attr.attr,
  444. &sys_reipl_ccw_loadparm_attr.attr,
  445. NULL,
  446. };
  447. static struct attribute_group reipl_ccw_attr_group = {
  448. .name = IPL_CCW_STR,
  449. .attrs = reipl_ccw_attrs,
  450. };
  451. /* NSS reipl device attributes */
  452. DEFINE_IPL_ATTR_STR_RW(reipl_nss, name, "%s\n", "%s\n", reipl_nss_name);
  453. static struct attribute *reipl_nss_attrs[] = {
  454. &sys_reipl_nss_name_attr.attr,
  455. NULL,
  456. };
  457. static struct attribute_group reipl_nss_attr_group = {
  458. .name = IPL_NSS_STR,
  459. .attrs = reipl_nss_attrs,
  460. };
  461. /* reipl type */
  462. static int reipl_set_type(enum ipl_type type)
  463. {
  464. if (!(reipl_capabilities & type))
  465. return -EINVAL;
  466. switch(type) {
  467. case IPL_TYPE_CCW:
  468. if (MACHINE_IS_VM)
  469. reipl_method = REIPL_METHOD_CCW_VM;
  470. else
  471. reipl_method = REIPL_METHOD_CCW_CIO;
  472. break;
  473. case IPL_TYPE_FCP:
  474. if (diag308_set_works)
  475. reipl_method = REIPL_METHOD_FCP_RW_DIAG;
  476. else if (MACHINE_IS_VM)
  477. reipl_method = REIPL_METHOD_FCP_RO_VM;
  478. else
  479. reipl_method = REIPL_METHOD_FCP_RO_DIAG;
  480. break;
  481. case IPL_TYPE_FCP_DUMP:
  482. reipl_method = REIPL_METHOD_FCP_DUMP;
  483. break;
  484. case IPL_TYPE_NSS:
  485. reipl_method = REIPL_METHOD_NSS;
  486. break;
  487. case IPL_TYPE_UNKNOWN:
  488. reipl_method = REIPL_METHOD_DEFAULT;
  489. break;
  490. default:
  491. BUG();
  492. }
  493. reipl_type = type;
  494. return 0;
  495. }
  496. static ssize_t reipl_type_show(struct kobject *kobj,
  497. struct kobj_attribute *attr, char *page)
  498. {
  499. return sprintf(page, "%s\n", ipl_type_str(reipl_type));
  500. }
  501. static ssize_t reipl_type_store(struct kobject *kobj,
  502. struct kobj_attribute *attr,
  503. const char *buf, size_t len)
  504. {
  505. int rc = -EINVAL;
  506. if (strncmp(buf, IPL_CCW_STR, strlen(IPL_CCW_STR)) == 0)
  507. rc = reipl_set_type(IPL_TYPE_CCW);
  508. else if (strncmp(buf, IPL_FCP_STR, strlen(IPL_FCP_STR)) == 0)
  509. rc = reipl_set_type(IPL_TYPE_FCP);
  510. else if (strncmp(buf, IPL_NSS_STR, strlen(IPL_NSS_STR)) == 0)
  511. rc = reipl_set_type(IPL_TYPE_NSS);
  512. return (rc != 0) ? rc : len;
  513. }
  514. static struct kobj_attribute reipl_type_attr =
  515. __ATTR(reipl_type, 0644, reipl_type_show, reipl_type_store);
  516. static struct kset *reipl_kset;
  517. /*
  518. * dump section
  519. */
  520. /* FCP dump device attributes */
  521. DEFINE_IPL_ATTR_RW(dump_fcp, wwpn, "0x%016llx\n", "%016llx\n",
  522. dump_block_fcp->ipl_info.fcp.wwpn);
  523. DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%016llx\n",
  524. dump_block_fcp->ipl_info.fcp.lun);
  525. DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n",
  526. dump_block_fcp->ipl_info.fcp.bootprog);
  527. DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n",
  528. dump_block_fcp->ipl_info.fcp.br_lba);
  529. DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n",
  530. dump_block_fcp->ipl_info.fcp.devno);
  531. static struct attribute *dump_fcp_attrs[] = {
  532. &sys_dump_fcp_device_attr.attr,
  533. &sys_dump_fcp_wwpn_attr.attr,
  534. &sys_dump_fcp_lun_attr.attr,
  535. &sys_dump_fcp_bootprog_attr.attr,
  536. &sys_dump_fcp_br_lba_attr.attr,
  537. NULL,
  538. };
  539. static struct attribute_group dump_fcp_attr_group = {
  540. .name = IPL_FCP_STR,
  541. .attrs = dump_fcp_attrs,
  542. };
  543. /* CCW dump device attributes */
  544. DEFINE_IPL_ATTR_RW(dump_ccw, device, "0.0.%04llx\n", "0.0.%llx\n",
  545. dump_block_ccw->ipl_info.ccw.devno);
  546. static struct attribute *dump_ccw_attrs[] = {
  547. &sys_dump_ccw_device_attr.attr,
  548. NULL,
  549. };
  550. static struct attribute_group dump_ccw_attr_group = {
  551. .name = IPL_CCW_STR,
  552. .attrs = dump_ccw_attrs,
  553. };
  554. /* dump type */
  555. static int dump_set_type(enum dump_type type)
  556. {
  557. if (!(dump_capabilities & type))
  558. return -EINVAL;
  559. switch(type) {
  560. case DUMP_TYPE_CCW:
  561. if (MACHINE_IS_VM)
  562. dump_method = DUMP_METHOD_CCW_VM;
  563. else if (diag308_set_works)
  564. dump_method = DUMP_METHOD_CCW_DIAG;
  565. else
  566. dump_method = DUMP_METHOD_CCW_CIO;
  567. break;
  568. case DUMP_TYPE_FCP:
  569. dump_method = DUMP_METHOD_FCP_DIAG;
  570. break;
  571. default:
  572. dump_method = DUMP_METHOD_NONE;
  573. }
  574. dump_type = type;
  575. return 0;
  576. }
  577. static ssize_t dump_type_show(struct kobject *kobj,
  578. struct kobj_attribute *attr, char *page)
  579. {
  580. return sprintf(page, "%s\n", dump_type_str(dump_type));
  581. }
  582. static ssize_t dump_type_store(struct kobject *kobj,
  583. struct kobj_attribute *attr,
  584. const char *buf, size_t len)
  585. {
  586. int rc = -EINVAL;
  587. if (strncmp(buf, DUMP_NONE_STR, strlen(DUMP_NONE_STR)) == 0)
  588. rc = dump_set_type(DUMP_TYPE_NONE);
  589. else if (strncmp(buf, DUMP_CCW_STR, strlen(DUMP_CCW_STR)) == 0)
  590. rc = dump_set_type(DUMP_TYPE_CCW);
  591. else if (strncmp(buf, DUMP_FCP_STR, strlen(DUMP_FCP_STR)) == 0)
  592. rc = dump_set_type(DUMP_TYPE_FCP);
  593. return (rc != 0) ? rc : len;
  594. }
  595. static struct kobj_attribute dump_type_attr =
  596. __ATTR(dump_type, 0644, dump_type_show, dump_type_store);
  597. static struct kset *dump_kset;
  598. /*
  599. * Shutdown actions section
  600. */
  601. static struct kset *shutdown_actions_kset;
  602. /* on panic */
  603. static ssize_t on_panic_show(struct kobject *kobj,
  604. struct kobj_attribute *attr, char *page)
  605. {
  606. return sprintf(page, "%s\n", shutdown_action_str(on_panic_action));
  607. }
  608. static ssize_t on_panic_store(struct kobject *kobj,
  609. struct kobj_attribute *attr,
  610. const char *buf, size_t len)
  611. {
  612. if (strncmp(buf, SHUTDOWN_REIPL_STR, strlen(SHUTDOWN_REIPL_STR)) == 0)
  613. on_panic_action = SHUTDOWN_REIPL;
  614. else if (strncmp(buf, SHUTDOWN_DUMP_STR,
  615. strlen(SHUTDOWN_DUMP_STR)) == 0)
  616. on_panic_action = SHUTDOWN_DUMP;
  617. else if (strncmp(buf, SHUTDOWN_STOP_STR,
  618. strlen(SHUTDOWN_STOP_STR)) == 0)
  619. on_panic_action = SHUTDOWN_STOP;
  620. else
  621. return -EINVAL;
  622. return len;
  623. }
  624. static struct kobj_attribute on_panic_attr =
  625. __ATTR(on_panic, 0644, on_panic_show, on_panic_store);
  626. void do_reipl(void)
  627. {
  628. struct ccw_dev_id devid;
  629. static char buf[100];
  630. char loadparm[LOADPARM_LEN + 1];
  631. switch (reipl_method) {
  632. case REIPL_METHOD_CCW_CIO:
  633. devid.devno = reipl_block_ccw->ipl_info.ccw.devno;
  634. if (ipl_info.type == IPL_TYPE_CCW && devid.devno == ipl_devno)
  635. diag308(DIAG308_IPL, NULL);
  636. devid.ssid = 0;
  637. reipl_ccw_dev(&devid);
  638. break;
  639. case REIPL_METHOD_CCW_VM:
  640. reipl_get_ascii_loadparm(loadparm);
  641. if (strlen(loadparm) == 0)
  642. sprintf(buf, "IPL %X CLEAR",
  643. reipl_block_ccw->ipl_info.ccw.devno);
  644. else
  645. sprintf(buf, "IPL %X CLEAR LOADPARM '%s'",
  646. reipl_block_ccw->ipl_info.ccw.devno, loadparm);
  647. __cpcmd(buf, NULL, 0, NULL);
  648. break;
  649. case REIPL_METHOD_CCW_DIAG:
  650. diag308(DIAG308_SET, reipl_block_ccw);
  651. diag308(DIAG308_IPL, NULL);
  652. break;
  653. case REIPL_METHOD_FCP_RW_DIAG:
  654. diag308(DIAG308_SET, reipl_block_fcp);
  655. diag308(DIAG308_IPL, NULL);
  656. break;
  657. case REIPL_METHOD_FCP_RO_DIAG:
  658. diag308(DIAG308_IPL, NULL);
  659. break;
  660. case REIPL_METHOD_FCP_RO_VM:
  661. __cpcmd("IPL", NULL, 0, NULL);
  662. break;
  663. case REIPL_METHOD_NSS:
  664. sprintf(buf, "IPL %s", reipl_nss_name);
  665. __cpcmd(buf, NULL, 0, NULL);
  666. break;
  667. case REIPL_METHOD_DEFAULT:
  668. if (MACHINE_IS_VM)
  669. __cpcmd("IPL", NULL, 0, NULL);
  670. diag308(DIAG308_IPL, NULL);
  671. break;
  672. case REIPL_METHOD_FCP_DUMP:
  673. default:
  674. break;
  675. }
  676. signal_processor(smp_processor_id(), sigp_stop_and_store_status);
  677. }
  678. static void do_dump(void)
  679. {
  680. struct ccw_dev_id devid;
  681. static char buf[100];
  682. switch (dump_method) {
  683. case DUMP_METHOD_CCW_CIO:
  684. smp_send_stop();
  685. devid.devno = dump_block_ccw->ipl_info.ccw.devno;
  686. devid.ssid = 0;
  687. reipl_ccw_dev(&devid);
  688. break;
  689. case DUMP_METHOD_CCW_VM:
  690. smp_send_stop();
  691. sprintf(buf, "STORE STATUS");
  692. __cpcmd(buf, NULL, 0, NULL);
  693. sprintf(buf, "IPL %X", dump_block_ccw->ipl_info.ccw.devno);
  694. __cpcmd(buf, NULL, 0, NULL);
  695. break;
  696. case DUMP_METHOD_CCW_DIAG:
  697. diag308(DIAG308_SET, dump_block_ccw);
  698. diag308(DIAG308_DUMP, NULL);
  699. break;
  700. case DUMP_METHOD_FCP_DIAG:
  701. diag308(DIAG308_SET, dump_block_fcp);
  702. diag308(DIAG308_DUMP, NULL);
  703. break;
  704. case DUMP_METHOD_NONE:
  705. default:
  706. return;
  707. }
  708. printk(KERN_EMERG "Dump failed!\n");
  709. }
  710. /* init functions */
  711. static int __init ipl_register_fcp_files(void)
  712. {
  713. int rc;
  714. rc = sysfs_create_group(&ipl_kset->kobj,
  715. &ipl_fcp_attr_group);
  716. if (rc)
  717. goto out;
  718. rc = sysfs_create_bin_file(&ipl_kset->kobj,
  719. &ipl_parameter_attr);
  720. if (rc)
  721. goto out_ipl_parm;
  722. rc = sysfs_create_bin_file(&ipl_kset->kobj,
  723. &ipl_scp_data_attr);
  724. if (!rc)
  725. goto out;
  726. sysfs_remove_bin_file(&ipl_kset->kobj, &ipl_parameter_attr);
  727. out_ipl_parm:
  728. sysfs_remove_group(&ipl_kset->kobj, &ipl_fcp_attr_group);
  729. out:
  730. return rc;
  731. }
  732. static int __init ipl_init(void)
  733. {
  734. int rc;
  735. ipl_kset = kset_create_and_add("ipl", NULL, firmware_kobj);
  736. if (!ipl_kset)
  737. return -ENOMEM;
  738. switch (ipl_info.type) {
  739. case IPL_TYPE_CCW:
  740. rc = sysfs_create_group(&ipl_kset->kobj,
  741. &ipl_ccw_attr_group);
  742. break;
  743. case IPL_TYPE_FCP:
  744. case IPL_TYPE_FCP_DUMP:
  745. rc = ipl_register_fcp_files();
  746. break;
  747. case IPL_TYPE_NSS:
  748. rc = sysfs_create_group(&ipl_kset->kobj,
  749. &ipl_nss_attr_group);
  750. break;
  751. default:
  752. rc = sysfs_create_group(&ipl_kset->kobj,
  753. &ipl_unknown_attr_group);
  754. break;
  755. }
  756. if (rc)
  757. kset_unregister(ipl_kset);
  758. return rc;
  759. }
  760. static void __init reipl_probe(void)
  761. {
  762. void *buffer;
  763. buffer = (void *) get_zeroed_page(GFP_KERNEL);
  764. if (!buffer)
  765. return;
  766. if (diag308(DIAG308_STORE, buffer) == DIAG308_RC_OK)
  767. diag308_set_works = 1;
  768. free_page((unsigned long)buffer);
  769. }
  770. static int __init reipl_nss_init(void)
  771. {
  772. int rc;
  773. if (!MACHINE_IS_VM)
  774. return 0;
  775. rc = sysfs_create_group(&reipl_kset->kobj, &reipl_nss_attr_group);
  776. if (rc)
  777. return rc;
  778. strncpy(reipl_nss_name, kernel_nss_name, NSS_NAME_SIZE + 1);
  779. reipl_capabilities |= IPL_TYPE_NSS;
  780. return 0;
  781. }
  782. static int __init reipl_ccw_init(void)
  783. {
  784. int rc;
  785. reipl_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
  786. if (!reipl_block_ccw)
  787. return -ENOMEM;
  788. rc = sysfs_create_group(&reipl_kset->kobj, &reipl_ccw_attr_group);
  789. if (rc) {
  790. free_page((unsigned long)reipl_block_ccw);
  791. return rc;
  792. }
  793. reipl_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN;
  794. reipl_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
  795. reipl_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN;
  796. reipl_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW;
  797. /* check if read scp info worked and set loadparm */
  798. if (sclp_ipl_info.is_valid)
  799. memcpy(reipl_block_ccw->ipl_info.ccw.load_param,
  800. &sclp_ipl_info.loadparm, LOADPARM_LEN);
  801. else
  802. /* read scp info failed: set empty loadparm (EBCDIC blanks) */
  803. memset(reipl_block_ccw->ipl_info.ccw.load_param, 0x40,
  804. LOADPARM_LEN);
  805. /* FIXME: check for diag308_set_works when enabling diag ccw reipl */
  806. if (!MACHINE_IS_VM)
  807. sys_reipl_ccw_loadparm_attr.attr.mode = S_IRUGO;
  808. if (ipl_info.type == IPL_TYPE_CCW)
  809. reipl_block_ccw->ipl_info.ccw.devno = ipl_devno;
  810. reipl_capabilities |= IPL_TYPE_CCW;
  811. return 0;
  812. }
  813. static int __init reipl_fcp_init(void)
  814. {
  815. int rc;
  816. if ((!diag308_set_works) && (ipl_info.type != IPL_TYPE_FCP))
  817. return 0;
  818. if ((!diag308_set_works) && (ipl_info.type == IPL_TYPE_FCP))
  819. make_attrs_ro(reipl_fcp_attrs);
  820. reipl_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
  821. if (!reipl_block_fcp)
  822. return -ENOMEM;
  823. rc = sysfs_create_group(&reipl_kset->kobj, &reipl_fcp_attr_group);
  824. if (rc) {
  825. free_page((unsigned long)reipl_block_fcp);
  826. return rc;
  827. }
  828. if (ipl_info.type == IPL_TYPE_FCP) {
  829. memcpy(reipl_block_fcp, IPL_PARMBLOCK_START, PAGE_SIZE);
  830. } else {
  831. reipl_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
  832. reipl_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
  833. reipl_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN;
  834. reipl_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
  835. reipl_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_IPL;
  836. }
  837. reipl_capabilities |= IPL_TYPE_FCP;
  838. return 0;
  839. }
  840. static int __init reipl_init(void)
  841. {
  842. int rc;
  843. reipl_kset = kset_create_and_add("reipl", NULL, firmware_kobj);
  844. if (!reipl_kset)
  845. return -ENOMEM;
  846. rc = sysfs_create_file(&reipl_kset->kobj, &reipl_type_attr.attr);
  847. if (rc) {
  848. kset_unregister(reipl_kset);
  849. return rc;
  850. }
  851. rc = reipl_ccw_init();
  852. if (rc)
  853. return rc;
  854. rc = reipl_fcp_init();
  855. if (rc)
  856. return rc;
  857. rc = reipl_nss_init();
  858. if (rc)
  859. return rc;
  860. rc = reipl_set_type(ipl_info.type);
  861. if (rc)
  862. return rc;
  863. return 0;
  864. }
  865. static int __init dump_ccw_init(void)
  866. {
  867. int rc;
  868. dump_block_ccw = (void *) get_zeroed_page(GFP_KERNEL);
  869. if (!dump_block_ccw)
  870. return -ENOMEM;
  871. rc = sysfs_create_group(&dump_kset->kobj, &dump_ccw_attr_group);
  872. if (rc) {
  873. free_page((unsigned long)dump_block_ccw);
  874. return rc;
  875. }
  876. dump_block_ccw->hdr.len = IPL_PARM_BLK_CCW_LEN;
  877. dump_block_ccw->hdr.version = IPL_PARM_BLOCK_VERSION;
  878. dump_block_ccw->hdr.blk0_len = IPL_PARM_BLK0_CCW_LEN;
  879. dump_block_ccw->hdr.pbt = DIAG308_IPL_TYPE_CCW;
  880. dump_capabilities |= DUMP_TYPE_CCW;
  881. return 0;
  882. }
  883. static int __init dump_fcp_init(void)
  884. {
  885. int rc;
  886. if (!sclp_ipl_info.has_dump)
  887. return 0; /* LDIPL DUMP is not installed */
  888. if (!diag308_set_works)
  889. return 0;
  890. dump_block_fcp = (void *) get_zeroed_page(GFP_KERNEL);
  891. if (!dump_block_fcp)
  892. return -ENOMEM;
  893. rc = sysfs_create_group(&dump_kset->kobj, &dump_fcp_attr_group);
  894. if (rc) {
  895. free_page((unsigned long)dump_block_fcp);
  896. return rc;
  897. }
  898. dump_block_fcp->hdr.len = IPL_PARM_BLK_FCP_LEN;
  899. dump_block_fcp->hdr.version = IPL_PARM_BLOCK_VERSION;
  900. dump_block_fcp->hdr.blk0_len = IPL_PARM_BLK0_FCP_LEN;
  901. dump_block_fcp->hdr.pbt = DIAG308_IPL_TYPE_FCP;
  902. dump_block_fcp->ipl_info.fcp.opt = DIAG308_IPL_OPT_DUMP;
  903. dump_capabilities |= DUMP_TYPE_FCP;
  904. return 0;
  905. }
  906. #define SHUTDOWN_ON_PANIC_PRIO 0
  907. static int shutdown_on_panic_notify(struct notifier_block *self,
  908. unsigned long event, void *data)
  909. {
  910. if (on_panic_action == SHUTDOWN_DUMP)
  911. do_dump();
  912. else if (on_panic_action == SHUTDOWN_REIPL)
  913. do_reipl();
  914. return NOTIFY_OK;
  915. }
  916. static struct notifier_block shutdown_on_panic_nb = {
  917. .notifier_call = shutdown_on_panic_notify,
  918. .priority = SHUTDOWN_ON_PANIC_PRIO
  919. };
  920. static int __init dump_init(void)
  921. {
  922. int rc;
  923. dump_kset = kset_create_and_add("dump", NULL, firmware_kobj);
  924. if (!dump_kset)
  925. return -ENOMEM;
  926. rc = sysfs_create_file(&dump_kset->kobj, &dump_type_attr);
  927. if (rc) {
  928. kset_unregister(dump_kset);
  929. return rc;
  930. }
  931. rc = dump_ccw_init();
  932. if (rc)
  933. return rc;
  934. rc = dump_fcp_init();
  935. if (rc)
  936. return rc;
  937. dump_set_type(DUMP_TYPE_NONE);
  938. return 0;
  939. }
  940. static int __init shutdown_actions_init(void)
  941. {
  942. int rc;
  943. shutdown_actions_kset = kset_create_and_add("shutdown_actions", NULL,
  944. firmware_kobj);
  945. if (!shutdown_actions_kset)
  946. return -ENOMEM;
  947. rc = sysfs_create_file(&shutdown_actions_kset->kobj, &on_panic_attr);
  948. if (rc) {
  949. kset_unregister(shutdown_actions_kset);
  950. return rc;
  951. }
  952. atomic_notifier_chain_register(&panic_notifier_list,
  953. &shutdown_on_panic_nb);
  954. return 0;
  955. }
  956. static int __init s390_ipl_init(void)
  957. {
  958. int rc;
  959. sclp_get_ipl_info(&sclp_ipl_info);
  960. reipl_probe();
  961. rc = ipl_init();
  962. if (rc)
  963. return rc;
  964. rc = reipl_init();
  965. if (rc)
  966. return rc;
  967. rc = dump_init();
  968. if (rc)
  969. return rc;
  970. rc = shutdown_actions_init();
  971. if (rc)
  972. return rc;
  973. return 0;
  974. }
  975. __initcall(s390_ipl_init);
  976. void __init ipl_save_parameters(void)
  977. {
  978. struct cio_iplinfo iplinfo;
  979. unsigned int *ipl_ptr;
  980. void *src, *dst;
  981. if (cio_get_iplinfo(&iplinfo))
  982. return;
  983. ipl_devno = iplinfo.devno;
  984. ipl_flags |= IPL_DEVNO_VALID;
  985. if (!iplinfo.is_qdio)
  986. return;
  987. ipl_flags |= IPL_PARMBLOCK_VALID;
  988. ipl_ptr = (unsigned int *)__LC_IPL_PARMBLOCK_PTR;
  989. src = (void *)(unsigned long)*ipl_ptr;
  990. dst = (void *)IPL_PARMBLOCK_ORIGIN;
  991. memmove(dst, src, PAGE_SIZE);
  992. *ipl_ptr = IPL_PARMBLOCK_ORIGIN;
  993. }
  994. static LIST_HEAD(rcall);
  995. static DEFINE_MUTEX(rcall_mutex);
  996. void register_reset_call(struct reset_call *reset)
  997. {
  998. mutex_lock(&rcall_mutex);
  999. list_add(&reset->list, &rcall);
  1000. mutex_unlock(&rcall_mutex);
  1001. }
  1002. EXPORT_SYMBOL_GPL(register_reset_call);
  1003. void unregister_reset_call(struct reset_call *reset)
  1004. {
  1005. mutex_lock(&rcall_mutex);
  1006. list_del(&reset->list);
  1007. mutex_unlock(&rcall_mutex);
  1008. }
  1009. EXPORT_SYMBOL_GPL(unregister_reset_call);
  1010. static void do_reset_calls(void)
  1011. {
  1012. struct reset_call *reset;
  1013. list_for_each_entry(reset, &rcall, list)
  1014. reset->fn();
  1015. }
  1016. u32 dump_prefix_page;
  1017. void s390_reset_system(void)
  1018. {
  1019. struct _lowcore *lc;
  1020. lc = (struct _lowcore *)(unsigned long) store_prefix();
  1021. /* Stack for interrupt/machine check handler */
  1022. lc->panic_stack = S390_lowcore.panic_stack;
  1023. /* Save prefix page address for dump case */
  1024. dump_prefix_page = (u32)(unsigned long) lc;
  1025. /* Disable prefixing */
  1026. set_prefix(0);
  1027. /* Disable lowcore protection */
  1028. __ctl_clear_bit(0,28);
  1029. /* Set new machine check handler */
  1030. S390_lowcore.mcck_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
  1031. S390_lowcore.mcck_new_psw.addr =
  1032. PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler;
  1033. /* Set new program check handler */
  1034. S390_lowcore.program_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
  1035. S390_lowcore.program_new_psw.addr =
  1036. PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler;
  1037. do_reset_calls();
  1038. }