diff options
| author | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-08-30 19:41:02 -0400 |
|---|---|---|
| committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-10-22 15:57:27 -0400 |
| commit | 42ee1471e9b879479a15debac752314a596c738e (patch) | |
| tree | 119d3a47d8561a5447b8de882fa45362cb34b8f7 | |
| parent | 35ae11fd146384d222f3bb1f17eed1970cc92c36 (diff) | |
xen: implement "extra" memory to reserve space for pages not present at boot
When using the e820 map to get the initial pseudo-physical address space,
look for either Xen-provided memory which doesn't lie within an E820
region, or an E820 RAM region which extends beyond the Xen-provided
memory range.
Count these pages, and add them to a new "extra memory" range. This range
has an E820 RAM range to describe it - so the kernel will allocate page
structures for it - but it is also marked reserved so that the kernel
will not attempt to use it.
The balloon driver can then add this range as a set of currently
ballooned-out pages, which can be used to extend the domain beyond its
original size.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
| -rw-r--r-- | arch/x86/xen/setup.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/arch/x86/xen/setup.c b/arch/x86/xen/setup.c index dd2eb2a9303f..f9a99eaddcdc 100644 --- a/arch/x86/xen/setup.c +++ b/arch/x86/xen/setup.c | |||
| @@ -34,6 +34,26 @@ extern void xen_sysenter_target(void); | |||
| 34 | extern void xen_syscall_target(void); | 34 | extern void xen_syscall_target(void); |
| 35 | extern void xen_syscall32_target(void); | 35 | extern void xen_syscall32_target(void); |
| 36 | 36 | ||
| 37 | /* Amount of extra memory space we add to the e820 ranges */ | ||
| 38 | phys_addr_t xen_extra_mem_start, xen_extra_mem_size; | ||
| 39 | |||
| 40 | static __init void xen_add_extra_mem(unsigned long pages) | ||
| 41 | { | ||
| 42 | u64 size = (u64)pages * PAGE_SIZE; | ||
| 43 | |||
| 44 | if (!pages) | ||
| 45 | return; | ||
| 46 | |||
| 47 | e820_add_region(xen_extra_mem_start + xen_extra_mem_size, size, E820_RAM); | ||
| 48 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); | ||
| 49 | |||
| 50 | reserve_early(xen_extra_mem_start + xen_extra_mem_size, | ||
| 51 | xen_extra_mem_start + xen_extra_mem_size + size, | ||
| 52 | "XEN EXTRA"); | ||
| 53 | |||
| 54 | xen_extra_mem_size += size; | ||
| 55 | } | ||
| 56 | |||
| 37 | static unsigned long __init xen_release_chunk(phys_addr_t start_addr, | 57 | static unsigned long __init xen_release_chunk(phys_addr_t start_addr, |
| 38 | phys_addr_t end_addr) | 58 | phys_addr_t end_addr) |
| 39 | { | 59 | { |
| @@ -105,7 +125,6 @@ static unsigned long __init xen_return_unused_memory(unsigned long max_pfn, | |||
| 105 | /** | 125 | /** |
| 106 | * machine_specific_memory_setup - Hook for machine specific memory setup. | 126 | * machine_specific_memory_setup - Hook for machine specific memory setup. |
| 107 | **/ | 127 | **/ |
| 108 | |||
| 109 | char * __init xen_memory_setup(void) | 128 | char * __init xen_memory_setup(void) |
| 110 | { | 129 | { |
| 111 | static struct e820entry map[E820MAX] __initdata; | 130 | static struct e820entry map[E820MAX] __initdata; |
| @@ -114,6 +133,7 @@ char * __init xen_memory_setup(void) | |||
| 114 | unsigned long long mem_end; | 133 | unsigned long long mem_end; |
| 115 | int rc; | 134 | int rc; |
| 116 | struct xen_memory_map memmap; | 135 | struct xen_memory_map memmap; |
| 136 | unsigned long extra_pages = 0; | ||
| 117 | int i; | 137 | int i; |
| 118 | 138 | ||
| 119 | max_pfn = min(MAX_DOMAIN_PAGES, max_pfn); | 139 | max_pfn = min(MAX_DOMAIN_PAGES, max_pfn); |
| @@ -135,6 +155,7 @@ char * __init xen_memory_setup(void) | |||
| 135 | BUG_ON(rc); | 155 | BUG_ON(rc); |
| 136 | 156 | ||
| 137 | e820.nr_map = 0; | 157 | e820.nr_map = 0; |
| 158 | xen_extra_mem_start = mem_end; | ||
| 138 | for (i = 0; i < memmap.nr_entries; i++) { | 159 | for (i = 0; i < memmap.nr_entries; i++) { |
| 139 | unsigned long long end = map[i].addr + map[i].size; | 160 | unsigned long long end = map[i].addr + map[i].size; |
| 140 | if (map[i].type == E820_RAM) { | 161 | if (map[i].type == E820_RAM) { |
| @@ -143,6 +164,8 @@ char * __init xen_memory_setup(void) | |||
| 143 | if (end > mem_end) { | 164 | if (end > mem_end) { |
| 144 | /* Truncate region to max_mem. */ | 165 | /* Truncate region to max_mem. */ |
| 145 | map[i].size -= end - mem_end; | 166 | map[i].size -= end - mem_end; |
| 167 | |||
| 168 | extra_pages += PFN_DOWN(end - mem_end); | ||
| 146 | } | 169 | } |
| 147 | } | 170 | } |
| 148 | if (map[i].size > 0) | 171 | if (map[i].size > 0) |
| @@ -169,7 +192,9 @@ char * __init xen_memory_setup(void) | |||
| 169 | 192 | ||
| 170 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); | 193 | sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map); |
| 171 | 194 | ||
| 172 | xen_return_unused_memory(xen_start_info->nr_pages, &e820); | 195 | extra_pages += xen_return_unused_memory(xen_start_info->nr_pages, &e820); |
| 196 | |||
| 197 | xen_add_extra_mem(extra_pages); | ||
| 173 | 198 | ||
| 174 | return "Xen"; | 199 | return "Xen"; |
| 175 | } | 200 | } |
