]>
Commit | Line | Data |
---|---|---|
cc90b958 BS |
1 | From: jbeulich@novell.com |
2 | Subject: fix issues with the assignment of huge amounts of memory | |
3 | Patch-mainline: obsolete | |
4 | ||
5 | At the same time remove the non-applicable and broken support for the | |
6 | memmap= command line option. | |
cc90b958 | 7 | |
00e5a55c BS |
8 | --- sle11-2009-05-14.orig/arch/x86/kernel/e820-xen.c 2009-02-17 14:01:20.000000000 +0100 |
9 | +++ sle11-2009-05-14/arch/x86/kernel/e820-xen.c 2009-03-13 16:14:19.000000000 +0100 | |
10 | @@ -1308,6 +1308,26 @@ static int __init parse_memopt(char *p) | |
cc90b958 BS |
11 | |
12 | i = e820.nr_map - 1; | |
13 | current_end = e820.map[i].addr + e820.map[i].size; | |
14 | + | |
15 | + /* | |
16 | + * A little less than 2% of available memory are needed for page | |
17 | + * tables, p2m map, and mem_map. Hence the maximum amount of memory | |
18 | + * we can potentially balloon up to can in no case exceed about 50 | |
19 | + * times of what we've been given initially. Since even with that we | |
20 | + * won't be able to boot (due to various calculations done based on | |
21 | + * the total number of pages) we further restrict this to factor 32. | |
22 | + */ | |
23 | + if ((mem_size >> (PAGE_SHIFT + 5)) > xen_start_info->nr_pages) { | |
24 | + u64 size = (u64)xen_start_info->nr_pages << 5; | |
25 | + | |
26 | + printk(KERN_WARNING "mem=%Luk is invalid for an initial" | |
27 | + " allocation of %luk, using %Luk\n", | |
28 | + (unsigned long long)mem_size >> 10, | |
29 | + xen_start_info->nr_pages << (PAGE_SHIFT - 10), | |
30 | + (unsigned long long)size << (PAGE_SHIFT - 10)); | |
31 | + mem_size = size << PAGE_SHIFT; | |
32 | + } | |
33 | + | |
34 | if (current_end < mem_size) { | |
35 | /* | |
36 | * The e820 map ends before our requested size so | |
00e5a55c | 37 | @@ -1367,6 +1387,7 @@ static int __init parse_memmap_opt(char |
cc90b958 BS |
38 | return *p == '\0' ? 0 : -EINVAL; |
39 | } | |
40 | early_param("memmap", parse_memmap_opt); | |
41 | +#endif | |
42 | ||
43 | void __init finish_e820_parsing(void) | |
44 | { | |
00e5a55c | 45 | @@ -1381,7 +1402,6 @@ void __init finish_e820_parsing(void) |
cc90b958 BS |
46 | e820_print_map("user"); |
47 | } | |
48 | } | |
49 | -#endif | |
50 | ||
51 | static inline const char *e820_type_to_string(int e820_type) | |
52 | { | |
00e5a55c BS |
53 | @@ -1407,7 +1427,7 @@ void __init e820_reserve_resources(void) |
54 | struct resource *res; | |
55 | u64 end; | |
56 | ||
57 | - res = alloc_bootmem_low(sizeof(struct resource) * e820.nr_map); | |
58 | + res = alloc_bootmem(sizeof(struct resource) * e820.nr_map); | |
59 | for (i = 0; i < e820.nr_map; i++) { | |
60 | end = e820.map[i].addr + e820.map[i].size - 1; | |
61 | #ifndef CONFIG_RESOURCES_64BIT | |
62 | --- sle11-2009-05-14.orig/arch/x86/kernel/setup-xen.c 2008-11-17 13:58:02.000000000 +0100 | |
63 | +++ sle11-2009-05-14/arch/x86/kernel/setup-xen.c 2009-02-16 17:05:16.000000000 +0100 | |
cc90b958 BS |
64 | @@ -128,12 +128,7 @@ static struct notifier_block xen_panic_b |
65 | unsigned long *phys_to_machine_mapping; | |
66 | EXPORT_SYMBOL(phys_to_machine_mapping); | |
67 | ||
68 | -unsigned long *pfn_to_mfn_frame_list_list, | |
69 | -#ifdef CONFIG_X86_64 | |
70 | - *pfn_to_mfn_frame_list[512]; | |
71 | -#else | |
72 | - *pfn_to_mfn_frame_list[128]; | |
73 | -#endif | |
74 | +unsigned long *pfn_to_mfn_frame_list_list, **pfn_to_mfn_frame_list; | |
75 | ||
76 | /* Raw start-of-day parameters from the hypervisor. */ | |
77 | start_info_t *xen_start_info; | |
00e5a55c | 78 | @@ -1037,17 +1032,17 @@ void __init setup_arch(char **cmdline_p) |
cc90b958 BS |
79 | p2m_pages = xen_start_info->nr_pages; |
80 | ||
81 | if (!xen_feature(XENFEAT_auto_translated_physmap)) { | |
82 | - unsigned long i, j; | |
83 | + unsigned long i, j, size; | |
84 | unsigned int k, fpp; | |
85 | ||
86 | /* Make sure we have a large enough P->M table. */ | |
87 | phys_to_machine_mapping = alloc_bootmem_pages( | |
88 | max_pfn * sizeof(unsigned long)); | |
89 | - memset(phys_to_machine_mapping, ~0, | |
90 | - max_pfn * sizeof(unsigned long)); | |
91 | memcpy(phys_to_machine_mapping, | |
92 | (unsigned long *)xen_start_info->mfn_list, | |
93 | p2m_pages * sizeof(unsigned long)); | |
94 | + memset(phys_to_machine_mapping + p2m_pages, ~0, | |
95 | + (max_pfn - p2m_pages) * sizeof(unsigned long)); | |
96 | free_bootmem( | |
97 | __pa(xen_start_info->mfn_list), | |
98 | PFN_PHYS(PFN_UP(xen_start_info->nr_pages * | |
00e5a55c | 99 | @@ -1057,15 +1052,26 @@ void __init setup_arch(char **cmdline_p) |
cc90b958 BS |
100 | * Initialise the list of the frames that specify the list of |
101 | * frames that make up the p2m table. Used by save/restore. | |
102 | */ | |
103 | - pfn_to_mfn_frame_list_list = alloc_bootmem_pages(PAGE_SIZE); | |
104 | - | |
105 | fpp = PAGE_SIZE/sizeof(unsigned long); | |
106 | + size = (max_pfn + fpp - 1) / fpp; | |
107 | + size = (size + fpp - 1) / fpp; | |
108 | + ++size; /* include a zero terminator for crash tools */ | |
109 | + size *= sizeof(unsigned long); | |
110 | + pfn_to_mfn_frame_list_list = alloc_bootmem_pages(size); | |
111 | + if (size > PAGE_SIZE | |
112 | + && xen_create_contiguous_region((unsigned long) | |
113 | + pfn_to_mfn_frame_list_list, | |
114 | + get_order(size), 0)) | |
115 | + BUG(); | |
116 | + size -= sizeof(unsigned long); | |
117 | + pfn_to_mfn_frame_list = alloc_bootmem(size); | |
118 | + | |
119 | for (i = j = 0, k = -1; i < max_pfn; i += fpp, j++) { | |
120 | if (j == fpp) | |
121 | j = 0; | |
122 | if (j == 0) { | |
123 | k++; | |
124 | - BUG_ON(k>=ARRAY_SIZE(pfn_to_mfn_frame_list)); | |
125 | + BUG_ON(k * sizeof(unsigned long) >= size); | |
126 | pfn_to_mfn_frame_list[k] = | |
127 | alloc_bootmem_pages(PAGE_SIZE); | |
128 | pfn_to_mfn_frame_list_list[k] = | |
00e5a55c BS |
129 | --- sle11-2009-05-14.orig/arch/x86/kernel/setup_percpu-xen.c 2009-03-16 16:38:16.000000000 +0100 |
130 | +++ sle11-2009-05-14/arch/x86/kernel/setup_percpu-xen.c 2009-03-13 16:14:41.000000000 +0100 | |
131 | @@ -211,7 +211,7 @@ static void __init setup_node_to_cpumask | |
132 | } | |
133 | ||
134 | /* allocate the map */ | |
135 | - map = alloc_bootmem_low(nr_node_ids * sizeof(cpumask_t)); | |
136 | + map = alloc_bootmem(nr_node_ids * sizeof(cpumask_t)); | |
137 | ||
138 | pr_debug(KERN_DEBUG "Node to cpumask map at %p for %d nodes\n", | |
139 | map, nr_node_ids); | |
140 | --- sle11-2009-05-14.orig/drivers/xen/core/machine_kexec.c 2009-03-16 16:38:16.000000000 +0100 | |
141 | +++ sle11-2009-05-14/drivers/xen/core/machine_kexec.c 2009-03-13 16:13:15.000000000 +0100 | |
142 | @@ -57,7 +57,7 @@ void __init xen_machine_kexec_setup_reso | |
143 | ||
144 | /* allocate xen_phys_cpus */ | |
145 | ||
146 | - xen_phys_cpus = alloc_bootmem_low(k * sizeof(struct resource)); | |
147 | + xen_phys_cpus = alloc_bootmem(k * sizeof(struct resource)); | |
148 | BUG_ON(xen_phys_cpus == NULL); | |
149 | ||
150 | /* fill in xen_phys_cpus with per-cpu crash note information */ | |
151 | --- sle11-2009-05-14.orig/drivers/xen/core/machine_reboot.c 2009-02-17 12:23:48.000000000 +0100 | |
152 | +++ sle11-2009-05-14/drivers/xen/core/machine_reboot.c 2009-02-17 12:25:29.000000000 +0100 | |
153 | @@ -76,7 +76,7 @@ static void post_suspend(int suspend_can | |
cc90b958 BS |
154 | unsigned long shinfo_mfn; |
155 | extern unsigned long max_pfn; | |
156 | extern unsigned long *pfn_to_mfn_frame_list_list; | |
157 | - extern unsigned long *pfn_to_mfn_frame_list[]; | |
158 | + extern unsigned long **pfn_to_mfn_frame_list; | |
159 | ||
160 | if (suspend_cancelled) { | |
161 | xen_start_info->store_mfn = |