From: Bernhard Walle <bwalle@suse.de>
To: linux-kernel@vger.kernel.org, kexec@lists.infradead.org
Cc: akpm@linux-foundation.org, ak@suse.de
Subject: [patch 2/2] Check if the crashkernel area is behind BSS
Date: Mon, 15 Oct 2007 13:50:44 +0200 [thread overview]
Message-ID: <20071015115043.244612028@strauss.suse.de> (raw)
In-Reply-To: <20071015115042.391348549@strauss.suse.de>
[-- Attachment #1: crashkernel_check_end --]
[-- Type: text/plain, Size: 3436 bytes --]
This patch checks if the crashkernel base address is after the end of BSS
on i386 and x86_64.
Having "Kernel bss" in the resource tree is not sufficient since that only
prevents "crash kernel" from appearing in the resource tree and therefore kexec
from loading the crashdump kernel since it checks /proc/iomem. However, the
crashkernel memory would still be reserved.
Signed-off-by: Bernhard Walle <bwalle@suse.de>
---
arch/x86/kernel/setup_32.c | 31 +++++++++++++++++++++----------
arch/x86/kernel/setup_64.c | 31 +++++++++++++++++++++----------
2 files changed, 42 insertions(+), 20 deletions(-)
--- a/arch/x86/kernel/setup_32.c
+++ b/arch/x86/kernel/setup_32.c
@@ -403,18 +403,29 @@ static void __init reserve_crashkernel(v
ret = parse_crashkernel(boot_command_line, total_mem,
&crash_size, &crash_base);
if (ret == 0 && crash_size > 0) {
- if (crash_base > 0) {
- printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
- "for crashkernel (System RAM: %ldMB)\n",
- (unsigned long)(crash_size >> 20),
- (unsigned long)(crash_base >> 20),
- (unsigned long)(total_mem >> 20));
- crashk_res.start = crash_base;
- crashk_res.end = crash_base + crash_size - 1;
- reserve_bootmem(crash_base, crash_size);
- } else
+ if (crash_base <= 0) {
printk(KERN_INFO "crashkernel reservation failed - "
"you have to specify a base address\n");
+ return;
+ }
+
+ if (base < virt_to_phys(&_end)) {
+ printk(KERN_WARNING "base address for crashkernel "
+ "(%luMB) is too low -- 0M-%luMB area "
+ "is needed by the kernel\n",
+ base >> 20, virt_to_phys(&_end) << 20);
+ return;
+ }
+
+ printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
+ "for crashkernel (System RAM: %ldMB)\n",
+ (unsigned long)(crash_size >> 20),
+ (unsigned long)(crash_base >> 20),
+ (unsigned long)(total_mem >> 20));
+
+ crashk_res.start = crash_base;
+ crashk_res.end = crash_base + crash_size - 1;
+ reserve_bootmem(crash_base, crash_size);
}
}
#else
--- a/arch/x86/kernel/setup_64.c
+++ b/arch/x86/kernel/setup_64.c
@@ -210,18 +210,29 @@ static void __init reserve_crashkernel(v
ret = parse_crashkernel(boot_command_line, free_mem,
&crash_size, &crash_base);
if (ret == 0 && crash_size) {
- if (crash_base > 0) {
- printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
- "for crashkernel (System RAM: %ldMB)\n",
- (unsigned long)(crash_size >> 20),
- (unsigned long)(crash_base >> 20),
- (unsigned long)(free_mem >> 20));
- crashk_res.start = crash_base;
- crashk_res.end = crash_base + crash_size - 1;
- reserve_bootmem(crash_base, crash_size);
- } else
+ if (crash_base <= 0) {
printk(KERN_INFO "crashkernel reservation failed - "
"you have to specify a base address\n");
+ return;
+ }
+
+ if (crash_base < virt_to_phys(&_end)) {
+ printk(KERN_WARNING "base address for crashkernel "
+ "(%lluMB) is too low -- 0M-%luMB area "
+ "is needed by the kernel\n",
+ crash_base >> 20,
+ virt_to_phys(&_end) << 20);
+ return;
+ }
+
+ printk(KERN_INFO "Reserving %ldMB of memory at %ldMB "
+ "for crashkernel (System RAM: %ldMB)\n",
+ (unsigned long)(crash_size >> 20),
+ (unsigned long)(crash_base >> 20),
+ (unsigned long)(free_mem >> 20));
+ crashk_res.start = crash_base;
+ crashk_res.end = crash_base + crash_size - 1;
+ reserve_bootmem(crash_base, crash_size);
}
}
#else
--
next prev parent reply other threads:[~2007-10-15 11:51 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-15 11:50 [patch 0/2] Protect crashkernel against BSS overlap Bernhard Walle
2007-10-15 11:50 ` [patch 1/2] Add BSS to resource tree Bernhard Walle
2007-10-15 18:32 ` Andrew Morton
2007-10-15 21:24 ` Bernhard Walle
2007-10-15 11:50 ` Bernhard Walle [this message]
2007-10-16 5:49 ` [patch 0/2] Protect crashkernel against BSS overlap Vivek Goyal
2007-10-16 9:59 ` Andi Kleen
2007-10-16 16:26 ` Bernhard Walle
2007-10-16 16:28 ` Bernhard Walle
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=20071015115043.244612028@strauss.suse.de \
--to=bwalle@suse.de \
--cc=ak@suse.de \
--cc=akpm@linux-foundation.org \
--cc=kexec@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
/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
Powered by JetHome