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

[Xen-changelog] Ensure that _PAGE_GLOBAL bit is never set in any pagetable if the CPU



ChangeSet 1.1659, 2005/06/03 09:12:15+01:00, kaf24@xxxxxxxxxxxxxxxxxxxx

        Ensure that _PAGE_GLOBAL bit is never set in any pagetable if the CPU
        does not support PGE (Page Global Extension).
        Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>



 arch/x86/setup.c              |    4 ++--
 arch/x86/x86_32/mm.c          |   32 +++++++++++++++++---------------
 include/asm-x86/page.h        |    5 -----
 include/asm-x86/x86_32/page.h |    5 +++++
 include/asm-x86/x86_64/page.h |    3 +++
 5 files changed, 27 insertions(+), 22 deletions(-)


diff -Nru a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      2005-06-03 05:02:52 -04:00
+++ b/xen/arch/x86/setup.c      2005-06-03 05:02:52 -04:00
@@ -147,6 +147,8 @@
 
     early_cpu_init();
 
+    paging_init();
+
     /* Unmap the first page of CPU0's stack. */
     memguard_guard_stack(cpu0_stack);
 
@@ -167,8 +169,6 @@
     find_smp_config();
 
     smp_alloc_memory();
-
-    paging_init();
 
     dmi_scan_machine();
 
diff -Nru a/xen/arch/x86/x86_32/mm.c b/xen/arch/x86/x86_32/mm.c
--- a/xen/arch/x86/x86_32/mm.c  2005-06-03 05:02:52 -04:00
+++ b/xen/arch/x86/x86_32/mm.c  2005-06-03 05:02:52 -04:00
@@ -28,6 +28,9 @@
 #include <asm/fixmap.h>
 #include <asm/domain_page.h>
 
+unsigned int PAGE_HYPERVISOR         = __PAGE_HYPERVISOR;
+unsigned int PAGE_HYPERVISOR_NOCACHE = __PAGE_HYPERVISOR_NOCACHE;
+
 static unsigned long mpt_size;
 
 struct pfn_info *alloc_xen_pagetable(void)
@@ -72,6 +75,19 @@
 
     idle0_vcpu.arch.monitor_table = mk_pagetable(__pa(idle_pg_table));
 
+    if ( cpu_has_pge )
+    {
+        /* Suitable Xen mapping can be GLOBAL. */
+        PAGE_HYPERVISOR         |= _PAGE_GLOBAL;
+        PAGE_HYPERVISOR_NOCACHE |= _PAGE_GLOBAL;
+        /* Transform early mappings (e.g., the frametable). */
+        for ( v = HYPERVISOR_VIRT_START; v; v += (1 << L2_PAGETABLE_SHIFT) )
+            if ( (l2e_get_flags(idle_pg_table_l2[l2_linear_offset(v)]) &
+                  (_PAGE_PSE|_PAGE_PRESENT)) == (_PAGE_PSE|_PAGE_PRESENT) )
+                l2e_add_flags(idle_pg_table_l2[l2_linear_offset(v)],
+                              _PAGE_GLOBAL);
+    }
+
     /*
      * Allocate and map the machine-to-phys table and create read-only mapping 
      * of MPT for guest-OS use.  Without PAE we'll end up with one 4MB page, 
@@ -86,25 +102,11 @@
         if ( (pg = alloc_domheap_pages(NULL, PAGETABLE_ORDER)) == NULL )
             panic("Not enough memory to bootstrap Xen.\n");
         idle_pg_table_l2[l2_linear_offset(RDWR_MPT_VIRT_START) + i] =
-            l2e_from_page(pg, __PAGE_HYPERVISOR | _PAGE_PSE);
+            l2e_from_page(pg, PAGE_HYPERVISOR | _PAGE_PSE);
         idle_pg_table_l2[l2_linear_offset(RO_MPT_VIRT_START) + i] =
             l2e_from_page(pg, (__PAGE_HYPERVISOR | _PAGE_PSE) & ~_PAGE_RW);
     }
     memset((void *)RDWR_MPT_VIRT_START, 0x55, mpt_size);
-
-    /* Xen PSE mappings can all be GLOBAL. */
-    if ( cpu_has_pge )
-    {
-        for ( v = HYPERVISOR_VIRT_START; v; v += (1 << L2_PAGETABLE_SHIFT) )
-        {
-            if ( (l2e_get_flags(idle_pg_table_l2[l2_linear_offset(v)]) &
-                  (_PAGE_PSE|_PAGE_PRESENT)) != (_PAGE_PSE|_PAGE_PRESENT) )
-                continue;
-            if ( (v >= RO_MPT_VIRT_START) && (v < RO_MPT_VIRT_END) )
-                continue;
-            l2e_add_flags(idle_pg_table_l2[l2_linear_offset(v)], _PAGE_GLOBAL);
-        }
-    }
 
     /* Create page tables for ioremap(). */
     for ( i = 0; i < (IOREMAP_MBYTES >> (L2_PAGETABLE_SHIFT - 20)); i++ )
