From: "Jan Beulich" Subject: [PATCH 2/2] compat wrapper for XENMEM_add_to_physmap_batch Date: Fri, 20 Dec 2013 13:08:28 +0000 Message-ID: <52B44F5C020000780010F8ED@nat28.tlf.novell.com> References: <52B44E7B020000780010F8BD@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part93A0785C.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 1Vtzob-0005M2-Lm for xen-devel@lists.xenproject.org; Fri, 20 Dec 2013 13:08:30 +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. --=__Part93A0785C.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Signed-off-by: Jan Beulich --- a/xen/common/compat/memory.c +++ b/xen/common/compat/memory.c @@ -27,12 +27,14 @@ int compat_memory_op(unsigned int cmd, X struct xen_memory_reservation *rsrv; struct xen_memory_exchange *xchg; struct xen_add_to_physmap *atp; + struct xen_add_to_physmap_batch *atpb; struct xen_remove_from_physmap *xrfp; } nat; union { struct compat_memory_reservation rsrv; struct compat_memory_exchange xchg; struct compat_add_to_physmap atp; + struct compat_add_to_physmap_batch atpb; } cmp; =20 set_xen_guest_handle(nat.hnd, COMPAT_ARG_XLAT_VIRT_BASE); @@ -200,6 +202,60 @@ int compat_memory_op(unsigned int cmd, X =20 break; =20 + case XENMEM_add_to_physmap_batch: + { + unsigned int limit =3D (COMPAT_ARG_XLAT_SIZE - sizeof(*nat.atp= b)) + / (sizeof(nat.atpb->idxs.p) + sizeof(nat.= atpb->gpfns.p)); + xen_ulong_t *idxs =3D (void *)(nat.atpb + 1); + xen_pfn_t *gpfns =3D (void *)(idxs + limit); + + if ( copy_from_guest(&cmp.atpb, compat, 1) || + !compat_handle_okay(cmp.atpb.idxs, cmp.atpb.size) || + !compat_handle_okay(cmp.atpb.gpfns, cmp.atpb.size) || + !compat_handle_okay(cmp.atpb.errs, cmp.atpb.size) ) + return -EFAULT; + + end_extent =3D start_extent + limit; + if ( end_extent > cmp.atpb.size ) + end_extent =3D cmp.atpb.size; + + idxs -=3D start_extent; + gpfns -=3D start_extent; + + for ( i =3D start_extent; i < end_extent; ++i ) + { + compat_ulong_t idx; + compat_pfn_t gpfn; + + if ( __copy_from_compat_offset(&idx, cmp.atpb.idxs, i, 1) = || + __copy_from_compat_offset(&gpfn, cmp.atpb.gpfns, i, = 1) ) + return -EFAULT; + idxs[i] =3D idx; + gpfns[i] =3D gpfn; + } + +#define XLAT_add_to_physmap_batch_HNDL_idxs(_d_, _s_) \ + set_xen_guest_handle((_d_)->idxs, idxs) +#define XLAT_add_to_physmap_batch_HNDL_gpfns(_d_, _s_) \ + set_xen_guest_handle((_d_)->gpfns, gpfns) +#define XLAT_add_to_physmap_batch_HNDL_errs(_d_, _s_) \ + guest_from_compat_handle((_d_)->errs, (_s_)->errs) + + XLAT_add_to_physmap_batch(nat.atpb, &cmp.atpb); + +#undef XLAT_add_to_physmap_batch_HNDL_errs +#undef XLAT_add_to_physmap_batch_HNDL_gpfns +#undef XLAT_add_to_physmap_batch_HNDL_idxs + + if ( end_extent < cmp.atpb.size ) + { + nat.atpb->size =3D end_extent; + ++split; + } + + break; + } + case XENMEM_remove_from_physmap: { struct compat_remove_from_physmap cmp; @@ -321,6 +377,10 @@ int compat_memory_op(unsigned int cmd, X break; } =20 + case XENMEM_add_to_physmap_batch: + start_extent =3D end_extent; + break; + case XENMEM_maximum_ram_page: case XENMEM_current_reservation: case XENMEM_maximum_reservation: --- a/xen/include/xlat.lst +++ b/xen/include/xlat.lst @@ -55,6 +55,7 @@ ! kexec_image kexec.h ! kexec_range kexec.h ! add_to_physmap memory.h +! add_to_physmap_batch memory.h ! foreign_memory_map memory.h ! memory_exchange memory.h ! memory_map memory.h --=__Part93A0785C.1__= Content-Type: text/plain; name="xatpb-compat.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xatpb-compat.patch" compat wrapper for XENMEM_add_to_physmap_batch=0A=0ASigned-off-by: Jan = Beulich =0A=0A--- a/xen/common/compat/memory.c=0A+++ = b/xen/common/compat/memory.c=0A@@ -27,12 +27,14 @@ int compat_memory_op(uns= igned int cmd, X=0A struct xen_memory_reservation *rsrv;=0A = struct xen_memory_exchange *xchg;=0A struct xen_add_to= _physmap *atp;=0A+ struct xen_add_to_physmap_batch *atpb;=0A = struct xen_remove_from_physmap *xrfp;=0A } nat;=0A = union {=0A struct compat_memory_reservation rsrv;=0A = struct compat_memory_exchange xchg;=0A struct compat_add_to_= physmap atp;=0A+ struct compat_add_to_physmap_batch atpb;=0A = } cmp;=0A =0A set_xen_guest_handle(nat.hnd, COMPAT_ARG_XLAT_VI= RT_BASE);=0A@@ -200,6 +202,60 @@ int compat_memory_op(unsigned int cmd, = X=0A =0A break;=0A =0A+ case XENMEM_add_to_physmap_batch= :=0A+ {=0A+ unsigned int limit =3D (COMPAT_ARG_XLAT_SIZE = - sizeof(*nat.atpb))=0A+ / (sizeof(nat.atpb= ->idxs.p) + sizeof(nat.atpb->gpfns.p));=0A+ xen_ulong_t *idxs = =3D (void *)(nat.atpb + 1);=0A+ xen_pfn_t *gpfns =3D (void = *)(idxs + limit);=0A+=0A+ if ( copy_from_guest(&cmp.atpb, = compat, 1) ||=0A+ !compat_handle_okay(cmp.atpb.idxs, = cmp.atpb.size) ||=0A+ !compat_handle_okay(cmp.atpb.gpfns, = cmp.atpb.size) ||=0A+ !compat_handle_okay(cmp.atpb.errs, = cmp.atpb.size) )=0A+ return -EFAULT;=0A+=0A+ = end_extent =3D start_extent + limit;=0A+ if ( end_extent > = cmp.atpb.size )=0A+ end_extent =3D cmp.atpb.size;=0A+=0A+ = idxs -=3D start_extent;=0A+ gpfns -=3D start_extent;=0A= +=0A+ for ( i =3D start_extent; i < end_extent; ++i )=0A+ = {=0A+ compat_ulong_t idx;=0A+ compat_pfn= _t gpfn;=0A+=0A+ if ( __copy_from_compat_offset(&idx, = cmp.atpb.idxs, i, 1) ||=0A+ __copy_from_compat_offset(&= gpfn, cmp.atpb.gpfns, i, 1) )=0A+ return -EFAULT;=0A+ = idxs[i] =3D idx;=0A+ gpfns[i] =3D gpfn;=0A+ = }=0A+=0A+#define XLAT_add_to_physmap_batch_HNDL_idxs(_d_, _s_) = \=0A+ set_xen_guest_handle((_d_)->idxs, idxs)=0A+#define = XLAT_add_to_physmap_batch_HNDL_gpfns(_d_, _s_) \=0A+ set_xen_gue= st_handle((_d_)->gpfns, gpfns)=0A+#define XLAT_add_to_physmap_batch_HNDL_er= rs(_d_, _s_) \=0A+ guest_from_compat_handle((_d_)->errs, = (_s_)->errs)=0A+=0A+ XLAT_add_to_physmap_batch(nat.atpb, = &cmp.atpb);=0A+=0A+#undef XLAT_add_to_physmap_batch_HNDL_errs=0A+#undef = XLAT_add_to_physmap_batch_HNDL_gpfns=0A+#undef XLAT_add_to_physmap_batch_HN= DL_idxs=0A+=0A+ if ( end_extent < cmp.atpb.size )=0A+ = {=0A+ nat.atpb->size =3D end_extent;=0A+ = ++split;=0A+ }=0A+=0A+ break;=0A+ }=0A+=0A = case XENMEM_remove_from_physmap:=0A {=0A struct = compat_remove_from_physmap cmp;=0A@@ -321,6 +377,10 @@ int compat_memory_op= (unsigned int cmd, X=0A break;=0A }=0A =0A+ = case XENMEM_add_to_physmap_batch:=0A+ start_extent =3D = end_extent;=0A+ break;=0A+=0A case XENMEM_maximum_ram_pa= ge:=0A case XENMEM_current_reservation:=0A case XENMEM_maxi= mum_reservation:=0A--- a/xen/include/xlat.lst=0A+++ b/xen/include/xlat.lst= =0A@@ -55,6 +55,7 @@=0A ! kexec_image kexec.h=0A = ! kexec_range kexec.h=0A ! add_to_physmap = memory.h=0A+! add_to_physmap_batch memory.h=0A ! = foreign_memory_map memory.h=0A ! memory_exchange = memory.h=0A ! memory_map memory.h=0A --=__Part93A0785C.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 --=__Part93A0785C.1__=--