From: "Jan Beulich" Subject: [PATCH] kexec: prefer __copy_to_guest() when possible Date: Tue, 27 Jan 2015 17:19:40 +0000 Message-ID: <54C7D6BC0200007800059FD5@mail.emea.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part8FBA11BC.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YG9nw-0007S9-JH for xen-devel@lists.xenproject.org; Tue, 27 Jan 2015 17:19:56 +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: David Vrabel 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. --=__Part8FBA11BC.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline It's slightly cheaper and safe as long a copy_from_guest() for the same guest address range was issued before. Signed-off-by: Jan Beulich --- a/xen/common/kexec.c +++ b/xen/common/kexec.c @@ -663,8 +663,8 @@ static int kexec_get_range(XEN_GUEST_HAN =20 ret =3D kexec_get_range_internal(&range); =20 - if ( ret =3D=3D 0 && unlikely(copy_to_guest(uarg, &range, 1)) ) - return -EFAULT; + if ( ret =3D=3D 0 && unlikely(__copy_to_guest(uarg, &range, 1)) ) + ret =3D -EFAULT; =20 return ret; } @@ -687,10 +687,11 @@ static int kexec_get_range_compat(XEN_GU if ( (range.start | range.size) & ~(unsigned long)(~0u) ) return -ERANGE; =20 - if ( ret =3D=3D 0 ) { + if ( ret =3D=3D 0 ) + { XLAT_kexec_range(&compat_range, &range); - if ( unlikely(copy_to_guest(uarg, &compat_range, 1)) ) - return -EFAULT; + if ( unlikely(__copy_to_guest(uarg, &compat_range, 1)) ) + ret =3D -EFAULT; } =20 return ret; --=__Part8FBA11BC.1__= Content-Type: text/plain; name="kexec-copy-to-guest.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="kexec-copy-to-guest.patch" kexec: prefer __copy_to_guest() when possible=0A=0AIt's slightly cheaper = and safe as long a copy_from_guest() for the same=0Aguest address range = was issued before.=0A=0ASigned-off-by: Jan Beulich =0A= =0A--- a/xen/common/kexec.c=0A+++ b/xen/common/kexec.c=0A@@ -663,8 +663,8 = @@ static int kexec_get_range(XEN_GUEST_HAN=0A =0A ret =3D kexec_get_ra= nge_internal(&range);=0A =0A- if ( ret =3D=3D 0 && unlikely(copy_to_gues= t(uarg, &range, 1)) )=0A- return -EFAULT;=0A+ if ( ret =3D=3D 0 = && unlikely(__copy_to_guest(uarg, &range, 1)) )=0A+ ret =3D = -EFAULT;=0A =0A return ret;=0A }=0A@@ -687,10 +687,11 @@ static int = kexec_get_range_compat(XEN_GU=0A if ( (range.start | range.size) & = ~(unsigned long)(~0u) )=0A return -ERANGE;=0A =0A- if ( ret = =3D=3D 0 ) {=0A+ if ( ret =3D=3D 0 )=0A+ {=0A XLAT_kexec_rang= e(&compat_range, &range);=0A- if ( unlikely(copy_to_guest(uarg, = &compat_range, 1)) )=0A- return -EFAULT;=0A+ if ( = unlikely(__copy_to_guest(uarg, &compat_range, 1)) )=0A+ ret = =3D -EFAULT;=0A }=0A =0A return ret;=0A --=__Part8FBA11BC.1__= 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 --=__Part8FBA11BC.1__=--