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 1 of 3] xenpaging: check p2mt in p2m_mem_paging funct

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 1 of 3] xenpaging: check p2mt in p2m_mem_paging functions
From: Olaf Hering <olaf@xxxxxxxxx>
Date: Wed, 19 Oct 2011 16:23:21 +0200
Delivery-date: Wed, 19 Oct 2011 07:31:10 -0700
Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; t=1319034205; l=1852; s=domk; d=aepfle.de; h=To:From:Date:References:In-Reply-To:Subject: Content-Transfer-Encoding:MIME-Version:Content-Type:X-RZG-CLASS-ID: X-RZG-AUTH; bh=gwDNlHGDoxnpQl9wOPbvUuxZz0s=; b=sZL5N0aYkWAcBwl8zd0ODz1NqN+qeivyvSmJyl7YtSvw4mrjxbygxcRa6BFlBNvPfXK Maed7836Ps4UIXHfVg6GpHuNa9VVbq3SBXiv7ytXMevt6QW/SAZKMKP1cu80hO0RrLvy/ DvGJJIYlICKALKaARebrWDMSU44EYxMkELo=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1319034200@xxxxxxxxxxxx>
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>
References: <patchbomb.1319034200@xxxxxxxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mercurial-patchbomb/1.7.5
# HG changeset patch
# User Olaf Hering <olaf@xxxxxxxxx>
# Date 1319034159 -7200
# Node ID f835012a0c062e70495aa341d41e3970a121bf6a
# Parent  6880bfc48504db31e2680de01bfadf4db3b0b7a0
xenpaging: check p2mt in p2m_mem_paging functions

Add checks to forward the p2m_ram_paging* state properly during page-in.

Resume can be called several times if several vcpus called populate for
the gfn. Finish resume only once.

v2:
 - remove debug output for non-p2m_ram_rw case

Signed-off-by: Olaf Hering <olaf@xxxxxxxxx>

diff -r 6880bfc48504 -r f835012a0c06 xen/arch/x86/mm/p2m.c
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -851,16 +851,22 @@ int p2m_mem_paging_prep(struct domain *d
     p2m_access_t a;
     mfn_t mfn;
     struct p2m_domain *p2m = p2m_get_hostp2m(d);
-    int ret = -ENOMEM;
+    int ret;
 
     p2m_lock(p2m);
 
     mfn = p2m->get_entry(p2m, gfn, &p2mt, &a, p2m_query, NULL);
 
+    ret = -ENOENT;
+    /* Allow only missing pages */
+    if ( p2mt != p2m_ram_paging_in_start )
+        goto out;
+
     /* Allocate a page if the gfn does not have one yet */
     if ( !mfn_valid(mfn) )
     {
         /* Get a free page */
+        ret = -ENOMEM;
         page = alloc_domheap_page(p2m->domain, 0);
         if ( unlikely(page == NULL) )
             goto out;
@@ -896,9 +902,13 @@ void p2m_mem_paging_resume(struct domain
     {
         p2m_lock(p2m);
         mfn = p2m->get_entry(p2m, rsp.gfn, &p2mt, &a, p2m_query, NULL);
-        set_p2m_entry(p2m, rsp.gfn, mfn, 0, p2m_ram_rw, a);
-        set_gpfn_from_mfn(mfn_x(mfn), rsp.gfn);
-        audit_p2m(p2m, 1);
+        /* Allow only pages which were prepared properly, or pages which were 
nominated but not evicted */
+        if ( mfn_valid(mfn) && ( p2mt == p2m_ram_paging_in || p2mt == 
p2m_ram_paging_in_start ) )
+        {
+            set_p2m_entry(p2m, rsp.gfn, mfn, 0, p2m_ram_rw, a);
+            set_gpfn_from_mfn(mfn_x(mfn), rsp.gfn);
+            audit_p2m(p2m, 1);
+        }
         p2m_unlock(p2m);
     }
 

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