Skip to content

Commit f86593b

Browse files
maheshsalmpe
authored andcommitted
powerpc/fadump: Throw proper error message on fadump registration failure
fadump fails to register when there are holes in reserved memory area. This can happen if user has hot-removed a memory that falls in the fadump reserved memory area. Throw a meaningful error message to the user in such case. Signed-off-by: Mahesh Salgaonkar <mahesh@linux.vnet.ibm.com> [mpe: is_reserved_memory_area_contiguous() returns bool, unsplit string] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent a4e92ce commit f86593b

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

arch/powerpc/kernel/fadump.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,35 @@ static int is_boot_memory_area_contiguous(void)
237237
return ret;
238238
}
239239

240+
/*
241+
* Returns true, if there are no holes in reserved memory area,
242+
* false otherwise.
243+
*/
244+
static bool is_reserved_memory_area_contiguous(void)
245+
{
246+
struct memblock_region *reg;
247+
unsigned long start, end;
248+
unsigned long d_start = fw_dump.reserve_dump_area_start;
249+
unsigned long d_end = d_start + fw_dump.reserve_dump_area_size;
250+
251+
for_each_memblock(memory, reg) {
252+
start = max(d_start, (unsigned long)reg->base);
253+
end = min(d_end, (unsigned long)(reg->base + reg->size));
254+
if (d_start < end) {
255+
/* Memory hole from d_start to start */
256+
if (start > d_start)
257+
break;
258+
259+
if (end == d_end)
260+
return true;
261+
262+
d_start = end + 1;
263+
}
264+
}
265+
266+
return false;
267+
}
268+
240269
/* Print firmware assisted dump configurations for debugging purpose. */
241270
static void fadump_show_config(void)
242271
{
@@ -603,8 +632,10 @@ static int register_fw_dump(struct fadump_mem_struct *fdm)
603632
break;
604633
case -3:
605634
if (!is_boot_memory_area_contiguous())
606-
pr_err("Can't have holes in boot memory area while "
607-
"registering fadump\n");
635+
pr_err("Can't have holes in boot memory area while registering fadump\n");
636+
else if (!is_reserved_memory_area_contiguous())
637+
pr_err("Can't have holes in reserved memory area while"
638+
" registering fadump\n");
608639

609640
printk(KERN_ERR "Failed to register firmware-assisted kernel"
610641
" dump. Parameter Error(%d).\n", rc);

0 commit comments

Comments
 (0)