Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > eab357269fb8735c5e1a2938e6c77cae > files > 3370

kernel-2.6.18-164.10.1.el5.src.rpm

From: Matthew Garrett <mjg@redhat.com>
Date: Wed, 4 Mar 2009 12:38:40 +0000
Subject: [x86] reserve low 64k of memory to avoid BIOS corruption
Message-id: 20090304123840.GA29669@srcf.ucam.org
O-Subject: [RHEL 5.4 PATCH] x86: Reserve low 64k of memory to avoid BIOS corruption
Bugzilla: 471851
RH-Acked-by: Neil Horman <nhorman@redhat.com>
RH-Acked-by: Prarit Bhargava <prarit@redhat.com>
RH-Acked-by: Dave Anderson <anderson@redhat.com>

Many BIOSes use sections of the lower 64k of memory as scratch space.
This can result in a range of failures, especially over suspend/resume.
This patch reserves this range in order to prevent OS state being
corrupted by this. Upstream currently makes this conditional on BIOS
vendor, but in our kernel it's not possible to perform DMI matches until
the memory setup has already been completed. There's also more bugs
cropping up which indicate the problem is more widespread, so upstream
may go with a blanket approach in the long run anyway.

My primary concern with this patch is that it means that the default
(disabled) crash kernel area is now within a reserved range. The effect
of this just seems to be that the crash kernel is no longer listed in
/proc/iomem when unconfigured.

Fixes bug 471851

diff --git a/arch/i386/kernel/setup.c b/arch/i386/kernel/setup.c
index d7f056d..0fec4c9 100644
--- a/arch/i386/kernel/setup.c
+++ b/arch/i386/kernel/setup.c
@@ -688,6 +688,17 @@ int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
 			return -1;
 
 		/*
+		 * Some BIOSes corrupt RAM in the 0 - 64k region.
+		 * Reserve this memory.
+		 */
+		if (type == E820_RAM) {
+			if (start < 0x10000ULL && end > 0x10000ULL) {
+				start = 0x10000ULL;
+				size = end - start;
+			}
+		}
+
+		/*
 		 * Some BIOSes claim RAM in the 640k - 1M region.
 		 * Not right. Fix it up.
 		 */
diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c
index f98cc6d..f6702b2 100644
--- a/arch/x86_64/kernel/e820.c
+++ b/arch/x86_64/kernel/e820.c
@@ -596,6 +596,17 @@ static int __init copy_e820_map(struct e820entry * biosmap, int nr_map)
 			return -1;
 
 		/*
+		 * Some BIOSes corrupt RAM in the 0 - 64k region.
+		 * Reserve this memory.
+		 */
+		if (type == E820_RAM) {
+			if (start < 0x10000ULL && end > 0x10000ULL) {
+				start = 0x10000ULL;
+				size = end - start;
+			}
+		}
+
+		/*
 		 * Some BIOSes claim RAM in the 640k - 1M region.
 		 * Not right. Fix it up.
 		 *