Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 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 | * |
Heiko Carstens | a53c8fa | 2012-07-20 11:15:04 +0200 | [diff] [blame] | 8 | * Copyright IBM Corp. 2003, 2008 |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 9 | * Author(s): Michael Holzheu |
| 10 | */ |
| 11 | |
Michael Holzheu | 17159dc6 | 2008-12-25 13:39:51 +0100 | [diff] [blame] | 12 | #define KMSG_COMPONENT "zdump" |
| 13 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 14 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 15 | #include <linux/init.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 16 | #include <linux/slab.h> |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 17 | #include <linux/miscdevice.h> |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 18 | #include <linux/debugfs.h> |
Heiko Carstens | 3948a10 | 2011-10-30 15:16:55 +0100 | [diff] [blame] | 19 | #include <linux/module.h> |
Philipp Hachtmann | 50be634 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 20 | #include <linux/memblock.h> |
| 21 | |
Heiko Carstens | cbb870c | 2010-02-26 22:37:43 +0100 | [diff] [blame] | 22 | #include <asm/asm-offsets.h> |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 23 | #include <asm/ipl.h> |
| 24 | #include <asm/sclp.h> |
| 25 | #include <asm/setup.h> |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 26 | #include <asm/uaccess.h> |
| 27 | #include <asm/debug.h> |
| 28 | #include <asm/processor.h> |
| 29 | #include <asm/irqflags.h> |
Frank Munzert | 159d1ff | 2009-03-26 15:24:45 +0100 | [diff] [blame] | 30 | #include <asm/checksum.h> |
Martin Schwidefsky | bbfed51 | 2015-10-15 11:14:19 +0200 | [diff] [blame] | 31 | #include <asm/os_info.h> |
Michael Holzheu | a62bc07 | 2014-10-06 17:57:43 +0200 | [diff] [blame] | 32 | #include <asm/switch_to.h> |
Heiko Carstens | 763968e | 2007-05-10 15:45:46 +0200 | [diff] [blame] | 33 | #include "sclp.h" |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 34 | |
| 35 | #define TRACE(x...) debug_sprintf_event(zcore_dbf, 1, x) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 36 | |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 37 | #define CHUNK_INFO_SIZE 34 /* 2 16-byte char, each followed by blank */ |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 38 | |
| 39 | enum arch_id { |
| 40 | ARCH_S390 = 0, |
| 41 | ARCH_S390X = 1, |
| 42 | }; |
| 43 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 44 | struct ipib_info { |
| 45 | unsigned long ipib; |
| 46 | u32 checksum; |
| 47 | } __attribute__((packed)); |
| 48 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 49 | static struct debug_info *zcore_dbf; |
| 50 | static int hsa_available; |
| 51 | static struct dentry *zcore_dir; |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 52 | static struct dentry *zcore_memmap_file; |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 53 | static struct dentry *zcore_reipl_file; |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 54 | static struct dentry *zcore_hsa_file; |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 55 | static struct ipl_parameter_block *ipl_block; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 56 | |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 57 | static char hsa_buf[PAGE_SIZE] __aligned(PAGE_SIZE); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 58 | |
Martin Schwidefsky | df9694c | 2015-10-12 10:43:37 +0200 | [diff] [blame] | 59 | /* |
| 60 | * Copy memory from HSA to user memory (not reentrant): |
| 61 | * |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 62 | * @dest: User buffer where memory should be copied to |
Martin Schwidefsky | df9694c | 2015-10-12 10:43:37 +0200 | [diff] [blame] | 63 | * @src: Start address within HSA where data should be copied |
| 64 | * @count: Size of buffer, which should be copied |
| 65 | */ |
| 66 | int memcpy_hsa_user(void __user *dest, unsigned long src, size_t count) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 67 | { |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 68 | unsigned long offset, bytes; |
| 69 | |
| 70 | if (!hsa_available) |
| 71 | return -ENODATA; |
| 72 | |
| 73 | while (count) { |
| 74 | if (sclp_sdias_copy(hsa_buf, src / PAGE_SIZE + 2, 1)) { |
| 75 | TRACE("sclp_sdias_copy() failed\n"); |
| 76 | return -EIO; |
| 77 | } |
| 78 | offset = src % PAGE_SIZE; |
| 79 | bytes = min(PAGE_SIZE - offset, count); |
| 80 | if (copy_to_user(dest, hsa_buf + offset, bytes)) |
| 81 | return -EFAULT; |
| 82 | src += bytes; |
| 83 | dest += bytes; |
| 84 | count -= bytes; |
| 85 | } |
| 86 | return 0; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 87 | } |
| 88 | |
Martin Schwidefsky | df9694c | 2015-10-12 10:43:37 +0200 | [diff] [blame] | 89 | /* |
| 90 | * Copy memory from HSA to kernel memory (not reentrant): |
| 91 | * |
| 92 | * @dest: Kernel or user buffer where memory should be copied to |
| 93 | * @src: Start address within HSA where data should be copied |
| 94 | * @count: Size of buffer, which should be copied |
| 95 | */ |
| 96 | int memcpy_hsa_kernel(void *dest, unsigned long src, size_t count) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 97 | { |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 98 | unsigned long offset, bytes; |
| 99 | |
| 100 | if (!hsa_available) |
| 101 | return -ENODATA; |
| 102 | |
| 103 | while (count) { |
| 104 | if (sclp_sdias_copy(hsa_buf, src / PAGE_SIZE + 2, 1)) { |
| 105 | TRACE("sclp_sdias_copy() failed\n"); |
| 106 | return -EIO; |
| 107 | } |
| 108 | offset = src % PAGE_SIZE; |
| 109 | bytes = min(PAGE_SIZE - offset, count); |
| 110 | memcpy(dest, hsa_buf + offset, bytes); |
| 111 | src += bytes; |
| 112 | dest += bytes; |
| 113 | count -= bytes; |
| 114 | } |
| 115 | return 0; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 116 | } |
| 117 | |
Martin Schwidefsky | ffa52d0 | 2015-10-28 09:47:58 +0100 | [diff] [blame] | 118 | static int __init init_cpu_info(void) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 119 | { |
Martin Schwidefsky | 1a2c584 | 2015-10-29 10:59:15 +0100 | [diff] [blame] | 120 | struct save_area *sa; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 121 | |
| 122 | /* get info for boot cpu from lowcore, stored in the HSA */ |
Martin Schwidefsky | 1a2c584 | 2015-10-29 10:59:15 +0100 | [diff] [blame] | 123 | sa = save_area_boot_cpu(); |
| 124 | if (!sa) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 125 | return -ENOMEM; |
Martin Schwidefsky | 1a2c584 | 2015-10-29 10:59:15 +0100 | [diff] [blame] | 126 | if (memcpy_hsa_kernel(hsa_buf, __LC_FPREGS_SAVE_AREA, 512) < 0) { |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 127 | TRACE("could not copy from HSA\n"); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 128 | return -EIO; |
| 129 | } |
Martin Schwidefsky | 1a2c584 | 2015-10-29 10:59:15 +0100 | [diff] [blame] | 130 | save_area_add_regs(sa, hsa_buf); /* vx registers are saved in smp.c */ |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 131 | return 0; |
| 132 | } |
| 133 | |
| 134 | /* |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 135 | * Release the HSA |
| 136 | */ |
| 137 | static void release_hsa(void) |
| 138 | { |
| 139 | diag308(DIAG308_REL_HSA, NULL); |
| 140 | hsa_available = 0; |
| 141 | } |
| 142 | |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 143 | static ssize_t zcore_memmap_read(struct file *filp, char __user *buf, |
| 144 | size_t count, loff_t *ppos) |
| 145 | { |
| 146 | return simple_read_from_buffer(buf, count, ppos, filp->private_data, |
Philipp Hachtmann | 50be634 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 147 | memblock.memory.cnt * CHUNK_INFO_SIZE); |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | static int zcore_memmap_open(struct inode *inode, struct file *filp) |
| 151 | { |
Philipp Hachtmann | 50be634 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 152 | struct memblock_region *reg; |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 153 | char *buf; |
Philipp Hachtmann | 50be634 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 154 | int i = 0; |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 155 | |
Philipp Hachtmann | 50be634 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 156 | buf = kzalloc(memblock.memory.cnt * CHUNK_INFO_SIZE, GFP_KERNEL); |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 157 | if (!buf) { |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 158 | return -ENOMEM; |
| 159 | } |
Philipp Hachtmann | 50be634 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 160 | for_each_memblock(memory, reg) { |
| 161 | sprintf(buf + (i++ * CHUNK_INFO_SIZE), "%016llx %016llx ", |
| 162 | (unsigned long long) reg->base, |
| 163 | (unsigned long long) reg->size); |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 164 | } |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 165 | filp->private_data = buf; |
Martin Schwidefsky | 58ea91c | 2010-05-17 10:00:07 +0200 | [diff] [blame] | 166 | return nonseekable_open(inode, filp); |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 167 | } |
| 168 | |
| 169 | static int zcore_memmap_release(struct inode *inode, struct file *filp) |
| 170 | { |
| 171 | kfree(filp->private_data); |
| 172 | return 0; |
| 173 | } |
| 174 | |
| 175 | static const struct file_operations zcore_memmap_fops = { |
| 176 | .owner = THIS_MODULE, |
| 177 | .read = zcore_memmap_read, |
| 178 | .open = zcore_memmap_open, |
| 179 | .release = zcore_memmap_release, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 180 | .llseek = no_llseek, |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 181 | }; |
| 182 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 183 | static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf, |
| 184 | size_t count, loff_t *ppos) |
| 185 | { |
| 186 | if (ipl_block) { |
| 187 | diag308(DIAG308_SET, ipl_block); |
Heiko Carstens | 0599eea | 2016-06-11 11:24:27 +0200 | [diff] [blame^] | 188 | diag308(DIAG308_LOAD_CLEAR, NULL); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 189 | } |
| 190 | return count; |
| 191 | } |
| 192 | |
| 193 | static int zcore_reipl_open(struct inode *inode, struct file *filp) |
| 194 | { |
Martin Schwidefsky | 58ea91c | 2010-05-17 10:00:07 +0200 | [diff] [blame] | 195 | return nonseekable_open(inode, filp); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | static int zcore_reipl_release(struct inode *inode, struct file *filp) |
| 199 | { |
| 200 | return 0; |
| 201 | } |
| 202 | |
| 203 | static const struct file_operations zcore_reipl_fops = { |
| 204 | .owner = THIS_MODULE, |
| 205 | .write = zcore_reipl_write, |
| 206 | .open = zcore_reipl_open, |
| 207 | .release = zcore_reipl_release, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 208 | .llseek = no_llseek, |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 209 | }; |
| 210 | |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 211 | static ssize_t zcore_hsa_read(struct file *filp, char __user *buf, |
| 212 | size_t count, loff_t *ppos) |
| 213 | { |
| 214 | static char str[18]; |
| 215 | |
| 216 | if (hsa_available) |
David Hildenbrand | 37c5f6c | 2015-05-06 13:18:59 +0200 | [diff] [blame] | 217 | snprintf(str, sizeof(str), "%lx\n", sclp.hsa_size); |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 218 | else |
| 219 | snprintf(str, sizeof(str), "0\n"); |
| 220 | return simple_read_from_buffer(buf, count, ppos, str, strlen(str)); |
| 221 | } |
| 222 | |
| 223 | static ssize_t zcore_hsa_write(struct file *filp, const char __user *buf, |
| 224 | size_t count, loff_t *ppos) |
| 225 | { |
| 226 | char value; |
| 227 | |
| 228 | if (*ppos != 0) |
| 229 | return -EPIPE; |
| 230 | if (copy_from_user(&value, buf, 1)) |
| 231 | return -EFAULT; |
| 232 | if (value != '0') |
| 233 | return -EINVAL; |
| 234 | release_hsa(); |
| 235 | return count; |
| 236 | } |
| 237 | |
| 238 | static const struct file_operations zcore_hsa_fops = { |
| 239 | .owner = THIS_MODULE, |
| 240 | .write = zcore_hsa_write, |
| 241 | .read = zcore_hsa_read, |
| 242 | .open = nonseekable_open, |
| 243 | .llseek = no_llseek, |
| 244 | }; |
| 245 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 246 | static int __init check_sdias(void) |
| 247 | { |
David Hildenbrand | 37c5f6c | 2015-05-06 13:18:59 +0200 | [diff] [blame] | 248 | if (!sclp.hsa_size) { |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 249 | TRACE("Could not determine HSA size\n"); |
Michael Holzheu | e657d8f | 2013-11-13 10:38:27 +0100 | [diff] [blame] | 250 | return -ENODEV; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 251 | } |
| 252 | return 0; |
| 253 | } |
| 254 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 255 | /* |
| 256 | * Provide IPL parameter information block from either HSA or memory |
| 257 | * for future reipl |
| 258 | */ |
| 259 | static int __init zcore_reipl_init(void) |
| 260 | { |
| 261 | struct ipib_info ipib_info; |
| 262 | int rc; |
| 263 | |
| 264 | rc = memcpy_hsa_kernel(&ipib_info, __LC_DUMP_REIPL, sizeof(ipib_info)); |
| 265 | if (rc) |
| 266 | return rc; |
| 267 | if (ipib_info.ipib == 0) |
| 268 | return 0; |
| 269 | ipl_block = (void *) __get_free_page(GFP_KERNEL); |
| 270 | if (!ipl_block) |
| 271 | return -ENOMEM; |
David Hildenbrand | 37c5f6c | 2015-05-06 13:18:59 +0200 | [diff] [blame] | 272 | if (ipib_info.ipib < sclp.hsa_size) |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 273 | rc = memcpy_hsa_kernel(ipl_block, ipib_info.ipib, PAGE_SIZE); |
| 274 | else |
Michael Holzheu | 92fe313 | 2010-03-24 11:49:50 +0100 | [diff] [blame] | 275 | rc = memcpy_real(ipl_block, (void *) ipib_info.ipib, PAGE_SIZE); |
Michael Holzheu | 76ef964 | 2010-04-22 17:17:07 +0200 | [diff] [blame] | 276 | if (rc || csum_partial(ipl_block, ipl_block->hdr.len, 0) != |
Frank Munzert | 159d1ff | 2009-03-26 15:24:45 +0100 | [diff] [blame] | 277 | ipib_info.checksum) { |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 278 | TRACE("Checksum does not match\n"); |
| 279 | free_page((unsigned long) ipl_block); |
| 280 | ipl_block = NULL; |
| 281 | } |
| 282 | return 0; |
| 283 | } |
| 284 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 285 | static int __init zcore_init(void) |
| 286 | { |
| 287 | unsigned char arch; |
| 288 | int rc; |
| 289 | |
| 290 | if (ipl_info.type != IPL_TYPE_FCP_DUMP) |
| 291 | return -ENODATA; |
Michael Holzheu | 3f25dc4 | 2011-11-14 11:19:05 +0100 | [diff] [blame] | 292 | if (OLDMEM_BASE) |
| 293 | return -ENODATA; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 294 | |
| 295 | zcore_dbf = debug_register("zcore", 4, 1, 4 * sizeof(long)); |
| 296 | debug_register_view(zcore_dbf, &debug_sprintf_view); |
| 297 | debug_set_level(zcore_dbf, 6); |
| 298 | |
| 299 | TRACE("devno: %x\n", ipl_info.data.fcp.dev_id.devno); |
| 300 | TRACE("wwpn: %llx\n", (unsigned long long) ipl_info.data.fcp.wwpn); |
| 301 | TRACE("lun: %llx\n", (unsigned long long) ipl_info.data.fcp.lun); |
| 302 | |
Heiko Carstens | 763968e | 2007-05-10 15:45:46 +0200 | [diff] [blame] | 303 | rc = sclp_sdias_init(); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 304 | if (rc) |
| 305 | goto fail; |
| 306 | |
| 307 | rc = check_sdias(); |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 308 | if (rc) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 309 | goto fail; |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 310 | hsa_available = 1; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 311 | |
| 312 | rc = memcpy_hsa_kernel(&arch, __LC_AR_MODE_ID, 1); |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 313 | if (rc) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 314 | goto fail; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 315 | |
Heiko Carstens | f64ca21 | 2010-02-26 22:37:32 +0100 | [diff] [blame] | 316 | if (arch == ARCH_S390) { |
| 317 | pr_alert("The 64-bit dump tool cannot be used for a " |
| 318 | "32-bit system\n"); |
| 319 | rc = -EINVAL; |
| 320 | goto fail; |
| 321 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 322 | |
Martin Schwidefsky | ffa52d0 | 2015-10-28 09:47:58 +0100 | [diff] [blame] | 323 | pr_alert("DETECTED 'S390X (64 bit) OS'\n"); |
| 324 | rc = init_cpu_info(); |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 325 | if (rc) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 326 | goto fail; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 327 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 328 | rc = zcore_reipl_init(); |
| 329 | if (rc) |
| 330 | goto fail; |
| 331 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 332 | zcore_dir = debugfs_create_dir("zcore" , NULL); |
| 333 | if (!zcore_dir) { |
| 334 | rc = -ENOMEM; |
| 335 | goto fail; |
| 336 | } |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 337 | zcore_memmap_file = debugfs_create_file("memmap", S_IRUSR, zcore_dir, |
| 338 | NULL, &zcore_memmap_fops); |
| 339 | if (!zcore_memmap_file) { |
| 340 | rc = -ENOMEM; |
Martin Schwidefsky | ffa52d0 | 2015-10-28 09:47:58 +0100 | [diff] [blame] | 341 | goto fail_dir; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 342 | } |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 343 | zcore_reipl_file = debugfs_create_file("reipl", S_IRUSR, zcore_dir, |
| 344 | NULL, &zcore_reipl_fops); |
| 345 | if (!zcore_reipl_file) { |
| 346 | rc = -ENOMEM; |
| 347 | goto fail_memmap_file; |
| 348 | } |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 349 | zcore_hsa_file = debugfs_create_file("hsa", S_IRUSR|S_IWUSR, zcore_dir, |
| 350 | NULL, &zcore_hsa_fops); |
| 351 | if (!zcore_hsa_file) { |
| 352 | rc = -ENOMEM; |
| 353 | goto fail_reipl_file; |
| 354 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 355 | return 0; |
| 356 | |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 357 | fail_reipl_file: |
| 358 | debugfs_remove(zcore_reipl_file); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 359 | fail_memmap_file: |
| 360 | debugfs_remove(zcore_memmap_file); |
Frank Munzert | 12e0c95 | 2008-07-17 17:16:40 +0200 | [diff] [blame] | 361 | fail_dir: |
| 362 | debugfs_remove(zcore_dir); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 363 | fail: |
| 364 | diag308(DIAG308_REL_HSA, NULL); |
| 365 | return rc; |
| 366 | } |
| 367 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 368 | static void __exit zcore_exit(void) |
| 369 | { |
| 370 | debug_unregister(zcore_dbf); |
Heiko Carstens | 763968e | 2007-05-10 15:45:46 +0200 | [diff] [blame] | 371 | sclp_sdias_exit(); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 372 | free_page((unsigned long) ipl_block); |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 373 | debugfs_remove(zcore_hsa_file); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 374 | debugfs_remove(zcore_reipl_file); |
| 375 | debugfs_remove(zcore_memmap_file); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 376 | debugfs_remove(zcore_dir); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 377 | diag308(DIAG308_REL_HSA, NULL); |
| 378 | } |
| 379 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 380 | MODULE_AUTHOR("Copyright IBM Corp. 2003,2008"); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 381 | MODULE_DESCRIPTION("zcore module for zfcpdump support"); |
| 382 | MODULE_LICENSE("GPL"); |
| 383 | |
| 384 | subsys_initcall(zcore_init); |
| 385 | module_exit(zcore_exit); |