diff -Nru a/xen/include/asm-x86/page.h b/xen/include/asm-x86/page.h
--- a/xen/include/asm-x86/page.h        2005-06-03 05:02:52 -04:00
+++ b/xen/include/asm-x86/page.h        2005-06-03 05:02:52 -04:00
@@ -257,11 +257,6 @@
 #define __PAGE_HYPERVISOR_NOCACHE \
     (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_PCD | _PAGE_ACCESSED)
 
-#define MAKE_GLOBAL(_x) ((_x) | _PAGE_GLOBAL)
-
-#define PAGE_HYPERVISOR MAKE_GLOBAL(__PAGE_HYPERVISOR)
-#define PAGE_HYPERVISOR_NOCACHE MAKE_GLOBAL(__PAGE_HYPERVISOR_NOCACHE)
-
 #ifndef __ASSEMBLY__
 
 static __inline__ int get_order(unsigned long size)
diff -Nru a/xen/include/asm-x86/x86_32/page.h 
b/xen/include/asm-x86/x86_32/page.h
--- a/xen/include/asm-x86/x86_32/page.h 2005-06-03 05:02:52 -04:00
+++ b/xen/include/asm-x86/x86_32/page.h 2005-06-03 05:02:52 -04:00
@@ -20,6 +20,11 @@
 #define l1_linear_offset(_a) ((_a) >> L1_PAGETABLE_SHIFT)
 #define l2_linear_offset(_a) ((_a) >> L2_PAGETABLE_SHIFT)
 
+#ifndef __ASSEMBLY__
+extern unsigned int PAGE_HYPERVISOR;
+extern unsigned int PAGE_HYPERVISOR_NOCACHE;
+#endif
+
 #endif /* __X86_32_PAGE_H__ */
 
 /*
diff -Nru a/xen/include/asm-x86/x86_64/page.h 
b/xen/include/asm-x86/x86_64/page.h
--- a/xen/include/asm-x86/x86_64/page.h 2005-06-03 05:02:52 -04:00
+++ b/xen/include/asm-x86/x86_64/page.h 2005-06-03 05:02:52 -04:00
@@ -76,6 +76,9 @@
 #define L3_DISALLOW_MASK (0xFFFFF180U & ~_PAGE_NX) /* must-be-zero */
 #define L4_DISALLOW_MASK (0xFFFFF180U & ~_PAGE_NX) /* must-be-zero */
 
+#define PAGE_HYPERVISOR         (__PAGE_HYPERVISOR         | _PAGE_GLOBAL)
+#define PAGE_HYPERVISOR_NOCACHE (__PAGE_HYPERVISOR_NOCACHE | _PAGE_GLOBAL)
+
 #endif /* __X86_64_PAGE_H__ */
 
 /*

_______________________________________________
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®.