rename XENMEM_add_to_physmap_{range => batch}
authorJan Beulich <jbeulich@suse.com>
Wed, 8 Jan 2014 08:04:48 +0000 (09:04 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 8 Jan 2014 08:04:48 +0000 (09:04 +0100)
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@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Keir Fraser <keir@xen.org>
xen/common/memory.c
xen/include/public/arch-arm.h
xen/include/public/memory.h

index 9aa65a8993dbf72fbfb54d7b5ecb2d269f7c9f39..5a0efd57e236a90a318903a60801a7bf0d123d06 100644 (file)
@@ -628,54 +628,54 @@ static int xenmem_add_to_physmap(struct domain *d,
     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;
@@ -830,7 +830,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         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;
 
@@ -857,29 +857,29 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         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;
 
@@ -890,7 +890,7 @@ long do_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
             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);
 
index 2e7fb3e57c2631bfe77607b88107d66f389d4f60..74965560f9d34ccd33e6ea60308cc66adceb3b3e 100644 (file)
@@ -91,7 +91,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:
index 7a26dee0087962c8b23f8b2ed909b5a5ac8d7320..f19ac14bed74322fcd9f361a06c63dd0c6d9276d 100644 (file)
@@ -207,8 +207,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
 #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_add_to_physmap_t;
 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;
+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