From: "Jan Beulich" Subject: [PATCH 1/2] rename XENMEM_add_to_physmap_{range => batch} (v2) Date: Fri, 20 Dec 2013 13:07:59 +0000 Message-ID: <52B44F3F020000780010F8E9@nat28.tlf.novell.com> References: <52B44E7B020000780010F8BD@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartF0C31B3F.1__=" Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1Vtzo8-0004y0-K9 for xen-devel@lists.xenproject.org; Fri, 20 Dec 2013 13:08:01 +0000 In-Reply-To: <52B44E7B020000780010F8BD@nat28.tlf.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: Keir Fraser , Ian Campbell 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. --=__PartF0C31B3F.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline The use of "range" here wasn't really correct - there are no ranges involved. As the comment in the public header already correctly said, all this is about is batching of XENMEM_add_to_physmap calls (with the addition of having a way to specify a foreign domain for XENMAPSPACE_gmfn_foreign). Suggested-by: Ian Campbell Signed-off-by: Jan Beulich Acked-by: Ian Campbell --- v2: fix the compatibility DEFINE_XEN_GUEST_HANDLE() --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -595,54 +595,54 @@ static int xenmem_add_to_physmap(struct=20 return rc; } =20 -static int xenmem_add_to_physmap_range(struct domain *d, - struct xen_add_to_physmap_range = *xatpr, +static int xenmem_add_to_physmap_batch(struct domain *d, + struct xen_add_to_physmap_batch = *xatpb, unsigned int start) { unsigned int done =3D 0; int rc; =20 - if ( xatpr->size < start ) + if ( xatpb->size < start ) return -EILSEQ; =20 - guest_handle_add_offset(xatpr->idxs, start); - guest_handle_add_offset(xatpr->gpfns, start); - guest_handle_add_offset(xatpr->errs, start); - xatpr->size -=3D start; + guest_handle_add_offset(xatpb->idxs, start); + guest_handle_add_offset(xatpb->gpfns, start); + guest_handle_add_offset(xatpb->errs, start); + xatpb->size -=3D start; =20 - while ( xatpr->size > done ) + while ( xatpb->size > done ) { xen_ulong_t idx; xen_pfn_t gpfn; =20 - if ( unlikely(__copy_from_guest_offset(&idx, xatpr->idxs, 0, 1)) = ) + if ( unlikely(__copy_from_guest_offset(&idx, xatpb->idxs, 0, 1)) = ) { rc =3D -EFAULT; goto out; } =20 - if ( unlikely(__copy_from_guest_offset(&gpfn, xatpr->gpfns, 0, = 1)) ) + if ( unlikely(__copy_from_guest_offset(&gpfn, xatpb->gpfns, 0, = 1)) ) { rc =3D -EFAULT; goto out; } =20 - rc =3D xenmem_add_to_physmap_one(d, xatpr->space, - xatpr->foreign_domid, + rc =3D xenmem_add_to_physmap_one(d, xatpb->space, + xatpb->foreign_domid, idx, gpfn); =20 - if ( unlikely(__copy_to_guest_offset(xatpr->errs, 0, &rc, 1)) ) + if ( unlikely(__copy_to_guest_offset(xatpb->errs, 0, &rc, 1)) ) { rc =3D -EFAULT; goto out; } =20 - guest_handle_add_offset(xatpr->idxs, 1); - guest_handle_add_offset(xatpr->gpfns, 1); - guest_handle_add_offset(xatpr->errs, 1); + guest_handle_add_offset(xatpb->idxs, 1); + guest_handle_add_offset(xatpb->gpfns, 1); + guest_handle_add_offset(xatpb->errs, 1); =20 /* Check for continuation if it's not the last iteration. */ - if ( xatpr->size > ++done && hypercall_preempt_check() ) + if ( xatpb->size > ++done && hypercall_preempt_check() ) { rc =3D start + done; goto out; @@ -797,7 +797,7 @@ long do_memory_op(unsigned long cmd, XEN if ( copy_from_guest(&xatp, arg, 1) ) return -EFAULT; =20 - /* Foreign mapping is only possible via add_to_physmap_range. */ + /* Foreign mapping is only possible via add_to_physmap_batch. */ if ( xatp.space =3D=3D XENMAPSPACE_gmfn_foreign ) return -ENOSYS; =20 @@ -824,29 +824,29 @@ long do_memory_op(unsigned long cmd, XEN return rc; } =20 - case XENMEM_add_to_physmap_range: + case XENMEM_add_to_physmap_batch: { - struct xen_add_to_physmap_range xatpr; + struct xen_add_to_physmap_batch xatpb; struct domain *d; =20 - BUILD_BUG_ON((typeof(xatpr.size))-1 > + BUILD_BUG_ON((typeof(xatpb.size))-1 > (UINT_MAX >> MEMOP_EXTENT_SHIFT)); =20 /* Check for malicious or buggy input. */ - if ( start_extent !=3D (typeof(xatpr.size))start_extent ) + if ( start_extent !=3D (typeof(xatpb.size))start_extent ) return -EDOM; =20 - if ( copy_from_guest(&xatpr, arg, 1) || - !guest_handle_okay(xatpr.idxs, xatpr.size) || - !guest_handle_okay(xatpr.gpfns, xatpr.size) || - !guest_handle_okay(xatpr.errs, xatpr.size) ) + if ( copy_from_guest(&xatpb, arg, 1) || + !guest_handle_okay(xatpb.idxs, xatpb.size) || + !guest_handle_okay(xatpb.gpfns, xatpb.size) || + !guest_handle_okay(xatpb.errs, xatpb.size) ) return -EFAULT; =20 /* This mapspace is unsupported for this hypercall. */ - if ( xatpr.space =3D=3D XENMAPSPACE_gmfn_range ) + if ( xatpb.space =3D=3D XENMAPSPACE_gmfn_range ) return -EOPNOTSUPP; =20 - d =3D rcu_lock_domain_by_any_id(xatpr.domid); + d =3D rcu_lock_domain_by_any_id(xatpb.domid); if ( d =3D=3D NULL ) return -ESRCH; =20 @@ -857,7 +857,7 @@ long do_memory_op(unsigned long cmd, XEN return rc; } =20 - rc =3D xenmem_add_to_physmap_range(d, &xatpr, start_extent); + rc =3D xenmem_add_to_physmap_batch(d, &xatpb, start_extent); =20 rcu_unlock_domain(d); =20 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -79,7 +79,7 @@ * * In addition the following arch specific sub-ops: * * XENMEM_add_to_physmap - * * XENMEM_add_to_physmap_range + * * XENMEM_add_to_physmap_batch * * HYPERVISOR_domctl * All generic sub-operations, with the exception of: --- a/xen/include/public/memory.h +++ b/xen/include/public/memory.h @@ -207,8 +207,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_map #define XENMAPSPACE_gmfn 2 /* GMFN */ #define XENMAPSPACE_gmfn_range 3 /* GMFN range, XENMEM_add_to_physmap = only. */ #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom, - * XENMEM_add_to_physmap_range only. - */ + * XENMEM_add_to_physmap_batch only. = */ /* ` } */ =20 /* @@ -238,8 +237,8 @@ typedef struct xen_add_to_physmap xen_ad DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t); =20 /* A batched version of add_to_physmap. */ -#define XENMEM_add_to_physmap_range 23 -struct xen_add_to_physmap_range { +#define XENMEM_add_to_physmap_batch 23 +struct xen_add_to_physmap_batch { /* IN */ /* Which domain to change the mapping for. */ domid_t domid; @@ -260,8 +259,15 @@ struct xen_add_to_physmap_range { /* Per index error code. */ XEN_GUEST_HANDLE(int) errs; }; -typedef struct xen_add_to_physmap_range xen_add_to_physmap_range_t; -DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_range_t); +typedef struct xen_add_to_physmap_batch xen_add_to_physmap_batch_t; +DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_batch_t); + +#if __XEN_INTERFACE_VERSION__ < 0x00040400 +#define XENMEM_add_to_physmap_range XENMEM_add_to_physmap_batch +#define xen_add_to_physmap_range xen_add_to_physmap_batch +typedef struct xen_add_to_physmap_batch xen_add_to_physmap_range_t; +DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_range_t); +#endif =20 /* * Unmaps the page appearing at a particular GPFN from the specified = guest's --=__PartF0C31B3F.1__= Content-Type: text/plain; name="xatpr-naming.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xatpr-naming.patch" rename XENMEM_add_to_physmap_{range =3D> batch}=0A=0AThe use of "range" = here wasn't really correct - there are no ranges=0Ainvolved. As the = comment in the public header already correctly said,=0Aall this is about = is batching of XENMEM_add_to_physmap calls (with=0Athe addition of having = a way to specify a foreign domain for=0AXENMAPSPACE_gmfn_foreign).=0A=0ASug= gested-by: Ian Campbell =0ASigned-off-by: Jan = Beulich =0AAcked-by: Ian Campbell =0A---=0Av2: fix the compatibility DEFINE_XEN_GUEST_HANDLE()=0A=0A--- = a/xen/common/memory.c=0A+++ b/xen/common/memory.c=0A@@ -595,54 +595,54 @@ = static int xenmem_add_to_physmap(struct =0A return rc;=0A }=0A = =0A-static int xenmem_add_to_physmap_range(struct domain *d,=0A- = struct xen_add_to_physmap_range *xatpr,=0A+stat= ic int xenmem_add_to_physmap_batch(struct domain *d,=0A+ = struct xen_add_to_physmap_batch *xatpb,=0A = unsigned int start)=0A {=0A unsigned int = done =3D 0;=0A int rc;=0A =0A- if ( xatpr->size < start )=0A+ if = ( xatpb->size < start )=0A return -EILSEQ;=0A =0A- guest_handle_= add_offset(xatpr->idxs, start);=0A- guest_handle_add_offset(xatpr->gpfns= , start);=0A- guest_handle_add_offset(xatpr->errs, start);=0A- = xatpr->size -=3D start;=0A+ guest_handle_add_offset(xatpb->idxs, = start);=0A+ guest_handle_add_offset(xatpb->gpfns, start);=0A+ = guest_handle_add_offset(xatpb->errs, start);=0A+ xatpb->size -=3D = start;=0A =0A- while ( xatpr->size > done )=0A+ while ( xatpb->size = > done )=0A {=0A xen_ulong_t idx;=0A xen_pfn_t = gpfn;=0A =0A- if ( unlikely(__copy_from_guest_offset(&idx, = xatpr->idxs, 0, 1)) )=0A+ if ( unlikely(__copy_from_guest_offset(&id= x, xatpb->idxs, 0, 1)) )=0A {=0A rc =3D -EFAULT;=0A = goto out;=0A }=0A =0A- if ( unlikely(__copy_from_gu= est_offset(&gpfn, xatpr->gpfns, 0, 1)) )=0A+ if ( unlikely(__copy_fr= om_guest_offset(&gpfn, xatpb->gpfns, 0, 1)) )=0A {=0A = rc =3D -EFAULT;=0A goto out;=0A }=0A =0A- rc = =3D xenmem_add_to_physmap_one(d, xatpr->space,=0A- = xatpr->foreign_domid,=0A+ rc =3D xenmem_add_to_physmap= _one(d, xatpb->space,=0A+ xatpb->fore= ign_domid,=0A idx, gpfn);=0A =0A- = if ( unlikely(__copy_to_guest_offset(xatpr->errs, 0, &rc, 1)) )=0A+ = if ( unlikely(__copy_to_guest_offset(xatpb->errs, 0, &rc, 1)) )=0A = {=0A rc =3D -EFAULT;=0A goto out;=0A = }=0A =0A- guest_handle_add_offset(xatpr->idxs, 1);=0A- = guest_handle_add_offset(xatpr->gpfns, 1);=0A- guest_handle_add_offse= t(xatpr->errs, 1);=0A+ guest_handle_add_offset(xatpb->idxs, 1);=0A+ = guest_handle_add_offset(xatpb->gpfns, 1);=0A+ guest_handle_ad= d_offset(xatpb->errs, 1);=0A =0A /* Check for continuation if it's = not the last iteration. */=0A- if ( xatpr->size > ++done && = hypercall_preempt_check() )=0A+ if ( xatpb->size > ++done && = hypercall_preempt_check() )=0A {=0A rc =3D start + = done;=0A goto out;=0A@@ -797,7 +797,7 @@ long do_memory_op(unsi= gned long cmd, XEN=0A if ( copy_from_guest(&xatp, arg, 1) )=0A = return -EFAULT;=0A =0A- /* Foreign mapping is only possible = via add_to_physmap_range. */=0A+ /* Foreign mapping is only = possible via add_to_physmap_batch. */=0A if ( xatp.space =3D=3D = XENMAPSPACE_gmfn_foreign )=0A return -ENOSYS;=0A =0A@@ -824,29 = +824,29 @@ long do_memory_op(unsigned long cmd, XEN=0A return = rc;=0A }=0A =0A- case XENMEM_add_to_physmap_range:=0A+ case = XENMEM_add_to_physmap_batch:=0A {=0A- struct xen_add_to_physmap_= range xatpr;=0A+ struct xen_add_to_physmap_batch xatpb;=0A = struct domain *d;=0A =0A- BUILD_BUG_ON((typeof(xatpr.size))-1 >=0A+ = BUILD_BUG_ON((typeof(xatpb.size))-1 >=0A = (UINT_MAX >> MEMOP_EXTENT_SHIFT));=0A =0A /* Check for malicious = or buggy input. */=0A- if ( start_extent !=3D (typeof(xatpr.size))st= art_extent )=0A+ if ( start_extent !=3D (typeof(xatpb.size))start_ex= tent )=0A return -EDOM;=0A =0A- if ( copy_from_guest(&xa= tpr, arg, 1) ||=0A- !guest_handle_okay(xatpr.idxs, xatpr.size) = ||=0A- !guest_handle_okay(xatpr.gpfns, xatpr.size) ||=0A- = !guest_handle_okay(xatpr.errs, xatpr.size) )=0A+ if ( = copy_from_guest(&xatpb, arg, 1) ||=0A+ !guest_handle_okay(xatpb= .idxs, xatpb.size) ||=0A+ !guest_handle_okay(xatpb.gpfns, = xatpb.size) ||=0A+ !guest_handle_okay(xatpb.errs, xatpb.size) = )=0A return -EFAULT;=0A =0A /* This mapspace is = unsupported for this hypercall. */=0A- if ( xatpr.space =3D=3D = XENMAPSPACE_gmfn_range )=0A+ if ( xatpb.space =3D=3D XENMAPSPACE_gmf= n_range )=0A return -EOPNOTSUPP;=0A =0A- d =3D = rcu_lock_domain_by_any_id(xatpr.domid);=0A+ d =3D rcu_lock_domain_by= _any_id(xatpb.domid);=0A if ( d =3D=3D NULL )=0A = return -ESRCH;=0A =0A@@ -857,7 +857,7 @@ long do_memory_op(unsigned long = cmd, XEN=0A return rc;=0A }=0A =0A- rc =3D = xenmem_add_to_physmap_range(d, &xatpr, start_extent);=0A+ rc =3D = xenmem_add_to_physmap_batch(d, &xatpb, start_extent);=0A =0A = rcu_unlock_domain(d);=0A =0A--- a/xen/include/public/arch-arm.h=0A+++ = b/xen/include/public/arch-arm.h=0A@@ -79,7 +79,7 @@=0A *=0A * In = addition the following arch specific sub-ops:=0A * * XENMEM_add_to_phys= map=0A- * * XENMEM_add_to_physmap_range=0A+ * * XENMEM_add_to_physmap= _batch=0A *=0A * HYPERVISOR_domctl=0A * All generic sub-operations, = with the exception of:=0A--- a/xen/include/public/memory.h=0A+++ b/xen/incl= ude/public/memory.h=0A@@ -207,8 +207,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_machp= hys_map=0A #define XENMAPSPACE_gmfn 2 /* GMFN */=0A #define = XENMAPSPACE_gmfn_range 3 /* GMFN range, XENMEM_add_to_physmap only. = */=0A #define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom,=0A- = * XENMEM_add_to_physmap_range only.=0A- = */=0A+ * = XENMEM_add_to_physmap_batch only. */=0A /* ` } */=0A =0A /*=0A@@ -238,8 = +237,8 @@ typedef struct xen_add_to_physmap xen_ad=0A DEFINE_XEN_GUEST_HAND= LE(xen_add_to_physmap_t);=0A =0A /* A batched version of add_to_physmap. = */=0A-#define XENMEM_add_to_physmap_range 23=0A-struct xen_add_to_physmap_r= ange {=0A+#define XENMEM_add_to_physmap_batch 23=0A+struct xen_add_to_physm= ap_batch {=0A /* IN */=0A /* Which domain to change the mapping = for. */=0A domid_t domid;=0A@@ -260,8 +259,15 @@ struct xen_add_to_phys= map_range {=0A /* Per index error code. */=0A XEN_GUEST_HANDLE(int)= errs;=0A };=0A-typedef struct xen_add_to_physmap_range xen_add_to_physmap_= range_t;=0A-DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_range_t);=0A+typedef= struct xen_add_to_physmap_batch xen_add_to_physmap_batch_t;=0A+DEFINE_XEN_= GUEST_HANDLE(xen_add_to_physmap_batch_t);=0A+=0A+#if __XEN_INTERFACE_VERSIO= N__ < 0x00040400=0A+#define XENMEM_add_to_physmap_range XENMEM_add_to_physm= ap_batch=0A+#define xen_add_to_physmap_range xen_add_to_physmap_batch=0A+ty= pedef struct xen_add_to_physmap_batch xen_add_to_physmap_range_t;=0A+DEFINE= _XEN_GUEST_HANDLE(xen_add_to_physmap_range_t);=0A+#endif=0A =0A /*=0A * = Unmaps the page appearing at a particular GPFN from the specified = guest's=0A --=__PartF0C31B3F.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 --=__PartF0C31B3F.1__=--