[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1273796396-29649-31-git-send-email-yinghai@kernel.org>
Date: Thu, 13 May 2010 17:19:51 -0700
From: Yinghai Lu <yinghai@...nel.org>
To: Ingo Molnar <mingo@...e.hu>, Thomas Gleixner <tglx@...utronix.de>,
"H. Peter Anvin" <hpa@...or.com>,
Andrew Morton <akpm@...ux-foundation.org>
Cc: David Miller <davem@...emloft.net>,
Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Johannes Weiner <hannes@...xchg.org>,
linux-kernel@...r.kernel.org, linux-arch@...r.kernel.org,
Yinghai Lu <yinghai@...nel.org>
Subject: [PATCH 30/35] x86: Align e820 ram range to page
for 2.6.34
To workaround wrong BIOS memory map.
Signed-off-by: Yinghai Lu <yinghai@...nel.org>
---
arch/x86/kernel/e820.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 44 insertions(+), 0 deletions(-)
diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 4bbbd6b..78ca7ce 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -910,6 +910,47 @@ static int __init parse_memmap_opt(char *p)
}
early_param("memmap", parse_memmap_opt);
+static void __init e820_align_ram_page(void)
+{
+ int i;
+ bool changed = false;;
+
+ for (i = 0; i < e820.nr_map; i++) {
+ struct e820entry *entry = &e820.map[i];
+ u64 start, end;
+ u64 start_aligned, end_aligned;
+
+ if (entry->type != E820_RAM)
+ continue;
+
+ start = entry->addr;
+ end = start + entry->size;
+
+ start_aligned = round_up(start, PAGE_SIZE);
+ end_aligned = round_down(end, PAGE_SIZE);
+
+ if (end_aligned <= start_aligned) {
+ e820_update_range(start, end - start, E820_RAM, E820_RESERVED);
+ changed = true;
+ continue;
+ }
+ if (start < start_aligned) {
+ e820_update_range(start, start_aligned - start, E820_RAM, E820_RESERVED);
+ changed = true;
+ }
+ if (end_aligned < end) {
+ e820_update_range(end_aligned, end - end_aligned, E820_RAM, E820_RESERVED);
+ changed = true;
+ }
+ }
+
+ if (changed) {
+ sanitize_e820_map();
+ printk(KERN_INFO "aligned physical RAM map:\n");
+ e820_print_map("aligned");
+ }
+}
+
void __init finish_e820_parsing(void)
{
if (userdef) {
@@ -922,6 +963,9 @@ void __init finish_e820_parsing(void)
printk(KERN_INFO "user-defined physical RAM map:\n");
e820_print_map("user");
}
+
+ /* In case, We have RAM entres that are not PAGE aligned */
+ e820_align_ram_page();
}
static inline const char *e820_type_to_string(int e820_type)
--
1.6.4.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists