Skip to content

Commit 70916e9

Browse files
Baoquan Heakpm00
authored andcommitted
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/[email protected] Signed-off-by: Baoquan He <[email protected]> Reviewed-by: Zhen Lei <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Chen Jiahao <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent a9e1a3d commit 70916e9

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

include/linux/crash_core.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ Elf_Word *append_elf_note(Elf_Word *buf, char *name, unsigned int type,
7979
void *data, size_t data_len);
8080
void final_note(Elf_Word *buf);
8181

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+
8288
int __init parse_crashkernel(char *cmdline, unsigned long long system_ram,
8389
unsigned long long *crash_size, unsigned long long *crash_base,
8490
unsigned long long *low_size, bool *high);

kernel/crash_core.c

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,9 @@ static int __init __parse_crashkernel(char *cmdline,
283283
/*
284284
* That function is the entry point for command line parsing and should be
285285
* 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'.
286289
*/
287290
int __init parse_crashkernel(char *cmdline,
288291
unsigned long long system_ram,
@@ -296,10 +299,37 @@ int __init parse_crashkernel(char *cmdline,
296299
/* crashkernel=X[@offset] */
297300
ret = __parse_crashkernel(cmdline, system_ram, crash_size,
298301
crash_base, NULL);
299-
if (!high)
300-
return ret;
302+
#ifdef CONFIG_ARCH_HAS_GENERIC_CRASHKERNEL_RESERVATION
303+
/*
304+
* If non-NULL 'high' passed in and no normal crashkernel
305+
* setting detected, try parsing crashkernel=,high|low.
306+
*/
307+
if (high && ret == -ENOENT) {
308+
ret = __parse_crashkernel(cmdline, 0, crash_size,
309+
crash_base, suffix_tbl[SUFFIX_HIGH]);
310+
if (ret || !*crash_size)
311+
return -EINVAL;
301312

302-
return 0;
313+
/*
314+
* crashkernel=Y,low can be specified or not, but invalid value
315+
* is not allowed.
316+
*/
317+
ret = __parse_crashkernel(cmdline, 0, low_size,
318+
crash_base, suffix_tbl[SUFFIX_LOW]);
319+
if (ret == -ENOENT) {
320+
*low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE;
321+
ret = 0;
322+
} else if (ret) {
323+
return ret;
324+
}
325+
326+
*high = true;
327+
}
328+
#endif
329+
if (!*crash_size)
330+
ret = -EINVAL;
331+
332+
return ret;
303333
}
304334

305335
int __init parse_crashkernel_high(char *cmdline,

0 commit comments

Comments
 (0)