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

[Xen-changelog] [xen master] mm: unmap page for direct mapped domain on decrease reservation



commit 68f2e49032fa32c9cc5413994d8b072d3d2bd048
Author:     Julien Grall <julien.grall@xxxxxxxxxx>
AuthorDate: Tue Oct 27 14:47:01 2015 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Oct 27 14:47:01 2015 +0100

    mm: unmap page for direct mapped domain on decrease reservation
    
    Direct mapped domain needs to retrieve the exact same underlying
    physical page when the region is re-populated.
    
    Currently, when the memory reservation for this domain is decreased, the
    request is just ignored and the page stayed mapped in the P2M. However,
    this make more difficult to spot issue when the domain has not yet mapped
    foreign page but trying to access the region.
    
    What we really care for direct mapped domain is to not give back the
    page to the allocator. So we can re-enable to direct mapped when the guest
    memory region is re-populated.
    
    The rest of the process to remove a page can be safely done. This
    also ensures us to stay close to the normal domain memory handling.
    
    At the same time, drop the trailing whitespaces around the code
    modified.
    
    Signed-off-by: Julien Grall <julien.grall@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/common/memory.c |   20 +++++++++++---------
 1 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/xen/common/memory.c b/xen/common/memory.c
index f6aed0d..241655b 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -257,8 +257,17 @@ int guest_remove_page(struct domain *d, unsigned long gmfn)
 
     if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) )
         put_page_and_type(page);
-            
-    if ( test_and_clear_bit(_PGC_allocated, &page->count_info) )
+
+    /*
+     * With the lack of an IOMMU on some platforms, domains with DMA-capable
+     * device must retrieve the same pfn when the hypercall populate_physmap
+     * is called.
+     *
+     * For this purpose (and to match populate_physmap() behavior), the page
+     * is kept allocated.
+     */
+    if ( !is_domain_direct_mapped(d) &&
+         test_and_clear_bit(_PGC_allocated, &page->count_info) )
         put_page(page);
 
     guest_physmap_remove_page(d, gmfn, mfn, 0);
@@ -309,13 +318,6 @@ static void decrease_reservation(struct memop_args *a)
              && p2m_pod_decrease_reservation(a->domain, gmfn, a->extent_order) 
)
             continue;
 
-        /* With the lack for iommu on some ARM platform, domain with 
DMA-capable
-         * device must retrieve the same pfn when the hypercall
-         * populate_physmap is called.
-         */
-        if ( is_domain_direct_mapped(a->domain) )
-            continue;
-
         for ( j = 0; j < (1 << a->extent_order); j++ )
             if ( !guest_remove_page(a->domain, gmfn + j) )
                 goto out;
--
generated by git-patchbot for /home/xen/git/xen.git#master

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