From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Cooper Subject: Re: [PATCH v2 1/2] x86/P2M: pass on errors from p2m_set_entry() Date: Tue, 6 May 2014 15:09:30 +0100 Message-ID: <5368ED1A.1020702@citrix.com> References: <5368FD60020000780000F635@mail.emea.novell.com> <536900B7020000780000F666@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1308453069098663481==" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Whg3q-0006DN-SF for xen-devel@lists.xenproject.org; Tue, 06 May 2014 14:09:35 +0000 In-Reply-To: <536900B7020000780000F666@mail.emea.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: xen-devel , Tim Deegan List-Id: xen-devel@lists.xenproject.org --===============1308453069098663481== Content-Type: multipart/alternative; boundary="------------060605010902030301020209" --------------060605010902030301020209 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit On 06/05/14 14:33, Jan Beulich wrote: > ... at least in a couple of straightforward cases. > > Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper > --- > v2: Split out change to p2m_change_type(). > > --- a/xen/arch/x86/mm/p2m.c > +++ b/xen/arch/x86/mm/p2m.c > @@ -501,7 +501,7 @@ void p2m_final_teardown(struct domain *d > } > > > -static void > +static int > p2m_remove_page(struct p2m_domain *p2m, unsigned long gfn, unsigned long mfn, > unsigned int page_order) > { > @@ -515,7 +515,7 @@ p2m_remove_page(struct p2m_domain *p2m, > if ( need_iommu(p2m->domain) ) > for ( i = 0; i < (1 << page_order); i++ ) > iommu_unmap_page(p2m->domain, mfn + i); > - return; > + return 0; > } > > ASSERT(gfn_locked_by_me(p2m, gfn)); > @@ -531,8 +531,8 @@ p2m_remove_page(struct p2m_domain *p2m, > ASSERT( !p2m_is_valid(t) || mfn + i == mfn_x(mfn_return) ); > } > } > - p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), page_order, p2m_invalid, > - p2m->default_access); > + return p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), page_order, p2m_invalid, > + p2m->default_access); > } > > void > @@ -957,8 +957,7 @@ int p2m_mem_paging_nominate(struct domai > goto out; > > /* Fix p2m entry */ > - p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_paging_out, a); > - ret = 0; > + ret = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_paging_out, a); > > out: > gfn_unlock(p2m, gfn, 0); > @@ -1022,7 +1021,8 @@ int p2m_mem_paging_evict(struct domain * > put_page(page); > > /* Remove mapping from p2m table */ > - p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), PAGE_ORDER_4K, p2m_ram_paged, a); > + ret = p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), PAGE_ORDER_4K, > + p2m_ram_paged, a); > > /* Clear content before returning the page to Xen */ > scrub_one_page(page); > @@ -1030,8 +1030,6 @@ int p2m_mem_paging_evict(struct domain * > /* Track number of paged gfns */ > atomic_inc(&d->paged_pages); > > - ret = 0; > - > out_put: > /* Put the page back so it gets freed */ > put_page(page); > @@ -1231,16 +1229,14 @@ int p2m_mem_paging_prep(struct domain *d > /* Make the page already guest-accessible. If the pager still has a > * pending resume operation, it will be idempotent p2m entry-wise, > * but will unpause the vcpu */ > - p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, > - paging_mode_log_dirty(d) ? p2m_ram_logdirty : > - p2m_ram_rw, a); > + ret = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, > + paging_mode_log_dirty(d) ? p2m_ram_logdirty > + : p2m_ram_rw, a); > set_gpfn_from_mfn(mfn_x(mfn), gfn); > > if ( !page_extant ) > atomic_dec(&d->paged_pages); > > - ret = 0; > - > out: > gfn_unlock(p2m, gfn, 0); > return ret; > > > > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@lists.xen.org > http://lists.xen.org/xen-devel --------------060605010902030301020209 Content-Type: text/html; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit
On 06/05/14 14:33, Jan Beulich wrote:
... at least in a couple of straightforward cases.

Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>

---
v2: Split out change to p2m_change_type().

--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -501,7 +501,7 @@ void p2m_final_teardown(struct domain *d
 }
 
 
-static void
+static int
 p2m_remove_page(struct p2m_domain *p2m, unsigned long gfn, unsigned long mfn,
                 unsigned int page_order)
 {
@@ -515,7 +515,7 @@ p2m_remove_page(struct p2m_domain *p2m, 
         if ( need_iommu(p2m->domain) )
             for ( i = 0; i < (1 << page_order); i++ )
                 iommu_unmap_page(p2m->domain, mfn + i);
-        return;
+        return 0;
     }
 
     ASSERT(gfn_locked_by_me(p2m, gfn));
@@ -531,8 +531,8 @@ p2m_remove_page(struct p2m_domain *p2m, 
             ASSERT( !p2m_is_valid(t) || mfn + i == mfn_x(mfn_return) );
         }
     }
-    p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), page_order, p2m_invalid,
-                  p2m->default_access);
+    return p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), page_order, p2m_invalid,
+                         p2m->default_access);
 }
 
 void
@@ -957,8 +957,7 @@ int p2m_mem_paging_nominate(struct domai
         goto out;
 
     /* Fix p2m entry */
-    p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_paging_out, a);
-    ret = 0;
+    ret = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_paging_out, a);
 
  out:
     gfn_unlock(p2m, gfn, 0);
@@ -1022,7 +1021,8 @@ int p2m_mem_paging_evict(struct domain *
         put_page(page);
 
     /* Remove mapping from p2m table */
-    p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), PAGE_ORDER_4K, p2m_ram_paged, a);
+    ret = p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), PAGE_ORDER_4K,
+                        p2m_ram_paged, a);
 
     /* Clear content before returning the page to Xen */
     scrub_one_page(page);
@@ -1030,8 +1030,6 @@ int p2m_mem_paging_evict(struct domain *
     /* Track number of paged gfns */
     atomic_inc(&d->paged_pages);
 
-    ret = 0;
-
  out_put:
     /* Put the page back so it gets freed */
     put_page(page);
@@ -1231,16 +1229,14 @@ int p2m_mem_paging_prep(struct domain *d
     /* Make the page already guest-accessible. If the pager still has a
      * pending resume operation, it will be idempotent p2m entry-wise,
      * but will unpause the vcpu */
-    p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K,
-                  paging_mode_log_dirty(d) ? p2m_ram_logdirty :
-                  p2m_ram_rw, a);
+    ret = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K,
+                        paging_mode_log_dirty(d) ? p2m_ram_logdirty
+                                                 : p2m_ram_rw, a);
     set_gpfn_from_mfn(mfn_x(mfn), gfn);
 
     if ( !page_extant )
         atomic_dec(&d->paged_pages);
 
-    ret = 0;
-
  out:
     gfn_unlock(p2m, gfn, 0);
     return ret;





_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

--------------060605010902030301020209-- --===============1308453069098663481== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --===============1308453069098663481==--