WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Tidy up audit code for PAE plus avoid its use during liv

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Tidy up audit code for PAE plus avoid its use during live migrate where
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 29 Nov 2005 16:44:07 +0000
Delivery-date: Tue, 29 Nov 2005 16:44:17 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User smh22@xxxxxxxxxxxxxxxxxxxx
# Node ID 689315a7ff80f25d9176f2907cc50d1dbec4cdcd
# Parent  37b93f40eb0a5c2bccff54d9b6b8357ee6b00864
Tidy up audit code for PAE plus avoid its use during live migrate where 
it is not strictly required. 

Signed-off-by: Steven Hand <steven@xxxxxxxxxxxxx>

diff -r 37b93f40eb0a -r 689315a7ff80 xen/arch/x86/audit.c
--- a/xen/arch/x86/audit.c      Tue Nov 29 13:50:30 2005
+++ b/xen/arch/x86/audit.c      Tue Nov 29 14:54:44 2005
@@ -51,7 +51,30 @@
     int errors = 0;
     int shadow_refcounts = !!shadow_mode_refcounts(d);
     int shadow_enabled = !!shadow_mode_enabled(d);
-    int l2limit;
+
+    int l2limit( unsigned long mfn )
+    {
+
+        if ( shadow_mode_external(d) )
+            return L2_PAGETABLE_ENTRIES;
+
+#ifdef __i386__
+#ifdef CONFIG_X86_PAE
+        /* 32b PAE */
+        if ( (( frame_table[mfn].u.inuse.type_info & PGT_va_mask ) 
+           >> PGT_va_shift) == 3 )
+            return l2_table_offset(HYPERVISOR_VIRT_START); 
+        else
+            return L2_PAGETABLE_ENTRIES;
+#else
+        /* 32b non-PAE */
+        return DOMAIN_ENTRIES_PER_L2_PAGETABLE;
+#endif
+#else
+        /* 64b */
+        return 0; /* XXX x86/64 XXX */
+#endif
+    }
 
     void _adjust(struct pfn_info *page, int adjtype ADJUST_EXTRA_ARGS)
     {
@@ -121,15 +144,15 @@
 
     void adjust_l2_page(unsigned long mfn, int shadow)
     {
-        unsigned long *pt = map_domain_page(mfn);
+        l2_pgentry_t *pt = map_domain_page(mfn);
         int i;
         u32 page_type;
 
-        for ( i = 0; i < l2limit; i++ )
-        {
-            if ( pt[i] & _PAGE_PRESENT )
-            {
-                unsigned long l1mfn = pt[i] >> PAGE_SHIFT;
+        for ( i = 0; i < l2limit(mfn); i++ )
+        {
+            if ( l2e_get_flags(pt[i]) & _PAGE_PRESENT )
+            {
+               unsigned long l1mfn = l2e_get_pfn(pt[i]);
                 struct pfn_info *l1page = pfn_to_page(l1mfn);
 
                 if ( noisy )
@@ -199,7 +222,7 @@
         if ( shadow_mode_translate(d) && !shadow_mode_external(d) )
         {
             unsigned long hl2mfn =
-                pt[l2_table_offset(LINEAR_PT_VIRT_START)] >> PAGE_SHIFT;
+                l2e_get_pfn(pt[l2_table_offset(LINEAR_PT_VIRT_START)]);
             struct pfn_info *hl2page = pfn_to_page(hl2mfn);
             adjust(hl2page, 0);
         }
@@ -209,14 +232,14 @@
 
     void adjust_hl2_page(unsigned long hl2mfn)
     {
-        unsigned long *pt = map_domain_page(hl2mfn);
+        l2_pgentry_t *pt = map_domain_page(hl2mfn);
         int i;
 
-        for ( i = 0; i < l2limit; i++ )
-        {
-            if ( pt[i] & _PAGE_PRESENT )
-            {
-                unsigned long gmfn = pt[i] >> PAGE_SHIFT;
+        for ( i = 0; i < l2limit(hl2mfn); i++ )
+        {
+            if ( l2e_get_flags(pt[i]) & _PAGE_PRESENT )
+            {
+                unsigned long gmfn = l2e_get_pfn(pt[i]);
                 struct pfn_info *gpage = pfn_to_page(gmfn);
 
                 if ( gmfn < 0x100 )
@@ -256,14 +279,14 @@
 
     void adjust_l1_page(unsigned long l1mfn)
     {
-        unsigned long *pt = map_domain_page(l1mfn);
+        l1_pgentry_t *pt = map_domain_page(l1mfn);
         int i;
 
         for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
         {
-            if ( pt[i] & _PAGE_PRESENT )
-            {
-                unsigned long gmfn = pt[i] >> PAGE_SHIFT;
+            if ( l1e_get_flags(pt[i]) & _PAGE_PRESENT )
+            {
+                unsigned long gmfn = l1e_get_pfn(pt[i]);
                 struct pfn_info *gpage = pfn_to_page(gmfn);
 
                 if ( gmfn < 0x100 )
@@ -280,7 +303,7 @@
 
                 if ( noisy )
                 {
-                    if ( pt[i] & _PAGE_RW )
+                    if ( l1e_get_flags(pt[i]) & _PAGE_RW )
                     {
                         // If it's not a writable page, complain.
                         //
@@ -320,7 +343,7 @@
                     }
                 }
 
-                adjust(gpage, (pt[i] & _PAGE_RW) ? 1 : 0);
+                adjust(gpage, (l1e_get_flags(pt[i]) & _PAGE_RW) ? 1 : 0);
             }
         }
 
@@ -544,15 +567,6 @@
         }
     }
 
-#ifdef __i386__
-    if ( shadow_mode_external(d) )
-        l2limit = L2_PAGETABLE_ENTRIES;
-    else
-        l2limit = DOMAIN_ENTRIES_PER_L2_PAGETABLE;
-#else
-    l2limit = 0; /* XXX x86/64 XXX */
-#endif
-
     adjust_for_pgtbase();
 
     adjust_guest_pages();
@@ -604,16 +618,17 @@
                              unsigned long mfn)
     {
         struct pfn_info *page = &frame_table[mfn];
-        unsigned long *pt = map_domain_page(mfn);
+        l1_pgentry_t *pt = map_domain_page(mfn);
         int i;
 
         for ( i = 0; i < L1_PAGETABLE_ENTRIES; i++ )
         {
-            if ( (pt[i] & _PAGE_PRESENT) && ((pt[i] >> PAGE_SHIFT) == xmfn) )
+            if ( (l1e_get_flags(pt[i]) & _PAGE_PRESENT) && 
+                 (l1e_get_pfn(pt[i]) == xmfn) )
                 printk("     found dom=%d mfn=%lx t=%" PRtype_info " c=%08x "
-                       "pt[i=%x]=%lx\n",
+                       "pt[i=%x]=%" PRIpte "\n",
                        d->domain_id, mfn, page->u.inuse.type_info,
-                       page->count_info, i, pt[i]);
+                       page->count_info, i, l1e_get_intpte(pt[i]));
         }
 
         unmap_domain_page(pt);           
diff -r 37b93f40eb0a -r 689315a7ff80 xen/arch/x86/shadow_public.c
--- a/xen/arch/x86/shadow_public.c      Tue Nov 29 13:50:30 2005
+++ b/xen/arch/x86/shadow_public.c      Tue Nov 29 14:54:44 2005
@@ -1077,36 +1077,40 @@
     //
     free_shadow_pages(d);
 
-    /*
-     * Tear down its counts by disassembling its page-table-based ref counts.
-     * Also remove CR3's gcount/tcount.
-     * That leaves things like GDTs and LDTs and external refs in tact.
-     *
-     * Most pages will be writable tcount=0.
-     * Some will still be L1 tcount=0 or L2 tcount=0.
-     * Maybe some pages will be type none tcount=0.
-     * Pages granted external writable refs (via grant tables?) will
-     * still have a non-zero tcount.  That's OK.
-     *
-     * gcounts will generally be 1 for PGC_allocated.
-     * GDTs and LDTs will have additional gcounts.
-     * Any grant-table based refs will still be in the gcount.
-     *
-     * We attempt to grab writable refs to each page (thus setting its type).
-     * Immediately put back those type refs.
-     *
-     * Assert that no pages are left with L1/L2/L3/L4 type.
-     */
-    audit_adjust_pgtables(d, -1, 1);
-
     d->arch.shadow_mode = mode;
 
     if ( shadow_mode_refcounts(d) )
     {
-        struct list_head *list_ent = d->page_list.next;
-        while ( list_ent != &d->page_list )
-        {
-            struct pfn_info *page = list_entry(list_ent, struct pfn_info, 
list);
+        struct list_head *list_ent; 
+
+        /*
+         * Tear down its counts by disassembling its page-table-based refcounts
+         * Also remove CR3's gcount/tcount.
+         * That leaves things like GDTs and LDTs and external refs in tact.
+         *
+         * Most pages will be writable tcount=0.
+         * Some will still be L1 tcount=0 or L2 tcount=0.
+         * Maybe some pages will be type none tcount=0.
+         * Pages granted external writable refs (via grant tables?) will
+         * still have a non-zero tcount.  That's OK.
+         *
+         * gcounts will generally be 1 for PGC_allocated.
+         * GDTs and LDTs will have additional gcounts.
+         * Any grant-table based refs will still be in the gcount.
+         *
+         * We attempt to grab writable refs to each page thus setting its type
+         * Immediately put back those type refs.
+         *
+         * Assert that no pages are left with L1/L2/L3/L4 type.
+         */
+        audit_adjust_pgtables(d, -1, 1);
+
+
+        for (list_ent = d->page_list.next; list_ent != &d->page_list; 
+             list_ent = page->list.next) {
+            
+            struct pfn_info *page = list_entry(list_ent, 
+                                               struct pfn_info, list);
             if ( !get_page_type(page, PGT_writable_page) )
                 BUG();
             put_page_type(page);
@@ -1114,13 +1118,13 @@
              * We use tlbflush_timestamp as back pointer to smfn, and need to
              * clean up it.
              */
-            if ( shadow_mode_external(d) )
+            if (shadow_mode_external(d))
                 page->tlbflush_timestamp = 0;
-            list_ent = page->list.next;
-        }
-    }
-
-    audit_adjust_pgtables(d, 1, 1);
+        }
+        
+        audit_adjust_pgtables(d, 1, 1);
+  
+    }
 
     return 0;
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Tidy up audit code for PAE plus avoid its use during live migrate where, Xen patchbot -unstable <=