Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

crash: use macro to add crashk_res into iomem early for specific arch

There are regression reports[1][2] that crashkernel region on x86_64 can't
be added into iomem tree sometime. This causes the later failure of kdump
loading.

This happened after commit 4a693ce65b18 ("kdump: defer the insertion of
crashkernel resources") was merged.

Even though, these reported issues are proved to be related to other
component, they are just exposed after above commmit applied, I still
would like to keep crashk_res and crashk_low_res being added into iomem
early as before because the early adding has been always there on x86_64
and working very well. For safety of kdump, Let's change it back.

Here, add a macro HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY to limit that
only ARCH defining the macro can have the early adding
crashk_res/_low_res into iomem. Then define
HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY on x86 to enable it.

Note: In reserve_crashkernel_low(), there's a remnant of crashk_low_res
handling which was mistakenly added back in commit 85fcde402db1 ("kexec:
split crashkernel reservation code out from crash_core.c").

[1]
[PATCH V2] x86/kexec: do not update E820 kexec table for setup_data
https://lore.kernel.org/all/Zfv8iCL6CT2JqLIC@darkstar.users.ipa.redhat.com/T/#u

[2]
Question about Address Range Validation in Crash Kernel Allocation
https://lore.kernel.org/all/4eeac1f733584855965a2ea62fa4da58@huawei.com/T/#u

Link: https://lkml.kernel.org/r/ZgDYemRQ2jxjLkq+@MiWiFi-R3L-srv
Fixes: 4a693ce65b18 ("kdump: defer the insertion of crashkernel resources")
Signed-off-by: Baoquan He <bhe@redhat.com>
Cc: Dave Young <dyoung@redhat.com>
Cc: Huacai Chen <chenhuacai@loongson.cn>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Bohac <jbohac@suse.cz>
Cc: Li Huafei <lihuafei1@huawei.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Baoquan He and committed by
Andrew Morton
32fbe524 25cd2414

+9
+2
arch/x86/include/asm/crash_reserve.h
··· 39 39 #endif 40 40 } 41 41 42 + #define HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY 43 + 42 44 #endif /* _X86_CRASH_RESERVE_H */
+7
kernel/crash_reserve.c
··· 366 366 367 367 crashk_low_res.start = low_base; 368 368 crashk_low_res.end = low_base + low_size - 1; 369 + #ifdef HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY 369 370 insert_resource(&iomem_resource, &crashk_low_res); 371 + #endif 370 372 #endif 371 373 return 0; 372 374 } ··· 450 448 451 449 crashk_res.start = crash_base; 452 450 crashk_res.end = crash_base + crash_size - 1; 451 + #ifdef HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY 452 + insert_resource(&iomem_resource, &crashk_res); 453 + #endif 453 454 } 454 455 456 + #ifndef HAVE_ARCH_ADD_CRASH_RES_TO_IOMEM_EARLY 455 457 static __init int insert_crashkernel_resources(void) 456 458 { 457 459 if (crashk_res.start < crashk_res.end) ··· 467 461 return 0; 468 462 } 469 463 early_initcall(insert_crashkernel_resources); 464 + #endif 470 465 #endif