From: "Jan Beulich" Subject: [PATCH] x86: fix hypercall continuation cancellation in XENMAPSPACE_gmfn_range compat wrapper Date: Wed, 28 Nov 2012 07:43:57 +0000 Message-ID: <50B5CECD02000078000ABF99@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE0D108AD.0__=" Return-path: 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 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. --=__PartE0D108AD.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline When no continuation was established, there must also not be an attempt to cancel it - hypercall_cancel_continuation(), in the non-HVM, non- multicall case, adjusts the guest mode return address in a way assuming that an earlier call hypercall_create_continuation() took place. Once touching this code, also restructure it slightly to improve readability and switch to using the more relaxed copy function (copying from the same guest memory already validated the virtual address range). Signed-off-by: Jan Beulich --- a/xen/arch/x86/x86_64/compat/mm.c +++ b/xen/arch/x86/x86_64/compat/mm.c @@ -66,21 +66,20 @@ int compat_arch_memory_op(int op, XEN_GU XLAT_add_to_physmap(nat, &cmp); rc =3D arch_memory_op(op, guest_handle_from_ptr(nat, void)); =20 - if ( cmp.space =3D=3D XENMAPSPACE_gmfn_range ) + if ( !rc || cmp.space !=3D XENMAPSPACE_gmfn_range ) + break; + + XLAT_add_to_physmap(&cmp, nat); + if ( __copy_to_guest(arg, &cmp, 1) ) { - if ( rc ) - { - XLAT_add_to_physmap(&cmp, nat); - if ( copy_to_guest(arg, &cmp, 1) ) - { - hypercall_cancel_continuation(); - return -EFAULT; - } - } if ( rc =3D=3D __HYPERVISOR_memory_op ) - hypercall_xlat_continuation(NULL, 0x2, nat, arg); + hypercall_cancel_continuation(); + return -EFAULT; } =20 + if ( rc =3D=3D __HYPERVISOR_memory_op ) + hypercall_xlat_continuation(NULL, 0x2, nat, arg); + break; } =20 --=__PartE0D108AD.0__= Content-Type: text/plain; name="x86-compat-atp-gmfn-range-cont.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86-compat-atp-gmfn-range-cont.patch" x86: fix hypercall continuation cancellation in XENMAPSPACE_gmfn_range = compat wrapper=0A=0AWhen no continuation was established, there must also = not be an attempt=0Ato cancel it - hypercall_cancel_continuation(), in the = non-HVM, non-=0Amulticall case, adjusts the guest mode return address in a = way assuming=0Athat an earlier call hypercall_create_continuation() took = place.=0A=0AOnce touching this code, also restructure it slightly to = improve=0Areadability and switch to using the more relaxed copy function = (copying=0Afrom the same guest memory already validated the virtual = address=0Arange).=0A=0ASigned-off-by: Jan Beulich =0A=0A= --- a/xen/arch/x86/x86_64/compat/mm.c=0A+++ b/xen/arch/x86/x86_64/compat/mm= .c=0A@@ -66,21 +66,20 @@ int compat_arch_memory_op(int op, XEN_GU=0A = XLAT_add_to_physmap(nat, &cmp);=0A rc =3D arch_memory_op(op, = guest_handle_from_ptr(nat, void));=0A =0A- if ( cmp.space =3D=3D = XENMAPSPACE_gmfn_range )=0A+ if ( !rc || cmp.space !=3D XENMAPSPACE_= gmfn_range )=0A+ break;=0A+=0A+ XLAT_add_to_physmap(&cmp,= nat);=0A+ if ( __copy_to_guest(arg, &cmp, 1) )=0A {=0A- = if ( rc )=0A- {=0A- XLAT_add_to_physmap(&= cmp, nat);=0A- if ( copy_to_guest(arg, &cmp, 1) )=0A- = {=0A- hypercall_cancel_continuation();=0A- = return -EFAULT;=0A- }=0A- }=0A = if ( rc =3D=3D __HYPERVISOR_memory_op )=0A- = hypercall_xlat_continuation(NULL, 0x2, nat, arg);=0A+ = hypercall_cancel_continuation();=0A+ return -EFAULT;=0A = }=0A =0A+ if ( rc =3D=3D __HYPERVISOR_memory_op )=0A+ = hypercall_xlat_continuation(NULL, 0x2, nat, arg);=0A+=0A break;=0A = }=0A =0A --=__PartE0D108AD.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 --=__PartE0D108AD.0__=--