Greg Kroah-Hartman | 6f05e69 | 2017-11-14 18:38:03 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-1.0+ |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 2 | /* |
| 3 | * zcore module to export memory content and register sets for creating system |
Alexander Egorenkov | bd37b36 | 2020-09-29 20:24:55 +0200 | [diff] [blame] | 4 | * dumps on SCSI/NVMe disks (zfcp/nvme dump). |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 5 | * |
Mauro Carvalho Chehab | 8b4a503 | 2019-06-08 23:27:16 -0300 | [diff] [blame] | 6 | * For more information please refer to Documentation/s390/zfcpdump.rst |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 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/debugfs.h> |
Andy Shevchenko | f39650d | 2021-06-30 18:54:59 -0700 | [diff] [blame] | 18 | #include <linux/panic_notifier.h> |
Alexander Egorenkov | dabdfac | 2021-02-25 14:28:52 +0100 | [diff] [blame] | 19 | #include <linux/reboot.h> |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 20 | #include <linux/uio.h> |
Philipp Hachtmann | 50be634 | 2014-01-29 18:16:01 +0100 | [diff] [blame] | 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> |
Linus Torvalds | 7c0f6ba | 2016-12-24 11:46:01 -0800 | [diff] [blame] | 26 | #include <linux/uaccess.h> |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 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> |
Alexander Gordeev | 2f0e8aa | 2022-07-24 15:02:16 +0200 | [diff] [blame] | 33 | #include <asm/maccess.h> |
Heiko Carstens | 763968e | 2007-05-10 15:45:46 +0200 | [diff] [blame] | 34 | #include "sclp.h" |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 35 | |
| 36 | #define TRACE(x...) debug_sprintf_event(zcore_dbf, 1, x) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 37 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 38 | enum arch_id { |
| 39 | ARCH_S390 = 0, |
| 40 | ARCH_S390X = 1, |
| 41 | }; |
| 42 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 43 | struct ipib_info { |
| 44 | unsigned long ipib; |
| 45 | u32 checksum; |
| 46 | } __attribute__((packed)); |
| 47 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 48 | static struct debug_info *zcore_dbf; |
| 49 | static int hsa_available; |
| 50 | static struct dentry *zcore_dir; |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 51 | static struct dentry *zcore_reipl_file; |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 52 | static struct dentry *zcore_hsa_file; |
Philipp Rudo | f3df44e7 | 2019-03-14 13:50:32 +0100 | [diff] [blame] | 53 | static struct ipl_parameter_block *zcore_ipl_block; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 54 | |
Alexander Gordeev | 9ffed25 | 2022-07-19 07:16:33 +0200 | [diff] [blame] | 55 | static DEFINE_MUTEX(hsa_buf_mutex); |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 56 | static char hsa_buf[PAGE_SIZE] __aligned(PAGE_SIZE); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 57 | |
Martin Schwidefsky | df9694c | 2015-10-12 10:43:37 +0200 | [diff] [blame] | 58 | /* |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 59 | * Copy memory from HSA to iterator (not reentrant): |
Martin Schwidefsky | df9694c | 2015-10-12 10:43:37 +0200 | [diff] [blame] | 60 | * |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 61 | * @iter: Iterator where memory should be copied to |
Martin Schwidefsky | df9694c | 2015-10-12 10:43:37 +0200 | [diff] [blame] | 62 | * @src: Start address within HSA where data should be copied |
| 63 | * @count: Size of buffer, which should be copied |
| 64 | */ |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 65 | size_t memcpy_hsa_iter(struct iov_iter *iter, unsigned long src, size_t count) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 66 | { |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 67 | size_t bytes, copied, res = 0; |
| 68 | unsigned long offset; |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 69 | |
| 70 | if (!hsa_available) |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 71 | return 0; |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 72 | |
Alexander Gordeev | 9ffed25 | 2022-07-19 07:16:33 +0200 | [diff] [blame] | 73 | mutex_lock(&hsa_buf_mutex); |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 74 | while (count) { |
| 75 | if (sclp_sdias_copy(hsa_buf, src / PAGE_SIZE + 2, 1)) { |
| 76 | TRACE("sclp_sdias_copy() failed\n"); |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 77 | break; |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 78 | } |
| 79 | offset = src % PAGE_SIZE; |
| 80 | bytes = min(PAGE_SIZE - offset, count); |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 81 | copied = copy_to_iter(hsa_buf + offset, bytes, iter); |
| 82 | count -= copied; |
| 83 | src += copied; |
| 84 | res += copied; |
| 85 | if (copied < bytes) |
| 86 | break; |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 87 | } |
Alexander Gordeev | 9ffed25 | 2022-07-19 07:16:33 +0200 | [diff] [blame] | 88 | mutex_unlock(&hsa_buf_mutex); |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 89 | return res; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 90 | } |
| 91 | |
Martin Schwidefsky | df9694c | 2015-10-12 10:43:37 +0200 | [diff] [blame] | 92 | /* |
| 93 | * Copy memory from HSA to kernel memory (not reentrant): |
| 94 | * |
| 95 | * @dest: Kernel or user buffer where memory should be copied to |
| 96 | * @src: Start address within HSA where data should be copied |
| 97 | * @count: Size of buffer, which should be copied |
| 98 | */ |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 99 | static inline int memcpy_hsa_kernel(void *dst, unsigned long src, size_t count) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 100 | { |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 101 | struct iov_iter iter; |
| 102 | struct kvec kvec; |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 103 | |
Alexander Gordeev | ebbc957 | 2022-07-19 07:16:36 +0200 | [diff] [blame] | 104 | kvec.iov_base = dst; |
| 105 | kvec.iov_len = count; |
| 106 | iov_iter_kvec(&iter, WRITE, &kvec, 1, count); |
| 107 | if (memcpy_hsa_iter(&iter, src, count) < count) |
| 108 | return -EIO; |
Martin Schwidefsky | 019d6be | 2015-10-12 10:51:54 +0200 | [diff] [blame] | 109 | return 0; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 110 | } |
| 111 | |
Martin Schwidefsky | ffa52d0 | 2015-10-28 09:47:58 +0100 | [diff] [blame] | 112 | static int __init init_cpu_info(void) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 113 | { |
Martin Schwidefsky | 1a2c584 | 2015-10-29 10:59:15 +0100 | [diff] [blame] | 114 | struct save_area *sa; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 115 | |
| 116 | /* get info for boot cpu from lowcore, stored in the HSA */ |
Martin Schwidefsky | 1a2c584 | 2015-10-29 10:59:15 +0100 | [diff] [blame] | 117 | sa = save_area_boot_cpu(); |
| 118 | if (!sa) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 119 | return -ENOMEM; |
Martin Schwidefsky | 1a2c584 | 2015-10-29 10:59:15 +0100 | [diff] [blame] | 120 | if (memcpy_hsa_kernel(hsa_buf, __LC_FPREGS_SAVE_AREA, 512) < 0) { |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 121 | TRACE("could not copy from HSA\n"); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 122 | return -EIO; |
| 123 | } |
Martin Schwidefsky | 1a2c584 | 2015-10-29 10:59:15 +0100 | [diff] [blame] | 124 | 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] | 125 | return 0; |
| 126 | } |
| 127 | |
| 128 | /* |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 129 | * Release the HSA |
| 130 | */ |
| 131 | static void release_hsa(void) |
| 132 | { |
| 133 | diag308(DIAG308_REL_HSA, NULL); |
| 134 | hsa_available = 0; |
| 135 | } |
| 136 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 137 | static ssize_t zcore_reipl_write(struct file *filp, const char __user *buf, |
| 138 | size_t count, loff_t *ppos) |
| 139 | { |
Philipp Rudo | f3df44e7 | 2019-03-14 13:50:32 +0100 | [diff] [blame] | 140 | if (zcore_ipl_block) { |
| 141 | diag308(DIAG308_SET, zcore_ipl_block); |
Heiko Carstens | 0599eea | 2016-06-11 11:24:27 +0200 | [diff] [blame] | 142 | diag308(DIAG308_LOAD_CLEAR, NULL); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 143 | } |
| 144 | return count; |
| 145 | } |
| 146 | |
| 147 | static int zcore_reipl_open(struct inode *inode, struct file *filp) |
| 148 | { |
Kirill Smelkov | c5bf68f | 2019-03-26 23:51:19 +0300 | [diff] [blame] | 149 | return stream_open(inode, filp); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 150 | } |
| 151 | |
| 152 | static int zcore_reipl_release(struct inode *inode, struct file *filp) |
| 153 | { |
| 154 | return 0; |
| 155 | } |
| 156 | |
| 157 | static const struct file_operations zcore_reipl_fops = { |
| 158 | .owner = THIS_MODULE, |
| 159 | .write = zcore_reipl_write, |
| 160 | .open = zcore_reipl_open, |
| 161 | .release = zcore_reipl_release, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 162 | .llseek = no_llseek, |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 163 | }; |
| 164 | |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 165 | static ssize_t zcore_hsa_read(struct file *filp, char __user *buf, |
| 166 | size_t count, loff_t *ppos) |
| 167 | { |
| 168 | static char str[18]; |
| 169 | |
| 170 | if (hsa_available) |
David Hildenbrand | 37c5f6c | 2015-05-06 13:18:59 +0200 | [diff] [blame] | 171 | snprintf(str, sizeof(str), "%lx\n", sclp.hsa_size); |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 172 | else |
| 173 | snprintf(str, sizeof(str), "0\n"); |
| 174 | return simple_read_from_buffer(buf, count, ppos, str, strlen(str)); |
| 175 | } |
| 176 | |
| 177 | static ssize_t zcore_hsa_write(struct file *filp, const char __user *buf, |
| 178 | size_t count, loff_t *ppos) |
| 179 | { |
| 180 | char value; |
| 181 | |
| 182 | if (*ppos != 0) |
| 183 | return -EPIPE; |
| 184 | if (copy_from_user(&value, buf, 1)) |
| 185 | return -EFAULT; |
| 186 | if (value != '0') |
| 187 | return -EINVAL; |
| 188 | release_hsa(); |
| 189 | return count; |
| 190 | } |
| 191 | |
| 192 | static const struct file_operations zcore_hsa_fops = { |
| 193 | .owner = THIS_MODULE, |
| 194 | .write = zcore_hsa_write, |
| 195 | .read = zcore_hsa_read, |
| 196 | .open = nonseekable_open, |
| 197 | .llseek = no_llseek, |
| 198 | }; |
| 199 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 200 | static int __init check_sdias(void) |
| 201 | { |
David Hildenbrand | 37c5f6c | 2015-05-06 13:18:59 +0200 | [diff] [blame] | 202 | if (!sclp.hsa_size) { |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 203 | TRACE("Could not determine HSA size\n"); |
Michael Holzheu | e657d8f | 2013-11-13 10:38:27 +0100 | [diff] [blame] | 204 | return -ENODEV; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 205 | } |
| 206 | return 0; |
| 207 | } |
| 208 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 209 | /* |
| 210 | * Provide IPL parameter information block from either HSA or memory |
| 211 | * for future reipl |
| 212 | */ |
| 213 | static int __init zcore_reipl_init(void) |
| 214 | { |
| 215 | struct ipib_info ipib_info; |
| 216 | int rc; |
| 217 | |
| 218 | rc = memcpy_hsa_kernel(&ipib_info, __LC_DUMP_REIPL, sizeof(ipib_info)); |
| 219 | if (rc) |
| 220 | return rc; |
| 221 | if (ipib_info.ipib == 0) |
| 222 | return 0; |
Philipp Rudo | f3df44e7 | 2019-03-14 13:50:32 +0100 | [diff] [blame] | 223 | zcore_ipl_block = (void *) __get_free_page(GFP_KERNEL); |
| 224 | if (!zcore_ipl_block) |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 225 | return -ENOMEM; |
David Hildenbrand | 37c5f6c | 2015-05-06 13:18:59 +0200 | [diff] [blame] | 226 | if (ipib_info.ipib < sclp.hsa_size) |
Philipp Rudo | f3df44e7 | 2019-03-14 13:50:32 +0100 | [diff] [blame] | 227 | rc = memcpy_hsa_kernel(zcore_ipl_block, ipib_info.ipib, |
| 228 | PAGE_SIZE); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 229 | else |
Alexander Gordeev | 303fd98 | 2022-01-29 09:24:50 +0100 | [diff] [blame] | 230 | rc = memcpy_real(zcore_ipl_block, ipib_info.ipib, PAGE_SIZE); |
Philipp Rudo | f3df44e7 | 2019-03-14 13:50:32 +0100 | [diff] [blame] | 231 | if (rc || (__force u32)csum_partial(zcore_ipl_block, zcore_ipl_block->hdr.len, 0) != |
Frank Munzert | 159d1ff | 2009-03-26 15:24:45 +0100 | [diff] [blame] | 232 | ipib_info.checksum) { |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 233 | TRACE("Checksum does not match\n"); |
Philipp Rudo | f3df44e7 | 2019-03-14 13:50:32 +0100 | [diff] [blame] | 234 | free_page((unsigned long) zcore_ipl_block); |
| 235 | zcore_ipl_block = NULL; |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 236 | } |
| 237 | return 0; |
| 238 | } |
| 239 | |
Alexander Egorenkov | dabdfac | 2021-02-25 14:28:52 +0100 | [diff] [blame] | 240 | static int zcore_reboot_and_on_panic_handler(struct notifier_block *self, |
| 241 | unsigned long event, |
| 242 | void *data) |
| 243 | { |
| 244 | if (hsa_available) |
| 245 | release_hsa(); |
| 246 | |
| 247 | return NOTIFY_OK; |
| 248 | } |
| 249 | |
| 250 | static struct notifier_block zcore_reboot_notifier = { |
| 251 | .notifier_call = zcore_reboot_and_on_panic_handler, |
| 252 | /* we need to be notified before reipl and kdump */ |
| 253 | .priority = INT_MAX, |
| 254 | }; |
| 255 | |
| 256 | static struct notifier_block zcore_on_panic_notifier = { |
| 257 | .notifier_call = zcore_reboot_and_on_panic_handler, |
| 258 | /* we need to be notified before reipl and kdump */ |
| 259 | .priority = INT_MAX, |
| 260 | }; |
| 261 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 262 | static int __init zcore_init(void) |
| 263 | { |
| 264 | unsigned char arch; |
| 265 | int rc; |
| 266 | |
Alexander Egorenkov | bd37b36 | 2020-09-29 20:24:55 +0200 | [diff] [blame] | 267 | if (!is_ipl_type_dump()) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 268 | return -ENODATA; |
Alexander Egorenkov | e9e7870 | 2021-06-15 14:25:41 +0200 | [diff] [blame] | 269 | if (oldmem_data.start) |
Michael Holzheu | 3f25dc4 | 2011-11-14 11:19:05 +0100 | [diff] [blame] | 270 | return -ENODATA; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 271 | |
| 272 | zcore_dbf = debug_register("zcore", 4, 1, 4 * sizeof(long)); |
| 273 | debug_register_view(zcore_dbf, &debug_sprintf_view); |
| 274 | debug_set_level(zcore_dbf, 6); |
| 275 | |
Alexander Egorenkov | bd37b36 | 2020-09-29 20:24:55 +0200 | [diff] [blame] | 276 | if (ipl_info.type == IPL_TYPE_FCP_DUMP) { |
| 277 | TRACE("type: fcp\n"); |
| 278 | TRACE("devno: %x\n", ipl_info.data.fcp.dev_id.devno); |
| 279 | TRACE("wwpn: %llx\n", (unsigned long long) ipl_info.data.fcp.wwpn); |
| 280 | TRACE("lun: %llx\n", (unsigned long long) ipl_info.data.fcp.lun); |
| 281 | } else if (ipl_info.type == IPL_TYPE_NVME_DUMP) { |
| 282 | TRACE("type: nvme\n"); |
| 283 | TRACE("fid: %x\n", ipl_info.data.nvme.fid); |
| 284 | TRACE("nsid: %x\n", ipl_info.data.nvme.nsid); |
| 285 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 286 | |
Heiko Carstens | 763968e | 2007-05-10 15:45:46 +0200 | [diff] [blame] | 287 | rc = sclp_sdias_init(); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 288 | if (rc) |
| 289 | goto fail; |
| 290 | |
| 291 | rc = check_sdias(); |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 292 | if (rc) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 293 | goto fail; |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 294 | hsa_available = 1; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 295 | |
| 296 | rc = memcpy_hsa_kernel(&arch, __LC_AR_MODE_ID, 1); |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 297 | if (rc) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 298 | goto fail; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 299 | |
Heiko Carstens | f64ca21 | 2010-02-26 22:37:32 +0100 | [diff] [blame] | 300 | if (arch == ARCH_S390) { |
| 301 | pr_alert("The 64-bit dump tool cannot be used for a " |
| 302 | "32-bit system\n"); |
| 303 | rc = -EINVAL; |
| 304 | goto fail; |
| 305 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 306 | |
Michael Holzheu | 6896226 | 2016-11-14 18:51:41 +0100 | [diff] [blame] | 307 | pr_alert("The dump process started for a 64-bit operating system\n"); |
Martin Schwidefsky | ffa52d0 | 2015-10-28 09:47:58 +0100 | [diff] [blame] | 308 | rc = init_cpu_info(); |
Michael Holzheu | 2a062ab | 2008-07-14 09:59:38 +0200 | [diff] [blame] | 309 | if (rc) |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 310 | goto fail; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 311 | |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 312 | rc = zcore_reipl_init(); |
| 313 | if (rc) |
| 314 | goto fail; |
| 315 | |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 316 | zcore_dir = debugfs_create_dir("zcore" , NULL); |
Frank Munzert | 099b765 | 2009-03-26 15:23:43 +0100 | [diff] [blame] | 317 | zcore_reipl_file = debugfs_create_file("reipl", S_IRUSR, zcore_dir, |
| 318 | NULL, &zcore_reipl_fops); |
Michael Holzheu | b4b3d12 | 2013-01-21 18:37:41 +0100 | [diff] [blame] | 319 | zcore_hsa_file = debugfs_create_file("hsa", S_IRUSR|S_IWUSR, zcore_dir, |
| 320 | NULL, &zcore_hsa_fops); |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 321 | |
Alexander Egorenkov | dabdfac | 2021-02-25 14:28:52 +0100 | [diff] [blame] | 322 | register_reboot_notifier(&zcore_reboot_notifier); |
| 323 | atomic_notifier_chain_register(&panic_notifier_list, &zcore_on_panic_notifier); |
| 324 | |
Alexander Egorenkov | 7449ca8 | 2021-02-26 11:21:05 +0100 | [diff] [blame] | 325 | return 0; |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 326 | fail: |
| 327 | diag308(DIAG308_REL_HSA, NULL); |
| 328 | return rc; |
| 329 | } |
Michael Holzheu | 411ed32 | 2007-04-27 16:01:49 +0200 | [diff] [blame] | 330 | subsys_initcall(zcore_init); |