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

[Xen-changelog] [xen-unstable] x86: Fix paging_init() to not overwrite existing page-directory entry



# HG changeset patch
# User Keir Fraser <keir@xxxxxxxxxxxxx>
# Date 1187968754 -3600
# Node ID f279d776fcb0fd3d06c96e6e9b46d71bc1156968
# Parent  1892f4a9822fe0993c758a4c4719082a0dd5baa6
x86: Fix paging_init() to not overwrite existing page-directory entry
for fixmap area.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/arch/x86/x86_32/mm.c |   15 +++++++++------
 xen/arch/x86/x86_64/mm.c |    8 ++++----
 2 files changed, 13 insertions(+), 10 deletions(-)

diff -r 1892f4a9822f -r f279d776fcb0 xen/arch/x86/x86_32/mm.c
--- a/xen/arch/x86/x86_32/mm.c  Fri Aug 17 16:48:10 2007 +0100
+++ b/xen/arch/x86/x86_32/mm.c  Fri Aug 24 16:19:14 2007 +0100
@@ -68,7 +68,6 @@ l2_pgentry_t *virt_to_xen_l2e(unsigned l
 
 void __init paging_init(void)
 {
-    void *ioremap_pt;
     unsigned long v;
     struct page_info *pg;
     int i;
@@ -115,13 +114,17 @@ void __init paging_init(void)
     for ( i = 0; i < (mpt_size / BYTES_PER_LONG); i++)
         set_gpfn_from_mfn(i, 0x55555555);
 
-    /* Create page tables for ioremap(). */
+    /* Create page tables for ioremap()/map_domain_page_global(). */
     for ( i = 0; i < (IOREMAP_MBYTES >> (L2_PAGETABLE_SHIFT - 20)); i++ )
     {
-        ioremap_pt = alloc_xenheap_page();
-        clear_page(ioremap_pt);
-        l2e_write(&idle_pg_table_l2[l2_linear_offset(IOREMAP_VIRT_START) + i],
-                  l2e_from_page(virt_to_page(ioremap_pt), __PAGE_HYPERVISOR));
+        void *p;
+        l2_pgentry_t *pl2e;
+        pl2e = &idle_pg_table_l2[l2_linear_offset(IOREMAP_VIRT_START) + i];
+        if ( l2e_get_flags(*pl2e) & _PAGE_PRESENT )
+            continue;
+        p = alloc_xenheap_page();
+        clear_page(p);
+        l2e_write(pl2e, l2e_from_page(virt_to_page(p), __PAGE_HYPERVISOR));
     }
 }
 
diff -r 1892f4a9822f -r f279d776fcb0 xen/arch/x86/x86_64/mm.c
--- a/xen/arch/x86/x86_64/mm.c  Fri Aug 17 16:48:10 2007 +0100
+++ b/xen/arch/x86/x86_64/mm.c  Fri Aug 24 16:19:14 2007 +0100
@@ -100,15 +100,15 @@ void __init paging_init(void)
     unsigned long i, mpt_size, va;
     l3_pgentry_t *l3_ro_mpt;
     l2_pgentry_t *l2_ro_mpt = NULL;
-    struct page_info *l1_pg, *l2_pg;
+    struct page_info *l1_pg, *l2_pg, *l3_pg;
 
     /* Create user-accessible L2 directory to map the MPT for guests. */
-    if ( (l2_pg = alloc_domheap_page(NULL)) == NULL )
+    if ( (l3_pg = alloc_domheap_page(NULL)) == NULL )
         goto nomem;
-    l3_ro_mpt = page_to_virt(l2_pg);
+    l3_ro_mpt = page_to_virt(l3_pg);
     clear_page(l3_ro_mpt);
     l4e_write(&idle_pg_table[l4_table_offset(RO_MPT_VIRT_START)],
-              l4e_from_page(l2_pg, __PAGE_HYPERVISOR | _PAGE_USER));
+              l4e_from_page(l3_pg, __PAGE_HYPERVISOR | _PAGE_USER));
 
     /*
      * Allocate and map the machine-to-phys table.

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
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®.