aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/mm.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@suse.com>2012-12-11 13:47:53 +0100
committerJan Beulich <jbeulich@suse.com>2012-12-11 13:47:53 +0100
commit23dbeb5aceb9709f06481884d205095e348793e2 (patch)
tree85ea0f1ac40a8d5556c8874be4a8b5f862efdcc1 /xen/arch/x86/mm.c
parent645d0367d83fde42f5041da58c3e508ebcfb430b (diff)
downloadxen-23dbeb5aceb9709f06481884d205095e348793e2.tar.gz
xen-23dbeb5aceb9709f06481884d205095e348793e2.tar.bz2
xen-23dbeb5aceb9709f06481884d205095e348793e2.zip
x86: frame table related improvements
- fix super page frame table setup for memory hotplug case (should create full table, or else the hotplug code would need to do the necessary table population) - simplify super page frame table setup (can re-use frame table setup code) - slightly streamline frame table setup code - fix (tighten) a BUG_ON() and an ASSERT() condition - fix spage <-> pdx conversion macros (they had no users so far, and hence no-one noticed how broken they were) Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
Diffstat (limited to 'xen/arch/x86/mm.c')
-rw-r--r--xen/arch/x86/mm.c54
1 files changed, 19 insertions, 35 deletions
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index c474e587ec..da34570587 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -182,28 +182,6 @@ static uint32_t base_disallow_mask;
!is_hvm_domain(d)) ? \
L1_DISALLOW_MASK : (L1_DISALLOW_MASK & ~PAGE_CACHE_ATTRS))
-static void __init init_spagetable(void)
-{
- unsigned long s, start = SPAGETABLE_VIRT_START;
- unsigned long end = SPAGETABLE_VIRT_END;
- unsigned long step, mfn;
- unsigned int max_entries;
-
- step = 1UL << PAGETABLE_ORDER;
- max_entries = (max_pdx + ((1UL<<SUPERPAGE_ORDER)-1)) >> SUPERPAGE_ORDER;
- end = start + (((max_entries * sizeof(*spage_table)) +
- ((1UL<<SUPERPAGE_SHIFT)-1)) & (~((1UL<<SUPERPAGE_SHIFT)-1)));
-
- for (s = start; s < end; s += step << PAGE_SHIFT)
- {
- mfn = alloc_boot_pages(step, step);
- if ( !mfn )
- panic("Not enough memory for spage table");
- map_pages_to_xen(s, mfn, step, PAGE_HYPERVISOR);
- }
- memset((void *)start, 0, end - start);
-}
-
static void __init init_frametable_chunk(void *start, void *end)
{
unsigned long s = (unsigned long)start;
@@ -232,15 +210,25 @@ static void __init init_frametable_chunk(void *start, void *end)
}
memset(start, 0, end - start);
- memset(end, -1, s - (unsigned long)end);
+ memset(end, -1, s - e);
+}
+
+static void __init init_spagetable(void)
+{
+ BUILD_BUG_ON(XEN_VIRT_END > SPAGETABLE_VIRT_START);
+
+ init_frametable_chunk(spage_table,
+ mem_hotplug ? (void *)SPAGETABLE_VIRT_END
+ : pdx_to_spage(max_pdx - 1) + 1);
}
void __init init_frametable(void)
{
unsigned int sidx, eidx, nidx;
unsigned int max_idx = (max_pdx + PDX_GROUP_COUNT - 1) / PDX_GROUP_COUNT;
+ struct page_info *end_pg, *top_pg;
- BUILD_BUG_ON(XEN_VIRT_END > FRAMETABLE_VIRT_END);
+ BUILD_BUG_ON(XEN_VIRT_END > FRAMETABLE_VIRT_START);
BUILD_BUG_ON(FRAMETABLE_VIRT_START & ((1UL << L2_PAGETABLE_SHIFT) - 1));
for ( sidx = 0; ; sidx = nidx )
@@ -252,17 +240,13 @@ void __init init_frametable(void)
init_frametable_chunk(pdx_to_page(sidx * PDX_GROUP_COUNT),
pdx_to_page(eidx * PDX_GROUP_COUNT));
}
- if ( !mem_hotplug )
- init_frametable_chunk(pdx_to_page(sidx * PDX_GROUP_COUNT),
- pdx_to_page(max_pdx - 1) + 1);
- else
- {
- init_frametable_chunk(pdx_to_page(sidx * PDX_GROUP_COUNT),
- pdx_to_page(max_idx * PDX_GROUP_COUNT - 1) + 1);
- memset(pdx_to_page(max_pdx), -1,
- (unsigned long)pdx_to_page(max_idx * PDX_GROUP_COUNT) -
- (unsigned long)pdx_to_page(max_pdx));
- }
+
+ end_pg = pdx_to_page(max_pdx - 1) + 1;
+ top_pg = mem_hotplug ? pdx_to_page(max_idx * PDX_GROUP_COUNT - 1) + 1
+ : end_pg;
+ init_frametable_chunk(pdx_to_page(sidx * PDX_GROUP_COUNT), top_pg);
+ memset(end_pg, -1, (unsigned long)top_pg - (unsigned long)end_pg);
+
if (opt_allow_superpage)
init_spagetable();
}