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

[Xen-changelog] [xen-unstable] common: Use get_page_from_gfn() instead of get_gfn()/put_gfn.


  • To: xen-changelog@xxxxxxxxxxxxxxxxxxx
  • From: Xen patchbot-unstable <patchbot@xxxxxxx>
  • Date: Fri, 18 May 2012 17:11:18 +0000
  • Delivery-date: Fri, 18 May 2012 17:11:25 +0000
  • List-id: "Change log for Mercurial \(receive only\)" <xen-changelog.lists.xen.org>

# HG changeset patch
# User Tim Deegan <tim@xxxxxxx>
# Date 1337246694 -3600
# Node ID de050e895ea27e456258cf70418943e05378b37e
# Parent  974ad81bb68b8744df1e3b77c9e6191a9abd26d0
common: Use get_page_from_gfn() instead of get_gfn()/put_gfn.

Signed-off-by: Tim Deegan <tim@xxxxxxx>
Signed-off-by: Andres Lagar-Cavilla <andres@xxxxxxxxxxxxxxxx>
---


diff -r 974ad81bb68b -r de050e895ea2 xen/common/memory.c
--- a/xen/common/memory.c       Thu May 17 10:24:54 2012 +0100
+++ b/xen/common/memory.c       Thu May 17 10:24:54 2012 +0100
@@ -676,7 +676,7 @@ long do_memory_op(unsigned long cmd, XEN
     case XENMEM_remove_from_physmap:
     {
         struct xen_remove_from_physmap xrfp;
-        unsigned long mfn;
+        struct page_info *page;
         struct domain *d;
 
         if ( copy_from_guest(&xrfp, arg, 1) )
@@ -694,15 +694,15 @@ long do_memory_op(unsigned long cmd, XEN
 
         domain_lock(d);
 
-        mfn = get_gfn_untyped(d, xrfp.gpfn);
-
-        if ( mfn_valid(mfn) )
-            guest_physmap_remove_page(d, xrfp.gpfn, mfn, 0);
+        page = get_page_from_gfn(d, xrfp.gpfn, NULL, P2M_ALLOC);
+        if ( page )
+        {
+            guest_physmap_remove_page(d, xrfp.gpfn, page_to_mfn(page), 0);
+            put_page(page);
+        }
         else
             rc = -ENOENT;
 
-        put_gfn(d, xrfp.gpfn);
-
         domain_unlock(d);
 
         rcu_unlock_domain(d);
diff -r 974ad81bb68b -r de050e895ea2 xen/common/tmem_xen.c
--- a/xen/common/tmem_xen.c     Thu May 17 10:24:54 2012 +0100
+++ b/xen/common/tmem_xen.c     Thu May 17 10:24:54 2012 +0100
@@ -107,30 +107,25 @@ static inline void cli_put_page(tmem_cli
 static inline void *cli_get_page(tmem_cli_mfn_t cmfn, unsigned long *pcli_mfn,
                                  pfp_t **pcli_pfp, bool_t cli_write)
 {
-    unsigned long cli_mfn;
     p2m_type_t t;
     struct page_info *page;
-    int ret;
 
-    cli_mfn = mfn_x(get_gfn(current->domain, cmfn, &t));
-    if ( t != p2m_ram_rw || !mfn_valid(cli_mfn) )
+    page = get_page_from_gfn(current->domain, cmfn, &t, P2M_ALLOC);
+    if ( !page || t != p2m_ram_rw )
     {
-            put_gfn(current->domain, (unsigned long) cmfn);
-            return NULL;
+        if ( page )
+            put_page(page);
     }
-    page = mfn_to_page(cli_mfn);
-    if ( cli_write )
-        ret = get_page_and_type(page, current->domain, PGT_writable_page);
-    else
-        ret = get_page(page, current->domain);
-    if ( !ret )
+
+    if ( cli_write && !get_page_type(page, PGT_writable_page) )
     {
-        put_gfn(current->domain, (unsigned long) cmfn);
+        put_page(page);
         return NULL;
     }
-    *pcli_mfn = cli_mfn;
+
+    *pcli_mfn = page_to_mfn(page);
     *pcli_pfp = (pfp_t *)page;
-    return map_domain_page(cli_mfn);
+    return map_domain_page(*pcli_mfn);
 }
 
 static inline void cli_put_page(tmem_cli_mfn_t cmfn, void *cli_va, pfp_t 
*cli_pfp,
@@ -144,7 +139,6 @@ static inline void cli_put_page(tmem_cli
     else
         put_page((struct page_info *)cli_pfp);
     unmap_domain_page(cli_va);
-    put_gfn(current->domain, (unsigned long) cmfn);
 }
 #endif
 
diff -r 974ad81bb68b -r de050e895ea2 xen/xsm/flask/hooks.c
--- a/xen/xsm/flask/hooks.c     Thu May 17 10:24:54 2012 +0100
+++ b/xen/xsm/flask/hooks.c     Thu May 17 10:24:54 2012 +0100
@@ -1318,6 +1318,7 @@ static int flask_mmu_normal_update(struc
     struct domain_security_struct *dsec;
     u32 fsid;
     struct avc_audit_data ad;
+    struct page_info *page = NULL;
 
     if (d != t)
         rc = domain_has_perm(d, t, SECCLASS_MMU, MMU__REMOTE_REMAP);
@@ -1333,8 +1334,9 @@ static int flask_mmu_normal_update(struc
         map_perms |= MMU__MAP_WRITE;
 
     AVC_AUDIT_DATA_INIT(&ad, MEMORY);
-    fmfn = get_gfn_untyped(f, l1e_get_pfn(l1e_from_intpte(fpte)));
-
+    page = get_page_from_gfn(f, l1e_get_pfn(l1e_from_intpte(fpte)),
+                             NULL, P2M_ALLOC);
+    fmfn = page ? page_to_mfn(page) : INVALID_MFN;
     ad.sdom = d;
     ad.tdom = f;
     ad.memory.pte = fpte;
@@ -1342,7 +1344,8 @@ static int flask_mmu_normal_update(struc
 
     rc = get_mfn_sid(fmfn, &fsid);
 
-    put_gfn(f, fmfn);
+    if ( page )
+        put_page(page);
 
     if ( rc )
         return rc;
@@ -1370,7 +1373,7 @@ static int flask_update_va_mapping(struc
     int rc = 0;
     u32 psid;
     u32 map_perms = MMU__MAP_READ;
-    unsigned long mfn;
+    struct page_info *page = NULL;
     struct domain_security_struct *dsec;
 
     if ( !(l1e_get_flags(pte) & _PAGE_PRESENT) )
@@ -1381,8 +1384,10 @@ static int flask_update_va_mapping(struc
 
     dsec = d->ssid;
 
-    mfn = get_gfn_untyped(f, l1e_get_pfn(pte));
-    rc = get_mfn_sid(mfn, &psid);
+    page = get_page_from_gfn(f, l1e_get_pfn(pte), NULL, P2M_ALLOC);
+    rc = get_mfn_sid(page ? page_to_mfn(page) : INVALID_MFN, &psid);
+    if ( page )
+        put_page(page);
     if ( rc )
         return rc;
 

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