[PATCH] riscv: kdump: return early for invalid 'crashkernel=0' input

Austin Kim posted 1 patch 1 month, 3 weeks ago
arch/riscv/mm/init.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] riscv: kdump: return early for invalid 'crashkernel=0' input
Posted by Austin Kim 1 month, 3 weeks ago
From: Austin Kim <austin.kim@lge.com>

An invalid 'crashkernel=0' can be specified when running kdump.
By adding a check for 'crashkernel=0', it can return early when detecting
this invalid input.

Signed-off-by: Austin Kim <austin.kim@lge.com>
---
 arch/riscv/mm/init.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
index 811e03786..e61fec445 100644
--- a/arch/riscv/mm/init.c
+++ b/arch/riscv/mm/init.c
@@ -1409,7 +1409,8 @@ static void __init arch_reserve_crashkernel(void)
 	ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
 				&crash_size, &crash_base,
 				&low_size, NULL, &high);
-	if (ret)
+	/* invalid value specified or 'crashkernel=0' */
+	if (ret || !crash_size)
 		return;
 
 	reserve_crashkernel_generic(crash_size, crash_base, low_size, high);
-- 
2.34.1
Re: [PATCH] riscv: kdump: return early for invalid 'crashkernel=0' input
Posted by Paul Walmsley 1 month, 2 weeks ago
Hi,

On Fri, 6 Feb 2026, Austin Kim wrote:

> From: Austin Kim <austin.kim@lge.com>
> 
> An invalid 'crashkernel=0' can be specified when running kdump.
> By adding a check for 'crashkernel=0', it can return early when detecting
> this invalid input.
> 
> Signed-off-by: Austin Kim <austin.kim@lge.com>
> ---
>  arch/riscv/mm/init.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index 811e03786..e61fec445 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -1409,7 +1409,8 @@ static void __init arch_reserve_crashkernel(void)
>  	ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
>  				&crash_size, &crash_base,
>  				&low_size, NULL, &high);
> -	if (ret)
> +	/* invalid value specified or 'crashkernel=0' */
> +	if (ret || !crash_size)
>  		return;
>  
>  	reserve_crashkernel_generic(crash_size, crash_base, low_size, high);

Should this fix the common code in kernel/crash_reserve.c to return an 
error code when crashkernel=0 so it benefits other architectures?


- Paul
Re: [PATCH] riscv: kdump: return early for invalid 'crashkernel=0' input
Posted by Austin Kim 1 month, 2 weeks ago
Hello Paul,

2026년 2월 13일 (금) AM 9:47, Paul Walmsley <pjw@kernel.org>님이 작성:
>
> Hi,
>
> On Fri, 6 Feb 2026, Austin Kim wrote:
>
> > From: Austin Kim <austin.kim@lge.com>
> >
> > An invalid 'crashkernel=0' can be specified when running kdump.
> > By adding a check for 'crashkernel=0', it can return early when detecting
> > this invalid input.
> >
> > Signed-off-by: Austin Kim <austin.kim@lge.com>
> > ---
> >  arch/riscv/mm/init.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> > index 811e03786..e61fec445 100644
> > --- a/arch/riscv/mm/init.c
> > +++ b/arch/riscv/mm/init.c
> > @@ -1409,7 +1409,8 @@ static void __init arch_reserve_crashkernel(void)
> >       ret = parse_crashkernel(boot_command_line, memblock_phys_mem_size(),
> >                               &crash_size, &crash_base,
> >                               &low_size, NULL, &high);
> > -     if (ret)
> > +     /* invalid value specified or 'crashkernel=0' */
> > +     if (ret || !crash_size)
> >               return;
> >
> >       reserve_crashkernel_generic(crash_size, crash_base, low_size, high);
>
> Should this fix the common code in kernel/crash_reserve.c to return an
> error code when crashkernel=0 so it benefits other architectures?

Thanks for another better idea.

I will find out the way to add exception handling for the "crashkernel=0" case
in the generic APIs below.

kernel/crash_reserve.c
static int __init __parse_crashkernel(...)
static __init char *get_last_crashkernel(...)

As you said, it would be better if other architectures will benefit
from this change.

BR,
Austin Kim

>
>
> - Paul