aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/xen/setup.c20
-rw-r--r--drivers/xen/balloon.c44
-rw-r--r--include/xen/page.h10
3 files changed, 46 insertions, 28 deletions
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c
index c983717c018c..0c8e974c738a 100644
--- a/arch/x86/xen/setup.c
+++ b/arch/x86/xen/setup.c
@@ -37,7 +37,7 @@ extern void xen_syscall_target(void);
37extern void xen_syscall32_target(void); 37extern void xen_syscall32_target(void);
38 38
39/* Amount of extra memory space we add to the e820 ranges */ 39/* Amount of extra memory space we add to the e820 ranges */
40phys_addr_t xen_extra_mem_start, xen_extra_mem_size; 40struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
41 41
42/* Number of pages released from the initial allocation. */ 42/* Number of pages released from the initial allocation. */
43unsigned long xen_released_pages; 43unsigned long xen_released_pages;
@@ -59,7 +59,7 @@ static void __init xen_add_extra_mem(unsigned long pages)
59 unsigned long pfn; 59 unsigned long pfn;
60 60
61 u64 size = (u64)pages * PAGE_SIZE; 61 u64 size = (u64)pages * PAGE_SIZE;
62 u64 extra_start = xen_extra_mem_start + xen_extra_mem_size; 62 u64 extra_start = xen_extra_mem[0].start + xen_extra_mem[0].size;
63 63
64 if (!pages) 64 if (!pages)
65 return; 65 return;
@@ -69,7 +69,7 @@ static void __init xen_add_extra_mem(unsigned long pages)
69 69
70 memblock_x86_reserve_range(extra_start, extra_start + size, "XEN EXTRA"); 70 memblock_x86_reserve_range(extra_start, extra_start + size, "XEN EXTRA");
71 71
72 xen_extra_mem_size += size; 72 xen_extra_mem[0].size += size;
73 73
74 xen_max_p2m_pfn = PFN_DOWN(extra_start + size); 74 xen_max_p2m_pfn = PFN_DOWN(extra_start + size);
75 75
@@ -242,7 +242,7 @@ char * __init xen_memory_setup(void)
242 242
243 memcpy(map_raw, map, sizeof(map)); 243 memcpy(map_raw, map, sizeof(map));
244 e820.nr_map = 0; 244 e820.nr_map = 0;
245 xen_extra_mem_start = mem_end; 245 xen_extra_mem[0].start = mem_end;
246 for (i = 0; i < memmap.nr_entries; i++) { 246 for (i = 0; i < memmap.nr_entries; i++) {
247 unsigned long long end; 247 unsigned long long end;
248 248
@@ -270,8 +270,8 @@ char * __init xen_memory_setup(void)
270 e820_add_region(end, delta, E820_UNUSABLE); 270 e820_add_region(end, delta, E820_UNUSABLE);
271 } 271 }
272 272
273 if (map[i].size > 0 && end > xen_extra_mem_start) 273 if (map[i].size > 0 && end > xen_extra_mem[0].start)
274 xen_extra_mem_start = end; 274 xen_extra_mem[0].start = end;
275 275
276 /* Add region if any remains */ 276 /* Add region if any remains */
277 if (map[i].size > 0) 277 if (map[i].size > 0)
@@ -279,10 +279,10 @@ char * __init xen_memory_setup(void)
279 } 279 }
280 /* Align the balloon area so that max_low_pfn does not get set 280 /* Align the balloon area so that max_low_pfn does not get set
281 * to be at the _end_ of the PCI gap at the far end (fee01000). 281 * to be at the _end_ of the PCI gap at the far end (fee01000).
282 * Note that xen_extra_mem_start gets set in the loop above to be 282 * Note that the start of balloon area gets set in the loop above
283 * past the last E820 region. */ 283 * to be past the last E820 region. */
284 if (xen_initial_domain() && (xen_extra_mem_start < (1ULL<<32))) 284 if (xen_initial_domain() && (xen_extra_mem[0].start < (1ULL<<32)))
285 xen_extra_mem_start = (1ULL<<32); 285 xen_extra_mem[0].start = (1ULL<<32);
286 286
287 /* 287 /*
288 * In domU, the ISA region is normal, usable memory, but we 288 * In domU, the ISA region is normal, usable memory, but we
diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index 9efb993090aa..fc43b53651d7 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -555,11 +555,32 @@ void free_xenballooned_pages(int nr_pages, struct page** pages)
555} 555}
556EXPORT_SYMBOL(free_xenballooned_pages); 556EXPORT_SYMBOL(free_xenballooned_pages);
557 557
558static int __init balloon_init(void) 558static void __init balloon_add_region(unsigned long start_pfn,
559 unsigned long pages)
559{ 560{
560 unsigned long pfn, extra_pfn_end; 561 unsigned long pfn, extra_pfn_end;
561 struct page *page; 562 struct page *page;
562 563
564 /*
565 * If the amount of usable memory has been limited (e.g., with
566 * the 'mem' command line parameter), don't add pages beyond
567 * this limit.
568 */
569 extra_pfn_end = min(max_pfn, start_pfn + pages);
570
571 for (pfn = start_pfn; pfn < extra_pfn_end; pfn++) {
572 page = pfn_to_page(pfn);
573 /* totalram_pages and totalhigh_pages do not
574 include the boot-time balloon extension, so
575 don't subtract from it. */
576 __balloon_append(page);
577 }
578}
579
580static int __init balloon_init(void)
581{
582 int i;
583
563 if (!xen_domain()) 584 if (!xen_domain())
564 return -ENODEV; 585 return -ENODEV;
565 586
@@ -587,23 +608,12 @@ static int __init balloon_init(void)
587 608
588 /* 609 /*
589 * Initialize the balloon with pages from the extra memory 610 * Initialize the balloon with pages from the extra memory
590 * region (see arch/x86/xen/setup.c). 611 * regions (see arch/x86/xen/setup.c).
591 *
592 * If the amount of usable memory has been limited (e.g., with
593 * the 'mem' command line parameter), don't add pages beyond
594 * this limit.
595 */ 612 */
596 extra_pfn_end = min(max_pfn, 613 for (i = 0; i < XEN_EXTRA_MEM_MAX_REGIONS; i++)
597 (unsigned long)PFN_DOWN(xen_extra_mem_start 614 if (xen_extra_mem[i].size)
598 + xen_extra_mem_size)); 615 balloon_add_region(PFN_UP(xen_extra_mem[i].start),
599 for (pfn = PFN_UP(xen_extra_mem_start); 616 PFN_DOWN(xen_extra_mem[i].size));
600 pfn < extra_pfn_end;
601 pfn++) {
602 page = pfn_to_page(pfn);
603 /* totalram_pages and totalhigh_pages do not include the boot-time
604 balloon extension, so don't subtract from it. */
605 __balloon_append(page);
606 }
607 617
608 return 0; 618 return 0;
609} 619}
diff --git a/include/xen/page.h b/include/xen/page.h
index 92b61f8c772c..12765b6f9517 100644
--- a/include/xen/page.h
+++ b/include/xen/page.h
@@ -3,7 +3,15 @@
3 3
4#include <asm/xen/page.h> 4#include <asm/xen/page.h>
5 5
6extern phys_addr_t xen_extra_mem_start, xen_extra_mem_size; 6struct xen_memory_region {
7 phys_addr_t start;
8 phys_addr_t size;
9};
10
11#define XEN_EXTRA_MEM_MAX_REGIONS 128 /* == E820MAX */
12
13extern __initdata
14struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS];
7 15
8extern unsigned long xen_released_pages; 16extern unsigned long xen_released_pages;
9 17