zcore.c 17 KB

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