diff options
author | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-08-26 18:04:48 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-10-22 15:57:18 -0400 |
commit | a171ce6e7b4d967b9f9b8ba7c076a8a6d26e432b (patch) | |
tree | 390e26005e9e49c8926b33b134b0b74c7dbf9b8f /arch/x86 | |
parent | 5e941c093989dfb6b67148d2410d79b1be8debfe (diff) |
xen: dynamically allocate p2m space
Use early brk mechanism to allocate p2m tables, to save memory when
booting non-Xen.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch/x86')
-rw-r--r-- | arch/x86/xen/mmu.c | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index 42086ac406af..ecbdcf0d45d4 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -174,18 +174,16 @@ DEFINE_PER_CPU(unsigned long, xen_current_cr3); /* actual vcpu cr3 */ | |||
174 | #define TOP_ENTRIES (MAX_DOMAIN_PAGES / P2M_ENTRIES_PER_PAGE) | 174 | #define TOP_ENTRIES (MAX_DOMAIN_PAGES / P2M_ENTRIES_PER_PAGE) |
175 | 175 | ||
176 | /* Placeholder for holes in the address space */ | 176 | /* Placeholder for holes in the address space */ |
177 | static unsigned long p2m_missing[P2M_ENTRIES_PER_PAGE] __page_aligned_data = | 177 | static RESERVE_BRK_ARRAY(unsigned long, p2m_missing, P2M_ENTRIES_PER_PAGE); |
178 | { [ 0 ... P2M_ENTRIES_PER_PAGE-1 ] = ~0UL }; | ||
179 | 178 | ||
180 | /* Array of pointers to pages containing p2m entries */ | 179 | /* Array of pointers to pages containing p2m entries */ |
181 | static unsigned long *p2m_top[TOP_ENTRIES] __page_aligned_data = | 180 | static RESERVE_BRK_ARRAY(unsigned long *, p2m_top, TOP_ENTRIES); |
182 | { [ 0 ... TOP_ENTRIES - 1] = &p2m_missing[0] }; | ||
183 | 181 | ||
184 | /* Arrays of p2m arrays expressed in mfns used for save/restore */ | 182 | /* Arrays of p2m arrays expressed in mfns used for save/restore */ |
185 | static unsigned long p2m_top_mfn[TOP_ENTRIES] __page_aligned_bss; | 183 | static RESERVE_BRK_ARRAY(unsigned long, p2m_top_mfn, TOP_ENTRIES); |
186 | 184 | ||
187 | static unsigned long p2m_top_mfn_list[TOP_ENTRIES / P2M_ENTRIES_PER_PAGE] | 185 | static RESERVE_BRK_ARRAY(unsigned long, p2m_top_mfn_list, |
188 | __page_aligned_bss; | 186 | (TOP_ENTRIES / P2M_ENTRIES_PER_PAGE)); |
189 | 187 | ||
190 | static inline unsigned p2m_top_index(unsigned long pfn) | 188 | static inline unsigned p2m_top_index(unsigned long pfn) |
191 | { | 189 | { |
@@ -209,7 +207,7 @@ void xen_build_mfn_list_list(void) | |||
209 | p2m_top_mfn[topidx] = virt_to_mfn(p2m_top[topidx]); | 207 | p2m_top_mfn[topidx] = virt_to_mfn(p2m_top[topidx]); |
210 | } | 208 | } |
211 | 209 | ||
212 | for (idx = 0; idx < ARRAY_SIZE(p2m_top_mfn_list); idx++) { | 210 | for (idx = 0; idx < TOP_ENTRIES/P2M_ENTRIES_PER_PAGE; idx++) { |
213 | unsigned topidx = idx * P2M_ENTRIES_PER_PAGE; | 211 | unsigned topidx = idx * P2M_ENTRIES_PER_PAGE; |
214 | p2m_top_mfn_list[idx] = virt_to_mfn(&p2m_top_mfn[topidx]); | 212 | p2m_top_mfn_list[idx] = virt_to_mfn(&p2m_top_mfn[topidx]); |
215 | } | 213 | } |
@@ -230,6 +228,22 @@ void __init xen_build_dynamic_phys_to_machine(void) | |||
230 | unsigned long *mfn_list = (unsigned long *)xen_start_info->mfn_list; | 228 | unsigned long *mfn_list = (unsigned long *)xen_start_info->mfn_list; |
231 | unsigned long max_pfn = min(MAX_DOMAIN_PAGES, xen_start_info->nr_pages); | 229 | unsigned long max_pfn = min(MAX_DOMAIN_PAGES, xen_start_info->nr_pages); |
232 | unsigned pfn; | 230 | unsigned pfn; |
231 | unsigned i; | ||
232 | |||
233 | p2m_missing = extend_brk(sizeof(*p2m_missing) * P2M_ENTRIES_PER_PAGE, | ||
234 | PAGE_SIZE); | ||
235 | for (i = 0; i < P2M_ENTRIES_PER_PAGE; i++) | ||
236 | p2m_missing[i] = ~0UL; | ||
237 | |||
238 | p2m_top = extend_brk(sizeof(*p2m_top) * TOP_ENTRIES, | ||
239 | PAGE_SIZE); | ||
240 | for (i = 0; i < TOP_ENTRIES; i++) | ||
241 | p2m_top[i] = p2m_missing; | ||
242 | |||
243 | p2m_top_mfn = extend_brk(sizeof(*p2m_top_mfn) * TOP_ENTRIES, PAGE_SIZE); | ||
244 | p2m_top_mfn_list = extend_brk(sizeof(*p2m_top_mfn_list) * | ||
245 | (TOP_ENTRIES / P2M_ENTRIES_PER_PAGE), | ||
246 | PAGE_SIZE); | ||
233 | 247 | ||
234 | for (pfn = 0; pfn < max_pfn; pfn += P2M_ENTRIES_PER_PAGE) { | 248 | for (pfn = 0; pfn < max_pfn; pfn += P2M_ENTRIES_PER_PAGE) { |
235 | unsigned topidx = p2m_top_index(pfn); | 249 | unsigned topidx = p2m_top_index(pfn); |