]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
xen/mmu: Recycle the Xen provided L4, L3, and L2 pages
authorKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Thu, 26 Jul 2012 16:00:56 +0000 (12:00 -0400)
committerKonrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tue, 4 Sep 2012 13:18:56 +0000 (09:18 -0400)
As we are not using them. We end up only using the L1 pagetables
and grafting those to our page-tables.

[v1: Per Stefano's suggestion squashed two commits]
[v2: Per Stefano's suggestion simplified loop]
[v3: Fix smatch warnings]
[v4: Add more comments]
Acked-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
(cherry picked from commit 488f046df922af992c1a718eff276529c0510885)

Conflicts:

arch/x86/xen/mmu.c

arch/x86/xen/mmu.c

index af2c7e6258fc25fa3bce8f5e05e1e33938b9ea55..4da2c850c649e9ae27e53aaa076e4fc7fc5c88e3 100644 (file)
@@ -1811,18 +1811,18 @@ static void convert_pfn_mfn(void *v)
        for (i = 0; i < PTRS_PER_PTE; i++)
                pte[i] = xen_make_pte(pte[i].pte);
 }
-static __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
-                           unsigned long addr)
+static void __init check_pt_base(unsigned long *pt_base, unsigned long *pt_end,
+                                unsigned long addr)
 {
-       if (pt_base == PFN_DOWN(__pa(addr))) {
+       if (*pt_base == PFN_DOWN(__pa(addr))) {
                set_page_prot((void *)addr, PAGE_KERNEL);
                clear_page((void *)addr);
-               *pt_base++;
+               (*pt_base)++;
        }
-       if (pt_end == PFN_DOWN(__pa(addr))) {
+       if (*pt_end == PFN_DOWN(__pa(addr))) {
                set_page_prot((void *)addr, PAGE_KERNEL);
                clear_page((void *)addr);
-               *pt_end--;
+               (*pt_end)--;
        }
 }
 /*
@@ -1851,7 +1851,7 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
        max_pfn_mapped = PFN_DOWN(__pa(xen_start_info->mfn_list));
 
        pt_base = PFN_DOWN(__pa(xen_start_info->pt_base));
-       pt_end = PFN_DOWN(__pa(xen_start_info->pt_base + (xen_start_info->nr_pt_frames * PAGE_SIZE)));
+       pt_end = pt_base + xen_start_info->nr_pt_frames;
 
        /* Zap identity mapping */
        init_level4_pgt[0] = __pgd(0);
@@ -1919,7 +1919,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
        /* We can't that easily rip out L3 and L2, as the Xen pagetables are
         * set out this way: [L4], [L1], [L2], [L3], [L1], [L1] ...  for
         * the initial domain. For guests using the toolstack, they are in:
-        * [L4], [L3], [L2], [L1], [L1], order .. */
+        * [L4], [L3], [L2], [L1], [L1], order .. So for dom0 we can only
+        * rip out the [L4] (pgd), but for guests we shave off three pages.
+        */
        for (i = 0; i < ARRAY_SIZE(addr); i++)
                check_pt_base(&pt_base, &pt_end, addr[i]);