From: Jinjie Ruan <ruanjinjie@huawei.com>
To: <linux@armlinux.org.uk>, <bhe@redhat.com>, <vgoyal@redhat.com>,
<dyoung@redhat.com>, <paul.walmsley@sifive.com>,
<palmer@dabbelt.com>, <aou@eecs.berkeley.edu>, <arnd@arndb.de>,
<afd@ti.com>, <akpm@linux-foundation.org>,
<rmk+kernel@armlinux.org.uk>, <linus.walleij@linaro.org>,
<eric.devolder@oracle.com>, <gregkh@linuxfoundation.org>,
<deller@gmx.de>, <javierm@redhat.com>, <robh@kernel.org>,
<thunder.leizhen@huawei.com>, <austindh.kim@gmail.com>,
<linux-arm-kernel@lists.infradead.org>,
<linux-kernel@vger.kernel.org>, <kexec@lists.infradead.org>
Cc: <ruanjinjie@huawei.com>
Subject: [PATCH 1/3] crash: Fix memory reserve dead loop bug in reserve_crashkernel_generic()
Date: Mon, 8 Jul 2024 21:33:46 +0800 [thread overview]
Message-ID: <20240708133348.3592667-2-ruanjinjie@huawei.com> (raw)
In-Reply-To: <20240708133348.3592667-1-ruanjinjie@huawei.com>
If the platform do not support memory above 4G, such as 32 bit arch,
and CRASH_ADDR_LOW_MAX is equal to CRASH_ADDR_HIGH_MAX, the high
crash kernel memory reservation is meaningless and it will cause
dead loop and system stall:
-> reserve_crashkernel_generic() and high is true
-> memblock_phys_alloc_range() fail and return 0
-> search_end = CRASH_ADDR_LOW_MAX(same as CRASH_ADDR_HIGH_MAX)
-> call memblock_phys_alloc_range() again and fail agin.
-> search_end == CRASH_ADDR_HIGH_MAX satisfy again
......
However, the current check only considers the case where
CRASH_ADDR_HIGH_MAX is greater than CRASH_ADDR_LOW_MAX. Fix it.
Fixes: 0ab97169aa05 ("crash_core: add generic function to do reservation")
Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
---
kernel/crash_reserve.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/kernel/crash_reserve.c b/kernel/crash_reserve.c
index 5b2722a93a48..e18fb1bb5d28 100644
--- a/kernel/crash_reserve.c
+++ b/kernel/crash_reserve.c
@@ -390,6 +390,11 @@ void __init reserve_crashkernel_generic(char *cmdline,
} else if (high) {
search_base = CRASH_ADDR_LOW_MAX;
search_end = CRASH_ADDR_HIGH_MAX;
+
+ if (search_base >= search_end) {
+ pr_warn("crashkernel high memory reservation failed.\n");
+ return;
+ }
}
retry:
@@ -410,7 +415,8 @@ void __init reserve_crashkernel_generic(char *cmdline,
* low memory, fall back to high memory, the minimum required
* low memory will be reserved later.
*/
- if (!high && search_end == CRASH_ADDR_LOW_MAX) {
+ if (!high && search_end == CRASH_ADDR_LOW_MAX &&
+ CRASH_ADDR_HIGH_MAX > CRASH_ADDR_LOW_MAX) {
search_end = CRASH_ADDR_HIGH_MAX;
search_base = CRASH_ADDR_LOW_MAX;
crash_low_size = DEFAULT_CRASH_KERNEL_LOW_SIZE;
--
2.34.1
next prev parent reply other threads:[~2024-07-08 13:29 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-08 13:33 [PATCH 0/3] ARM: Use generic interface to simplify crashkernel reservation Jinjie Ruan
2024-07-08 13:33 ` Jinjie Ruan [this message]
2024-08-05 7:15 ` [PATCH 1/3] crash: Fix memory reserve dead loop bug in reserve_crashkernel_generic() Linus Walleij
2024-07-08 13:33 ` [PATCH 2/3] ARM: Fix crash kenrel data type bug Jinjie Ruan
2024-08-05 7:14 ` Linus Walleij
2024-07-08 13:33 ` [PATCH 3/3] ARM: Use generic interface to simplify crashkernel reservation Jinjie Ruan
2024-07-09 9:29 ` [PATCH 0/3] " Baoquan He
2024-07-09 9:50 ` Jinjie Ruan
2024-07-09 10:39 ` Baoquan He
2024-07-09 11:06 ` Jinjie Ruan
2024-07-09 14:06 ` Baoquan He
2024-07-10 1:52 ` Jinjie Ruan
2024-07-10 3:40 ` Baoquan He
2024-07-11 6:30 ` 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=20240708133348.3592667-2-ruanjinjie@huawei.com \
--to=ruanjinjie@huawei.com \
--cc=afd@ti.com \
--cc=akpm@linux-foundation.org \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=austindh.kim@gmail.com \
--cc=bhe@redhat.com \
--cc=deller@gmx.de \
--cc=dyoung@redhat.com \
--cc=eric.devolder@oracle.com \
--cc=gregkh@linuxfoundation.org \
--cc=javierm@redhat.com \
--cc=kexec@lists.infradead.org \
--cc=linus.walleij@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rmk+kernel@armlinux.org.uk \
--cc=robh@kernel.org \
--cc=thunder.leizhen@huawei.com \
--cc=vgoyal@redhat.com \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).