[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 1/2] rename XENMEM_add_to_physmap_{range => batch} (v2)



On Fri, 2013-12-20 at 13:07 +0000, Jan Beulich wrote:
> 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 <Ian.Campbell@xxxxxxxxxx>
> Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx>

Were you targeting this one at 4.4?

> ---
> 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 
>      return rc;
>  }
>  
> -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 = 0;
>      int rc;
>  
> -    if ( xatpr->size < start )
> +    if ( xatpb->size < start )
>          return -EILSEQ;
>  
> -    guest_handle_add_offset(xatpr->idxs, start);
> -    guest_handle_add_offset(xatpr->gpfns, start);
> -    guest_handle_add_offset(xatpr->errs, start);
> -    xatpr->size -= start;
> +    guest_handle_add_offset(xatpb->idxs, start);
> +    guest_handle_add_offset(xatpb->gpfns, start);
> +    guest_handle_add_offset(xatpb->errs, start);
> +    xatpb->size -= start;
>  
> -    while ( xatpr->size > done )
> +    while ( xatpb->size > done )
>      {
>          xen_ulong_t idx;
>          xen_pfn_t gpfn;
>  
> -        if ( unlikely(__copy_from_guest_offset(&idx, xatpr->idxs, 0, 1)) )
> +        if ( unlikely(__copy_from_guest_offset(&idx, xatpb->idxs, 0, 1)) )
>          {
>              rc = -EFAULT;
>              goto out;
>          }
>  
> -        if ( unlikely(__copy_from_guest_offset(&gpfn, xatpr->gpfns, 0, 1)) )
> +        if ( unlikely(__copy_from_guest_offset(&gpfn, xatpb->gpfns, 0, 1)) )
>          {
>              rc = -EFAULT;
>              goto out;
>          }
>  
> -        rc = xenmem_add_to_physmap_one(d, xatpr->space,
> -                                       xatpr->foreign_domid,
> +        rc = xenmem_add_to_physmap_one(d, xatpb->space,
> +                                       xatpb->foreign_domid,
>                                         idx, gpfn);
>  
> -        if ( unlikely(__copy_to_guest_offset(xatpr->errs, 0, &rc, 1)) )
> +        if ( unlikely(__copy_to_guest_offset(xatpb->errs, 0, &rc, 1)) )
>          {
>              rc = -EFAULT;
>              goto out;
>          }
>  
> -        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);
>  
>          /* 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 = 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;
>  
> -        /* Foreign mapping is only possible via add_to_physmap_range. */
> +        /* Foreign mapping is only possible via add_to_physmap_batch. */
>          if ( xatp.space == XENMAPSPACE_gmfn_foreign )
>              return -ENOSYS;
>  
> @@ -824,29 +824,29 @@ long do_memory_op(unsigned long cmd, XEN
>          return rc;
>      }
>  
> -    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;
>  
> -        BUILD_BUG_ON((typeof(xatpr.size))-1 >
> +        BUILD_BUG_ON((typeof(xatpb.size))-1 >
>                       (UINT_MAX >> MEMOP_EXTENT_SHIFT));
>  
>          /* Check for malicious or buggy input. */
> -        if ( start_extent != (typeof(xatpr.size))start_extent )
> +        if ( start_extent != (typeof(xatpb.size))start_extent )
>              return -EDOM;
>  
> -        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;
>  
>          /* This mapspace is unsupported for this hypercall. */
> -        if ( xatpr.space == XENMAPSPACE_gmfn_range )
> +        if ( xatpb.space == XENMAPSPACE_gmfn_range )
>              return -EOPNOTSUPP;
>  
> -        d = rcu_lock_domain_by_any_id(xatpr.domid);
> +        d = rcu_lock_domain_by_any_id(xatpb.domid);
>          if ( d == NULL )
>              return -ESRCH;
>  
> @@ -857,7 +857,7 @@ long do_memory_op(unsigned long cmd, XEN
>              return rc;
>          }
>  
> -        rc = xenmem_add_to_physmap_range(d, &xatpr, start_extent);
> +        rc = xenmem_add_to_physmap_batch(d, &xatpb, start_extent);
>  
>          rcu_unlock_domain(d);
>  
> --- 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. */
>  /* ` } */
>  
>  /*
> @@ -238,8 +237,8 @@ typedef struct xen_add_to_physmap xen_ad
>  DEFINE_XEN_GUEST_HANDLE(xen_add_to_physmap_t);
>  
>  /* 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
>  
>  /*
>   * Unmaps the page appearing at a particular GPFN from the specified guest's
> 
> 



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.