zcore.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. /*
  2. * zcore module to export memory content and register sets for creating system
  3. * dumps on SCSI disks (zfcpdump). The "zcore/mem" debugfs file shows the same
  4. * dump format as s390 standalone dumps.
  5. *
  6. * For more information please refer to Documentation/s390/zfcpdump.txt
  7. *
  8. * Copyright IBM Corp. 2003,2008
  9. * Author(s): Michael Holzheu
  10. */
  11. #define KMSG_COMPONENT "zdump"
  12. #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
  13. #include <linux/init.h>
  14. #include <linux/slab.h>
  15. #include <linux/miscdevice.h>
  16. #include <linux/debugfs.h>
  17. #include <linux/module.h>
  18. #include <asm/asm-offsets.h>
  19. #include <asm/ipl.h>
  20. #include <asm/sclp.h>
  21. #include <asm/setup.h>
  22. #include <asm/sigp.h>
  23. #include <asm/uaccess.h>
  24. #include <asm/debug.h>
  25. #include <asm/processor.h>
  26. #include <asm/irqflags.h>
  27. #include <asm/checksum.h>
  28. #include "sclp.h"
  29. #define TRACE(x...) debug_sprintf_event(zcore_dbf, 1, x)
  30. #define TO_USER 0
  31. #define TO_KERNEL 1
  32. #define CHUNK_INFO_SIZE 34 /* 2 16-byte char, each followed by blank */
  33. enum arch_id {
  34. ARCH_S390 = 0,
  35. ARCH_S390X = 1,
  36. };
  37. /* dump system info */
  38. struct sys_info {
  39. enum arch_id arch;
  40. unsigned long sa_base;
  41. u32 sa_size;
  42. int cpu_map[NR_CPUS];
  43. unsigned long mem_size;
  44. struct save_area lc_mask;
  45. };
  46. struct ipib_info {
  47. unsigned long ipib;
  48. u32 checksum;
  49. } __attribute__((packed));
  50. static struct sys_info sys_info;
  51. static struct debug_info *zcore_dbf;
  52. static int hsa_available;
  53. static struct dentry *zcore_dir;
  54. static struct dentry *zcore_file;
  55. static struct dentry *zcore_memmap_file;
  56. static struct dentry *zcore_reipl_file;
  57. static struct ipl_parameter_block *ipl_block;
  58. /*
  59. * Copy memory from HSA to kernel or user memory (not reentrant):
  60. *
  61. * @dest: Kernel or user buffer where memory should be copied to
  62. * @src: Start address within HSA where data should be copied
  63. * @count: Size of buffer, which should be copied
  64. * @mode: Either TO_KERNEL or TO_USER
  65. */
  66. static int memcpy_hsa(void *dest, unsigned long src, size_t count, int mode)
  67. {
  68. int offs, blk_num;
  69. static char buf[PAGE_SIZE] __attribute__((__aligned__(PAGE_SIZE)));
  70. if (count == 0)
  71. return 0;
  72. /* copy first block */
  73. offs = 0;
  74. if ((src % PAGE_SIZE) != 0) {
  75. blk_num = src / PAGE_SIZE + 2;
  76. if (sclp_sdias_copy(buf, blk_num, 1)) {
  77. TRACE("sclp_sdias_copy() failed\n");
  78. return -EIO;
  79. }
  80. offs = min((PAGE_SIZE - (src % PAGE_SIZE)), count);
  81. if (mode == TO_USER) {
  82. if (copy_to_user((__force __user void*) dest,
  83. buf + (src % PAGE_SIZE), offs))
  84. return -EFAULT;
  85. } else
  86. memcpy(dest, buf + (src % PAGE_SIZE), offs);
  87. }
  88. if (offs == count)
  89. goto out;
  90. /* copy middle */
  91. for (; (offs + PAGE_SIZE) <= count; offs += PAGE_SIZE) {
  92. blk_num = (src + offs) / PAGE_SIZE + 2;
  93. if (sclp_sdias_copy(buf, blk_num, 1)) {
  94. TRACE("sclp_sdias_copy() failed\n");
  95. return -EIO;
  96. }
  97. if (mode == TO_USER) {
  98. if (copy_to_user((__force __user void*) dest + offs,
  99. buf, PAGE_SIZE))
  100. return -EFAULT;
  101. } else
  102. memcpy(dest + offs, buf, PAGE_SIZE);
  103. }
  104. if (offs == count)
  105. goto out;
  106. /* copy last block */
  107. blk_num = (src + offs) / PAGE_SIZE + 2;
  108. if (sclp_sdias_copy(buf, blk_num, 1)) {
  109. TRACE("sclp_sdias_copy() failed\n");
  110. return -EIO;
  111. }
  112. if (mode == TO_USER) {
  113. if (copy_to_user((__force __user void*) dest + offs, buf,
  114. PAGE_SIZE))
  115. return -EFAULT;
  116. } else
  117. memcpy(dest + offs, buf, count - offs);
  118. out:
  119. return 0;
  120. }
  121. static int memcpy_hsa_user(void __user *dest, unsigned long src, size_t count)
  122. {
  123. return memcpy_hsa((void __force *) dest, src, count, TO_USER);
  124. }
  125. static int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count)
  126. {
  127. return memcpy_hsa(dest, src, count, TO_KERNEL);
  128. }
  129. static int __init init_cpu_info(enum arch_id arch)
  130. {
  131. struct save_area *sa;
  132. /* get info for boot cpu from lowcore, stored in the HSA */
  133. sa = kmalloc(sizeof(*sa), GFP_KERNEL);
  134. if (!sa)
  135. return -ENOMEM;
  136. if (memcpy_hsa_kernel(sa, sys_info.sa_base, sys_info.sa_size) < 0) {
  137. TRACE("could not copy from HSA\n");
  138. kfree(sa);
  139. return -EIO;
  140. }
  141. zfcpdump_save_areas[0] = sa;
  142. return 0;
  143. }
  144. static DEFINE_MUTEX(zcore_mutex);
  145. #define DUMP_VERSION 0x5
  146. #define DUMP_MAGIC 0xa8190173618f23fdULL
  147. #define DUMP_ARCH_S390X 2
  148. #define DUMP_ARCH_S390 1
  149. #define HEADER_SIZE 4096
  150. /* dump header dumped according to s390 crash dump format */
  151. struct zcore_header {
  152. u64 magic;
  153. u32 version;
  154. u32 header_size;
  155. u32 dump_level;
  156. u32 page_size;
  157. u64 mem_size;
  158. u64 mem_start;
  159. u64 mem_end;
  160. u32 num_pages;
  161. u32 pad1;
  162. u64 tod;
  163. struct cpuid cpu_id;
  164. u32 arch_id;
  165. u32 volnr;
  166. u32 build_arch;
  167. u64 rmem_size;
  168. u8 mvdump;
  169. u16 cpu_cnt;
  170. u16 real_cpu_cnt;
  171. u8 end_pad1[0x200-0x061];
  172. u64 mvdump_sign;
  173. u64 mvdump_zipl_time;
  174. u8 end_pad2[0x800-0x210];
  175. u32 lc_vec[512];
  176. } __attribute__((packed,__aligned__(16)));
  177. static struct zcore_header zcore_header = {
  178. .magic = DUMP_MAGIC,
  179. .version = DUMP_VERSION,
  180. .header_size = 4096,
  181. .dump_level = 0,
  182. .page_size = PAGE_SIZE,
  183. .mem_start = 0,
  184. #ifdef CONFIG_64BIT
  185. .build_arch = DUMP_ARCH_S390X,
  186. #else
  187. .build_arch = DUMP_ARCH_S390,
  188. #endif
  189. };
  190. /*
  191. * Copy lowcore info to buffer. Use map in order to copy only register parts.
  192. *
  193. * @buf: User buffer
  194. * @sa: Pointer to save area
  195. * @sa_off: Offset in save area to copy
  196. * @len: Number of bytes to copy
  197. */
  198. static int copy_lc(void __user *buf, void *sa, int sa_off, int len)
  199. {
  200. int i;
  201. char *lc_mask = (char*)&sys_info.lc_mask;
  202. for (i = 0; i < len; i++) {
  203. if (!lc_mask[i + sa_off])
  204. continue;
  205. if (copy_to_user(buf + i, sa + sa_off + i, 1))
  206. return -EFAULT;
  207. }
  208. return 0;
  209. }
  210. /*
  211. * Copy lowcores info to memory, if necessary
  212. *
  213. * @buf: User buffer
  214. * @addr: Start address of buffer in dump memory
  215. * @count: Size of buffer
  216. */
  217. static int zcore_add_lc(char __user *buf, unsigned long start, size_t count)
  218. {
  219. unsigned long end;
  220. int i = 0;
  221. if (count == 0)
  222. return 0;
  223. end = start + count;
  224. while (zfcpdump_save_areas[i]) {
  225. unsigned long cp_start, cp_end; /* copy range */
  226. unsigned long sa_start, sa_end; /* save area range */
  227. unsigned long prefix;
  228. unsigned long sa_off, len, buf_off;
  229. prefix = zfcpdump_save_areas[i]->pref_reg;
  230. sa_start = prefix + sys_info.sa_base;
  231. sa_end = prefix + sys_info.sa_base + sys_info.sa_size;
  232. if ((end < sa_start) || (start > sa_end))
  233. goto next;
  234. cp_start = max(start, sa_start);
  235. cp_end = min(end, sa_end);
  236. buf_off = cp_start - start;
  237. sa_off = cp_start - sa_start;
  238. len = cp_end - cp_start;
  239. TRACE("copy_lc for: %lx\n", start);
  240. if (copy_lc(buf + buf_off, zfcpdump_save_areas[i], sa_off, len))
  241. return -EFAULT;
  242. next:
  243. i++;
  244. }
  245. return 0;
  246. }
  247. /*
  248. * Read routine for zcore character device
  249. * First 4K are dump header
  250. * Next 32MB are HSA Memory
  251. * Rest is read from absolute Memory
  252. */
  253. static ssize_t zcore_read(struct file *file, char __user *buf, size_t count,
  254. loff_t *ppos)
  255. {
  256. unsigned long mem_start; /* Start address in memory */
  257. size_t mem_offs; /* Offset in dump memory */
  258. size_t hdr_count; /* Size of header part of output buffer */
  259. size_t size;
  260. int rc;
  261. mutex_lock(&zcore_mutex);
  262. if (*ppos > (sys_info.mem_size + HEADER_SIZE)) {
  263. rc = -EINVAL;
  264. goto fail;
  265. }
  266. count = min(count, (size_t) (sys_info.mem_size + HEADER_SIZE - *ppos));
  267. /* Copy dump header */
  268. if (*ppos < HEADER_SIZE) {
  269. size = min(count, (size_t) (HEADER_SIZE - *ppos));
  270. if (copy_to_user(buf, &zcore_header + *ppos, size)) {
  271. rc = -EFAULT;
  272. goto fail;
  273. }
  274. hdr_count = size;
  275. mem_start = 0;
  276. } else {
  277. hdr_count = 0;
  278. mem_start = *ppos - HEADER_SIZE;
  279. }
  280. mem_offs = 0;
  281. /* Copy from HSA data */
  282. if (*ppos < (ZFCPDUMP_HSA_SIZE + HEADER_SIZE)) {
  283. size = min((count - hdr_count), (size_t) (ZFCPDUMP_HSA_SIZE
  284. - mem_start));
  285. rc = memcpy_hsa_user(buf + hdr_count, mem_start, size);
  286. if (rc)
  287. goto fail;
  288. mem_offs += size;
  289. }
  290. /* Copy from real mem */
  291. size = count - mem_offs - hdr_count;
  292. rc = copy_to_user_real(buf + hdr_count + mem_offs,
  293. (void *) mem_start + mem_offs, size);
  294. if (rc)
  295. goto fail;
  296. /*
  297. * Since s390 dump analysis tools like lcrash or crash
  298. * expect register sets in the prefix pages of the cpus,
  299. * we copy them into the read buffer, if necessary.
  300. * buf + hdr_count: Start of memory part of output buffer
  301. * mem_start: Start memory address to copy from
  302. * count - hdr_count: Size of memory area to copy
  303. */
  304. if (zcore_add_lc(buf + hdr_count, mem_start, count - hdr_count)) {
  305. rc = -EFAULT;
  306. goto fail;
  307. }
  308. *ppos += count;
  309. fail:
  310. mutex_unlock(&zcore_mutex);
  311. return (rc < 0) ? rc : count;
  312. }
  313. static int zcore_open(struct inode *inode, struct file *filp)
  314. {
  315. if (!hsa_available)
  316. return -ENODATA;
  317. else
  318. return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
  319. }
  320. static int zcore_release(struct inode *inode, struct file *filep)
  321. {
  322. diag308(DIAG308_REL_HSA, NULL);
  323. hsa_available = 0;
  324. return 0;
  325. }
  326. static loff_t zcore_lseek(struct file *file, loff_t offset, int orig)
  327. {
  328. loff_t rc;
  329. mutex_lock(&zcore_mutex);
  330. switch (orig) {
  331. case 0:
  332. file->f_pos = offset;
  333. rc = file->f_pos;
  334. break;
  335. case 1:
  336. file->f_pos += offset;
  337. rc = file->f_pos;
  338. break;
  339. default:
  340. rc = -EINVAL;
  341. }
  342. mutex_unlock(&zcore_mutex);
  343. return rc;
  344. }
  345. static const struct file_operations zcore_fops = {
  346. .owner = THIS_MODULE,
  347. .llseek = zcore_lseek,
  348. .read = zcore_read,
  349. .open = zcore_open,
  350. .release = zcore_release,
  351. };
  352. static ssize_t zcore_memmap_read(struct file *filp, char __user *buf,
  353. size_t count, loff_t *ppos)
  354. {
  355. return simple_read_from_buffer(buf, count, ppos, filp->private_data,
  356. MEMORY_CHUNKS * CHUNK_INFO_SIZE);
  357. }
  358. static int zcore_memmap_open(struct inode *inode, struct file *filp)
  359. {
  360. int i;
  361. char *buf;
  362. struct mem_chunk *chunk_array;
  363. chunk_array = kzalloc(MEMORY_CHUNKS * sizeof(struct mem_chunk),
  364. GFP_KERNEL);
  365. if (!chunk_array)
  366. return -ENOMEM;
  367. detect_memory_layout(chunk_array);
  368. buf = kzalloc(MEMORY_CHUNKS * CHUNK_INFO_SIZE, GFP_KERNEL);
  369. if (!buf) {
  370. kfree(chunk_array);
  371. return -ENOMEM;
  372. }
  373. for (i = 0; i < MEMORY_CHUNKS; i++) {
  374. sprintf(buf + (i * CHUNK_INFO_SIZE), "%016llx %016llx ",
  375. (unsigned long long) chunk_array[i].addr,
  376. (unsigned long long) chunk_array[i].size);
  377. if (chunk_array[i].size == 0)
  378. break;
  379. }
  380. kfree(chunk_array);
  381. filp->private_data = buf;
  382. return nonseekable_open(inode, filp);
  383. }
  384. static int zcore_memmap_release(struct inode *inode, struct file *filp)
  385. {
  386. kfree(filp->private_data);
  387. return 0;
  388. }
  389. static const struct file_operations zcore_memmap_fops = {
  390. .owner = THIS_MODULE,
  391. .read = zcore_memmap_read,
  392. .open = zcore_memmap_open,
  393. .release = zcore_memmap_release,
  394. .llseek = no_llseek,
  395. };
  396. static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf,
  397. size_t count, loff_t *ppos)
  398. {
  399. if (ipl_block) {
  400. diag308(DIAG308_SET, ipl_block);
  401. diag308(DIAG308_IPL, NULL);
  402. }
  403. return count;
  404. }
  405. static int zcore_reipl_open(struct inode *inode, struct file *filp)
  406. {
  407. return nonseekable_open(inode, filp);
  408. }
  409. static int zcore_reipl_release(struct inode *inode, struct file *filp)
  410. {
  411. return 0;
  412. }
  413. static const struct file_operations zcore_reipl_fops = {
  414. .owner = THIS_MODULE,
  415. .write = zcore_reipl_write,
  416. .open = zcore_reipl_open,
  417. .release = zcore_reipl_release,
  418. .llseek = no_llseek,
  419. };
  420. #ifdef CONFIG_32BIT
  421. static void __init set_lc_mask(struct save_area *map)
  422. {
  423. memset(&map->ext_save, 0xff, sizeof(map->ext_save));
  424. memset(&map->timer, 0xff, sizeof(map->timer));
  425. memset(&map->clk_cmp, 0xff, sizeof(map->clk_cmp));
  426. memset(&map->psw, 0xff, sizeof(map->psw));
  427. memset(&map->pref_reg, 0xff, sizeof(map->pref_reg));
  428. memset(&map->acc_regs, 0xff, sizeof(map->acc_regs));
  429. memset(&map->fp_regs, 0xff, sizeof(map->fp_regs));
  430. memset(&map->gp_regs, 0xff, sizeof(map->gp_regs));
  431. memset(&map->ctrl_regs, 0xff, sizeof(map->ctrl_regs));
  432. }
  433. #else /* CONFIG_32BIT */
  434. static void __init set_lc_mask(struct save_area *map)
  435. {
  436. memset(&map->fp_regs, 0xff, sizeof(map->fp_regs));
  437. memset(&map->gp_regs, 0xff, sizeof(map->gp_regs));
  438. memset(&map->psw, 0xff, sizeof(map->psw));
  439. memset(&map->pref_reg, 0xff, sizeof(map->pref_reg));
  440. memset(&map->fp_ctrl_reg, 0xff, sizeof(map->fp_ctrl_reg));
  441. memset(&map->tod_reg, 0xff, sizeof(map->tod_reg));
  442. memset(&map->timer, 0xff, sizeof(map->timer));
  443. memset(&map->clk_cmp, 0xff, sizeof(map->clk_cmp));
  444. memset(&map->acc_regs, 0xff, sizeof(map->acc_regs));
  445. memset(&map->ctrl_regs, 0xff, sizeof(map->ctrl_regs));
  446. }
  447. #endif /* CONFIG_32BIT */
  448. /*
  449. * Initialize dump globals for a given architecture
  450. */
  451. static int __init sys_info_init(enum arch_id arch)
  452. {
  453. int rc;
  454. switch (arch) {
  455. case ARCH_S390X:
  456. pr_alert("DETECTED 'S390X (64 bit) OS'\n");
  457. break;
  458. case ARCH_S390:
  459. pr_alert("DETECTED 'S390 (32 bit) OS'\n");
  460. break;
  461. default:
  462. pr_alert("0x%x is an unknown architecture.\n",arch);
  463. return -EINVAL;
  464. }
  465. sys_info.sa_base = SAVE_AREA_BASE;
  466. sys_info.sa_size = sizeof(struct save_area);
  467. sys_info.arch = arch;
  468. set_lc_mask(&sys_info.lc_mask);
  469. rc = init_cpu_info(arch);
  470. if (rc)
  471. return rc;
  472. sys_info.mem_size = real_memory_size;
  473. return 0;
  474. }
  475. static int __init check_sdias(void)
  476. {
  477. int rc, act_hsa_size;
  478. rc = sclp_sdias_blk_count();
  479. if (rc < 0) {
  480. TRACE("Could not determine HSA size\n");
  481. return rc;
  482. }
  483. act_hsa_size = (rc - 1) * PAGE_SIZE;
  484. if (act_hsa_size < ZFCPDUMP_HSA_SIZE) {
  485. TRACE("HSA size too small: %i\n", act_hsa_size);
  486. return -EINVAL;
  487. }
  488. return 0;
  489. }
  490. static int __init get_mem_size(unsigned long *mem)
  491. {
  492. int i;
  493. struct mem_chunk *chunk_array;
  494. chunk_array = kzalloc(MEMORY_CHUNKS * sizeof(struct mem_chunk),
  495. GFP_KERNEL);
  496. if (!chunk_array)
  497. return -ENOMEM;
  498. detect_memory_layout(chunk_array);
  499. for (i = 0; i < MEMORY_CHUNKS; i++) {
  500. if (chunk_array[i].size == 0)
  501. break;
  502. *mem += chunk_array[i].size;
  503. }
  504. kfree(chunk_array);
  505. return 0;
  506. }
  507. static int __init zcore_header_init(int arch, struct zcore_header *hdr)
  508. {
  509. int rc, i;
  510. unsigned long memory = 0;
  511. u32 prefix;
  512. if (arch == ARCH_S390X)
  513. hdr->arch_id = DUMP_ARCH_S390X;
  514. else
  515. hdr->arch_id = DUMP_ARCH_S390;
  516. rc = get_mem_size(&memory);
  517. if (rc)
  518. return rc;
  519. hdr->mem_size = memory;
  520. hdr->rmem_size = memory;
  521. hdr->mem_end = sys_info.mem_size;
  522. hdr->num_pages = memory / PAGE_SIZE;
  523. hdr->tod = get_clock();
  524. get_cpu_id(&hdr->cpu_id);
  525. for (i = 0; zfcpdump_save_areas[i]; i++) {
  526. prefix = zfcpdump_save_areas[i]->pref_reg;
  527. hdr->real_cpu_cnt++;
  528. if (!prefix)
  529. continue;
  530. hdr->lc_vec[hdr->cpu_cnt] = prefix;
  531. hdr->cpu_cnt++;
  532. }
  533. return 0;
  534. }
  535. /*
  536. * Provide IPL parameter information block from either HSA or memory
  537. * for future reipl
  538. */
  539. static int __init zcore_reipl_init(void)
  540. {
  541. struct ipib_info ipib_info;
  542. int rc;
  543. rc = memcpy_hsa_kernel(&ipib_info, __LC_DUMP_REIPL, sizeof(ipib_info));
  544. if (rc)
  545. return rc;
  546. if (ipib_info.ipib == 0)
  547. return 0;
  548. ipl_block = (void *) __get_free_page(GFP_KERNEL);
  549. if (!ipl_block)
  550. return -ENOMEM;
  551. if (ipib_info.ipib < ZFCPDUMP_HSA_SIZE)
  552. rc = memcpy_hsa_kernel(ipl_block, ipib_info.ipib, PAGE_SIZE);
  553. else
  554. rc = memcpy_real(ipl_block, (void *) ipib_info.ipib, PAGE_SIZE);
  555. if (rc || csum_partial(ipl_block, ipl_block->hdr.len, 0) !=
  556. ipib_info.checksum) {
  557. TRACE("Checksum does not match\n");
  558. free_page((unsigned long) ipl_block);
  559. ipl_block = NULL;
  560. }
  561. return 0;
  562. }
  563. static int __init zcore_init(void)
  564. {
  565. unsigned char arch;
  566. int rc;
  567. if (ipl_info.type != IPL_TYPE_FCP_DUMP)
  568. return -ENODATA;
  569. zcore_dbf = debug_register("zcore", 4, 1, 4 * sizeof(long));
  570. debug_register_view(zcore_dbf, &debug_sprintf_view);
  571. debug_set_level(zcore_dbf, 6);
  572. TRACE("devno: %x\n", ipl_info.data.fcp.dev_id.devno);
  573. TRACE("wwpn: %llx\n", (unsigned long long) ipl_info.data.fcp.wwpn);
  574. TRACE("lun: %llx\n", (unsigned long long) ipl_info.data.fcp.lun);
  575. rc = sclp_sdias_init();
  576. if (rc)
  577. goto fail;
  578. rc = check_sdias();
  579. if (rc)
  580. goto fail;
  581. rc = memcpy_hsa_kernel(&arch, __LC_AR_MODE_ID, 1);
  582. if (rc)
  583. goto fail;
  584. #ifdef CONFIG_64BIT
  585. if (arch == ARCH_S390) {
  586. pr_alert("The 64-bit dump tool cannot be used for a "
  587. "32-bit system\n");
  588. rc = -EINVAL;
  589. goto fail;
  590. }
  591. #else /* CONFIG_64BIT */
  592. if (arch == ARCH_S390X) {
  593. pr_alert("The 32-bit dump tool cannot be used for a "
  594. "64-bit system\n");
  595. rc = -EINVAL;
  596. goto fail;
  597. }
  598. #endif /* CONFIG_64BIT */
  599. rc = sys_info_init(arch);
  600. if (rc)
  601. goto fail;
  602. rc = zcore_header_init(arch, &zcore_header);
  603. if (rc)
  604. goto fail;
  605. rc = zcore_reipl_init();
  606. if (rc)
  607. goto fail;
  608. zcore_dir = debugfs_create_dir("zcore" , NULL);
  609. if (!zcore_dir) {
  610. rc = -ENOMEM;
  611. goto fail;
  612. }
  613. zcore_file = debugfs_create_file("mem", S_IRUSR, zcore_dir, NULL,
  614. &zcore_fops);
  615. if (!zcore_file) {
  616. rc = -ENOMEM;
  617. goto fail_dir;
  618. }
  619. zcore_memmap_file = debugfs_create_file("memmap", S_IRUSR, zcore_dir,
  620. NULL, &zcore_memmap_fops);
  621. if (!zcore_memmap_file) {
  622. rc = -ENOMEM;
  623. goto fail_file;
  624. }
  625. zcore_reipl_file = debugfs_create_file("reipl", S_IRUSR, zcore_dir,
  626. NULL, &zcore_reipl_fops);
  627. if (!zcore_reipl_file) {
  628. rc = -ENOMEM;
  629. goto fail_memmap_file;
  630. }
  631. hsa_available = 1;
  632. return 0;
  633. fail_memmap_file:
  634. debugfs_remove(zcore_memmap_file);
  635. fail_file:
  636. debugfs_remove(zcore_file);
  637. fail_dir:
  638. debugfs_remove(zcore_dir);
  639. fail:
  640. diag308(DIAG308_REL_HSA, NULL);
  641. return rc;
  642. }
  643. static void __exit zcore_exit(void)
  644. {
  645. debug_unregister(zcore_dbf);
  646. sclp_sdias_exit();
  647. free_page((unsigned long) ipl_block);
  648. debugfs_remove(zcore_reipl_file);
  649. debugfs_remove(zcore_memmap_file);
  650. debugfs_remove(zcore_file);
  651. debugfs_remove(zcore_dir);
  652. diag308(DIAG308_REL_HSA, NULL);
  653. }
  654. MODULE_AUTHOR("Copyright IBM Corp. 2003,2008");
  655. MODULE_DESCRIPTION("zcore module for zfcpdump support");
  656. MODULE_LICENSE("GPL");
  657. subsys_initcall(zcore_init);
  658. module_exit(zcore_exit);