* [PATCH] zero-size E820 memory (kernel start-up failure)
@ 2002-12-20 11:02 Alexander Achenbach
2002-12-20 12:54 ` Dave Jones
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Achenbach @ 2002-12-20 11:02 UTC (permalink / raw)
To: davej, hpa, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1087 bytes --]
Hi everybody.
This patch fixes the
Ok, booting the kernel. [hangs]
problem with BIOSes that report E820 memory maps with zero-size entries.
Among the mainboards affected are
EPOX 4G4A+ (presumably)
EPOX 4BEA[-R]
Chaintech 9EJL .
In the past (kernels up to 2.4.20), these mainboards could only boot Linux
with explicit 'mem=' boot parameters.
Up to 2.4.20, a zero-size E820 memory region (eg 0xa0000 - 0xa0000)
reported by the BIOS causes 'sanitize_e820_map' to take the end of this
region as the start of another region, producing two overlapping regions
extending to the end of addressable memory. If the zero-size region is of
a higher type than 'usable RAM' (eg 'reserved'), this causes all memory
above the zero-size region to be marked unusable (leaving 640k as of the
above example -- the kernel fails to start at all).
The patch adds code to remove empty entries before sorting regions. It
was generated for a 2.4.20 kernel.
Best regards,
Alex
[ Please send answers to my Reply-To address.
I'm not subscribed to the kernel mailing list. ]
[-- Attachment #2: nullmem.diff --]
[-- Type: text/plain, Size: 2365 bytes --]
diff -ur linux-2.4.20/arch/i386/kernel/setup.c linux-2.4.20-nullmem/arch/i386/kernel/setup.c
--- linux-2.4.20/arch/i386/kernel/setup.c Fri Nov 29 00:53:09 2002
+++ linux-2.4.20-nullmem/arch/i386/kernel/setup.c Mon Dec 16 14:52:21 2002
@@ -71,6 +71,9 @@
* CacheSize bug workaround updates for AMD, Intel & VIA Cyrix.
* Dave Jones <davej@suse.de>, September, October 2001.
*
+ * Provisions for empty E820 memory regions (reported by certain BIOSes).
+ * Alex Achenbach <xela@slit.de>, December 2002.
+ *
*/
/*
@@ -501,7 +504,7 @@
int chgidx, still_changing;
int overlap_entries;
int new_bios_entry;
- int old_nr, new_nr;
+ int old_nr, new_nr, chg_nr;
int i;
/*
@@ -555,20 +558,24 @@
for (i=0; i < 2*old_nr; i++)
change_point[i] = &change_point_list[i];
- /* record all known change-points (starting and ending addresses) */
+ /* record all known change-points (starting and ending addresses),
+ omitting those that are for empty memory regions */
chgidx = 0;
for (i=0; i < old_nr; i++) {
- change_point[chgidx]->addr = biosmap[i].addr;
- change_point[chgidx++]->pbios = &biosmap[i];
- change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
- change_point[chgidx++]->pbios = &biosmap[i];
+ if (biosmap[i].size != 0) {
+ change_point[chgidx]->addr = biosmap[i].addr;
+ change_point[chgidx++]->pbios = &biosmap[i];
+ change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
+ change_point[chgidx++]->pbios = &biosmap[i];
+ }
}
+ chg_nr = chgidx; /* true number of change-points */
/* sort change-point list by memory addresses (low -> high) */
still_changing = 1;
while (still_changing) {
still_changing = 0;
- for (i=1; i < 2*old_nr; i++) {
+ for (i=1; i < chg_nr; i++) {
/* if <current_addr> > <last_addr>, swap */
/* or, if current=<start_addr> & last=<end_addr>, swap */
if ((change_point[i]->addr < change_point[i-1]->addr) ||
@@ -591,7 +598,7 @@
last_type = 0; /* start with undefined memory type */
last_addr = 0; /* start with 0 as last starting address */
/* loop through change-points, determining affect on the new bios map */
- for (chgidx=0; chgidx < 2*old_nr; chgidx++)
+ for (chgidx=0; chgidx < chg_nr; chgidx++)
{
/* keep track of all overlapping bios entries */
if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] zero-size E820 memory (kernel start-up failure)
2002-12-20 11:02 [PATCH] zero-size E820 memory (kernel start-up failure) Alexander Achenbach
@ 2002-12-20 12:54 ` Dave Jones
2002-12-21 10:48 ` Alexander Achenbach
0 siblings, 1 reply; 3+ messages in thread
From: Dave Jones @ 2002-12-20 12:54 UTC (permalink / raw)
To: xela; +Cc: hpa, linux-kernel
On Fri, Dec 20, 2002 at 12:02:57PM +0100, Alexander Achenbach wrote:
> Up to 2.4.20, a zero-size E820 memory region (eg 0xa0000 - 0xa0000)
> reported by the BIOS causes 'sanitize_e820_map' to take the end of this
> region as the start of another region, producing two overlapping regions
> extending to the end of addressable memory. If the zero-size region is of
> a higher type than 'usable RAM' (eg 'reserved'), this causes all memory
> above the zero-size region to be marked unusable (leaving 640k as of the
> above example -- the kernel fails to start at all).
>
> The patch adds code to remove empty entries before sorting regions. It
> was generated for a 2.4.20 kernel.
Looks good to me. Care to do a similar patch for 2.5 ?
Dave
--
| Dave Jones. http://www.codemonkey.org.uk
| SuSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] zero-size E820 memory (kernel start-up failure)
2002-12-20 12:54 ` Dave Jones
@ 2002-12-21 10:48 ` Alexander Achenbach
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Achenbach @ 2002-12-21 10:48 UTC (permalink / raw)
To: hpa; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 336 bytes --]
Hi again.
Dave Jones wrote:
>
> > The patch adds code to remove empty entries before sorting regions. It
> > was generated for a 2.4.20 kernel.
>
> Looks good to me. Care to do a similar patch for 2.5 ?
This is it, to be applied against 2.5.52.
I've tested the kernel on an EPOX 4BEA-R and it boots as it should.
Cheers,
Alex
[-- Attachment #2: nullmem-2.5.52.diff --]
[-- Type: text/plain, Size: 2338 bytes --]
diff -ru linux-2.5.52/arch/i386/kernel/setup.c linux-2.5.52-nullmem/arch/i386/kernel/setup.c
--- linux-2.5.52/arch/i386/kernel/setup.c Mon Dec 16 03:07:56 2002
+++ linux-2.5.52-nullmem/arch/i386/kernel/setup.c Fri Dec 20 15:48:35 2002
@@ -14,6 +14,9 @@
* Moved CPU detection code to cpu/${cpu}.c
* Patrick Mochel <mochel@osdl.org>, March 2002
*
+ * Provisions for empty E820 memory regions (reported by certain BIOSes).
+ * Alex Achenbach <xela@slit.de>, December 2002.
+ *
*/
/*
@@ -275,7 +278,7 @@
int chgidx, still_changing;
int overlap_entries;
int new_bios_entry;
- int old_nr, new_nr;
+ int old_nr, new_nr, chg_nr;
int i;
/*
@@ -329,20 +332,24 @@
for (i=0; i < 2*old_nr; i++)
change_point[i] = &change_point_list[i];
- /* record all known change-points (starting and ending addresses) */
+ /* record all known change-points (starting and ending addresses),
+ omitting those that are for empty memory regions */
chgidx = 0;
for (i=0; i < old_nr; i++) {
- change_point[chgidx]->addr = biosmap[i].addr;
- change_point[chgidx++]->pbios = &biosmap[i];
- change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
- change_point[chgidx++]->pbios = &biosmap[i];
+ if (biosmap[i].size != 0) {
+ change_point[chgidx]->addr = biosmap[i].addr;
+ change_point[chgidx++]->pbios = &biosmap[i];
+ change_point[chgidx]->addr = biosmap[i].addr + biosmap[i].size;
+ change_point[chgidx++]->pbios = &biosmap[i];
+ }
}
+ chg_nr = chgidx; /* true number of change-points */
/* sort change-point list by memory addresses (low -> high) */
still_changing = 1;
while (still_changing) {
still_changing = 0;
- for (i=1; i < 2*old_nr; i++) {
+ for (i=1; i < chg_nr; i++) {
/* if <current_addr> > <last_addr>, swap */
/* or, if current=<start_addr> & last=<end_addr>, swap */
if ((change_point[i]->addr < change_point[i-1]->addr) ||
@@ -365,7 +372,7 @@
last_type = 0; /* start with undefined memory type */
last_addr = 0; /* start with 0 as last starting address */
/* loop through change-points, determining affect on the new bios map */
- for (chgidx=0; chgidx < 2*old_nr; chgidx++)
+ for (chgidx=0; chgidx < chg_nr; chgidx++)
{
/* keep track of all overlapping bios entries */
if (change_point[chgidx]->addr == change_point[chgidx]->pbios->addr)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-12-21 10:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-12-20 11:02 [PATCH] zero-size E820 memory (kernel start-up failure) Alexander Achenbach
2002-12-20 12:54 ` Dave Jones
2002-12-21 10:48 ` Alexander Achenbach
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.