From: "Jan Beulich" Subject: [PATCH v2 1/2] x86/P2M: pass on errors from p2m_set_entry() Date: Tue, 06 May 2014 14:33:11 +0100 Message-ID: <536900B7020000780000F666@mail.emea.novell.com> References: <5368FD60020000780000F635@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part30020687.0__=" Return-path: Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WhfUi-00027p-F6 for xen-devel@lists.xenproject.org; Tue, 06 May 2014 13:33:16 +0000 In-Reply-To: <5368FD60020000780000F635@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: xen-devel Cc: Tim Deegan List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part30020687.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline ... at least in a couple of straightforward cases. Signed-off-by: Jan Beulich --- 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 } =20 =20 -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,=20 if ( need_iommu(p2m->domain) ) for ( i =3D 0; i < (1 << page_order); i++ ) iommu_unmap_page(p2m->domain, mfn + i); - return; + return 0; } =20 ASSERT(gfn_locked_by_me(p2m, gfn)); @@ -531,8 +531,8 @@ p2m_remove_page(struct p2m_domain *p2m,=20 ASSERT( !p2m_is_valid(t) || mfn + i =3D=3D 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); } =20 void @@ -957,8 +957,7 @@ int p2m_mem_paging_nominate(struct domai goto out; =20 /* Fix p2m entry */ - p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_paging_out, a); - ret =3D 0; + ret =3D p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_paging_out= , a); =20 out: gfn_unlock(p2m, gfn, 0); @@ -1022,7 +1021,8 @@ int p2m_mem_paging_evict(struct domain * put_page(page); =20 /* Remove mapping from p2m table */ - p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), PAGE_ORDER_4K, p2m_ram_page= d, a); + ret =3D p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), PAGE_ORDER_4K, + p2m_ram_paged, a); =20 /* 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); =20 - ret =3D 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 =3D 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); =20 if ( !page_extant ) atomic_dec(&d->paged_pages); =20 - ret =3D 0; - out: gfn_unlock(p2m, gfn, 0); return ret; --=__Part30020687.0__= Content-Type: text/plain; name="x86-p2m-set-entry-simple.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-p2m-set-entry-simple.patch" x86/P2M: pass on errors from p2m_set_entry()=0A=0A... at least in a couple = of straightforward cases.=0A=0ASigned-off-by: Jan Beulich =0A---=0Av2: Split out change to p2m_change_type().=0A=0A--- a/xen/arch/x= 86/mm/p2m.c=0A+++ b/xen/arch/x86/mm/p2m.c=0A@@ -501,7 +501,7 @@ void = p2m_final_teardown(struct domain *d=0A }=0A =0A =0A-static void=0A+static = int=0A p2m_remove_page(struct p2m_domain *p2m, unsigned long gfn, unsigned = long mfn,=0A unsigned int page_order)=0A {=0A@@ -515,7 = +515,7 @@ p2m_remove_page(struct p2m_domain *p2m, =0A if ( = need_iommu(p2m->domain) )=0A for ( i =3D 0; i < (1 << = page_order); i++ )=0A iommu_unmap_page(p2m->domain, mfn + = i);=0A- return;=0A+ return 0;=0A }=0A =0A ASSERT(gfn_= locked_by_me(p2m, gfn));=0A@@ -531,8 +531,8 @@ p2m_remove_page(struct = p2m_domain *p2m, =0A ASSERT( !p2m_is_valid(t) || mfn + i = =3D=3D mfn_x(mfn_return) );=0A }=0A }=0A- p2m_set_entry(p2m,= gfn, _mfn(INVALID_MFN), page_order, p2m_invalid,=0A- = p2m->default_access);=0A+ return p2m_set_entry(p2m, gfn, _mfn(INVALID_MF= N), page_order, p2m_invalid,=0A+ p2m->default_acces= s);=0A }=0A =0A void=0A@@ -957,8 +957,7 @@ int p2m_mem_paging_nominate(stru= ct domai=0A goto out;=0A =0A /* Fix p2m entry */=0A- = p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, p2m_ram_paging_out, a);=0A- = ret =3D 0;=0A+ ret =3D p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K, = p2m_ram_paging_out, a);=0A =0A out:=0A gfn_unlock(p2m, gfn, 0);=0A@@ = -1022,7 +1021,8 @@ int p2m_mem_paging_evict(struct domain *=0A = put_page(page);=0A =0A /* Remove mapping from p2m table */=0A- = p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), PAGE_ORDER_4K, p2m_ram_paged, = a);=0A+ ret =3D p2m_set_entry(p2m, gfn, _mfn(INVALID_MFN), PAGE_ORDER_4K= ,=0A+ p2m_ram_paged, a);=0A =0A /* Clear = content before returning the page to Xen */=0A scrub_one_page(page);=0A= @@ -1030,8 +1030,6 @@ int p2m_mem_paging_evict(struct domain *=0A /* = Track number of paged gfns */=0A atomic_inc(&d->paged_pages);=0A =0A- = ret =3D 0;=0A-=0A out_put:=0A /* Put the page back so it gets freed = */=0A put_page(page);=0A@@ -1231,16 +1229,14 @@ int p2m_mem_paging_prep= (struct domain *d=0A /* Make the page already guest-accessible. If the = pager still has a=0A * pending resume operation, it will be idempotent= p2m entry-wise,=0A * but will unpause the vcpu */=0A- p2m_set_entr= y(p2m, gfn, mfn, PAGE_ORDER_4K,=0A- paging_mode_log_dirty(= d) ? p2m_ram_logdirty :=0A- p2m_ram_rw, a);=0A+ ret = =3D p2m_set_entry(p2m, gfn, mfn, PAGE_ORDER_4K,=0A+ = paging_mode_log_dirty(d) ? p2m_ram_logdirty=0A+ = : p2m_ram_rw, a);=0A set_gpfn_from_mfn(mfn_x(mfn),= gfn);=0A =0A if ( !page_extant )=0A atomic_dec(&d->paged_pages= );=0A =0A- ret =3D 0;=0A-=0A out:=0A gfn_unlock(p2m, gfn, 0);=0A = return ret;=0A --=__Part30020687.0__= 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 --=__Part30020687.0__=--