Skip to contentSkip to conversation

xen: Simplify the space of spaces supported by XENMEM_add_to_physmap(_range)

PATCH In review Ian Campbell 3 participants 4 messages Jan 22, 2013 – Jan 24, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen: Simplify the space of spaces supported by XENMEM_add_to_physmap(_range)

XENMAPSPACE_gmfn_foreign is not supported by XENMEM_add_to_physmap.

Although in theory XENMEM_add_to_physmap_range could support XENMAPSPACE_gmfn_range this is no different to XENMAPSPACE_gmfn in the context of the ranged hypercall so disallow it to avoid any confusion.

---
 xen/arch/arm/mm.c           |    6 +++++-
 xen/include/public/memory.h |    6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)
xen/arch/arm/mm.c +5 -1
index eb5213e..faa9742 100644
@@ -648,7 +648,7 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( copy_from_guest(&xatp, arg, 1) )
             return -EFAULT;
 
-        /* This one is only supported by add_to_physmap_range */
+        /* Foreign mapping is only supported by add_to_physmap_range */
         if ( xatp.space == XENMAPSPACE_gmfn_foreign )
             return -EINVAL;
 
@@ -679,6 +679,10 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( copy_from_guest(&xatpr, arg, 1) )
             return -EFAULT;
 
+        /* This mapspace is redundant for this hypercall */
+        if ( xatpr.space == XENMAPSPACE_gmfn_range )
+            return -EINVAL;
+
         rc = rcu_lock_target_domain_by_id(xatpr.domid, &d);
         if ( rc != 0 )
             return rc;
xen/include/public/memory.h +4 -2
index 62acabd..a248c07 100644
@@ -203,8 +203,10 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
 #define XENMAPSPACE_shared_info  0 /* shared info page */
 #define XENMAPSPACE_grant_table  1 /* grant table page */
 #define XENMAPSPACE_gmfn         2 /* GMFN */
-#define XENMAPSPACE_gmfn_range   3 /* GMFN range */
-#define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom */
+#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.
+                                    */
 /* ` } */
 
 /*
Signature · 1 line
1.7.9.1
Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Ian Campbell

XENMAPSPACE_gmfn_foreign is not supported by XENMEM_add_to_physmap.

Although in theory XENMEM_add_to_physmap_range could support XENMAPSPACE_gmfn_range this is no different to XENMAPSPACE_gmfn in the context of the ranged hypercall so disallow it to avoid any confusion.

Quoted 48 lines
 xen/arch/arm/mm.c           |    6 +++++-
 xen/include/public/memory.h |    6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)
xen/arch/arm/mm.c +5 -1
index eb5213e..faa9742 100644
@@ -648,7 +648,7 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( copy_from_guest(&xatp, arg, 1) )
             return -EFAULT;
 
-        /* This one is only supported by add_to_physmap_range */
+        /* Foreign mapping is only supported by add_to_physmap_range */
         if ( xatp.space == XENMAPSPACE_gmfn_foreign )
             return -EINVAL;
 
@@ -679,6 +679,10 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void) arg)
         if ( copy_from_guest(&xatpr, arg, 1) )
             return -EFAULT;
 
+        /* This mapspace is redundant for this hypercall */
+        if ( xatpr.space == XENMAPSPACE_gmfn_range )
+            return -EINVAL;
+
         rc = rcu_lock_target_domain_by_id(xatpr.domid, &d);
         if ( rc != 0 )
             return rc;
xen/include/public/memory.h +4 -2
index 62acabd..a248c07 100644
@@ -203,8 +203,10 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
 #define XENMAPSPACE_shared_info  0 /* shared info page */
 #define XENMAPSPACE_grant_table  1 /* grant table page */
 #define XENMAPSPACE_gmfn         2 /* GMFN */
-#define XENMAPSPACE_gmfn_range   3 /* GMFN range */
-#define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom */
+#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.
+                                    */
 /* ` } */
 
 /*
Signature · 1 line
1.7.9.1
Acked-by on v1 1/1
#2 lore raw
In reply to Ian Campbell
Quoted 8 lines · Ian Campbell

XENMAPSPACE_gmfn_foreign is not supported by XENMEM_add_to_physmap.

Although in theory XENMEM_add_to_physmap_range could support XENMAPSPACE_gmfn_range this is no different to XENMAPSPACE_gmfn in the context of the ranged hypercall so disallow it to avoid any confusion.

Quoted 49 lines
---
 xen/arch/arm/mm.c           |    6 +++++-
 xen/include/public/memory.h |    6 ++++--
 2 files changed, 9 insertions(+), 3 deletions(-)
xen/arch/arm/mm.c +5 -1
index eb5213e..faa9742 100644
@@ -648,7 +648,7 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void)
 arg)
         if ( copy_from_guest(&xatp, arg, 1) )
             return -EFAULT;
 
-        /* This one is only supported by add_to_physmap_range */
+        /* Foreign mapping is only supported by add_to_physmap_range */
         if ( xatp.space == XENMAPSPACE_gmfn_foreign )
             return -EINVAL;
@@ -679,6 +679,10 @@ long arch_memory_op(int op, XEN_GUEST_HANDLE_PARAM(void)
 arg)
         if ( copy_from_guest(&xatpr, arg, 1) )
             return -EFAULT;
 
+        /* This mapspace is redundant for this hypercall */
+        if ( xatpr.space == XENMAPSPACE_gmfn_range )
+            return -EINVAL;
+
         rc = rcu_lock_target_domain_by_id(xatpr.domid, &d);
         if ( rc != 0 )
             return rc;
xen/include/public/memory.h +4 -2
index 62acabd..a248c07 100644
@@ -203,8 +203,10 @@ DEFINE_XEN_GUEST_HANDLE(xen_machphys_mapping_t);
 #define XENMAPSPACE_shared_info  0 /* shared info page */
 #define XENMAPSPACE_grant_table  1 /* grant table page */
 #define XENMAPSPACE_gmfn         2 /* GMFN */
-#define XENMAPSPACE_gmfn_range   3 /* GMFN range */
-#define XENMAPSPACE_gmfn_foreign 4 /* GMFN from another dom */
+#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.
+                                    */
 /* ` } */
 

/*

author Applied
#3 lore raw
Quoted 4 lines · Keir Fraser
Quoted 2 lines · Ian Campbell

XENMAPSPACE_gmfn_foreign is not supported by XENMEM_add_to_physmap.

Quoted 8 lines
Quoted 6 lines

Although in theory XENMEM_add_to_physmap_range could support XENMAPSPACE_gmfn_range this is no different to XENMAPSPACE_gmfn in the context of the ranged hypercall so disallow it to avoid any confusion.

Applied, thanks.