fadump.c (41a65d1618238e63be1439871eaf44dc3c6a737c) | fadump.c (8255da95e54519bb74638c2448ac17f4b34fe6f5) |
---|---|
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Firmware Assisted dump: A robust mechanism to get reliable kernel crash 4 * dump with assistance from firmware. This approach does not use kexec, 5 * instead firmware assists in booting the kdump kernel while preserving 6 * memory contents. The most of the code implementation has been adapted 7 * from phyp assisted dump implementation written by Linas Vepstas and 8 * Manish Ahuja --- 377 unchanged lines hidden (view full) --- 386 printk(KERN_INFO "Adjusted memory_limit for firmware-assisted" 387 " dump, now %#016llx\n", memory_limit); 388 } 389 if (memory_limit) 390 memory_boundary = memory_limit; 391 else 392 memory_boundary = memblock_end_of_DRAM(); 393 | 1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Firmware Assisted dump: A robust mechanism to get reliable kernel crash 4 * dump with assistance from firmware. This approach does not use kexec, 5 * instead firmware assists in booting the kdump kernel while preserving 6 * memory contents. The most of the code implementation has been adapted 7 * from phyp assisted dump implementation written by Linas Vepstas and 8 * Manish Ahuja --- 377 unchanged lines hidden (view full) --- 386 printk(KERN_INFO "Adjusted memory_limit for firmware-assisted" 387 " dump, now %#016llx\n", memory_limit); 388 } 389 if (memory_limit) 390 memory_boundary = memory_limit; 391 else 392 memory_boundary = memblock_end_of_DRAM(); 393 |
394 size = get_fadump_area_size(); 395 fw_dump.reserve_dump_area_size = size; |
|
394 if (fw_dump.dump_active) { 395 pr_info("Firmware-assisted dump is active.\n"); 396 397#ifdef CONFIG_HUGETLB_PAGE 398 /* 399 * FADump capture kernel doesn't care much about hugepages. 400 * In fact, handling hugepages in capture kernel is asking for 401 * trouble. So, disable HugeTLB support when fadump is active. --- 9 unchanged lines hidden (view full) --- 411 base = fw_dump.boot_memory_size; 412 size = memory_boundary - base; 413 fadump_reserve_crash_area(base, size); 414 415 fw_dump.fadumphdr_addr = 416 be64_to_cpu(fdm_active->rmr_region.destination_address) + 417 be64_to_cpu(fdm_active->rmr_region.source_len); 418 pr_debug("fadumphdr_addr = %pa\n", &fw_dump.fadumphdr_addr); | 396 if (fw_dump.dump_active) { 397 pr_info("Firmware-assisted dump is active.\n"); 398 399#ifdef CONFIG_HUGETLB_PAGE 400 /* 401 * FADump capture kernel doesn't care much about hugepages. 402 * In fact, handling hugepages in capture kernel is asking for 403 * trouble. So, disable HugeTLB support when fadump is active. --- 9 unchanged lines hidden (view full) --- 413 base = fw_dump.boot_memory_size; 414 size = memory_boundary - base; 415 fadump_reserve_crash_area(base, size); 416 417 fw_dump.fadumphdr_addr = 418 be64_to_cpu(fdm_active->rmr_region.destination_address) + 419 be64_to_cpu(fdm_active->rmr_region.source_len); 420 pr_debug("fadumphdr_addr = %pa\n", &fw_dump.fadumphdr_addr); |
419 fw_dump.reserve_dump_area_start = base; 420 fw_dump.reserve_dump_area_size = size; 421 } else { 422 size = get_fadump_area_size(); | |
423 424 /* | 421 422 /* |
423 * Start address of reserve dump area (permanent reservation) 424 * for re-registering FADump after dump capture. 425 */ 426 fw_dump.reserve_dump_area_start = 427 be64_to_cpu(fdm_active->cpu_state_data.destination_address); 428 } else { 429 /* |
|
425 * Reserve memory at an offset closer to bottom of the RAM to 426 * minimize the impact of memory hot-remove operation. We can't 427 * use memblock_find_in_range() here since it doesn't allocate 428 * from bottom to top. 429 */ 430 for (base = fw_dump.boot_memory_size; 431 base <= (memory_boundary - size); 432 base += size) { --- 9 unchanged lines hidden (view full) --- 442 443 pr_info("Reserved %ldMB of memory at %ldMB for firmware-" 444 "assisted dump (System RAM: %ldMB)\n", 445 (unsigned long)(size >> 20), 446 (unsigned long)(base >> 20), 447 (unsigned long)(memblock_phys_mem_size() >> 20)); 448 449 fw_dump.reserve_dump_area_start = base; | 430 * Reserve memory at an offset closer to bottom of the RAM to 431 * minimize the impact of memory hot-remove operation. We can't 432 * use memblock_find_in_range() here since it doesn't allocate 433 * from bottom to top. 434 */ 435 for (base = fw_dump.boot_memory_size; 436 base <= (memory_boundary - size); 437 base += size) { --- 9 unchanged lines hidden (view full) --- 447 448 pr_info("Reserved %ldMB of memory at %ldMB for firmware-" 449 "assisted dump (System RAM: %ldMB)\n", 450 (unsigned long)(size >> 20), 451 (unsigned long)(base >> 20), 452 (unsigned long)(memblock_phys_mem_size() >> 20)); 453 454 fw_dump.reserve_dump_area_start = base; |
450 fw_dump.reserve_dump_area_size = size; | |
451 return fadump_cma_init(); 452 } 453 return 1; 454} 455 456unsigned long __init arch_reserved_kernel_pages(void) 457{ 458 return memblock_reserved_size() / PAGE_SIZE; --- 801 unchanged lines hidden (view full) --- 1260 if (end > ra_end) 1261 fadump_release_reserved_area(ra_end, end); 1262 } else 1263 fadump_release_reserved_area(begin, end); 1264} 1265 1266static void fadump_invalidate_release_mem(void) 1267{ | 455 return fadump_cma_init(); 456 } 457 return 1; 458} 459 460unsigned long __init arch_reserved_kernel_pages(void) 461{ 462 return memblock_reserved_size() / PAGE_SIZE; --- 801 unchanged lines hidden (view full) --- 1264 if (end > ra_end) 1265 fadump_release_reserved_area(ra_end, end); 1266 } else 1267 fadump_release_reserved_area(begin, end); 1268} 1269 1270static void fadump_invalidate_release_mem(void) 1271{ |
1268 unsigned long reserved_area_start, reserved_area_end; 1269 unsigned long destination_address; 1270 | |
1271 mutex_lock(&fadump_mutex); 1272 if (!fw_dump.dump_active) { 1273 mutex_unlock(&fadump_mutex); 1274 return; 1275 } 1276 | 1272 mutex_lock(&fadump_mutex); 1273 if (!fw_dump.dump_active) { 1274 mutex_unlock(&fadump_mutex); 1275 return; 1276 } 1277 |
1277 destination_address = be64_to_cpu(fdm_active->cpu_state_data.destination_address); | |
1278 fadump_cleanup(); 1279 mutex_unlock(&fadump_mutex); 1280 | 1278 fadump_cleanup(); 1279 mutex_unlock(&fadump_mutex); 1280 |
1281 /* 1282 * Save the current reserved memory bounds we will require them 1283 * later for releasing the memory for general use. 1284 */ 1285 reserved_area_start = fw_dump.reserve_dump_area_start; 1286 reserved_area_end = reserved_area_start + 1287 fw_dump.reserve_dump_area_size; 1288 /* 1289 * Setup reserve_dump_area_start and its size so that we can 1290 * reuse this reserved memory for Re-registration. 1291 */ 1292 fw_dump.reserve_dump_area_start = destination_address; 1293 fw_dump.reserve_dump_area_size = get_fadump_area_size(); 1294 1295 fadump_release_memory(reserved_area_start, reserved_area_end); | 1281 fadump_release_memory(fw_dump.boot_memory_size, memblock_end_of_DRAM()); |
1296 fadump_free_cpu_notes_buf(); 1297 1298 /* Initialize the kernel dump memory structure for FAD registration. */ 1299 fw_dump.ops->fadump_init_mem_struct(&fw_dump); 1300} 1301 1302static ssize_t fadump_release_memory_store(struct kobject *kobj, 1303 struct kobj_attribute *attr, --- 221 unchanged lines hidden --- | 1282 fadump_free_cpu_notes_buf(); 1283 1284 /* Initialize the kernel dump memory structure for FAD registration. */ 1285 fw_dump.ops->fadump_init_mem_struct(&fw_dump); 1286} 1287 1288static ssize_t fadump_release_memory_store(struct kobject *kobj, 1289 struct kobj_attribute *attr, --- 221 unchanged lines hidden --- |