From: Cliff Wickman <cpw@sgi.com>
To: wille <junk@willeweb.com>
Cc: kexec@lists.infradead.org
Subject: Re: kexec: Overlapping memory segments error
Date: Thu, 20 Jan 2011 14:26:42 -0600 [thread overview]
Message-ID: <20110120202642.GA22671@sgi.com> (raw)
In-Reply-To: <201101201314.27153.junk@willeweb.com>
On Thu, Jan 20, 2011 at 01:14:27PM -0700, wille wrote:
> I am running a minimal system with a stripped down x86 2.6.32 Linux kernel.
> >From this environment I kexec to an Ubuntu Lucid i386 2.6.32 kernel. This
> works fine on *most* hardware, but on some machines the kexec -l fails with
> overlapping memory segments.
>
> First I used the kexec which comes with the Lucid i386 distro (kexec-tools
> 2.0.1 released 13th August 2009). Then I built kexec from the head of the
> git tree, which includes the patch "kexec: fix /sys/firmware/memmap memory
> range overlaps". I was hopeful this patch would fix my problem, but it
> still fails with an "Overlapping memory segments" error.
>
> As a specific example, on a Dell Latitude E6410 (which uses an Intel i7
> processor) the kexec -l fails with the following messages:
>
> setup_linux_vesafb: 640x480x16 @ e1000000 +12c000
> Overlapping memory segments at 0x7ffff000
>
> One final clue: if I do the same kexec -l, but without the --initrd option I
> don't get the "Overlapping memory segments..." message, but of course
> without an initrd the system doesn't boot.
>
> Any ideas?
>
> -wille
Does your code have this patch?
It went into the community.
http://git.kernel.org/?p=utils/kernel/kexec/kexec-tools.git;a=blob;f=kexec/arch/i386/kexec-x86-common.c
To: kexec@lists.infradead.org
Subject: [PATCH] kexec: fix /sys/firmware/memmap memory range overlaps
The memory ranges derived from /sys/firmware/memmap may overlap, causing
the kexec command to fail to load the crash kernel. The typical failure
reports 'Overlapping memory segments at 0x...'.
The preferred remedy might be to fix the BIOS or the kernel, but given
that they may at times generate overlaps, a check in the kexec command
will prevent crash dumps from being effectively disabled.
Diffed against git.kernel.org/pub/scm/linux/kernel/git/horms/kexec-tools.git
Signed-off-by: Cliff Wickman <cpw@sgi.com>
---
kexec/arch/i386/kexec-x86-common.c | 78 ++++++++++++++++++++++++++++++++++++-
1 file changed, 76 insertions(+), 2 deletions(-)
Index: kexec-tools/kexec/arch/i386/kexec-x86-common.c
===================================================================
--- kexec-tools.orig/kexec/arch/i386/kexec-x86-common.c
+++ kexec-tools/kexec/arch/i386/kexec-x86-common.c
@@ -129,6 +129,78 @@ static int get_memory_ranges_sysfs(struc
return 0;
}
+static void remove_range(struct memory_range *range, int nr_ranges, int index)
+{
+ int i, j;
+
+ for (i = index; i < (nr_ranges-1); i++) {
+ j = i+1;
+ range[i] = range[j];
+ }
+}
+
+/**
+ * Verifies and corrects any overlapping ranges.
+ * The ranges array is assumed to be sorted already.
+ *
+ * @param[out] range pointer that will be set to an array that holds the
+ * memory ranges
+ * @param[out] ranges number of ranges valid in @p range
+ *
+ * @return 0 on success, any other value on failure.
+ */
+static int fixup_memory_ranges_sysfs(struct memory_range **range, int *ranges)
+{
+ int i;
+ int j;
+ int change_made;
+ int nr_ranges = *ranges;
+ struct memory_range *rp = *range;
+
+again:
+ change_made = 0;
+ for (i = 0; i < (nr_ranges-1); i++) {
+ j = i+1;
+ if (rp[i].start > rp[j].start) {
+ fprintf(stderr, "sysfs memory out of order!!\n");
+ return 1;
+ }
+
+ if (rp[i].type != rp[j].type)
+ continue;
+
+ if (rp[i].start == rp[j].start) {
+ if (rp[i].end >= rp[j].end) {
+ remove_range(rp, nr_ranges, j);
+ nr_ranges--;
+ change_made++;
+ } else {
+ remove_range(rp, nr_ranges, i);
+ nr_ranges--;
+ change_made++;
+ }
+ } else {
+ if (rp[i].end > rp[j].start) {
+ if (rp[i].end < rp[j].end) {
+ rp[j].start = rp[i].end;
+ change_made++;
+ } else if (rp[i].end >= rp[j].end) {
+ remove_range(rp, nr_ranges, j);
+ nr_ranges--;
+ change_made++;
+ }
+ }
+ }
+ }
+
+ /* fixing/removing an entry may make it wrong relative to the next */
+ if (change_made)
+ goto again;
+
+ *ranges = nr_ranges;
+ return 0;
+}
+
/**
* Return a sorted list of memory ranges.
*
@@ -155,9 +227,11 @@ int get_memory_ranges(struct memory_rang
* even if we have /sys/firmware/memmap. Without that, /proc/vmcore
* is empty in the kdump kernel.
*/
- if (!xen_present() && have_sys_firmware_memmap())
+ if (!xen_present() && have_sys_firmware_memmap()) {
ret = get_memory_ranges_sysfs(range, ranges);
- else
+ if (!ret)
+ ret = fixup_memory_ranges_sysfs(range, ranges);
+ } else
ret = get_memory_ranges_proc_iomem(range, ranges);
/*
--
Cliff Wickman
SGI
cpw@sgi.com
(651) 683-3824
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
prev parent reply other threads:[~2011-01-20 20:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-20 20:14 kexec: Overlapping memory segments error wille
2011-01-20 20:26 ` Cliff Wickman [this message]
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=20110120202642.GA22671@sgi.com \
--to=cpw@sgi.com \
--cc=junk@willeweb.com \
--cc=kexec@lists.infradead.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