Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Thomas Gleixner <tglx@...>
Cc: Yinghai Lu <yhlu.kernel@...>, Ingo Molnar <mingo@...>, H. Peter Anvin <hpa@...>, Andrew Morton <akpm@...>, linux-kernel@vger.kernel.org <linux-kernel@...>
Date: Tuesday, May 27, 2008 - 4:37 pm

Thomas Gleixner wrote:
This patch is still required to make Xen boot with the e820 changes:

Subject: xen: boot via i386_start_kernel to get early reservations

Boot Xen via i386_start_kernel so that all the early reservations are
made properly; without these, it will start using the kernel and
pagetables as early heap memory, which is a bit suboptimal.

One tricky part is that reserve_early() will just panic if any of the
early reservations overlap any others.  When a Xen domain is built, it
constructs the initial address space as:

  kernel text+data+bss
  initrd
  inital pagetable

Therefore, when reserving the pagetable (from &_end to
init_pg_tables_end), it covers the whole initrd area.  If it then
tries to reserve the initrd, it will panic because of the overlap.

The simple fix here is to reserve INIT_PG_TABLE first, and then only
reserve the ramdisk if it doesn't overlap with the previous
reservations.  A better/more complex fix might be to make
reserve_early() deal with overlapping reservations.

Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
---
 arch/x86/kernel/head32.c |    6 ++++--
 arch/x86/xen/enlighten.c |    2 +-
 include/asm-x86/setup.h  |    1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

===================================================================
--- a/arch/x86/kernel/head32.c
+++ b/arch/x86/kernel/head32.c
@@ -66,6 +66,7 @@ void __init i386_start_kernel(void)
 void __init i386_start_kernel(void)
 {
 	reserve_early(__pa_symbol(&_text), __pa_symbol(&_end), "TEXT DATA BSS");
+	reserve_early(__pa_symbol(&_end), init_pg_tables_end, "INIT_PG_TABLE");
 
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Reserve INITRD */
@@ -73,10 +74,11 @@ void __init i386_start_kernel(void)
 		u64 ramdisk_image = boot_params.hdr.ramdisk_image;
 		u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
 		u64 ramdisk_end   = ramdisk_image + ramdisk_size;
-		reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
+		if (ramdisk_end < __pa_symbol(&_text) ||
+		    ramdisk_image >= init_pg_tables_end)
+			reserve_early(ramdisk_image, ramdisk_end, "RAMDISK");
 	}
 #endif
-	reserve_early(__pa_symbol(&_end), init_pg_tables_end, "INIT_PG_TABLE");
 
 	reserve_ebda_region();
 
===================================================================
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -1264,5 +1264,5 @@ asmlinkage void __init xen_start_kernel(
 	}
 
 	/* Start the world */
-	start_kernel();
+	i386_start_kernel();
 }
===================================================================
--- a/include/asm-x86/setup.h
+++ b/include/asm-x86/setup.h
@@ -58,6 +58,7 @@ int __init copy_e820_map(struct e820entr
 int __init copy_e820_map(struct e820entry *biosmap, int nr_map);
 void __init add_memory_region(unsigned long long start,
 			      unsigned long long size, int type);
+void __init i386_start_kernel(void);
 
 extern unsigned long init_pg_tables_end;
 


--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] x86: make e820.c to have common functions, Yinghai Lu, (Sun May 11, 3:30 am)
[PATCH] x86: extend e820 ealy_res support 32bit, Yinghai Lu, (Sun May 18, 4:18 am)
[PATCH] x86: 32bit numa srat fix early_ioremap leak, Yinghai Lu, (Thu May 29, 7:25 pm)
[PATCH] x86: cleanup max_pfn_mapped usage - 64bit, Yinghai Lu, (Mon Jun 2, 2:55 am)
[PATCH] x86: cleanup max_pfn_mapped usage - 32bit, Yinghai Lu, (Mon Jun 2, 2:53 am)
[PATCH] x86: numa_32 print out debug info all kva, Yinghai Lu, (Sun Jun 1, 1:56 am)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Thomas Gleixner, (Tue May 27, 11:44 am)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Jeremy Fitzhardinge, (Tue May 27, 4:37 pm)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Jeremy Fitzhardinge, (Tue May 27, 5:22 pm)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Jeremy Fitzhardinge, (Tue May 27, 5:47 pm)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Jeremy Fitzhardinge, (Wed May 28, 6:01 am)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Jeremy Fitzhardinge, (Thu May 29, 9:37 am)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Jeremy Fitzhardinge, (Fri May 30, 11:50 am)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Jeremy Fitzhardinge, (Wed May 28, 5:24 pm)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Thomas Gleixner, (Tue May 27, 4:58 pm)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix #2, Jeremy Fitzhardinge, (Tue May 27, 5:06 pm)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix v2, Jeremy Fitzhardinge, (Sat May 24, 4:54 am)
[PATCH] xen: boot via i386_start_kernel to get early reserva..., Jeremy Fitzhardinge, (Sat May 24, 5:49 am)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix v2, Jeremy Fitzhardinge, (Fri May 23, 7:38 pm)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix v2, Jeremy Fitzhardinge, (Fri May 23, 7:32 pm)
Re: [PATCH] x86: extend e820 ealy_res support 32bit - fix, Jeremy Fitzhardinge, (Thu May 22, 6:12 am)
[PATCH] x86: move e820_mark_nosave_regions to e820.c, Yinghai Lu, (Tue May 20, 11:10 pm)
Re: [PATCH] x86: make e820.c to have common functions, Ingo Molnar, (Tue May 13, 9:05 am)