ipl.c 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203
  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 decl_subsys(ipl, NULL);
  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 decl_subsys(reipl, NULL);
  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 decl_subsys(dump, NULL);
  598. /*
  599. * Shutdown actions section
  600. */
  601. static decl_subsys(shutdown_actions, NULL);
  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_subsys.kobj,
  715. &ipl_fcp_attr_group);
  716. if (rc)
  717. goto out;
  718. rc = sysfs_create_bin_file(&ipl_subsys.kobj,
  719. &ipl_parameter_attr);
  720. if (rc)
  721. goto out_ipl_parm;
  722. rc = sysfs_create_bin_file(&ipl_subsys.kobj,
  723. &ipl_scp_data_attr);
  724. if (!rc)
  725. goto out;
  726. sysfs_remove_bin_file(&ipl_subsys.kobj, &ipl_parameter_attr);
  727. out_ipl_parm:
  728. sysfs_remove_group(&ipl_subsys.kobj, &ipl_fcp_attr_group);
  729. out:
  730. return rc;
  731. }
  732. static int __init ipl_init(void)
  733. {
  734. int rc;
  735. rc = firmware_register(&ipl_subsys);
  736. if (rc)
  737. return rc;
  738. switch (ipl_info.type) {
  739. case IPL_TYPE_CCW:
  740. rc = sysfs_create_group(&ipl_subsys.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_subsys.kobj,
  749. &ipl_nss_attr_group);
  750. break;
  751. default:
  752. rc = sysfs_create_group(&ipl_subsys.kobj,
  753. &ipl_unknown_attr_group);
  754. break;
  755. }
  756. if (rc)
  757. firmware_unregister(&ipl_subsys);
  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_subsys.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_subsys.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_subsys.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. rc = firmware_register(&reipl_subsys);
  844. if (rc)
  845. return rc;
  846. rc = sysfs_create_file(&reipl_subsys.kobj, &reipl_type_attr.attr);
  847. if (rc) {
  848. firmware_unregister(&reipl_subsys);
  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_subsys.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_subsys.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. rc = firmware_register(&dump_subsys);
  924. if (rc)
  925. return rc;
  926. rc = sysfs_create_file(&dump_subsys.kobj, &dump_type_attr.attr);
  927. if (rc) {
  928. firmware_unregister(&dump_subsys);
  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. rc = firmware_register(&shutdown_actions_subsys);
  944. if (rc)
  945. return rc;
  946. rc = sysfs_create_file(&shutdown_actions_subsys.kobj, &on_panic_attr.attr);
  947. if (rc) {
  948. firmware_unregister(&shutdown_actions_subsys);
  949. return rc;
  950. }
  951. atomic_notifier_chain_register(&panic_notifier_list,
  952. &shutdown_on_panic_nb);
  953. return 0;
  954. }
  955. static int __init s390_ipl_init(void)
  956. {
  957. int rc;
  958. sclp_get_ipl_info(&sclp_ipl_info);
  959. reipl_probe();
  960. rc = ipl_init();
  961. if (rc)
  962. return rc;
  963. rc = reipl_init();
  964. if (rc)
  965. return rc;
  966. rc = dump_init();
  967. if (rc)
  968. return rc;
  969. rc = shutdown_actions_init();
  970. if (rc)
  971. return rc;
  972. return 0;
  973. }
  974. __initcall(s390_ipl_init);
  975. void __init ipl_save_parameters(void)
  976. {
  977. struct cio_iplinfo iplinfo;
  978. unsigned int *ipl_ptr;
  979. void *src, *dst;
  980. if (cio_get_iplinfo(&iplinfo))
  981. return;
  982. ipl_devno = iplinfo.devno;
  983. ipl_flags |= IPL_DEVNO_VALID;
  984. if (!iplinfo.is_qdio)
  985. return;
  986. ipl_flags |= IPL_PARMBLOCK_VALID;
  987. ipl_ptr = (unsigned int *)__LC_IPL_PARMBLOCK_PTR;
  988. src = (void *)(unsigned long)*ipl_ptr;
  989. dst = (void *)IPL_PARMBLOCK_ORIGIN;
  990. memmove(dst, src, PAGE_SIZE);
  991. *ipl_ptr = IPL_PARMBLOCK_ORIGIN;
  992. }
  993. static LIST_HEAD(rcall);
  994. static DEFINE_MUTEX(rcall_mutex);
  995. void register_reset_call(struct reset_call *reset)
  996. {
  997. mutex_lock(&rcall_mutex);
  998. list_add(&reset->list, &rcall);
  999. mutex_unlock(&rcall_mutex);
  1000. }
  1001. EXPORT_SYMBOL_GPL(register_reset_call);
  1002. void unregister_reset_call(struct reset_call *reset)
  1003. {
  1004. mutex_lock(&rcall_mutex);
  1005. list_del(&reset->list);
  1006. mutex_unlock(&rcall_mutex);
  1007. }
  1008. EXPORT_SYMBOL_GPL(unregister_reset_call);
  1009. static void do_reset_calls(void)
  1010. {
  1011. struct reset_call *reset;
  1012. list_for_each_entry(reset, &rcall, list)
  1013. reset->fn();
  1014. }
  1015. u32 dump_prefix_page;
  1016. void s390_reset_system(void)
  1017. {
  1018. struct _lowcore *lc;
  1019. lc = (struct _lowcore *)(unsigned long) store_prefix();
  1020. /* Stack for interrupt/machine check handler */
  1021. lc->panic_stack = S390_lowcore.panic_stack;
  1022. /* Save prefix page address for dump case */
  1023. dump_prefix_page = (u32)(unsigned long) lc;
  1024. /* Disable prefixing */
  1025. set_prefix(0);
  1026. /* Disable lowcore protection */
  1027. __ctl_clear_bit(0,28);
  1028. /* Set new machine check handler */
  1029. S390_lowcore.mcck_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
  1030. S390_lowcore.mcck_new_psw.addr =
  1031. PSW_ADDR_AMODE | (unsigned long) s390_base_mcck_handler;
  1032. /* Set new program check handler */
  1033. S390_lowcore.program_new_psw.mask = psw_kernel_bits & ~PSW_MASK_MCHECK;
  1034. S390_lowcore.program_new_psw.addr =
  1035. PSW_ADDR_AMODE | (unsigned long) s390_base_pgm_handler;
  1036. do_reset_calls();
  1037. }