aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/xen/setup.c23
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;
52static __init void xen_add_extra_mem(unsigned long pages) 52static __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
71static unsigned long __init xen_release_chunk(phys_addr_t start_addr, 70static 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);