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