linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mike Rapoport <rppt@kernel.org>
To: Jinjie Ruan <ruanjinjie@huawei.com>
Cc: linux@armlinux.org.uk, paul.walmsley@sifive.com,
	palmer@dabbelt.com, aou@eecs.berkeley.edu, tglx@linutronix.de,
	mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com,
	hpa@zytor.com, arnd@arndb.de, gregkh@linuxfoundation.org,
	deller@gmx.de, javierm@redhat.com, bhe@redhat.com,
	robh@kernel.org, alexghiti@rivosinc.com, bjorn@rivosinc.com,
	akpm@linux-foundation.org, namcao@linutronix.de,
	dawei.li@shingroup.cn, chenjiahao16@huawei.com,
	julian.stecklina@cyberus-technology.de,
	rafael.j.wysocki@intel.com, linux-arm-kernel@lists.infradead.org,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 3/3] riscv: kdump: Fix crash memory reserve exceed system memory bug
Date: Mon, 22 Jul 2024 09:38:45 +0300	[thread overview]
Message-ID: <Zp3-dZHhN7LbMggc@kernel.org> (raw)
In-Reply-To: <20240722035701.696874-4-ruanjinjie@huawei.com>

Hi,

On Mon, Jul 22, 2024 at 11:57:01AM +0800, Jinjie Ruan wrote:
> Similar with x86_32, on Riscv32 Qemu "virt" machine with 1GB memory, the
> crash kernel "crashkernel=4G" is ok as below:
> 	crashkernel reserved: 0x00000000bf400000 - 0x00000001bf400000 (4096 MB)
> 
> The cause is that the crash_size is parsed and printed with "unsigned long
> long" data type which is 8 bytes but allocated used with "phys_addr_t"
> which is 4 bytes in memblock_phys_alloc_range().
> 
> Fix it by checking if the crash_size is greater than system RAM size and
> warn out as parse_crashkernel_mem() do it if so.
> 
> After this patch, it fails and there is no above confusing reserve
> success info.
> 
> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
> ---
>  arch/riscv/mm/init.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c
> index bfa2dea95354..5d66a4937fcd 100644
> --- a/arch/riscv/mm/init.c
> +++ b/arch/riscv/mm/init.c
> @@ -1381,6 +1381,11 @@ static void __init arch_reserve_crashkernel(void)
>  	if (ret)
>  		return;
>  
> +	if (crash_size >= memblock_phys_mem_size()) {
> +		pr_warn("Crashkernel: invalid size.");
> +		return;
> +	}
> +

What the point of adding three identical checks right after the call to
parse_crashkernel()?

This check should be there and parse_crashkernel() should return error in
this case.

>  	reserve_crashkernel_generic(cmdline, crash_size, crash_base,
>  				    low_size, high);
>  }
> -- 
> 2.34.1
> 

-- 
Sincerely yours,
Mike.

  reply	other threads:[~2024-07-22  6:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-22  3:56 [PATCH v4 0/3] crash: Fix crash memory reserve exceed system memory bug Jinjie Ruan
2024-07-22  3:56 ` [PATCH v4 1/3] x86/kexec: " Jinjie Ruan
2024-07-22  3:57 ` [PATCH v4 2/3] ARM: " Jinjie Ruan
2024-07-29 11:14   ` Russell King (Oracle)
2024-07-22  3:57 ` [PATCH v4 3/3] riscv: kdump: " Jinjie Ruan
2024-07-22  6:38   ` Mike Rapoport [this message]
2024-07-22  7:04     ` Jinjie Ruan
2024-07-22  7:08     ` Jinjie Ruan
2024-07-22  7:23       ` Mike Rapoport
2024-07-22  7:49         ` Jinjie Ruan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Zp3-dZHhN7LbMggc@kernel.org \
    --to=rppt@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alexghiti@rivosinc.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=arnd@arndb.de \
    --cc=bhe@redhat.com \
    --cc=bjorn@rivosinc.com \
    --cc=bp@alien8.de \
    --cc=chenjiahao16@huawei.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dawei.li@shingroup.cn \
    --cc=deller@gmx.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=hpa@zytor.com \
    --cc=javierm@redhat.com \
    --cc=julian.stecklina@cyberus-technology.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@armlinux.org.uk \
    --cc=mingo@redhat.com \
    --cc=namcao@linutronix.de \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=robh@kernel.org \
    --cc=ruanjinjie@huawei.com \
    --cc=tglx@linutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).