Thomas Gleixner | 40b0b3f | 2019-06-03 07:44:46 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 2 | /* |
| 3 | * crash.c - kernel crash support code. |
| 4 | * Copyright (C) 2002-2004 Eric Biederman <ebiederm@xmission.com> |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Stephen Boyd | 44e8a5e | 2021-07-07 18:09:49 -0700 | [diff] [blame] | 7 | #include <linux/buildid.h> |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 8 | #include <linux/crash_core.h> |
Philipp Rudo | 71d2bce | 2021-12-24 21:12:39 -0800 | [diff] [blame] | 9 | #include <linux/init.h> |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 10 | #include <linux/utsname.h> |
| 11 | #include <linux/vmalloc.h> |
| 12 | |
| 13 | #include <asm/page.h> |
| 14 | #include <asm/sections.h> |
| 15 | |
Eric Biggers | a24d22b | 2020-11-12 21:20:21 -0800 | [diff] [blame] | 16 | #include <crypto/sha1.h> |
Vijay Balakrishna | 0935288 | 2020-08-11 18:36:33 -0700 | [diff] [blame] | 17 | |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 18 | /* vmcoreinfo stuff */ |
Omar Sandoval | 23c8509 | 2018-08-21 21:55:20 -0700 | [diff] [blame] | 19 | unsigned char *vmcoreinfo_data; |
| 20 | size_t vmcoreinfo_size; |
Xunlei Pang | 203e9e4 | 2017-07-12 14:33:14 -0700 | [diff] [blame] | 21 | u32 *vmcoreinfo_note; |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 22 | |
Xunlei Pang | 1229384 | 2017-07-12 14:33:21 -0700 | [diff] [blame] | 23 | /* trusted vmcoreinfo, e.g. we can make a copy in the crash memory */ |
| 24 | static unsigned char *vmcoreinfo_data_safecopy; |
| 25 | |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 26 | /* |
| 27 | * parsing the "crashkernel" commandline |
| 28 | * |
| 29 | * this code is intended to be called from architecture specific code |
| 30 | */ |
| 31 | |
| 32 | |
| 33 | /* |
| 34 | * This function parses command lines in the format |
| 35 | * |
| 36 | * crashkernel=ramsize-range:size[,...][@offset] |
| 37 | * |
| 38 | * The function returns 0 on success and -EINVAL on failure. |
| 39 | */ |
| 40 | static int __init parse_crashkernel_mem(char *cmdline, |
| 41 | unsigned long long system_ram, |
| 42 | unsigned long long *crash_size, |
| 43 | unsigned long long *crash_base) |
| 44 | { |
| 45 | char *cur = cmdline, *tmp; |
| 46 | |
| 47 | /* for each entry of the comma-separated list */ |
| 48 | do { |
| 49 | unsigned long long start, end = ULLONG_MAX, size; |
| 50 | |
| 51 | /* get the start of the range */ |
| 52 | start = memparse(cur, &tmp); |
| 53 | if (cur == tmp) { |
| 54 | pr_warn("crashkernel: Memory value expected\n"); |
| 55 | return -EINVAL; |
| 56 | } |
| 57 | cur = tmp; |
| 58 | if (*cur != '-') { |
| 59 | pr_warn("crashkernel: '-' expected\n"); |
| 60 | return -EINVAL; |
| 61 | } |
| 62 | cur++; |
| 63 | |
| 64 | /* if no ':' is here, than we read the end */ |
| 65 | if (*cur != ':') { |
| 66 | end = memparse(cur, &tmp); |
| 67 | if (cur == tmp) { |
| 68 | pr_warn("crashkernel: Memory value expected\n"); |
| 69 | return -EINVAL; |
| 70 | } |
| 71 | cur = tmp; |
| 72 | if (end <= start) { |
| 73 | pr_warn("crashkernel: end <= start\n"); |
| 74 | return -EINVAL; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | if (*cur != ':') { |
| 79 | pr_warn("crashkernel: ':' expected\n"); |
| 80 | return -EINVAL; |
| 81 | } |
| 82 | cur++; |
| 83 | |
| 84 | size = memparse(cur, &tmp); |
| 85 | if (cur == tmp) { |
| 86 | pr_warn("Memory value expected\n"); |
| 87 | return -EINVAL; |
| 88 | } |
| 89 | cur = tmp; |
| 90 | if (size >= system_ram) { |
| 91 | pr_warn("crashkernel: invalid size\n"); |
| 92 | return -EINVAL; |
| 93 | } |
| 94 | |
| 95 | /* match ? */ |
| 96 | if (system_ram >= start && system_ram < end) { |
| 97 | *crash_size = size; |
| 98 | break; |
| 99 | } |
| 100 | } while (*cur++ == ','); |
| 101 | |
| 102 | if (*crash_size > 0) { |
| 103 | while (*cur && *cur != ' ' && *cur != '@') |
| 104 | cur++; |
| 105 | if (*cur == '@') { |
| 106 | cur++; |
| 107 | *crash_base = memparse(cur, &tmp); |
| 108 | if (cur == tmp) { |
| 109 | pr_warn("Memory value expected after '@'\n"); |
| 110 | return -EINVAL; |
| 111 | } |
| 112 | } |
Dave Young | de40cce | 2017-11-17 15:30:12 -0800 | [diff] [blame] | 113 | } else |
| 114 | pr_info("crashkernel size resulted in zero bytes\n"); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 115 | |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | /* |
| 120 | * That function parses "simple" (old) crashkernel command lines like |
| 121 | * |
| 122 | * crashkernel=size[@offset] |
| 123 | * |
| 124 | * It returns 0 on success and -EINVAL on failure. |
| 125 | */ |
| 126 | static int __init parse_crashkernel_simple(char *cmdline, |
| 127 | unsigned long long *crash_size, |
| 128 | unsigned long long *crash_base) |
| 129 | { |
| 130 | char *cur = cmdline; |
| 131 | |
| 132 | *crash_size = memparse(cmdline, &cur); |
| 133 | if (cmdline == cur) { |
| 134 | pr_warn("crashkernel: memory value expected\n"); |
| 135 | return -EINVAL; |
| 136 | } |
| 137 | |
| 138 | if (*cur == '@') |
| 139 | *crash_base = memparse(cur+1, &cur); |
| 140 | else if (*cur != ' ' && *cur != '\0') { |
| 141 | pr_warn("crashkernel: unrecognized char: %c\n", *cur); |
| 142 | return -EINVAL; |
| 143 | } |
| 144 | |
| 145 | return 0; |
| 146 | } |
| 147 | |
| 148 | #define SUFFIX_HIGH 0 |
| 149 | #define SUFFIX_LOW 1 |
| 150 | #define SUFFIX_NULL 2 |
| 151 | static __initdata char *suffix_tbl[] = { |
| 152 | [SUFFIX_HIGH] = ",high", |
| 153 | [SUFFIX_LOW] = ",low", |
| 154 | [SUFFIX_NULL] = NULL, |
| 155 | }; |
| 156 | |
| 157 | /* |
| 158 | * That function parses "suffix" crashkernel command lines like |
| 159 | * |
| 160 | * crashkernel=size,[high|low] |
| 161 | * |
| 162 | * It returns 0 on success and -EINVAL on failure. |
| 163 | */ |
| 164 | static int __init parse_crashkernel_suffix(char *cmdline, |
| 165 | unsigned long long *crash_size, |
| 166 | const char *suffix) |
| 167 | { |
| 168 | char *cur = cmdline; |
| 169 | |
| 170 | *crash_size = memparse(cmdline, &cur); |
| 171 | if (cmdline == cur) { |
| 172 | pr_warn("crashkernel: memory value expected\n"); |
| 173 | return -EINVAL; |
| 174 | } |
| 175 | |
| 176 | /* check with suffix */ |
| 177 | if (strncmp(cur, suffix, strlen(suffix))) { |
| 178 | pr_warn("crashkernel: unrecognized char: %c\n", *cur); |
| 179 | return -EINVAL; |
| 180 | } |
| 181 | cur += strlen(suffix); |
| 182 | if (*cur != ' ' && *cur != '\0') { |
| 183 | pr_warn("crashkernel: unrecognized char: %c\n", *cur); |
| 184 | return -EINVAL; |
| 185 | } |
| 186 | |
| 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | static __init char *get_last_crashkernel(char *cmdline, |
| 191 | const char *name, |
| 192 | const char *suffix) |
| 193 | { |
| 194 | char *p = cmdline, *ck_cmdline = NULL; |
| 195 | |
| 196 | /* find crashkernel and use the last one if there are more */ |
| 197 | p = strstr(p, name); |
| 198 | while (p) { |
| 199 | char *end_p = strchr(p, ' '); |
| 200 | char *q; |
| 201 | |
| 202 | if (!end_p) |
| 203 | end_p = p + strlen(p); |
| 204 | |
| 205 | if (!suffix) { |
| 206 | int i; |
| 207 | |
| 208 | /* skip the one with any known suffix */ |
| 209 | for (i = 0; suffix_tbl[i]; i++) { |
| 210 | q = end_p - strlen(suffix_tbl[i]); |
| 211 | if (!strncmp(q, suffix_tbl[i], |
| 212 | strlen(suffix_tbl[i]))) |
| 213 | goto next; |
| 214 | } |
| 215 | ck_cmdline = p; |
| 216 | } else { |
| 217 | q = end_p - strlen(suffix); |
| 218 | if (!strncmp(q, suffix, strlen(suffix))) |
| 219 | ck_cmdline = p; |
| 220 | } |
| 221 | next: |
| 222 | p = strstr(p+1, name); |
| 223 | } |
| 224 | |
| 225 | if (!ck_cmdline) |
| 226 | return NULL; |
| 227 | |
| 228 | return ck_cmdline; |
| 229 | } |
| 230 | |
| 231 | static int __init __parse_crashkernel(char *cmdline, |
| 232 | unsigned long long system_ram, |
| 233 | unsigned long long *crash_size, |
| 234 | unsigned long long *crash_base, |
| 235 | const char *name, |
| 236 | const char *suffix) |
| 237 | { |
| 238 | char *first_colon, *first_space; |
| 239 | char *ck_cmdline; |
| 240 | |
| 241 | BUG_ON(!crash_size || !crash_base); |
| 242 | *crash_size = 0; |
| 243 | *crash_base = 0; |
| 244 | |
| 245 | ck_cmdline = get_last_crashkernel(cmdline, name, suffix); |
| 246 | |
| 247 | if (!ck_cmdline) |
| 248 | return -EINVAL; |
| 249 | |
| 250 | ck_cmdline += strlen(name); |
| 251 | |
| 252 | if (suffix) |
| 253 | return parse_crashkernel_suffix(ck_cmdline, crash_size, |
| 254 | suffix); |
| 255 | /* |
| 256 | * if the commandline contains a ':', then that's the extended |
| 257 | * syntax -- if not, it must be the classic syntax |
| 258 | */ |
| 259 | first_colon = strchr(ck_cmdline, ':'); |
| 260 | first_space = strchr(ck_cmdline, ' '); |
| 261 | if (first_colon && (!first_space || first_colon < first_space)) |
| 262 | return parse_crashkernel_mem(ck_cmdline, system_ram, |
| 263 | crash_size, crash_base); |
| 264 | |
| 265 | return parse_crashkernel_simple(ck_cmdline, crash_size, crash_base); |
| 266 | } |
| 267 | |
| 268 | /* |
| 269 | * That function is the entry point for command line parsing and should be |
| 270 | * called from the arch-specific code. |
| 271 | */ |
| 272 | int __init parse_crashkernel(char *cmdline, |
| 273 | unsigned long long system_ram, |
| 274 | unsigned long long *crash_size, |
| 275 | unsigned long long *crash_base) |
| 276 | { |
| 277 | return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, |
| 278 | "crashkernel=", NULL); |
| 279 | } |
| 280 | |
| 281 | int __init parse_crashkernel_high(char *cmdline, |
| 282 | unsigned long long system_ram, |
| 283 | unsigned long long *crash_size, |
| 284 | unsigned long long *crash_base) |
| 285 | { |
| 286 | return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, |
| 287 | "crashkernel=", suffix_tbl[SUFFIX_HIGH]); |
| 288 | } |
| 289 | |
| 290 | int __init parse_crashkernel_low(char *cmdline, |
| 291 | unsigned long long system_ram, |
| 292 | unsigned long long *crash_size, |
| 293 | unsigned long long *crash_base) |
| 294 | { |
| 295 | return __parse_crashkernel(cmdline, system_ram, crash_size, crash_base, |
| 296 | "crashkernel=", suffix_tbl[SUFFIX_LOW]); |
| 297 | } |
| 298 | |
Philipp Rudo | 71d2bce | 2021-12-24 21:12:39 -0800 | [diff] [blame] | 299 | /* |
| 300 | * Add a dummy early_param handler to mark crashkernel= as a known command line |
| 301 | * parameter and suppress incorrect warnings in init/main.c. |
| 302 | */ |
| 303 | static int __init parse_crashkernel_dummy(char *arg) |
| 304 | { |
| 305 | return 0; |
| 306 | } |
| 307 | early_param("crashkernel", parse_crashkernel_dummy); |
| 308 | |
Hari Bathini | 51dbd92 | 2017-05-08 15:56:21 -0700 | [diff] [blame] | 309 | Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type, |
| 310 | void *data, size_t data_len) |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 311 | { |
Hari Bathini | 51dbd92 | 2017-05-08 15:56:21 -0700 | [diff] [blame] | 312 | struct elf_note *note = (struct elf_note *)buf; |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 313 | |
Hari Bathini | 51dbd92 | 2017-05-08 15:56:21 -0700 | [diff] [blame] | 314 | note->n_namesz = strlen(name) + 1; |
| 315 | note->n_descsz = data_len; |
| 316 | note->n_type = type; |
| 317 | buf += DIV_ROUND_UP(sizeof(*note), sizeof(Elf_Word)); |
| 318 | memcpy(buf, name, note->n_namesz); |
| 319 | buf += DIV_ROUND_UP(note->n_namesz, sizeof(Elf_Word)); |
| 320 | memcpy(buf, data, data_len); |
| 321 | buf += DIV_ROUND_UP(data_len, sizeof(Elf_Word)); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 322 | |
| 323 | return buf; |
| 324 | } |
| 325 | |
Hari Bathini | 51dbd92 | 2017-05-08 15:56:21 -0700 | [diff] [blame] | 326 | void final_note(Elf_Word *buf) |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 327 | { |
Hari Bathini | 51dbd92 | 2017-05-08 15:56:21 -0700 | [diff] [blame] | 328 | memset(buf, 0, sizeof(struct elf_note)); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | static void update_vmcoreinfo_note(void) |
| 332 | { |
| 333 | u32 *buf = vmcoreinfo_note; |
| 334 | |
| 335 | if (!vmcoreinfo_size) |
| 336 | return; |
| 337 | buf = append_elf_note(buf, VMCOREINFO_NOTE_NAME, 0, vmcoreinfo_data, |
| 338 | vmcoreinfo_size); |
| 339 | final_note(buf); |
| 340 | } |
| 341 | |
Xunlei Pang | 1229384 | 2017-07-12 14:33:21 -0700 | [diff] [blame] | 342 | void crash_update_vmcoreinfo_safecopy(void *ptr) |
| 343 | { |
| 344 | if (ptr) |
| 345 | memcpy(ptr, vmcoreinfo_data, vmcoreinfo_size); |
| 346 | |
| 347 | vmcoreinfo_data_safecopy = ptr; |
| 348 | } |
| 349 | |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 350 | void crash_save_vmcoreinfo(void) |
| 351 | { |
Xunlei Pang | 203e9e4 | 2017-07-12 14:33:14 -0700 | [diff] [blame] | 352 | if (!vmcoreinfo_note) |
| 353 | return; |
| 354 | |
Xunlei Pang | 1229384 | 2017-07-12 14:33:21 -0700 | [diff] [blame] | 355 | /* Use the safe copy to generate vmcoreinfo note if have */ |
| 356 | if (vmcoreinfo_data_safecopy) |
| 357 | vmcoreinfo_data = vmcoreinfo_data_safecopy; |
| 358 | |
Arnd Bergmann | 91bc9aa | 2018-08-21 21:55:49 -0700 | [diff] [blame] | 359 | vmcoreinfo_append_str("CRASHTIME=%lld\n", ktime_get_real_seconds()); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 360 | update_vmcoreinfo_note(); |
| 361 | } |
| 362 | |
| 363 | void vmcoreinfo_append_str(const char *fmt, ...) |
| 364 | { |
| 365 | va_list args; |
| 366 | char buf[0x50]; |
| 367 | size_t r; |
| 368 | |
| 369 | va_start(args, fmt); |
| 370 | r = vscnprintf(buf, sizeof(buf), fmt, args); |
| 371 | va_end(args); |
| 372 | |
Xunlei Pang | 5203f49 | 2017-07-12 14:33:17 -0700 | [diff] [blame] | 373 | r = min(r, (size_t)VMCOREINFO_BYTES - vmcoreinfo_size); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 374 | |
| 375 | memcpy(&vmcoreinfo_data[vmcoreinfo_size], buf, r); |
| 376 | |
| 377 | vmcoreinfo_size += r; |
| 378 | } |
| 379 | |
| 380 | /* |
| 381 | * provide an empty default implementation here -- architecture |
| 382 | * code may override this |
| 383 | */ |
| 384 | void __weak arch_crash_save_vmcoreinfo(void) |
| 385 | {} |
| 386 | |
| 387 | phys_addr_t __weak paddr_vmcoreinfo_note(void) |
| 388 | { |
Xunlei Pang | 203e9e4 | 2017-07-12 14:33:14 -0700 | [diff] [blame] | 389 | return __pa(vmcoreinfo_note); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 390 | } |
Marc-André Lureau | 43d4cb4 | 2018-02-28 16:06:13 +0100 | [diff] [blame] | 391 | EXPORT_SYMBOL(paddr_vmcoreinfo_note); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 392 | |
| 393 | static int __init crash_save_vmcoreinfo_init(void) |
| 394 | { |
Xunlei Pang | 203e9e4 | 2017-07-12 14:33:14 -0700 | [diff] [blame] | 395 | vmcoreinfo_data = (unsigned char *)get_zeroed_page(GFP_KERNEL); |
| 396 | if (!vmcoreinfo_data) { |
| 397 | pr_warn("Memory allocation for vmcoreinfo_data failed\n"); |
| 398 | return -ENOMEM; |
| 399 | } |
| 400 | |
| 401 | vmcoreinfo_note = alloc_pages_exact(VMCOREINFO_NOTE_SIZE, |
| 402 | GFP_KERNEL | __GFP_ZERO); |
| 403 | if (!vmcoreinfo_note) { |
| 404 | free_page((unsigned long)vmcoreinfo_data); |
| 405 | vmcoreinfo_data = NULL; |
| 406 | pr_warn("Memory allocation for vmcoreinfo_note failed\n"); |
| 407 | return -ENOMEM; |
| 408 | } |
| 409 | |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 410 | VMCOREINFO_OSRELEASE(init_uts_ns.name.release); |
Stephen Boyd | 44e8a5e | 2021-07-07 18:09:49 -0700 | [diff] [blame] | 411 | VMCOREINFO_BUILD_ID(); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 412 | VMCOREINFO_PAGESIZE(PAGE_SIZE); |
| 413 | |
| 414 | VMCOREINFO_SYMBOL(init_uts_ns); |
Alexander Egorenkov | ca4a924 | 2020-12-15 20:45:31 -0800 | [diff] [blame] | 415 | VMCOREINFO_OFFSET(uts_namespace, name); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 416 | VMCOREINFO_SYMBOL(node_online_map); |
| 417 | #ifdef CONFIG_MMU |
Omar Sandoval | eff4345 | 2018-08-21 21:55:17 -0700 | [diff] [blame] | 418 | VMCOREINFO_SYMBOL_ARRAY(swapper_pg_dir); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 419 | #endif |
| 420 | VMCOREINFO_SYMBOL(_stext); |
| 421 | VMCOREINFO_SYMBOL(vmap_area_list); |
| 422 | |
Mike Rapoport | a9ee6cf | 2021-06-28 19:43:01 -0700 | [diff] [blame] | 423 | #ifndef CONFIG_NUMA |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 424 | VMCOREINFO_SYMBOL(mem_map); |
| 425 | VMCOREINFO_SYMBOL(contig_page_data); |
| 426 | #endif |
| 427 | #ifdef CONFIG_SPARSEMEM |
Kirill A. Shutemov | a0b1280 | 2018-01-12 16:53:14 -0800 | [diff] [blame] | 428 | VMCOREINFO_SYMBOL_ARRAY(mem_section); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 429 | VMCOREINFO_LENGTH(mem_section, NR_SECTION_ROOTS); |
| 430 | VMCOREINFO_STRUCT_SIZE(mem_section); |
| 431 | VMCOREINFO_OFFSET(mem_section, section_mem_map); |
Pingfan Liu | 4f5aecd | 2021-06-15 18:23:36 -0700 | [diff] [blame] | 432 | VMCOREINFO_NUMBER(SECTION_SIZE_BITS); |
Bhupesh Sharma | 1d50e5d | 2020-05-14 00:22:36 +0530 | [diff] [blame] | 433 | VMCOREINFO_NUMBER(MAX_PHYSMEM_BITS); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 434 | #endif |
| 435 | VMCOREINFO_STRUCT_SIZE(page); |
| 436 | VMCOREINFO_STRUCT_SIZE(pglist_data); |
| 437 | VMCOREINFO_STRUCT_SIZE(zone); |
| 438 | VMCOREINFO_STRUCT_SIZE(free_area); |
| 439 | VMCOREINFO_STRUCT_SIZE(list_head); |
| 440 | VMCOREINFO_SIZE(nodemask_t); |
| 441 | VMCOREINFO_OFFSET(page, flags); |
| 442 | VMCOREINFO_OFFSET(page, _refcount); |
| 443 | VMCOREINFO_OFFSET(page, mapping); |
| 444 | VMCOREINFO_OFFSET(page, lru); |
| 445 | VMCOREINFO_OFFSET(page, _mapcount); |
| 446 | VMCOREINFO_OFFSET(page, private); |
| 447 | VMCOREINFO_OFFSET(page, compound_dtor); |
| 448 | VMCOREINFO_OFFSET(page, compound_order); |
| 449 | VMCOREINFO_OFFSET(page, compound_head); |
| 450 | VMCOREINFO_OFFSET(pglist_data, node_zones); |
| 451 | VMCOREINFO_OFFSET(pglist_data, nr_zones); |
Mike Rapoport | 43b02ba | 2021-06-28 19:43:05 -0700 | [diff] [blame] | 452 | #ifdef CONFIG_FLATMEM |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 453 | VMCOREINFO_OFFSET(pglist_data, node_mem_map); |
| 454 | #endif |
| 455 | VMCOREINFO_OFFSET(pglist_data, node_start_pfn); |
| 456 | VMCOREINFO_OFFSET(pglist_data, node_spanned_pages); |
| 457 | VMCOREINFO_OFFSET(pglist_data, node_id); |
| 458 | VMCOREINFO_OFFSET(zone, free_area); |
| 459 | VMCOREINFO_OFFSET(zone, vm_stat); |
| 460 | VMCOREINFO_OFFSET(zone, spanned_pages); |
| 461 | VMCOREINFO_OFFSET(free_area, free_list); |
| 462 | VMCOREINFO_OFFSET(list_head, next); |
| 463 | VMCOREINFO_OFFSET(list_head, prev); |
| 464 | VMCOREINFO_OFFSET(vmap_area, va_start); |
| 465 | VMCOREINFO_OFFSET(vmap_area, list); |
| 466 | VMCOREINFO_LENGTH(zone.free_area, MAX_ORDER); |
| 467 | log_buf_vmcoreinfo_setup(); |
| 468 | VMCOREINFO_LENGTH(free_area.free_list, MIGRATE_TYPES); |
| 469 | VMCOREINFO_NUMBER(NR_FREE_PAGES); |
| 470 | VMCOREINFO_NUMBER(PG_lru); |
| 471 | VMCOREINFO_NUMBER(PG_private); |
| 472 | VMCOREINFO_NUMBER(PG_swapcache); |
Petr Tesarik | 1cbf29d | 2018-04-13 15:35:34 -0700 | [diff] [blame] | 473 | VMCOREINFO_NUMBER(PG_swapbacked); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 474 | VMCOREINFO_NUMBER(PG_slab); |
| 475 | #ifdef CONFIG_MEMORY_FAILURE |
| 476 | VMCOREINFO_NUMBER(PG_hwpoison); |
| 477 | #endif |
| 478 | VMCOREINFO_NUMBER(PG_head_mask); |
Matthew Wilcox | 6e292b9 | 2018-06-07 17:08:18 -0700 | [diff] [blame] | 479 | #define PAGE_BUDDY_MAPCOUNT_VALUE (~PG_buddy) |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 480 | VMCOREINFO_NUMBER(PAGE_BUDDY_MAPCOUNT_VALUE); |
| 481 | #ifdef CONFIG_HUGETLB_PAGE |
| 482 | VMCOREINFO_NUMBER(HUGETLB_PAGE_DTOR); |
David Hildenbrand | e04b742 | 2019-03-05 15:42:27 -0800 | [diff] [blame] | 483 | #define PAGE_OFFLINE_MAPCOUNT_VALUE (~PG_offline) |
| 484 | VMCOREINFO_NUMBER(PAGE_OFFLINE_MAPCOUNT_VALUE); |
Hari Bathini | 692f66f | 2017-05-08 15:56:18 -0700 | [diff] [blame] | 485 | #endif |
| 486 | |
| 487 | arch_crash_save_vmcoreinfo(); |
| 488 | update_vmcoreinfo_note(); |
| 489 | |
| 490 | return 0; |
| 491 | } |
| 492 | |
| 493 | subsys_initcall(crash_save_vmcoreinfo_init); |