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