[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] x86: consolidate initialization of PV guest L4 page tables


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Mon, 04 Feb 2013 15:44:11 +0000
  • Delivery-date: Mon, 04 Feb 2013 15:44:38 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Jan Beulich <jbeulich@xxxxxxxx>
# Date 1358946581 -3600
# Node ID 1e21eaa3b85dae54af8f02f89de3000727d4ecc1
# Parent  54b4c6802d50d5f1bc8f2fcb17bc6f9bfea56cde
x86: consolidate initialization of PV guest L4 page tables

So far this has been repeated in 3 places, requiring to remember to
update all of them if a change is being made.

Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
---


diff -r 54b4c6802d50 -r 1e21eaa3b85d xen/arch/x86/domain.c
--- a/xen/arch/x86/domain.c     Wed Jan 23 14:08:44 2013 +0100
+++ b/xen/arch/x86/domain.c     Wed Jan 23 14:09:41 2013 +0100
@@ -290,13 +290,8 @@ static int setup_compat_l4(struct vcpu *
     pg->u.inuse.type_info = PGT_l4_page_table|PGT_validated|1;
 
     l4tab = page_to_virt(pg);
-    copy_page(l4tab, idle_pg_table);
-    l4tab[0] = l4e_empty();
-    l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] =
-        l4e_from_page(pg, __PAGE_HYPERVISOR);
-    l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] =
-        l4e_from_paddr(__pa(v->domain->arch.mm_perdomain_l3),
-                       __PAGE_HYPERVISOR);
+    clear_page(l4tab);
+    init_guest_l4_table(l4tab, v->domain);
 
     v->arch.guest_table = pagetable_from_page(pg);
     v->arch.guest_table_user = v->arch.guest_table;
diff -r 54b4c6802d50 -r 1e21eaa3b85d xen/arch/x86/domain_build.c
--- a/xen/arch/x86/domain_build.c       Wed Jan 23 14:08:44 2013 +0100
+++ b/xen/arch/x86/domain_build.c       Wed Jan 23 14:09:41 2013 +0100
@@ -622,13 +622,7 @@ int __init construct_dom0(
         l3start = __va(mpt_alloc); mpt_alloc += PAGE_SIZE;
     }
     clear_page(l4tab);
-    for ( i = l4_table_offset(HYPERVISOR_VIRT_START);
-          i < l4_table_offset(HYPERVISOR_VIRT_END); ++i )
-        l4tab[i] = idle_pg_table[i];
-    l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] =
-        l4e_from_paddr(__pa(l4start), __PAGE_HYPERVISOR);
-    l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] =
-        l4e_from_paddr(__pa(d->arch.mm_perdomain_l3), __PAGE_HYPERVISOR);
+    init_guest_l4_table(l4tab, d);
     v->arch.guest_table = pagetable_from_paddr(__pa(l4start));
     if ( is_pv_32on64_domain(d) )
         v->arch.guest_table_user = v->arch.guest_table;
diff -r 54b4c6802d50 -r 1e21eaa3b85d xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Wed Jan 23 14:08:44 2013 +0100
+++ b/xen/arch/x86/mm.c Wed Jan 23 14:09:41 2013 +0100
@@ -1315,6 +1315,18 @@ static int alloc_l3_table(struct page_in
     return rc > 0 ? 0 : rc;
 }
 
+void init_guest_l4_table(l4_pgentry_t l4tab[], const struct domain *d)
+{
+    /* Xen private mappings. */
+    memcpy(&l4tab[ROOT_PAGETABLE_FIRST_XEN_SLOT],
+           &idle_pg_table[ROOT_PAGETABLE_FIRST_XEN_SLOT],
+           ROOT_PAGETABLE_XEN_SLOTS * sizeof(l4_pgentry_t));
+    l4tab[l4_table_offset(LINEAR_PT_VIRT_START)] =
+        l4e_from_pfn(virt_to_mfn(l4tab), __PAGE_HYPERVISOR);
+    l4tab[l4_table_offset(PERDOMAIN_VIRT_START)] =
+        l4e_from_pfn(virt_to_mfn(d->arch.mm_perdomain_l3), __PAGE_HYPERVISOR);
+}
+
 static int alloc_l4_table(struct page_info *page, int preemptible)
 {
     struct domain *d = page_get_owner(page);
@@ -1358,15 +1370,7 @@ static int alloc_l4_table(struct page_in
         adjust_guest_l4e(pl4e[i], d);
     }
 
-    /* Xen private mappings. */
-    memcpy(&pl4e[ROOT_PAGETABLE_FIRST_XEN_SLOT],
-           &idle_pg_table[ROOT_PAGETABLE_FIRST_XEN_SLOT],
-           ROOT_PAGETABLE_XEN_SLOTS * sizeof(l4_pgentry_t));
-    pl4e[l4_table_offset(LINEAR_PT_VIRT_START)] =
-        l4e_from_pfn(pfn, __PAGE_HYPERVISOR);
-    pl4e[l4_table_offset(PERDOMAIN_VIRT_START)] =
-        l4e_from_page(virt_to_page(d->arch.mm_perdomain_l3),
-                      __PAGE_HYPERVISOR);
+    init_guest_l4_table(pl4e, d);
 
     return rc > 0 ? 0 : rc;
 }
diff -r 54b4c6802d50 -r 1e21eaa3b85d xen/include/asm-x86/mm.h
--- a/xen/include/asm-x86/mm.h  Wed Jan 23 14:08:44 2013 +0100
+++ b/xen/include/asm-x86/mm.h  Wed Jan 23 14:09:41 2013 +0100
@@ -316,6 +316,8 @@ static inline void *__page_to_virt(const
 int free_page_type(struct page_info *page, unsigned long type,
                    int preemptible);
 
+void init_guest_l4_table(l4_pgentry_t[], const struct domain *);
+
 int is_iomem_page(unsigned long mfn);
 
 void clear_superpage_mark(struct page_info *page);

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.