From: "Jan Beulich" Subject: [PATCH] x86/p2m: also clear defer_nested_flush on error Date: Tue, 15 Apr 2014 15:10:07 +0100 Message-ID: <534D59DF02000078000090A1@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE4D6F7AF.0__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Wa43w-0000pT-Ja for xen-devel@lists.xenproject.org; Tue, 15 Apr 2014 14:10:12 +0000 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. --=__PartE4D6F7AF.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline While presumably benign (domain creation ought to fail when P2M setup fails) let's be on the safe side and clear the flag as intended. And actually, the code can be streamlined quite a bit by recognizing that the only difference between the success and error cases is the message printed in each case. With that, a stray spin_unlock() also goes away. Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm/p2m.c +++ b/xen/arch/x86/mm/p2m.c @@ -435,18 +435,12 @@ int p2m_alloc_table(struct p2m_domain *p p2m->defer_nested_flush =3D 1; rc =3D p2m_set_entry(p2m, 0, _mfn(INVALID_MFN), PAGE_ORDER_4K, p2m_invalid, p2m->default_access); - if ( rc ) - goto error; p2m->defer_nested_flush =3D 0; - - P2M_PRINTK("p2m table initialised for slot zero\n"); - p2m_unlock(p2m); - return 0; - - spin_unlock(&p2m->domain->page_alloc_lock); - error: - P2M_PRINTK("failed to initialise p2m table for slot zero. rc:%d\n", = rc); p2m_unlock(p2m); + if ( !rc ) + P2M_PRINTK("p2m table initialised for slot zero\n"); + else + P2M_PRINTK("failed to initialise p2m table for slot zero (%d)\n", = rc); return rc; } =20 --=__PartE4D6F7AF.0__= Content-Type: text/plain; name="x86-p2m-clear-defer_nested_flush.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-p2m-clear-defer_nested_flush.patch" x86/p2m: also clear defer_nested_flush on error=0A=0AWhile presumably = benign (domain creation ought to fail when P2M setup=0Afails) let's be on = the safe side and clear the flag as intended. And=0Aactually, the code can = be streamlined quite a bit by recognizing that=0Athe only difference = between the success and error cases is the message=0Aprinted in each case. = With that, a stray spin_unlock() also goes away.=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/arch/x86/mm/p2m.c=0A+++ = b/xen/arch/x86/mm/p2m.c=0A@@ -435,18 +435,12 @@ int p2m_alloc_table(struct = p2m_domain *p=0A p2m->defer_nested_flush =3D 1;=0A rc =3D = p2m_set_entry(p2m, 0, _mfn(INVALID_MFN), PAGE_ORDER_4K,=0A = p2m_invalid, p2m->default_access);=0A- if ( rc )=0A- goto = error;=0A p2m->defer_nested_flush =3D 0;=0A-=0A- P2M_PRINTK("p2m = table initialised for slot zero\n");=0A- p2m_unlock(p2m);=0A- return = 0;=0A-=0A- spin_unlock(&p2m->domain->page_alloc_lock);=0A- error:=0A- = P2M_PRINTK("failed to initialise p2m table for slot zero. rc:%d\n", = rc);=0A p2m_unlock(p2m);=0A+ if ( !rc )=0A+ P2M_PRINTK("p2m = table initialised for slot zero\n");=0A+ else=0A+ P2M_PRINTK("fai= led to initialise p2m table for slot zero (%d)\n", rc);=0A return = rc;=0A }=0A =0A --=__PartE4D6F7AF.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 --=__PartE4D6F7AF.0__=--