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] [xen-unstable] x86/mm: fix up paging_mfn_is_dirty()

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] x86/mm: fix up paging_mfn_is_dirty()
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 23 Dec 2010 05:34:45 -0800
Delivery-date: Thu, 23 Dec 2010 05:44:18 -0800
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/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/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 Keir Fraser <keir@xxxxxxx>
# Date 1292415135 0
# Node ID f92ad250d80b47a4bcfe7632911f285ccf8cc552
# Parent  6ed80a93a5e031c5ffa13dee7d6dcecbbab42b67
x86/mm: fix up paging_mfn_is_dirty()

Add locking, and don't allocate the top-level page if it's not there.
Also gets rid of the default-to-1 case if there have been failed
allocations because the safer thing is actually to return 0 and avoid
modifying an un-dirtied page.

Signed-off-by: Tim Deegan <Tim.Deegan@xxxxxxxxxx>
---
 xen/arch/x86/mm/paging.c |   40 +++++++++++++++++-----------------------
 1 files changed, 17 insertions(+), 23 deletions(-)

diff -r 6ed80a93a5e0 -r f92ad250d80b xen/arch/x86/mm/paging.c
--- a/xen/arch/x86/mm/paging.c  Wed Dec 15 12:11:57 2010 +0000
+++ b/xen/arch/x86/mm/paging.c  Wed Dec 15 12:12:15 2010 +0000
@@ -311,51 +311,45 @@ int paging_mfn_is_dirty(struct domain *d
     unsigned long pfn;
     mfn_t mfn, *l4, *l3, *l2;
     unsigned long *l1;
-    int rv;
-
+    int rv = 0;
+
+    log_dirty_lock(d);
     ASSERT(paging_mode_log_dirty(d));
 
     /* We /really/ mean PFN here, even for non-translated guests. */
     pfn = get_gpfn_from_mfn(mfn_x(gmfn));
-    /* Page sharing not supported for shadow domains */
-    BUG_ON(SHARED_M2P(pfn));
-    if ( unlikely(!VALID_M2P(pfn)) )
-        return 0;
-    
-    if ( d->arch.paging.log_dirty.failed_allocs > 0 )
-        /* If we have any failed allocations our dirty log is bogus.
-         * Since we can't signal an error here, be conservative and
-         * report "dirty" in this case.  (The only current caller,
-         * _sh_propagate, leaves known-dirty pages writable, preventing
-         * subsequent dirty-logging faults from them.)
-         */
-        return 1;
-
-    l4 = paging_map_log_dirty_bitmap(d);
-    if ( !l4 ) 
-        return 0;
-
+    /* Shared pages are always read-only; invalid pages can't be dirty. */
+    if ( unlikely(SHARED_M2P(pfn) || !VALID_M2P(pfn)) )
+        goto out;
+
+    mfn = d->arch.paging.log_dirty.top;
+    if ( !mfn_valid(mfn) )
+        goto out;
+
+    l4 = map_domain_page(mfn_x(mfn));
     mfn = l4[L4_LOGDIRTY_IDX(pfn)];
     unmap_domain_page(l4);
     if ( !mfn_valid(mfn) )
-        return 0;
+        goto out;
 
     l3 = map_domain_page(mfn_x(mfn));
     mfn = l3[L3_LOGDIRTY_IDX(pfn)];
     unmap_domain_page(l3);
     if ( !mfn_valid(mfn) )
-        return 0;
+        goto out;
 
     l2 = map_domain_page(mfn_x(mfn));
     mfn = l2[L2_LOGDIRTY_IDX(pfn)];
     unmap_domain_page(l2);
     if ( !mfn_valid(mfn) )
-        return 0;
+        goto out;
 
     l1 = map_domain_page(mfn_x(mfn));
     rv = test_bit(L1_LOGDIRTY_IDX(pfn), l1);
     unmap_domain_page(l1);
 
+out:
+    log_dirty_unlock(d);
     return rv;
 }
 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] x86/mm: fix up paging_mfn_is_dirty(), Xen patchbot-unstable <=