]> xenbits.xensource.com Git - people/vhanquez/xen-unstable.git/commitdiff
x86/mem_sharing: Allow paging-in pages to be replaced by shared ones.
authorAndres Lagar-Cavilla <andres@lagarcavilla.org>
Fri, 18 May 2012 15:19:21 +0000 (16:19 +0100)
committerAndres Lagar-Cavilla <andres@lagarcavilla.org>
Fri, 18 May 2012 15:19:21 +0000 (16:19 +0100)
Making sure to tidy up any partially paged frames.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>
Acked-by: Tim Deegan <tim@xen.org>
Committed-by: Tim Deegan <tim@xen.org>
xen/arch/x86/mm/mem_sharing.c
xen/include/asm-x86/p2m.h

index a2d82e9bd87674962c5a25e57d33a7a8f8e266c1..510328554e99f2117d1a8a1a9c3b14ef36666be0 100644 (file)
@@ -1103,7 +1103,17 @@ int mem_sharing_add_to_physmap(struct domain *sd, unsigned long sgfn, shr_handle
         ret = 0;
         /* There is a chance we're plugging a hole where a paged out page was */
         if ( p2m_is_paging(cmfn_type) && (cmfn_type != p2m_ram_paging_out) )
+        {
             atomic_dec(&cd->paged_pages);
+            /* Further, there is a chance this was a valid page. Don't leak it. */
+            if ( mfn_valid(cmfn) )
+            {
+                struct page_info *cpage = mfn_to_page(cmfn);
+                ASSERT(cpage != NULL);
+                if ( test_and_clear_bit(_PGC_allocated, &cpage->count_info) )
+                    put_page(cpage);
+            }
+        }
     }
 
     atomic_inc(&nr_saved_mfns);
index febf76458297bd7fbd4b303fb37edb99823acd6b..63bc7cf451cdd4d2a06a40f2ac03bc11abb56169 100644 (file)
@@ -137,6 +137,7 @@ typedef unsigned int p2m_query_t;
  * entry */
 #define P2M_HOLE_TYPES (p2m_to_mask(p2m_mmio_dm)        \
                        | p2m_to_mask(p2m_invalid)       \
+                       | p2m_to_mask(p2m_ram_paging_in) \
                        | p2m_to_mask(p2m_ram_paged))
 
 /* Grant mapping types, which map to a real machine frame in another