diff options
author | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-11-22 19:31:35 -0500 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-11-22 19:34:28 -0500 |
commit | c2d0879112825cddddd6c4f9b2645ff32acd6dc5 (patch) | |
tree | 953a9658ec2e2e785ce5ca584b8df16294a4e0c5 /arch/x86/xen/setup.c | |
parent | 12334715720b012180579f57650879d0fbb11a84 (diff) |
xen: clean up "extra" memory handling some more
Make sure that extra_pages is added for all E820_RAM regions beyond
mem_end - completely excluded regions as well as the remains of partially
included regions.
Also makes sure the extra region is not unnecessarily high, and simplifies
the logic to decide which regions should be added.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch/x86/xen/setup.c')
-rw-r--r-- | arch/x86/xen/setup.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index 38fdffaa71d3..b85dceef56f7 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c | |||
@@ -182,24 +182,21 @@ char * __init xen_memory_setup(void) | |||
182 | for (i = 0; i < memmap.nr_entries; i++) { | 182 | for (i = 0; i < memmap.nr_entries; i++) { |
183 | unsigned long long end = map[i].addr + map[i].size; | 183 | unsigned long long end = map[i].addr + map[i].size; |
184 | 184 | ||
185 | if (map[i].type == E820_RAM) { | 185 | if (map[i].type == E820_RAM && end > mem_end) { |
186 | if (map[i].addr < mem_end && end > mem_end) { | 186 | /* RAM off the end - may be partially included */ |
187 | /* Truncate region to max_mem. */ | 187 | u64 delta = min(map[i].size, end - mem_end); |
188 | u64 delta = end - mem_end; | ||
189 | 188 | ||
190 | map[i].size -= delta; | 189 | map[i].size -= delta; |
191 | extra_pages += PFN_DOWN(delta); | 190 | end -= delta; |
192 | 191 | ||
193 | end = mem_end; | 192 | extra_pages += PFN_DOWN(delta); |
194 | } | ||
195 | } | 193 | } |
196 | 194 | ||
197 | if (end > xen_extra_mem_start) | 195 | if (map[i].size > 0 && end > xen_extra_mem_start) |
198 | xen_extra_mem_start = end; | 196 | xen_extra_mem_start = end; |
199 | 197 | ||
200 | /* If region is non-RAM or below mem_end, add what remains */ | 198 | /* Add region if any remains */ |
201 | if ((map[i].type != E820_RAM || map[i].addr < mem_end) && | 199 | if (map[i].size > 0) |
202 | map[i].size > 0) | ||
203 | e820_add_region(map[i].addr, map[i].size, map[i].type); | 200 | e820_add_region(map[i].addr, map[i].size, map[i].type); |
204 | } | 201 | } |
205 | 202 | ||