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-devel

[Xen-devel] [PATCH] x86/mm: early put_page when XENMEM_add_to_physmap(XE

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] x86/mm: early put_page when XENMEM_add_to_physmap(XENMAPSPACE_gmfn)
From: Kouya Shimura <kouya@xxxxxxxxxxxxxx>
Date: Thu, 24 Dec 2009 15:40:06 +0900
Delivery-date: Wed, 23 Dec 2009 22:40:44 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
When using a stub domain, xen massively complains as follows:

(XEN) sh error: sh_remove_all_mappings(): can't find all mappings of mfn be3c5: 
c=8000000000000004 t=00000000
(XEN) sh error: sh_remove_all_mappings(): can't find all mappings of mfn be3c4: 
c=8000000000000004 t=00000000
...

This comes from the XENMEM_add_to_physmap hypercall from hvmloader.

The guest_physmap_remove_page function calls sh_remove_all_mappings()
which checks reference count of the page. Then, calling
guest_physmap_remove_page after temporarily get_page is obviously
wrong. And early put_page is harmless here since domain_lock is
acquired.

Also, the restore program seems not to complain extra mappings
long before. Instead, the stub domain does. Thus the comment in
sh_remove_all_mappings() is rewritten.


Signed-off-by: Kouya Shimura <kouya@xxxxxxxxxxxxxx>

diff -r 07f98beddc18 xen/arch/x86/mm.c
--- a/xen/arch/x86/mm.c Wed Dec 23 08:22:13 2009 +0000
+++ b/xen/arch/x86/mm.c Thu Dec 24 14:07:04 2009 +0900
@@ -4304,6 +4304,9 @@ long arch_memory_op(int op, XEN_GUEST_HA
 
         domain_lock(d);
 
+        if ( page )
+            put_page(page);
+
         /* Remove previously mapped page if it was present. */
         prev_mfn = gmfn_to_mfn(d, xatp.gpfn);
         if ( mfn_valid(prev_mfn) )
@@ -4326,9 +4329,6 @@ long arch_memory_op(int op, XEN_GUEST_HA
         rc = guest_physmap_add_page(d, xatp.gpfn, mfn, 0);
 
         domain_unlock(d);
-
-        if ( page )
-            put_page(page);
 
         rcu_unlock_domain(d);
 
diff -r 07f98beddc18 xen/arch/x86/mm/shadow/common.c
--- a/xen/arch/x86/mm/shadow/common.c   Wed Dec 23 08:22:13 2009 +0000
+++ b/xen/arch/x86/mm/shadow/common.c   Thu Dec 24 14:07:04 2009 +0900
@@ -2606,7 +2606,7 @@ int sh_remove_all_mappings(struct vcpu *
     {
         /* Don't complain if we're in HVM and there are some extra mappings: 
          * The qemu helper process has an untyped mapping of this dom's RAM 
-         * and the HVM restore program takes another. */
+         * and the stub domain takes another. */
         if ( !(shadow_mode_external(v->domain)
                && (page->count_info & PGC_count_mask) <= 3
                && (page->u.inuse.type_info & PGT_count_mask) == 0) )
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] x86/mm: early put_page when XENMEM_add_to_physmap(XENMAPSPACE_gmfn), Kouya Shimura <=