Skip to content

Commit

Permalink
From patchwork series 432559
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox Snowpatch committed Nov 15, 2024
1 parent ad0be02 commit 8561a48
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 2 additions & 0 deletions arch/powerpc/include/asm/fadump.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@ extern int is_fadump_active(void);
extern int should_fadump_crash(void);
extern void crash_fadump(struct pt_regs *, const char *);
extern void fadump_cleanup(void);
void fadump_setup_param_area(void);
extern void fadump_append_bootargs(void);

#else /* CONFIG_FA_DUMP */
static inline int is_fadump_active(void) { return 0; }
static inline int should_fadump_crash(void) { return 0; }
static inline void crash_fadump(struct pt_regs *regs, const char *str) { }
static inline void fadump_cleanup(void) { }
static inline void fadump_setup_param_area(void) { }
static inline void fadump_append_bootargs(void) { }
#endif /* !CONFIG_FA_DUMP */

Expand Down
17 changes: 11 additions & 6 deletions arch/powerpc/kernel/fadump.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void __init fadump_append_bootargs(void)
if (!fw_dump.dump_active || !fw_dump.param_area_supported || !fw_dump.param_area)
return;

if (fw_dump.param_area >= fw_dump.boot_mem_top) {
if (fw_dump.param_area < fw_dump.boot_mem_top) {
if (memblock_reserve(fw_dump.param_area, COMMAND_LINE_SIZE)) {
pr_warn("WARNING: Can't use additional parameters area!\n");
fw_dump.param_area = 0;
Expand Down Expand Up @@ -1587,6 +1587,12 @@ static void __init fadump_init_files(void)
return;
}

if (fw_dump.param_area) {
rc = sysfs_create_file(fadump_kobj, &bootargs_append_attr.attr);
if (rc)
pr_err("unable to create bootargs_append sysfs file (%d)\n", rc);
}

debugfs_create_file("fadump_region", 0444, arch_debugfs_dir, NULL,
&fadump_region_fops);

Expand Down Expand Up @@ -1741,15 +1747,15 @@ static void __init fadump_process(void)
* Reserve memory to store additional parameters to be passed
* for fadump/capture kernel.
*/
static void __init fadump_setup_param_area(void)
void __init fadump_setup_param_area(void)
{
phys_addr_t range_start, range_end;

if (!fw_dump.param_area_supported || fw_dump.dump_active)
return;

/* This memory can't be used by PFW or bootloader as it is shared across kernels */
if (radix_enabled()) {
if (early_radix_enabled()) {
/*
* Anywhere in the upper half should be good enough as all memory
* is accessible in real mode.
Expand Down Expand Up @@ -1777,12 +1783,12 @@ static void __init fadump_setup_param_area(void)
COMMAND_LINE_SIZE,
range_start,
range_end);
if (!fw_dump.param_area || sysfs_create_file(fadump_kobj, &bootargs_append_attr.attr)) {
if (!fw_dump.param_area) {
pr_warn("WARNING: Could not setup area to pass additional parameters!\n");
return;
}

memset(phys_to_virt(fw_dump.param_area), 0, COMMAND_LINE_SIZE);
memset((void *)fw_dump.param_area, 0, COMMAND_LINE_SIZE);
}

/*
Expand All @@ -1808,7 +1814,6 @@ int __init setup_fadump(void)
}
/* Initialize the kernel dump memory structure and register with f/w */
else if (fw_dump.reserve_dump_area_size) {
fadump_setup_param_area();
fw_dump.ops->fadump_init_mem_struct(&fw_dump);
register_fadump();
}
Expand Down
7 changes: 7 additions & 0 deletions arch/powerpc/kernel/prom.c
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,13 @@ void __init early_init_devtree(void *params)

mmu_early_init_devtree();

/*
* Setup param area for passing additional parameters to the fadump
* capture kernel. Since this depends on the MMU type, the function
* must be called after the MMU type is finalized.
*/
fadump_setup_param_area();

#ifdef CONFIG_PPC_POWERNV
/* Scan and build the list of machine check recoverable ranges */
of_scan_flat_dt(early_init_dt_scan_recoverable_ranges, NULL);
Expand Down

0 comments on commit 8561a48

Please sign in to comment.