Skip to content

Commit 3416c9d

Browse files
hbathinimpe
authored andcommitted
powerpc/fadump: pass additional parameters when fadump is active
Append the additional parameters passed/set in the dedicated parameter area (RTAS_FADUMP_PARAM_AREA) to bootargs in fadump capture kernel. Signed-off-by: Hari Bathini <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://msgid.link/[email protected]
1 parent 683eab9 commit 3416c9d

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

arch/powerpc/include/asm/fadump.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ extern int is_fadump_active(void);
1919
extern int should_fadump_crash(void);
2020
extern void crash_fadump(struct pt_regs *, const char *);
2121
extern void fadump_cleanup(void);
22+
extern void fadump_append_bootargs(void);
2223

2324
#else /* CONFIG_FA_DUMP */
2425
static inline int is_fadump_active(void) { return 0; }
2526
static inline int should_fadump_crash(void) { return 0; }
2627
static inline void crash_fadump(struct pt_regs *regs, const char *str) { }
2728
static inline void fadump_cleanup(void) { }
29+
static inline void fadump_append_bootargs(void) { }
2830
#endif /* !CONFIG_FA_DUMP */
2931

3032
#if defined(CONFIG_FA_DUMP) || defined(CONFIG_PRESERVE_FA_DUMP)

arch/powerpc/kernel/fadump.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,41 @@ static int __init fadump_cma_init(void)
131131
static int __init fadump_cma_init(void) { return 1; }
132132
#endif /* CONFIG_CMA */
133133

134+
/*
135+
* Additional parameters meant for capture kernel are placed in a dedicated area.
136+
* If this is capture kernel boot, append these parameters to bootargs.
137+
*/
138+
void __init fadump_append_bootargs(void)
139+
{
140+
char *append_args;
141+
size_t len;
142+
143+
if (!fw_dump.dump_active || !fw_dump.param_area_supported || !fw_dump.param_area)
144+
return;
145+
146+
if (fw_dump.param_area >= fw_dump.boot_mem_top) {
147+
if (memblock_reserve(fw_dump.param_area, COMMAND_LINE_SIZE)) {
148+
pr_warn("WARNING: Can't use additional parameters area!\n");
149+
fw_dump.param_area = 0;
150+
return;
151+
}
152+
}
153+
154+
append_args = (char *)fw_dump.param_area;
155+
len = strlen(boot_command_line);
156+
157+
/*
158+
* Too late to fail even if cmdline size exceeds. Truncate additional parameters
159+
* to cmdline size and proceed anyway.
160+
*/
161+
if (len + strlen(append_args) >= COMMAND_LINE_SIZE - 1)
162+
pr_warn("WARNING: Appending parameters exceeds cmdline size. Truncating!\n");
163+
164+
pr_debug("Cmdline: %s\n", boot_command_line);
165+
snprintf(boot_command_line + len, COMMAND_LINE_SIZE - len, " %s", append_args);
166+
pr_info("Updated cmdline: %s\n", boot_command_line);
167+
}
168+
134169
/* Scan the Firmware Assisted dump configuration details. */
135170
int __init early_init_dt_scan_fw_dump(unsigned long node, const char *uname,
136171
int depth, void *data)

arch/powerpc/kernel/prom.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,9 @@ void __init early_init_devtree(void *params)
813813
*/
814814
of_scan_flat_dt(early_init_dt_scan_chosen_ppc, boot_command_line);
815815

816+
/* Append additional parameters passed for fadump capture kernel */
817+
fadump_append_bootargs();
818+
816819
/* Scan memory nodes and rebuild MEMBLOCKs */
817820
early_init_dt_scan_root();
818821
early_init_dt_scan_memory_ppc();

0 commit comments

Comments
 (0)