From: jbeulich@novell.com
Subject: fix issues with the assignment of huge amounts of memory
Patch-mainline: obsolete
+References: bnc#482614, bnc#537435
-At the same time remove the non-applicable and broken support for the
-memmap= command line option.
-
---- sle11-2009-07-31.orig/arch/x86/kernel/e820-xen.c 2009-02-17 14:01:20.000000000 +0100
-+++ sle11-2009-07-31/arch/x86/kernel/e820-xen.c 2009-03-13 16:14:19.000000000 +0100
-@@ -1308,6 +1308,26 @@ static int __init parse_memopt(char *p)
+--- sle11-2009-09-18.orig/arch/x86/kernel/e820-xen.c 2009-02-17 14:01:20.000000000 +0100
++++ sle11-2009-09-18/arch/x86/kernel/e820-xen.c 2009-09-18 10:08:03.000000000 +0200
+@@ -1317,6 +1317,26 @@ static int __init parse_memopt(char *p)
i = e820.nr_map - 1;
current_end = e820.map[i].addr + e820.map[i].size;
if (current_end < mem_size) {
/*
* The e820 map ends before our requested size so
-@@ -1367,6 +1387,7 @@ static int __init parse_memmap_opt(char
- return *p == '\0' ? 0 : -EINVAL;
- }
- early_param("memmap", parse_memmap_opt);
-+#endif
-
- void __init finish_e820_parsing(void)
- {
-@@ -1381,7 +1402,6 @@ void __init finish_e820_parsing(void)
- e820_print_map("user");
- }
- }
--#endif
-
- static inline const char *e820_type_to_string(int e820_type)
- {
-@@ -1407,7 +1427,7 @@ void __init e820_reserve_resources(void)
+@@ -1416,7 +1436,7 @@ void __init e820_reserve_resources(void)
struct resource *res;
u64 end;
for (i = 0; i < e820.nr_map; i++) {
end = e820.map[i].addr + e820.map[i].size - 1;
#ifndef CONFIG_RESOURCES_64BIT
---- sle11-2009-07-31.orig/arch/x86/kernel/setup-xen.c 2009-07-31 15:14:20.000000000 +0200
-+++ sle11-2009-07-31/arch/x86/kernel/setup-xen.c 2009-07-31 15:14:31.000000000 +0200
+@@ -1498,6 +1518,7 @@ char *__init __attribute__((weak)) machi
+ char * __init memory_setup(void)
+ {
+ int rc, nr_map;
++ unsigned long long maxmem;
+ struct xen_memory_map memmap;
+ /*
+ * This is rather large for a stack variable but this early in
+@@ -1527,6 +1548,22 @@ char * __init memory_setup(void)
+ BUG();
+
+ #ifdef CONFIG_XEN
++ /* See the comment in parse_memopt(). */
++ for (maxmem = rc = 0; rc < e820.nr_map; ++rc)
++ if (e820.map[rc].type == E820_RAM)
++ maxmem += e820.map[rc].size;
++ if ((maxmem >> (PAGE_SHIFT + 5)) > xen_start_info->nr_pages) {
++ unsigned long long size = (u64)xen_start_info->nr_pages << 5;
++
++ printk(KERN_WARNING "maxmem of %LuM is invalid for an initial"
++ " allocation of %luM, using %LuM\n",
++ maxmem >> 20,
++ xen_start_info->nr_pages >> (20 - PAGE_SHIFT),
++ size >> (20 - PAGE_SHIFT));
++ size <<= PAGE_SHIFT;
++ e820_remove_range(size, ULLONG_MAX - size, E820_RAM, 1);
++ }
++
+ if (is_initial_xendomain()) {
+ memmap.nr_entries = E820MAX;
+ set_xen_guest_handle(memmap.buffer, machine_e820.map);
+--- sle11-2009-09-18.orig/arch/x86/kernel/setup-xen.c 2009-07-31 15:14:20.000000000 +0200
++++ sle11-2009-09-18/arch/x86/kernel/setup-xen.c 2009-07-31 15:14:31.000000000 +0200
@@ -128,12 +128,7 @@ static struct notifier_block xen_panic_b
unsigned long *phys_to_machine_mapping;
EXPORT_SYMBOL(phys_to_machine_mapping);
pfn_to_mfn_frame_list[k] =
alloc_bootmem_pages(PAGE_SIZE);
pfn_to_mfn_frame_list_list[k] =
---- sle11-2009-07-31.orig/arch/x86/kernel/setup_percpu-xen.c 2009-06-04 10:21:39.000000000 +0200
-+++ sle11-2009-07-31/arch/x86/kernel/setup_percpu-xen.c 2009-03-13 16:14:41.000000000 +0100
-@@ -211,7 +211,7 @@ static void __init setup_node_to_cpumask
+--- sle11-2009-09-18.orig/arch/x86/kernel/setup_percpu-xen.c 2009-08-26 12:17:43.000000000 +0200
++++ sle11-2009-09-18/arch/x86/kernel/setup_percpu-xen.c 2009-08-26 12:19:19.000000000 +0200
+@@ -206,7 +206,7 @@ static void __init setup_node_to_cpumask
}
/* allocate the map */
pr_debug(KERN_DEBUG "Node to cpumask map at %p for %d nodes\n",
map, nr_node_ids);
---- sle11-2009-07-31.orig/drivers/xen/core/machine_kexec.c 2009-06-04 10:21:39.000000000 +0200
-+++ sle11-2009-07-31/drivers/xen/core/machine_kexec.c 2009-03-13 16:13:15.000000000 +0100
+--- sle11-2009-09-18.orig/drivers/xen/core/machine_kexec.c 2009-06-04 10:21:39.000000000 +0200
++++ sle11-2009-09-18/drivers/xen/core/machine_kexec.c 2009-03-13 16:13:15.000000000 +0100
@@ -57,7 +57,7 @@ void __init xen_machine_kexec_setup_reso
/* allocate xen_phys_cpus */
BUG_ON(xen_phys_cpus == NULL);
/* fill in xen_phys_cpus with per-cpu crash note information */
---- sle11-2009-07-31.orig/drivers/xen/core/machine_reboot.c 2009-02-17 12:23:48.000000000 +0100
-+++ sle11-2009-07-31/drivers/xen/core/machine_reboot.c 2009-02-17 12:25:29.000000000 +0100
+--- sle11-2009-09-18.orig/drivers/xen/core/machine_reboot.c 2009-02-17 12:23:48.000000000 +0100
++++ sle11-2009-09-18/drivers/xen/core/machine_reboot.c 2009-02-17 12:25:29.000000000 +0100
@@ -76,7 +76,7 @@ static void post_suspend(int suspend_can
unsigned long shinfo_mfn;
extern unsigned long max_pfn;