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

Configure Feed

Select the types of activity you want to include in your feed.

crash_core: change parse_crashkernel() to support crashkernel=,high|low parsing

Now parse_crashkernel() is a real entry point for all kinds of crahskernel
parsing on any architecture.

And wrap the crahskernel=,high|low handling inside
CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION ifdeffery scope.

Link: https://lkml.kernel.org/r/20230914033142.676708-4-bhe@redhat.com
Signed-off-by: Baoquan He <bhe@redhat.com>
Reviewed-by: Zhen Lei <thunder.leizhen@huawei.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Chen Jiahao <chenjiahao16@huawei.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Baoquan He and committed by
Andrew Morton
70916e9c a9e1a3d8

+39 -3
+6
include/linux/crash_core.h
··· 79 79 void *data, size_t data_len); 80 80 void final_note(Elf_Word *buf); 81 81 82 + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 83 + #ifndef DEFAULT_CRASH_KERNEL_LOW_SIZE 84 + #define DEFAULT_CRASH_KERNEL_LOW_SIZE (128UL << 20) 85 + #endif 86 + #endif 87 + 82 88 int __init parse_crashkernel(char *cmdline, unsigned long long system_ram, 83 89 unsigned long long *crash_size, unsigned long long *crash_base, 84 90 unsigned long long *low_size, bool *high);
+33 -3
kernel/crash_core.c
··· 283 283 /* 284 284 * That function is the entry point for command line parsing and should be 285 285 * called from the arch-specific code. 286 + * 287 + * If crashkernel=,high|low is supported on architecture, non-NULL values 288 + * should be passed to parameters 'low_size' and 'high'. 286 289 */ 287 290 int __init parse_crashkernel(char *cmdline, 288 291 unsigned long long system_ram, ··· 299 296 /* crashkernel=X[@offset] */ 300 297 ret = __parse_crashkernel(cmdline, system_ram, crash_size, 301 298 crash_base, NULL); 302 - if (!high) 303 - return ret; 299 + #ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION 300 + /* 301 + * If non-NULL 'high' passed in and no normal crashkernel 302 + * setting detected, try parsing crashkernel=,high|low. 303 + */ 304 + if (high && ret == -ENOENT) { 305 + ret = __parse_crashkernel(cmdline, 0, crash_size, 306 + crash_base, suffix_tbl[SUFFIX_HIGH]); 307 + if (ret || !*crash_size) 308 + return -EINVAL; 304 309 305 - return 0; 310 + /* 311 + * crashkernel=Y,low can be specified or not, but invalid value 312 + * is not allowed. 313 + */ 314 + ret = __parse_crashkernel(cmdline, 0, low_size, 315 + crash_base, suffix_tbl[SUFFIX_LOW]); 316 + if (ret == -ENOENT) { 317 + *low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE; 318 + ret = 0; 319 + } else if (ret) { 320 + return ret; 321 + } 322 + 323 + *high = true; 324 + } 325 + #endif 326 + if (!*crash_size) 327 + ret = -EINVAL; 328 + 329 + return ret; 306 330 } 307 331 308 332 int __init parse_crashkernel_high(char *cmdline,