diff options
author | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-08-26 19:08:31 -0400 |
---|---|---|
committer | Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com> | 2010-10-22 15:57:19 -0400 |
commit | a2e875298729540300a9a0324ee66e3b7883a912 (patch) | |
tree | 88a36491b77545e02319992de11eca5905225f49 /arch/x86/xen/mmu.c | |
parent | a171ce6e7b4d967b9f9b8ba7c076a8a6d26e432b (diff) |
xen: allocate p2m size based on actual max size
Allocate p2m tables based on the actual runtime maximum pfn rather than
the static config-time limit.
Signed-off-by: Jeremy Fitzhardinge <jeremy.fitzhardinge@citrix.com>
Diffstat (limited to 'arch/x86/xen/mmu.c')
-rw-r--r-- | arch/x86/xen/mmu.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c index ecbdcf0d45d4..151813d97552 100644 --- a/arch/x86/xen/mmu.c +++ b/arch/x86/xen/mmu.c | |||
@@ -169,25 +169,27 @@ DEFINE_PER_CPU(unsigned long, xen_current_cr3); /* actual vcpu cr3 */ | |||
169 | */ | 169 | */ |
170 | #define USER_LIMIT ((STACK_TOP_MAX + PGDIR_SIZE - 1) & PGDIR_MASK) | 170 | #define USER_LIMIT ((STACK_TOP_MAX + PGDIR_SIZE - 1) & PGDIR_MASK) |
171 | 171 | ||
172 | static unsigned long max_p2m_pfn __read_mostly = MAX_DOMAIN_PAGES; | ||
172 | 173 | ||
173 | #define P2M_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(unsigned long)) | 174 | #define P2M_ENTRIES_PER_PAGE (PAGE_SIZE / sizeof(unsigned long)) |
174 | #define TOP_ENTRIES (MAX_DOMAIN_PAGES / P2M_ENTRIES_PER_PAGE) | 175 | #define TOP_ENTRIES(pages) ((pages) / P2M_ENTRIES_PER_PAGE) |
176 | #define MAX_TOP_ENTRIES TOP_ENTRIES(MAX_DOMAIN_PAGES) | ||
175 | 177 | ||
176 | /* Placeholder for holes in the address space */ | 178 | /* Placeholder for holes in the address space */ |
177 | static RESERVE_BRK_ARRAY(unsigned long, p2m_missing, P2M_ENTRIES_PER_PAGE); | 179 | static RESERVE_BRK_ARRAY(unsigned long, p2m_missing, P2M_ENTRIES_PER_PAGE); |
178 | 180 | ||
179 | /* Array of pointers to pages containing p2m entries */ | 181 | /* Array of pointers to pages containing p2m entries */ |
180 | static RESERVE_BRK_ARRAY(unsigned long *, p2m_top, TOP_ENTRIES); | 182 | static RESERVE_BRK_ARRAY(unsigned long *, p2m_top, MAX_TOP_ENTRIES); |
181 | 183 | ||
182 | /* Arrays of p2m arrays expressed in mfns used for save/restore */ | 184 | /* Arrays of p2m arrays expressed in mfns used for save/restore */ |
183 | static RESERVE_BRK_ARRAY(unsigned long, p2m_top_mfn, TOP_ENTRIES); | 185 | static RESERVE_BRK_ARRAY(unsigned long, p2m_top_mfn, MAX_TOP_ENTRIES); |
184 | 186 | ||
185 | static RESERVE_BRK_ARRAY(unsigned long, p2m_top_mfn_list, | 187 | static RESERVE_BRK_ARRAY(unsigned long, p2m_top_mfn_list, |
186 | (TOP_ENTRIES / P2M_ENTRIES_PER_PAGE)); | 188 | (MAX_TOP_ENTRIES / P2M_ENTRIES_PER_PAGE)); |
187 | 189 | ||
188 | static inline unsigned p2m_top_index(unsigned long pfn) | 190 | static inline unsigned p2m_top_index(unsigned long pfn) |
189 | { | 191 | { |
190 | BUG_ON(pfn >= MAX_DOMAIN_PAGES); | 192 | BUG_ON(pfn >= max_p2m_pfn); |
191 | return pfn / P2M_ENTRIES_PER_PAGE; | 193 | return pfn / P2M_ENTRIES_PER_PAGE; |
192 | } | 194 | } |
193 | 195 | ||
@@ -201,13 +203,15 @@ void xen_build_mfn_list_list(void) | |||
201 | { | 203 | { |
202 | unsigned pfn, idx; | 204 | unsigned pfn, idx; |
203 | 205 | ||
204 | for (pfn = 0; pfn < MAX_DOMAIN_PAGES; pfn += P2M_ENTRIES_PER_PAGE) { | 206 | for (pfn = 0; pfn < max_p2m_pfn; pfn += P2M_ENTRIES_PER_PAGE) { |
205 | unsigned topidx = p2m_top_index(pfn); | 207 | unsigned topidx = p2m_top_index(pfn); |
206 | 208 | ||
207 | p2m_top_mfn[topidx] = virt_to_mfn(p2m_top[topidx]); | 209 | p2m_top_mfn[topidx] = virt_to_mfn(p2m_top[topidx]); |
208 | } | 210 | } |
209 | 211 | ||
210 | for (idx = 0; idx < TOP_ENTRIES/P2M_ENTRIES_PER_PAGE; idx++) { | 212 | for (idx = 0; |
213 | idx < TOP_ENTRIES(max_p2m_pfn)/P2M_ENTRIES_PER_PAGE; | ||
214 | idx++) { | ||
211 | unsigned topidx = idx * P2M_ENTRIES_PER_PAGE; | 215 | unsigned topidx = idx * P2M_ENTRIES_PER_PAGE; |
212 | p2m_top_mfn_list[idx] = virt_to_mfn(&p2m_top_mfn[topidx]); | 216 | p2m_top_mfn_list[idx] = virt_to_mfn(&p2m_top_mfn[topidx]); |
213 | } | 217 | } |
@@ -230,19 +234,22 @@ void __init xen_build_dynamic_phys_to_machine(void) | |||
230 | unsigned pfn; | 234 | unsigned pfn; |
231 | unsigned i; | 235 | unsigned i; |
232 | 236 | ||
237 | max_p2m_pfn = max_pfn; | ||
238 | |||
233 | p2m_missing = extend_brk(sizeof(*p2m_missing) * P2M_ENTRIES_PER_PAGE, | 239 | p2m_missing = extend_brk(sizeof(*p2m_missing) * P2M_ENTRIES_PER_PAGE, |
234 | PAGE_SIZE); | 240 | PAGE_SIZE); |
235 | for (i = 0; i < P2M_ENTRIES_PER_PAGE; i++) | 241 | for (i = 0; i < P2M_ENTRIES_PER_PAGE; i++) |
236 | p2m_missing[i] = ~0UL; | 242 | p2m_missing[i] = ~0UL; |
237 | 243 | ||
238 | p2m_top = extend_brk(sizeof(*p2m_top) * TOP_ENTRIES, | 244 | p2m_top = extend_brk(sizeof(*p2m_top) * TOP_ENTRIES(max_pfn), |
239 | PAGE_SIZE); | 245 | PAGE_SIZE); |
240 | for (i = 0; i < TOP_ENTRIES; i++) | 246 | for (i = 0; i < TOP_ENTRIES(max_pfn); i++) |
241 | p2m_top[i] = p2m_missing; | 247 | p2m_top[i] = p2m_missing; |
242 | 248 | ||
243 | p2m_top_mfn = extend_brk(sizeof(*p2m_top_mfn) * TOP_ENTRIES, PAGE_SIZE); | 249 | p2m_top_mfn = extend_brk(sizeof(*p2m_top_mfn) * TOP_ENTRIES(max_pfn), |
250 | PAGE_SIZE); | ||
244 | p2m_top_mfn_list = extend_brk(sizeof(*p2m_top_mfn_list) * | 251 | p2m_top_mfn_list = extend_brk(sizeof(*p2m_top_mfn_list) * |
245 | (TOP_ENTRIES / P2M_ENTRIES_PER_PAGE), | 252 | (TOP_ENTRIES(max_pfn) / P2M_ENTRIES_PER_PAGE), |
246 | PAGE_SIZE); | 253 | PAGE_SIZE); |
247 | 254 | ||
248 | for (pfn = 0; pfn < max_pfn; pfn += P2M_ENTRIES_PER_PAGE) { | 255 | for (pfn = 0; pfn < max_pfn; pfn += P2M_ENTRIES_PER_PAGE) { |
@@ -258,7 +265,7 @@ unsigned long get_phys_to_machine(unsigned long pfn) | |||
258 | { | 265 | { |
259 | unsigned topidx, idx; | 266 | unsigned topidx, idx; |
260 | 267 | ||
261 | if (unlikely(pfn >= MAX_DOMAIN_PAGES)) | 268 | if (unlikely(pfn >= max_p2m_pfn)) |
262 | return INVALID_P2M_ENTRY; | 269 | return INVALID_P2M_ENTRY; |
263 | 270 | ||
264 | topidx = p2m_top_index(pfn); | 271 | topidx = p2m_top_index(pfn); |
@@ -304,7 +311,7 @@ bool __set_phys_to_machine(unsigned long pfn, unsigned long mfn) | |||
304 | { | 311 | { |
305 | unsigned topidx, idx; | 312 | unsigned topidx, idx; |
306 | 313 | ||
307 | if (unlikely(pfn >= MAX_DOMAIN_PAGES)) { | 314 | if (unlikely(pfn >= max_p2m_pfn)) { |
308 | BUG_ON(mfn != INVALID_P2M_ENTRY); | 315 | BUG_ON(mfn != INVALID_P2M_ENTRY); |
309 | return true; | 316 | return true; |
310 | } | 317 | } |