Skip to contentSkip to conversation

2.6.17: E820 handling adjustments

PATCH In review Jan Beulich 1 participant 1 message Feb 14, 2007

lore
Share & tools
lore
#0 lore raw

PATCH 2/8 2.6.17: E820 handling adjustments

In certain places, machine_e820 should be used rather than e820.

arch/i386/kernel/setup-xen.c +21 -13
Index: head-2007-02-08/arch/i386/kernel/setup-xen.c
===================================================================
@@ -1034,8 +1034,16 @@ e820_all_mapped(unsigned long s, unsigne
 	u64 start = s;
 	u64 end = e;
 	int i;
+
+#ifndef CONFIG_XEN
 	for (i = 0; i < e820.nr_map; i++) {
 		struct e820entry *ei = &e820.map[i];
+#else
+	if (!is_initial_xendomain())
+		return 0;
+	for (i = 0; i < machine_e820.nr_map; ++i) {
+		const struct e820entry *ei = &machine_e820.map[i];
+#endif
 		if (type && ei->type != type)
 			continue;
 		/* is the region (part) in overlap with the current region ?*/
@@ -1505,9 +1513,6 @@ e820_setup_gap(struct e820entry *e820, i
  */
 static int __init request_standard_resources(void)
 {
-#ifdef CONFIG_XEN
-	struct xen_memory_map memmap;
-#endif
 	int	      i;
 
 	/* Nothing to do if not running in dom0. */
@@ -1516,13 +1521,6 @@ static int __init request_standard_resou
 
 	printk("Setting up standard PCI resources\n");
 #ifdef CONFIG_XEN
-	memmap.nr_entries = E820MAX;
-	set_xen_guest_handle(memmap.buffer, machine_e820.map);
-
-	if (HYPERVISOR_memory_op(XENMEM_machine_memory_map, &memmap))
-		BUG();
-	machine_e820.nr_map = memmap.nr_entries;
-
 	legacy_init_iomem_resources(machine_e820.map, machine_e820.nr_map,
 				    &code_resource, &data_resource);
 #else
@@ -1548,10 +1546,20 @@ static void __init register_memory(void)
 {
 
 #ifdef CONFIG_XEN
-	e820_setup_gap(machine_e820.map, machine_e820.nr_map);
-#else
-	e820_setup_gap(e820.map, e820.nr_map);
+	if (is_initial_xendomain()) {
+		struct xen_memory_map memmap;
+
+		memmap.nr_entries = E820MAX;
+		set_xen_guest_handle(memmap.buffer, machine_e820.map);
+
+		BUG_ON(HYPERVISOR_memory_op(XENMEM_machine_memory_map, &memmap));
+
+		machine_e820.nr_map = memmap.nr_entries;
+		e820_setup_gap(machine_e820.map, machine_e820.nr_map);
+	}
+	else
 #endif
+		e820_setup_gap(e820.map, e820.nr_map);
 }
 
 #ifdef CONFIG_MCA
arch/x86_64/kernel/e820-xen.c +11 -0
Index: head-2007-02-08/arch/x86_64/kernel/e820-xen.c
===================================================================
@@ -127,8 +127,19 @@ e820_any_mapped(unsigned long start, uns
 int __init e820_all_mapped(unsigned long start, unsigned long end, unsigned type)
 {
 	int i;
+
+#ifndef CONFIG_XEN
 	for (i = 0; i < e820.nr_map; i++) {
 		struct e820entry *ei = &e820.map[i];
+#else
+	extern struct e820map machine_e820;
+
+	if (!is_initial_xendomain())
+		return 0;
+	for (i = 0; i < machine_e820.nr_map; i++) {
+		const struct e820entry *ei = &machine_e820.map[i];
+#endif
+
 		if (type && ei->type != type)
 			continue;
 		/* is the region (part) in overlap with the current region ?*/
arch/x86_64/kernel/setup-xen.c +2 -2
Index: head-2007-02-08/arch/x86_64/kernel/setup-xen.c
===================================================================
@@ -585,8 +585,6 @@ static void discover_ebda(void)
 void __init setup_arch(char **cmdline_p)
 {
 #ifdef CONFIG_XEN
-	struct xen_memory_map memmap;
-
 	/* Register a call for panic conditions. */
 	atomic_notifier_chain_register(&panic_notifier_list, &xen_panic_block);
 
@@ -895,6 +893,8 @@ void __init setup_arch(char **cmdline_p)
 	probe_roms();
 #ifdef CONFIG_XEN
 	if (is_initial_xendomain()) {
+		struct xen_memory_map memmap;
+
 		memmap.nr_entries = E820MAX;
 		set_xen_guest_handle(memmap.buffer, machine_e820.map);