public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: fix e820_update_range size when overlapping
@ 2008-06-24 21:55 Yinghai Lu
  2008-06-24 21:56 ` [PATCH] x86: get max_pfn_mapped in init_memory_mapping Yinghai Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Yinghai Lu @ 2008-06-24 21:55 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel@vger.kernel.org


before that we relay on sanitize_e820_map to remove the overlap.

but e820_update_range(,,E820_RESERVED, E820_RAM) will not work

this patch fix that

who is going to use this?

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 512f779..15b4393 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -425,6 +425,11 @@ u64 __init e820_update_range(u64 start, u64 size, unsigned old_type,
 		e820_add_region(final_start, final_end - final_start,
 					 new_type);
 		real_updated_size += final_end - final_start;
+
+		ei->size -= final_end - final_start;
+		if (ei->addr < final_start)
+			continue;
+		ei->addr = final_end;
 	}
 	return real_updated_size;
 }

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] x86: get max_pfn_mapped in init_memory_mapping
  2008-06-24 21:55 [PATCH] x86: fix e820_update_range size when overlapping Yinghai Lu
@ 2008-06-24 21:56 ` Yinghai Lu
  2008-06-24 21:57   ` [PATCH] x86: add table_top check for alloc_low_page in 64 bit Yinghai Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Yinghai Lu @ 2008-06-24 21:56 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel@vger.kernel.org


so don't shift that in the loop

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0c92624..8bad202 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -398,7 +398,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end)
 	__flush_tlb_all();
 	update_page_count(PG_LEVEL_1G, pages);
 
-	return last_map_addr >> PAGE_SHIFT;
+	return last_map_addr;
 }
 
 static void __init find_early_table_space(unsigned long end)
@@ -606,7 +606,7 @@ unsigned long __init_refok init_memory_mapping(unsigned long start, unsigned lon
 	if (!after_bootmem)
 		early_memtest(start_phys, end_phys);
 
-	return last_map_addr;
+	return last_map_addr >> PAGE_SHIFT;
 }
 
 #ifndef CONFIG_NUMA

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] x86: add table_top check for alloc_low_page in 64 bit
  2008-06-24 21:56 ` [PATCH] x86: get max_pfn_mapped in init_memory_mapping Yinghai Lu
@ 2008-06-24 21:57   ` Yinghai Lu
  2008-06-24 21:58     ` [PATCH] x86: change size if e820_update/remove_range Yinghai Lu
  0 siblings, 1 reply; 4+ messages in thread
From: Yinghai Lu @ 2008-06-24 21:57 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel@vger.kernel.org


that range is from find_e820_area, so don't try to use end_pfn to see
if out of boundary...use table_top instead to avoid possible strange
result while cross the boundary...

also change early_printk to printk, because init_memory_mapping is after
early param parsing, and console=uart8250 already working at that time.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 0c92624..6517642 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -227,6 +227,7 @@ void __init cleanup_highmap(void)
 
 static unsigned long __initdata table_start;
 static unsigned long __meminitdata table_end;
+static unsigned long __meminitdata table_top;
 
 static __meminit void *alloc_low_page(unsigned long *phys)
 {
@@ -240,7 +241,7 @@ static __meminit void *alloc_low_page(unsigned long *phys)
 		return adr;
 	}
 
-	if (pfn >= end_pfn)
+	if (pfn >= table_top)
 		panic("alloc_low_page: ran out of memory");
 
 	adr = early_ioremap(pfn * PAGE_SIZE, PAGE_SIZE);
@@ -424,10 +425,10 @@ static void __init find_early_table_space(unsigned long end)
 
 	table_start >>= PAGE_SHIFT;
 	table_end = table_start;
+	table_top = table_start + (tables >> PAGE_SHIFT);
 
-	early_printk("kernel direct mapping tables up to %lx @ %lx-%lx\n",
-		end, table_start << PAGE_SHIFT,
-		(table_start << PAGE_SHIFT) + tables);
+	printk(KERN_DEBUG "kernel direct mapping tables up to %lx @ %lx-%lx\n",
+		end, table_start << PAGE_SHIFT, table_top << PAGE_SHIFT);
 }
 
 static void __init init_gbpages(void)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] x86: change size if e820_update/remove_range
  2008-06-24 21:57   ` [PATCH] x86: add table_top check for alloc_low_page in 64 bit Yinghai Lu
@ 2008-06-24 21:58     ` Yinghai Lu
  0 siblings, 0 replies; 4+ messages in thread
From: Yinghai Lu @ 2008-06-24 21:58 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner, H. Peter Anvin; +Cc: linux-kernel@vger.kernel.org


in case someone using crazy parameter while calling them.

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>

diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
index 512f779..6445220 100644
--- a/arch/x86/kernel/e820.c
+++ b/arch/x86/kernel/e820.c
@@ -405,6 +405,9 @@ u64 __init e820_update_range(u64 start, u64 size, unsigned old_type,
 
 	BUG_ON(old_type == new_type);
 
+	if (size > (ULLONG_MAX - start))
+		size = ULLONG_MAX - start;
+
 	for (i = 0; i < e820.nr_map; i++) {
 		struct e820entry *ei = &e820.map[i];
 		u64 final_start, final_end;
@@ -436,6 +439,9 @@ u64 __init e820_remove_range(u64 start, u64 size, unsigned old_type,
 	int i;
 	u64 real_removed_size = 0;
 
+	if (size > (ULLONG_MAX - start))
+		size = ULLONG_MAX - start;
+
 	for (i = 0; i < e820.nr_map; i++) {
 		struct e820entry *ei = &e820.map[i];
 		u64 final_start, final_end;

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-06-24 21:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-24 21:55 [PATCH] x86: fix e820_update_range size when overlapping Yinghai Lu
2008-06-24 21:56 ` [PATCH] x86: get max_pfn_mapped in init_memory_mapping Yinghai Lu
2008-06-24 21:57   ` [PATCH] x86: add table_top check for alloc_low_page in 64 bit Yinghai Lu
2008-06-24 21:58     ` [PATCH] x86: change size if e820_update/remove_range Yinghai Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox