diff options
author | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-09-29 19:54:33 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-10-22 15:57:32 -0400 |
commit | 3654581e47adc07072aebe239818485b68ea04f0 (patch) | |
tree | 1496912323225c1d1b5186dffedf58f6b9c08388 /arch | |
parent | 41f2e4771a4f1ba26c35438daf32917b9ef7858d (diff) |
xen: don't add extra_pages for RAM after mem_end
If an E820 region is entirely beyond mem_end, don't attempt to truncate
it and add the truncated pages to extra_pages, as they will be negative.
Also, make sure the extra memory region starts after all BIOS provided
E820 regions (and in the case of RAM regions, post-clipping).
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/xen/setup.c | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index cad2fcd130ec..7a4ab05cff8a 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c | |||
@@ -52,20 +52,19 @@ phys_addr_t xen_extra_mem_start, xen_extra_mem_size; | |||
52 | static __init void xen_add_extra_mem(unsigned long pages) | 52 | static __init void xen_add_extra_mem(unsigned long pages) |
53 | { | 53 | { |
54 | u64 size = (u64)pages * PAGE_SIZE; | 54 | u64 size = (u64)pages * PAGE_SIZE; |
55 | u64 extra_start = xen_extra_mem_start + xen_extra_mem_size; | ||
55 | 56 | ||
56 | if (!pages) | 57 | if (!pages) |
57 | return; | 58 | return; |
58 | 59 | ||
59 | e820_add_region(xen_extra_mem_start + xen_extra_mem_size, size, E820_RAM); | 60 | e820_add_region(extra_start, size, E820_RAM); |
60 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); | 61 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); |
61 | 62 | ||
62 | reserve_early(xen_extra_mem_start + xen_extra_mem_size, | 63 | reserve_early(extra_start, extra_start + size, "XEN EXTRA"); |
63 | xen_extra_mem_start + xen_extra_mem_size + size, | ||
64 | "XEN EXTRA"); | ||
65 | 64 | ||
66 | xen_extra_mem_size += size; | 65 | xen_extra_mem_size += size; |
67 | 66 | ||
68 | xen_max_p2m_pfn = PFN_DOWN(xen_extra_mem_start + xen_extra_mem_size); | 67 | xen_max_p2m_pfn = PFN_DOWN(extra_start + size); |
69 | } | 68 | } |
70 | 69 | ||
71 | static unsigned long __init xen_release_chunk(phys_addr_t start_addr, | 70 | static unsigned long __init xen_release_chunk(phys_addr_t start_addr, |
@@ -175,15 +174,21 @@ char * __init xen_memory_setup(void) | |||
175 | unsigned long long end = map[i].addr + map[i].size; | 174 | unsigned long long end = map[i].addr + map[i].size; |
176 | 175 | ||
177 | if (map[i].type == E820_RAM) { | 176 | if (map[i].type == E820_RAM) { |
178 | if (end > mem_end) { | 177 | if (map[i].addr < mem_end && end > mem_end) { |
179 | /* Truncate region to max_mem. */ | 178 | /* Truncate region to max_mem. */ |
180 | map[i].size -= end - mem_end; | 179 | u64 delta = end - mem_end; |
181 | 180 | ||
182 | extra_pages += PFN_DOWN(end - mem_end); | 181 | map[i].size -= delta; |
182 | extra_pages += PFN_DOWN(delta); | ||
183 | |||
184 | end = mem_end; | ||
183 | } | 185 | } |
184 | } else if (map[i].type != E820_RAM) | 186 | } |
187 | |||
188 | if (end > xen_extra_mem_start) | ||
185 | xen_extra_mem_start = end; | 189 | xen_extra_mem_start = end; |
186 | 190 | ||
191 | /* If region is non-RAM or below mem_end, add what remains */ | ||
187 | if ((map[i].type != E820_RAM || map[i].addr < mem_end) && | 192 | if ((map[i].type != E820_RAM || map[i].addr < mem_end) && |
188 | map[i].size > 0) | 193 | map[i].size > 0) |
189 | e820_add_region(map[i].addr, map[i].size, map[i].type); | 194 | e820_add_region(map[i].addr, map[i].size, map[i].type); |