From: "Jan Beulich" Subject: [PATCH] x86/HVM: clean up HVMOP_set_mem_type processing Date: Wed, 30 Apr 2014 14:47:54 +0100 Message-ID: <53611B2A020000780000DC9E@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartBE8C801A.0__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1WfUre-00089G-8z for xen-devel@lists.xenproject.org; Wed, 30 Apr 2014 13:47:58 +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 , Keir Fraser 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. --=__PartBE8C801A.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline - drop unused variable "mfn" - consistently do not use "else" when the prior "if" ends in "goto" - use printk() referencing the target domain instead of gdprintk() (which references the current domain) and slightly shorten message - annotate -EINVAL results in paging/shared paths to actually need switching to -EAGAIN (possible only when preemption logic got fixed to use -ERESTART) Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -4522,21 +4522,20 @@ long do_hvm_op(unsigned long op, XEN_GUE while ( a.nr > start_iter ) { unsigned long pfn =3D a.first_pfn + start_iter; - p2m_type_t t; - p2m_type_t nt; - mfn_t mfn; - mfn =3D get_gfn_unshare(d, pfn, &t); + p2m_type_t t, nt; + + get_gfn_unshare(d, pfn, &t); if ( p2m_is_paging(t) ) { put_gfn(d, pfn); p2m_mem_paging_populate(d, pfn); - rc =3D -EINVAL; + rc =3D -EINVAL; /* XXX EAGAIN */ goto param_fail4; } if ( p2m_is_shared(t) ) { put_gfn(d, pfn); - rc =3D -EINVAL; + rc =3D -EINVAL; /* XXX EAGAIN */ goto param_fail4; }=20 if ( !p2m_is_ram(t) && @@ -4545,18 +4544,14 @@ long do_hvm_op(unsigned long op, XEN_GUE put_gfn(d, pfn); goto param_fail4; } - else + nt =3D p2m_change_type(d, pfn, t, memtype[a.hvmmem_type]); + if ( nt !=3D t ) { - nt =3D p2m_change_type(d, pfn, t, memtype[a.hvmmem_type]);= - if ( nt !=3D t ) - { - put_gfn(d, pfn); - gdprintk(XENLOG_WARNING, - "type of pfn %#lx changed from %d to %d = while " - "we were trying to change it to %d\n", - pfn, t, nt, memtype[a.hvmmem_type]); - goto param_fail4; - } + put_gfn(d, pfn); + printk(XENLOG_G_WARNING + "d%d: GFN %#lx type changed from %d to %d while = trying to change it to %d\n", + d->domain_id, pfn, t, nt, memtype[a.hvmmem_type]); + goto param_fail4; } put_gfn(d, pfn); =20 --=__PartBE8C801A.0__= Content-Type: text/plain; name="x86-HVM-cleanup-set-mem-type.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-HVM-cleanup-set-mem-type.patch" x86/HVM: clean up HVMOP_set_mem_type processing=0A=0A- drop unused = variable "mfn"=0A- consistently do not use "else" when the prior "if" ends = in "goto"=0A- use printk() referencing the target domain instead of = gdprintk()=0A (which references the current domain) and slightly shorten = message=0A- annotate -EINVAL results in paging/shared paths to actually = need=0A switching to -EAGAIN (possible only when preemption logic got = fixed=0A to use -ERESTART)=0A=0ASigned-off-by: Jan Beulich =0A=0A--- a/xen/arch/x86/hvm/hvm.c=0A+++ b/xen/arch/x86/hvm/hvm.c=0A@@ = -4522,21 +4522,20 @@ long do_hvm_op(unsigned long op, XEN_GUE=0A = while ( a.nr > start_iter )=0A {=0A unsigned long pfn = =3D a.first_pfn + start_iter;=0A- p2m_type_t t;=0A- = p2m_type_t nt;=0A- mfn_t mfn;=0A- mfn =3D get_gfn_uns= hare(d, pfn, &t);=0A+ p2m_type_t t, nt;=0A+=0A+ = get_gfn_unshare(d, pfn, &t);=0A if ( p2m_is_paging(t) )=0A = {=0A put_gfn(d, pfn);=0A p2m_mem_pa= ging_populate(d, pfn);=0A- rc =3D -EINVAL;=0A+ = rc =3D -EINVAL; /* XXX EAGAIN */=0A goto param_fail4;=0A = }=0A if ( p2m_is_shared(t) )=0A {=0A = put_gfn(d, pfn);=0A- rc =3D -EINVAL;=0A+ = rc =3D -EINVAL; /* XXX EAGAIN */=0A goto = param_fail4;=0A } =0A if ( !p2m_is_ram(t) &&=0A@@ = -4545,18 +4544,14 @@ long do_hvm_op(unsigned long op, XEN_GUE=0A = put_gfn(d, pfn);=0A goto param_fail4;=0A = }=0A- else=0A+ nt =3D p2m_change_type(d, pfn, t, = memtype[a.hvmmem_type]);=0A+ if ( nt !=3D t )=0A = {=0A- nt =3D p2m_change_type(d, pfn, t, memtype[a.hvmmem_typ= e]);=0A- if ( nt !=3D t )=0A- {=0A- = put_gfn(d, pfn);=0A- gdprintk(XENLOG_WARNING,= =0A- "type of pfn %#lx changed from %d to %d = while "=0A- "we were trying to change it to = %d\n",=0A- pfn, t, nt, memtype[a.hvmmem_type]);= =0A- goto param_fail4;=0A- }=0A+ = put_gfn(d, pfn);=0A+ printk(XENLOG_G_WARNING=0A+ = "d%d: GFN %#lx type changed from %d to %d while trying = to change it to %d\n",=0A+ d->domain_id, pfn, t, nt, = memtype[a.hvmmem_type]);=0A+ goto param_fail4;=0A = }=0A put_gfn(d, pfn);=0A =0A --=__PartBE8C801A.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 --=__PartBE8C801A.0__=--