All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/6] Add dmops to allow use of VGA with restricted QEMU
@ 2018-01-12 12:45 Ross Lagerwall
  2018-01-12 12:45 ` [PATCH v3 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
                   ` (5 more replies)
  0 siblings, 6 replies; 14+ messages in thread
From: Ross Lagerwall @ 2018-01-12 12:45 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall, Paul Durrant, Ian Jackson, Jan Beulich

The recently added support for restricting QEMU prevents use of the VGA
console. This series addresses that by adding a couple of new dmops.
A corresponding patch for QEMU is needed to make use of the new dmops.

Changes in v3:
* Address Jan's comments - primarily adding a new patch to remove the
  existing pin_mem_cacheattr domctl.

Changes in v2:
* Address Paul's comments - mainly making add_to_physmap operate on a
  range.

Ross Lagerwall (6):
  xen/mm: Make xenmem_add_to_physmap global
  x86/hvm: Provide XEN_DMOP_add_to_physmap
  x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr
  tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
  tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr
  x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr

 tools/flask/policy/modules/xen.if               |  4 +-
 tools/libs/devicemodel/Makefile                 |  2 +-
 tools/libs/devicemodel/core.c                   | 39 ++++++++++++++++++
 tools/libs/devicemodel/include/xendevicemodel.h | 29 +++++++++++++
 tools/libs/devicemodel/libxendevicemodel.map    |  6 +++
 tools/libxc/include/xenctrl.h                   |  6 ---
 tools/libxc/include/xenctrl_compat.h            |  3 ++
 tools/libxc/xc_devicemodel_compat.c             |  8 ++++
 tools/libxc/xc_domain.c                         | 15 -------
 xen/arch/x86/domctl.c                           |  8 ----
 xen/arch/x86/hvm/dm.c                           | 55 +++++++++++++++++++++++++
 xen/common/memory.c                             |  5 +--
 xen/include/public/domctl.h                     |  7 +---
 xen/include/public/hvm/dm_op.h                  | 41 ++++++++++++++++++
 xen/include/xen/mm.h                            |  3 ++
 xen/include/xlat.lst                            |  2 +
 xen/xsm/flask/hooks.c                           |  3 --
 xen/xsm/flask/policy/access_vectors             |  2 -
 18 files changed, 192 insertions(+), 46 deletions(-)

-- 
2.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* [PATCH v3 1/6] xen/mm: Make xenmem_add_to_physmap global
  2018-01-12 12:45 [PATCH v3 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
@ 2018-01-12 12:45 ` Ross Lagerwall
  2018-01-12 12:45 ` [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Ross Lagerwall @ 2018-01-12 12:45 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Ross Lagerwall, Jan Beulich

Make it global in preparation to be called by a new dmop.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/memory.c  | 5 ++---
 xen/include/xen/mm.h | 3 +++
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/common/memory.c b/xen/common/memory.c
index 5a1508a..1dd2b23 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -741,9 +741,8 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg)
     return rc;
 }
 
-static int xenmem_add_to_physmap(struct domain *d,
-                                 struct xen_add_to_physmap *xatp,
-                                 unsigned int start)
+int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,
+                          unsigned int start)
 {
     unsigned int done = 0;
     long rc = 0;
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index e813c07..0e0e511 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -579,6 +579,9 @@ int xenmem_add_to_physmap_one(struct domain *d, unsigned int space,
                               union xen_add_to_physmap_batch_extra extra,
                               unsigned long idx, gfn_t gfn);
 
+int xenmem_add_to_physmap(struct domain *d, struct xen_add_to_physmap *xatp,
+                          unsigned int start);
+
 /* Return 0 on success, or negative on error. */
 int __must_check guest_remove_page(struct domain *d, unsigned long gmfn);
 int __must_check steal_page(struct domain *d, struct page_info *page,
-- 
2.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap
  2018-01-12 12:45 [PATCH v3 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
  2018-01-12 12:45 ` [PATCH v3 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
@ 2018-01-12 12:45 ` Ross Lagerwall
  2018-01-15 13:33   ` Paul Durrant
  2018-01-18  9:24   ` Jan Beulich
  2018-01-12 12:45 ` [PATCH v3 3/6] x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
                   ` (3 subsequent siblings)
  5 siblings, 2 replies; 14+ messages in thread
From: Ross Lagerwall @ 2018-01-12 12:45 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Ross Lagerwall, Paul Durrant,
	Jan Beulich

Provide XEN_DMOP_add_to_physmap, a limited version of
XENMEM_add_to_physmap to allow a deprivileged QEMU to move VRAM when a
guest programs its BAR. It is equivalent to XENMEM_add_to_physmap with
space == XENMAPSPACE_gmfn_range.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---

Changed in v3:
* Renamed idx -> src_gfn and gpfn -> dst_gfn.
* Increase the width of size and add an overflow check.
* Rework some of the descriptions.
* Dropped Paul's reviewed-by due to the above changes.

Changed in v2:
* Make it operate on a range.

 xen/arch/x86/hvm/dm.c          | 37 +++++++++++++++++++++++++++++++++++++
 xen/include/public/hvm/dm_op.h | 19 +++++++++++++++++++
 xen/include/xlat.lst           |  1 +
 3 files changed, 57 insertions(+)

diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index a787f43..4a2033e 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -640,6 +640,42 @@ static int dm_op(const struct dmop_args *op_args)
         break;
     }
 
+    case XEN_DMOP_add_to_physmap:
+    {
+        struct xen_dm_op_add_to_physmap *data =
+            &op.u.add_to_physmap;
+        struct xen_add_to_physmap xatp = {
+            .domid = op_args->domid,
+            .size = data->size,
+            .space = XENMAPSPACE_gmfn_range,
+            .idx = data->src_gfn,
+            .gpfn = data->dst_gfn,
+        };
+
+        if ( data->pad )
+        {
+            rc = -EINVAL;
+            break;
+        }
+
+        if ( xatp.size != data->size )
+        {
+            rc = -EOVERFLOW;
+            break;
+        }
+
+        rc = xenmem_add_to_physmap(d, &xatp, 0);
+        if ( rc > 0 )
+        {
+            data->size -= rc;
+            data->src_gfn += rc;
+            data->dst_gfn += rc;
+            const_op = false;
+            rc = -ERESTART;
+        }
+        break;
+    }
+
     default:
         rc = -EOPNOTSUPP;
         break;
@@ -669,6 +705,7 @@ CHECK_dm_op_set_mem_type;
 CHECK_dm_op_inject_event;
 CHECK_dm_op_inject_msi;
 CHECK_dm_op_remote_shutdown;
+CHECK_dm_op_add_to_physmap;
 
 int compat_dm_op(domid_t domid,
                  unsigned int nr_bufs,
diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h
index e173085..0d7e22f 100644
--- a/xen/include/public/hvm/dm_op.h
+++ b/xen/include/public/hvm/dm_op.h
@@ -368,6 +368,24 @@ struct xen_dm_op_remote_shutdown {
                            /* (Other reason values are not blocked) */
 };
 
+/*
+ * XEN_DMOP_add_to_physmap : Sets the GFNs at which a page range appears in
+ *                           the specified guest's address space. Identical to
+ *                           XENMEM_add_to_physmap with
+ *                           space == XENMAPSPACE_gmfn_range.
+ */
+#define XEN_DMOP_add_to_physmap 17
+
+struct xen_dm_op_add_to_physmap {
+    /* Number of GFNs to process. */
+    uint32_t size;
+    uint32_t pad;
+    /* Starting GFN of the source mapping page(s). */
+    uint64_aligned_t src_gfn;
+    /* Starting GFN where the source mapping page(s) should appear. */
+    uint64_aligned_t dst_gfn;
+};
+
 struct xen_dm_op {
     uint32_t op;
     uint32_t pad;
@@ -389,6 +407,7 @@ struct xen_dm_op {
         struct xen_dm_op_map_mem_type_to_ioreq_server
                 map_mem_type_to_ioreq_server;
         struct xen_dm_op_remote_shutdown remote_shutdown;
+        struct xen_dm_op_add_to_physmap add_to_physmap;
     } u;
 };
 
diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst
index 4346cbe..d40bac6 100644
--- a/xen/include/xlat.lst
+++ b/xen/include/xlat.lst
@@ -57,6 +57,7 @@
 ?	grant_entry_v2			grant_table.h
 ?	gnttab_swap_grant_ref		grant_table.h
 !	dm_op_buf			hvm/dm_op.h
+?	dm_op_add_to_physmap		hvm/dm_op.h
 ?	dm_op_create_ioreq_server	hvm/dm_op.h
 ?	dm_op_destroy_ioreq_server	hvm/dm_op.h
 ?	dm_op_get_ioreq_server_info	hvm/dm_op.h
-- 
2.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 3/6] x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr
  2018-01-12 12:45 [PATCH v3 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
  2018-01-12 12:45 ` [PATCH v3 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
  2018-01-12 12:45 ` [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
@ 2018-01-12 12:45 ` Ross Lagerwall
  2018-01-12 12:45 ` [PATCH v3 4/6] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap Ross Lagerwall
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 14+ messages in thread
From: Ross Lagerwall @ 2018-01-12 12:45 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Ross Lagerwall, Paul Durrant,
	Jan Beulich

Provide XEN_DMOP_pin_memory_cacheattr to allow a deprivileged QEMU to
pin the caching type of RAM after moving the VRAM. It is equivalent to
XEN_DOMCTL_pin_memory_cacheattr.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
---

Changed in v2:
* Check pad is 0.

 xen/arch/x86/hvm/dm.c          | 18 ++++++++++++++++++
 xen/include/public/hvm/dm_op.h | 14 ++++++++++++++
 xen/include/xlat.lst           |  1 +
 3 files changed, 33 insertions(+)

diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index 4a2033e..93dd769 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -20,6 +20,7 @@
 #include <xen/sched.h>
 
 #include <asm/hap.h>
+#include <asm/hvm/cacheattr.h>
 #include <asm/hvm/ioreq.h>
 #include <asm/shadow.h>
 
@@ -676,6 +677,22 @@ static int dm_op(const struct dmop_args *op_args)
         break;
     }
 
+    case XEN_DMOP_pin_memory_cacheattr:
+    {
+        const struct xen_dm_op_pin_memory_cacheattr *data =
+            &op.u.pin_memory_cacheattr;
+
+        if ( data->pad )
+        {
+            rc = -EINVAL;
+            break;
+        }
+
+        rc = hvm_set_mem_pinned_cacheattr(d, data->start, data->end,
+                                          data->type);
+        break;
+    }
+
     default:
         rc = -EOPNOTSUPP;
         break;
@@ -706,6 +723,7 @@ CHECK_dm_op_inject_event;
 CHECK_dm_op_inject_msi;
 CHECK_dm_op_remote_shutdown;
 CHECK_dm_op_add_to_physmap;
+CHECK_dm_op_pin_memory_cacheattr;
 
 int compat_dm_op(domid_t domid,
                  unsigned int nr_bufs,
diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h
index 0d7e22f..c2525b4 100644
--- a/xen/include/public/hvm/dm_op.h
+++ b/xen/include/public/hvm/dm_op.h
@@ -386,6 +386,19 @@ struct xen_dm_op_add_to_physmap {
     uint64_aligned_t dst_gfn;
 };
 
+/*
+ * XEN_DMOP_pin_memory_cacheattr : Pin caching type of RAM space.
+ *                                 Identical to XEN_DOMCTL_pin_mem_cacheattr.
+ */
+#define XEN_DMOP_pin_memory_cacheattr 18
+
+struct xen_dm_op_pin_memory_cacheattr {
+    uint64_aligned_t start; /* Start gfn. */
+    uint64_aligned_t end;   /* End gfn. */
+    uint32_t type;          /* XEN_DOMCTL_MEM_CACHEATTR_* */
+    uint32_t pad;
+};
+
 struct xen_dm_op {
     uint32_t op;
     uint32_t pad;
@@ -408,6 +421,7 @@ struct xen_dm_op {
                 map_mem_type_to_ioreq_server;
         struct xen_dm_op_remote_shutdown remote_shutdown;
         struct xen_dm_op_add_to_physmap add_to_physmap;
+        struct xen_dm_op_pin_memory_cacheattr pin_memory_cacheattr;
     } u;
 };
 
diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst
index d40bac6..fffb308 100644
--- a/xen/include/xlat.lst
+++ b/xen/include/xlat.lst
@@ -65,6 +65,7 @@
 ?	dm_op_inject_msi		hvm/dm_op.h
 ?	dm_op_ioreq_server_range	hvm/dm_op.h
 ?	dm_op_modified_memory		hvm/dm_op.h
+?	dm_op_pin_memory_cacheattr	hvm/dm_op.h
 ?	dm_op_remote_shutdown		hvm/dm_op.h
 ?	dm_op_set_ioreq_server_state	hvm/dm_op.h
 ?	dm_op_set_isa_irq_level		hvm/dm_op.h
-- 
2.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 4/6] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
  2018-01-12 12:45 [PATCH v3 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
                   ` (2 preceding siblings ...)
  2018-01-12 12:45 ` [PATCH v3 3/6] x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
@ 2018-01-12 12:45 ` Ross Lagerwall
  2018-01-12 12:45 ` [PATCH v3 5/6] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr Ross Lagerwall
  2018-01-12 12:45 ` [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
  5 siblings, 0 replies; 14+ messages in thread
From: Ross Lagerwall @ 2018-01-12 12:45 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall, Ian Jackson, Wei Liu

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
---

Changed in v3:
* Match width of size with updated hypervisor interface.
* Match description with the one for the hypervisor interface.

Changed in v2:
* Make it operate on a range.

 tools/libs/devicemodel/Makefile                 |  2 +-
 tools/libs/devicemodel/core.c                   | 20 ++++++++++++++++++++
 tools/libs/devicemodel/include/xendevicemodel.h | 15 +++++++++++++++
 tools/libs/devicemodel/libxendevicemodel.map    |  5 +++++
 4 files changed, 41 insertions(+), 1 deletion(-)

diff --git a/tools/libs/devicemodel/Makefile b/tools/libs/devicemodel/Makefile
index 342371a..5b2df7a 100644
--- a/tools/libs/devicemodel/Makefile
+++ b/tools/libs/devicemodel/Makefile
@@ -2,7 +2,7 @@ XEN_ROOT = $(CURDIR)/../../..
 include $(XEN_ROOT)/tools/Rules.mk
 
 MAJOR    = 1
-MINOR    = 1
+MINOR    = 2
 SHLIB_LDFLAGS += -Wl,--version-script=libxendevicemodel.map
 
 CFLAGS   += -Werror -Wmissing-prototypes
diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
index 355b7de..5545f61 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -564,6 +564,26 @@ int xendevicemodel_shutdown(
     return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
 }
 
+int xendevicemodel_add_to_physmap(
+    xendevicemodel_handle *dmod, domid_t domid, uint32_t size, uint64_t src_gfn,
+    uint64_t dst_gfn)
+{
+    struct xen_dm_op op;
+    struct xen_dm_op_add_to_physmap *data;
+
+    memset(&op, 0, sizeof(op));
+
+    op.op = XEN_DMOP_add_to_physmap;
+    data = &op.u.add_to_physmap;
+
+    data->size = size;
+    data->pad = 0;
+    data->src_gfn = src_gfn;
+    data->dst_gfn = dst_gfn;
+
+    return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
+}
+
 int xendevicemodel_restrict(xendevicemodel_handle *dmod, domid_t domid)
 {
     return osdep_xendevicemodel_restrict(dmod, domid);
diff --git a/tools/libs/devicemodel/include/xendevicemodel.h b/tools/libs/devicemodel/include/xendevicemodel.h
index dda0bc7..ac12239 100644
--- a/tools/libs/devicemodel/include/xendevicemodel.h
+++ b/tools/libs/devicemodel/include/xendevicemodel.h
@@ -325,6 +325,21 @@ int xendevicemodel_inject_event(
 int xendevicemodel_shutdown(
     xendevicemodel_handle *dmod, domid_t domid, unsigned int reason);
 
+/*
+ * Sets the GFNs at which a page range appears in the domain's address
+ * space.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm size Number of GFNs to process
+ * @parm src_gfn Starting GFN of the source mapping page(s)
+ * @parm dst_gfn Starting GFN where the source mapping page(s) should appear.
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_add_to_physmap(
+    xendevicemodel_handle *dmod, domid_t domid, uint32_t size, uint64_t src_gfn,
+    uint64_t dst_gfn);
+
 /**
  * This function restricts the use of this handle to the specified
  * domain.
diff --git a/tools/libs/devicemodel/libxendevicemodel.map b/tools/libs/devicemodel/libxendevicemodel.map
index cefd32b..4a19ecb 100644
--- a/tools/libs/devicemodel/libxendevicemodel.map
+++ b/tools/libs/devicemodel/libxendevicemodel.map
@@ -27,3 +27,8 @@ VERS_1.1 {
 	global:
 		xendevicemodel_shutdown;
 } VERS_1.0;
+
+VERS_1.2 {
+	global:
+		xendevicemodel_add_to_physmap;
+} VERS_1.1;
-- 
2.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 5/6] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr
  2018-01-12 12:45 [PATCH v3 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
                   ` (3 preceding siblings ...)
  2018-01-12 12:45 ` [PATCH v3 4/6] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap Ross Lagerwall
@ 2018-01-12 12:45 ` Ross Lagerwall
  2018-01-12 12:45 ` [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
  5 siblings, 0 replies; 14+ messages in thread
From: Ross Lagerwall @ 2018-01-12 12:45 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall, Ian Jackson, Wei Liu

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
---
 tools/libs/devicemodel/core.c                   | 19 +++++++++++++++++++
 tools/libs/devicemodel/include/xendevicemodel.h | 14 ++++++++++++++
 tools/libs/devicemodel/libxendevicemodel.map    |  1 +
 3 files changed, 34 insertions(+)

diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c
index 5545f61..27e1d50 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -584,6 +584,25 @@ int xendevicemodel_add_to_physmap(
     return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
 }
 
+int xendevicemodel_pin_memory_cacheattr(
+    xendevicemodel_handle *dmod, domid_t domid, uint64_t start, uint64_t end,
+    uint32_t type)
+{
+    struct xen_dm_op op;
+    struct xen_dm_op_pin_memory_cacheattr *data;
+
+    memset(&op, 0, sizeof(op));
+
+    op.op = XEN_DMOP_pin_memory_cacheattr;
+    data = &op.u.pin_memory_cacheattr;
+
+    data->start = start;
+    data->end = end;
+    data->type = type;
+
+    return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
+}
+
 int xendevicemodel_restrict(xendevicemodel_handle *dmod, domid_t domid)
 {
     return osdep_xendevicemodel_restrict(dmod, domid);
diff --git a/tools/libs/devicemodel/include/xendevicemodel.h b/tools/libs/devicemodel/include/xendevicemodel.h
index ac12239..9e60288 100644
--- a/tools/libs/devicemodel/include/xendevicemodel.h
+++ b/tools/libs/devicemodel/include/xendevicemodel.h
@@ -341,6 +341,20 @@ int xendevicemodel_add_to_physmap(
     uint64_t dst_gfn);
 
 /**
+ * Pins caching type of RAM space.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm start Start gfn
+ * @parm end End gfn
+ * @parm type XEN_DOMCTL_MEM_CACHEATTR_*
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_pin_memory_cacheattr(
+    xendevicemodel_handle *dmod, domid_t domid, uint64_t start, uint64_t end,
+    uint32_t type);
+
+/**
  * This function restricts the use of this handle to the specified
  * domain.
  *
diff --git a/tools/libs/devicemodel/libxendevicemodel.map b/tools/libs/devicemodel/libxendevicemodel.map
index 4a19ecb..e820b77 100644
--- a/tools/libs/devicemodel/libxendevicemodel.map
+++ b/tools/libs/devicemodel/libxendevicemodel.map
@@ -31,4 +31,5 @@ VERS_1.1 {
 VERS_1.2 {
 	global:
 		xendevicemodel_add_to_physmap;
+		xendevicemodel_pin_memory_cacheattr;
 } VERS_1.1;
-- 
2.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-12 12:45 [PATCH v3 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
                   ` (4 preceding siblings ...)
  2018-01-12 12:45 ` [PATCH v3 5/6] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr Ross Lagerwall
@ 2018-01-12 12:45 ` Ross Lagerwall
  2018-01-15 13:38   ` Paul Durrant
                     ` (2 more replies)
  5 siblings, 3 replies; 14+ messages in thread
From: Ross Lagerwall @ 2018-01-12 12:45 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Ross Lagerwall, Paul Durrant,
	Jan Beulich, Daniel De Graaf

Remove the implementation of XEN_DOMCTL_pin_mem_cacheattr since it has
been replaced by a dmop. Change xc_domain_pin_memory_cacheattr() so
that it is only defined when XC_WANT_COMPAT_DEVICEMODEL_API is set and
have it call the new dmop.  Leave the definitions of
XEN_DOMCTL_MEM_CACHEATTR_* since they are still used by QEMU.

Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---

New in v3.

 tools/flask/policy/modules/xen.if               |  4 ++--
 tools/libs/devicemodel/include/xendevicemodel.h |  2 +-
 tools/libxc/include/xenctrl.h                   |  6 ------
 tools/libxc/include/xenctrl_compat.h            |  3 +++
 tools/libxc/xc_devicemodel_compat.c             |  8 ++++++++
 tools/libxc/xc_domain.c                         | 15 ---------------
 xen/arch/x86/domctl.c                           |  8 --------
 xen/include/public/domctl.h                     |  7 +------
 xen/include/public/hvm/dm_op.h                  | 10 +++++++++-
 xen/xsm/flask/hooks.c                           |  3 ---
 xen/xsm/flask/policy/access_vectors             |  2 --
 11 files changed, 24 insertions(+), 44 deletions(-)

diff --git a/tools/flask/policy/modules/xen.if b/tools/flask/policy/modules/xen.if
index cb48a6c..459880b 100644
--- a/tools/flask/policy/modules/xen.if
+++ b/tools/flask/policy/modules/xen.if
@@ -57,7 +57,7 @@ define(`create_domain_common', `
 	allow $1 $2:shadow enable;
 	allow $1 $2:mmu { map_read map_write adjust memorymap physmap pinpage mmuext_op updatemp };
 	allow $1 $2:grant setup;
-	allow $1 $2:hvm { cacheattr getparam hvmctl sethvmc
+	allow $1 $2:hvm { getparam hvmctl sethvmc
 			setparam nested altp2mhvm altp2mhvm_op dm };
 ')
 
@@ -151,7 +151,7 @@ define(`device_model', `
 
 	allow $1 $2_target:domain { getdomaininfo shutdown };
 	allow $1 $2_target:mmu { map_read map_write adjust physmap target_hack };
-	allow $1 $2_target:hvm { getparam setparam hvmctl cacheattr dm };
+	allow $1 $2_target:hvm { getparam setparam hvmctl dm };
 ')
 
 # make_device_model(priv, dm_dom, hvm_dom)
diff --git a/tools/libs/devicemodel/include/xendevicemodel.h b/tools/libs/devicemodel/include/xendevicemodel.h
index 9e60288..892e770 100644
--- a/tools/libs/devicemodel/include/xendevicemodel.h
+++ b/tools/libs/devicemodel/include/xendevicemodel.h
@@ -347,7 +347,7 @@ int xendevicemodel_add_to_physmap(
  * @parm domid the domain id to be serviced
  * @parm start Start gfn
  * @parm end End gfn
- * @parm type XEN_DOMCTL_MEM_CACHEATTR_*
+ * @parm type XEN_DMOP_MEM_CACHEATTR_*
  * @return 0 on success, -1 on failure.
  */
 int xendevicemodel_pin_memory_cacheattr(
diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 09e1363..aa9472d 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1472,12 +1472,6 @@ int xc_domain_iomem_permission(xc_interface *xch,
                                unsigned long nr_mfns,
                                uint8_t allow_access);
 
-int xc_domain_pin_memory_cacheattr(xc_interface *xch,
-                                   uint32_t domid,
-                                   uint64_t start,
-                                   uint64_t end,
-                                   uint32_t type);
-
 unsigned long xc_make_page_below_4G(xc_interface *xch, uint32_t domid,
                                     unsigned long mfn);
 
diff --git a/tools/libxc/include/xenctrl_compat.h b/tools/libxc/include/xenctrl_compat.h
index a655e47..464f645 100644
--- a/tools/libxc/include/xenctrl_compat.h
+++ b/tools/libxc/include/xenctrl_compat.h
@@ -164,6 +164,9 @@ int xc_hvm_set_mem_type(
 int xc_hvm_inject_trap(
     xc_interface *xch, uint32_t domid, int vcpu, uint8_t vector,
     uint8_t type, uint32_t error_code, uint8_t insn_len, uint64_t cr2);
+int xc_domain_pin_memory_cacheattr(
+    xc_interface *xch, uint32_t domid, uint64_t start, uint64_t end,
+    uint32_t type);
 
 #endif /* XC_WANT_COMPAT_DEVICEMODEL_API */
 
diff --git a/tools/libxc/xc_devicemodel_compat.c b/tools/libxc/xc_devicemodel_compat.c
index dbd1785..a46011c 100644
--- a/tools/libxc/xc_devicemodel_compat.c
+++ b/tools/libxc/xc_devicemodel_compat.c
@@ -128,6 +128,14 @@ int xc_hvm_inject_trap(
                                        type, error_code, insn_len, cr2);
 }
 
+int xc_domain_pin_memory_cacheattr(
+    xc_interface *xch, uint32_t domid, uint64_t start, uint64_t end,
+    uint32_t type)
+{
+    return xendevicemodel_pin_memory_cacheattr(xch->dmod, domid, start, end,
+                                               type);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
index 3ccd27f..bef25b6 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -719,21 +719,6 @@ int xc_domain_setmaxmem(xc_interface *xch,
     return do_domctl(xch, &domctl);
 }
 
-int xc_domain_pin_memory_cacheattr(xc_interface *xch,
-                                   uint32_t domid,
-                                   uint64_t start,
-                                   uint64_t end,
-                                   uint32_t type)
-{
-    DECLARE_DOMCTL;
-    domctl.cmd = XEN_DOMCTL_pin_mem_cacheattr;
-    domctl.domain = domid;
-    domctl.u.pin_mem_cacheattr.start = start;
-    domctl.u.pin_mem_cacheattr.end = end;
-    domctl.u.pin_mem_cacheattr.type = type;
-    return do_domctl(xch, &domctl);
-}
-
 #if defined(__i386__) || defined(__x86_64__)
 int xc_domain_set_memory_map(xc_interface *xch,
                                uint32_t domid,
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 5973d9f..50172bf 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -23,7 +23,6 @@
 #include <asm/irq.h>
 #include <asm/hvm/hvm.h>
 #include <asm/hvm/support.h>
-#include <asm/hvm/cacheattr.h>
 #include <asm/processor.h>
 #include <asm/acpi.h> /* for hvm_acpi_power_button */
 #include <xen/hypercall.h> /* for arch_do_domctl */
@@ -857,13 +856,6 @@ long arch_do_domctl(
         break;
     }
 
-    case XEN_DOMCTL_pin_mem_cacheattr:
-        ret = hvm_set_mem_pinned_cacheattr(
-            d, domctl->u.pin_mem_cacheattr.start,
-            domctl->u.pin_mem_cacheattr.end,
-            domctl->u.pin_mem_cacheattr.type);
-        break;
-
     case XEN_DOMCTL_set_ext_vcpucontext:
     case XEN_DOMCTL_get_ext_vcpucontext:
     {
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 9ae72959..4f0d76f 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -597,10 +597,6 @@ struct xen_domctl_ioport_mapping {
 #define XEN_DOMCTL_MEM_CACHEATTR_WB  6
 #define XEN_DOMCTL_MEM_CACHEATTR_UCM 7
 #define XEN_DOMCTL_DELETE_MEM_CACHEATTR (~(uint32_t)0)
-struct xen_domctl_pin_mem_cacheattr {
-    uint64_aligned_t start, end;
-    uint32_t type; /* XEN_DOMCTL_MEM_CACHEATTR_* */
-};
 
 
 /* XEN_DOMCTL_set_ext_vcpucontext */
@@ -1148,7 +1144,7 @@ struct xen_domctl {
 #define XEN_DOMCTL_bind_pt_irq                   38
 #define XEN_DOMCTL_memory_mapping                39
 #define XEN_DOMCTL_ioport_mapping                40
-#define XEN_DOMCTL_pin_mem_cacheattr             41
+/* #define XEN_DOMCTL_pin_mem_cacheattr          41 Obsolete - use dmop */
 #define XEN_DOMCTL_set_ext_vcpucontext           42
 #define XEN_DOMCTL_get_ext_vcpucontext           43
 #define XEN_DOMCTL_set_opt_feature               44 /* Obsolete IA64 only */
@@ -1225,7 +1221,6 @@ struct xen_domctl {
         struct xen_domctl_bind_pt_irq       bind_pt_irq;
         struct xen_domctl_memory_mapping    memory_mapping;
         struct xen_domctl_ioport_mapping    ioport_mapping;
-        struct xen_domctl_pin_mem_cacheattr pin_mem_cacheattr;
         struct xen_domctl_ext_vcpucontext   ext_vcpucontext;
         struct xen_domctl_set_target        set_target;
         struct xen_domctl_subscribe         subscribe;
diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h
index c2525b4..929146b 100644
--- a/xen/include/public/hvm/dm_op.h
+++ b/xen/include/public/hvm/dm_op.h
@@ -395,7 +395,15 @@ struct xen_dm_op_add_to_physmap {
 struct xen_dm_op_pin_memory_cacheattr {
     uint64_aligned_t start; /* Start gfn. */
     uint64_aligned_t end;   /* End gfn. */
-    uint32_t type;          /* XEN_DOMCTL_MEM_CACHEATTR_* */
+/* Caching types: these happen to be the same as x86 MTRR/PAT type codes. */
+#define XEN_DMOP_MEM_CACHEATTR_UC  0
+#define XEN_DMOP_MEM_CACHEATTR_WC  1
+#define XEN_DMOP_MEM_CACHEATTR_WT  4
+#define XEN_DMOP_MEM_CACHEATTR_WP  5
+#define XEN_DMOP_MEM_CACHEATTR_WB  6
+#define XEN_DMOP_MEM_CACHEATTR_UCM 7
+#define XEN_DMOP_DELETE_MEM_CACHEATTR (~(uint32_t)0)
+    uint32_t type;          /* XEN_DMOP_MEM_CACHEATTR_* */
     uint32_t pad;
 };
 
diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
index 19ceacf..835b3d1 100644
--- a/xen/xsm/flask/hooks.c
+++ b/xen/xsm/flask/hooks.c
@@ -693,9 +693,6 @@ static int flask_domctl(struct domain *d, int cmd)
     case XEN_DOMCTL_mem_sharing_op:
         return current_has_perm(d, SECCLASS_HVM, HVM__MEM_SHARING);
 
-    case XEN_DOMCTL_pin_mem_cacheattr:
-        return current_has_perm(d, SECCLASS_HVM, HVM__CACHEATTR);
-
     case XEN_DOMCTL_sendtrigger:
         return current_has_perm(d, SECCLASS_DOMAIN, DOMAIN__TRIGGER);
 
diff --git a/xen/xsm/flask/policy/access_vectors b/xen/xsm/flask/policy/access_vectors
index d0a1ec5..50dfc36 100644
--- a/xen/xsm/flask/policy/access_vectors
+++ b/xen/xsm/flask/policy/access_vectors
@@ -264,8 +264,6 @@ class hvm
 # HVMOP_get_param
     getparam
     bind_irq
-# XEN_DOMCTL_pin_mem_cacheattr
-    cacheattr
 # HVMOP_get_mem_type,
 # HVMOP_set_mem_access, HVMOP_get_mem_access, HVMOP_pagetable_dying
     hvmctl
-- 
2.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply related	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap
  2018-01-12 12:45 ` [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
@ 2018-01-15 13:33   ` Paul Durrant
  2018-01-18  9:24   ` Jan Beulich
  1 sibling, 0 replies; 14+ messages in thread
From: Paul Durrant @ 2018-01-15 13:33 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, Tim (Xen.org),
	George Dunlap, Ross Lagerwall, Jan Beulich, Ian Jackson

> -----Original Message-----
> From: Ross Lagerwall [mailto:ross.lagerwall@citrix.com]
> Sent: 12 January 2018 12:45
> To: xen-devel@lists.xen.org
> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>; Paul Durrant
> <Paul.Durrant@citrix.com>; Jan Beulich <jbeulich@suse.com>; Andrew
> Cooper <Andrew.Cooper3@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Konrad
> Rzeszutek Wilk <konrad.wilk@oracle.com>; Stefano Stabellini
> <sstabellini@kernel.org>; Tim (Xen.org) <tim@xen.org>; Wei Liu
> <wei.liu2@citrix.com>
> Subject: [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap
> 
> Provide XEN_DMOP_add_to_physmap, a limited version of
> XENMEM_add_to_physmap to allow a deprivileged QEMU to move VRAM
> when a
> guest programs its BAR. It is equivalent to XENMEM_add_to_physmap with
> space == XENMAPSPACE_gmfn_range.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> ---
> 
> Changed in v3:
> * Renamed idx -> src_gfn and gpfn -> dst_gfn.
> * Increase the width of size and add an overflow check.
> * Rework some of the descriptions.
> * Dropped Paul's reviewed-by due to the above changes.
> 
> Changed in v2:
> * Make it operate on a range.
> 
>  xen/arch/x86/hvm/dm.c          | 37
> +++++++++++++++++++++++++++++++++++++
>  xen/include/public/hvm/dm_op.h | 19 +++++++++++++++++++
>  xen/include/xlat.lst           |  1 +
>  3 files changed, 57 insertions(+)
> 
> diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
> index a787f43..4a2033e 100644
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -640,6 +640,42 @@ static int dm_op(const struct dmop_args *op_args)
>          break;
>      }
> 
> +    case XEN_DMOP_add_to_physmap:
> +    {
> +        struct xen_dm_op_add_to_physmap *data =
> +            &op.u.add_to_physmap;
> +        struct xen_add_to_physmap xatp = {
> +            .domid = op_args->domid,
> +            .size = data->size,
> +            .space = XENMAPSPACE_gmfn_range,
> +            .idx = data->src_gfn,
> +            .gpfn = data->dst_gfn,
> +        };
> +
> +        if ( data->pad )
> +        {
> +            rc = -EINVAL;
> +            break;
> +        }
> +
> +        if ( xatp.size != data->size )
> +        {
> +            rc = -EOVERFLOW;
> +            break;
> +        }
> +
> +        rc = xenmem_add_to_physmap(d, &xatp, 0);
> +        if ( rc > 0 )
> +        {
> +            data->size -= rc;
> +            data->src_gfn += rc;
> +            data->dst_gfn += rc;
> +            const_op = false;
> +            rc = -ERESTART;
> +        }
> +        break;
> +    }
> +
>      default:
>          rc = -EOPNOTSUPP;
>          break;
> @@ -669,6 +705,7 @@ CHECK_dm_op_set_mem_type;
>  CHECK_dm_op_inject_event;
>  CHECK_dm_op_inject_msi;
>  CHECK_dm_op_remote_shutdown;
> +CHECK_dm_op_add_to_physmap;
> 
>  int compat_dm_op(domid_t domid,
>                   unsigned int nr_bufs,
> diff --git a/xen/include/public/hvm/dm_op.h
> b/xen/include/public/hvm/dm_op.h
> index e173085..0d7e22f 100644
> --- a/xen/include/public/hvm/dm_op.h
> +++ b/xen/include/public/hvm/dm_op.h
> @@ -368,6 +368,24 @@ struct xen_dm_op_remote_shutdown {
>                             /* (Other reason values are not blocked) */
>  };
> 
> +/*
> + * XEN_DMOP_add_to_physmap : Sets the GFNs at which a page range
> appears in
> + *                           the specified guest's address space. Identical to
> + *                           XENMEM_add_to_physmap with
> + *                           space == XENMAPSPACE_gmfn_range.
> + */
> +#define XEN_DMOP_add_to_physmap 17
> +
> +struct xen_dm_op_add_to_physmap {
> +    /* Number of GFNs to process. */
> +    uint32_t size;
> +    uint32_t pad;
> +    /* Starting GFN of the source mapping page(s). */
> +    uint64_aligned_t src_gfn;
> +    /* Starting GFN where the source mapping page(s) should appear. */
> +    uint64_aligned_t dst_gfn;
> +};
> +
>  struct xen_dm_op {
>      uint32_t op;
>      uint32_t pad;
> @@ -389,6 +407,7 @@ struct xen_dm_op {
>          struct xen_dm_op_map_mem_type_to_ioreq_server
>                  map_mem_type_to_ioreq_server;
>          struct xen_dm_op_remote_shutdown remote_shutdown;
> +        struct xen_dm_op_add_to_physmap add_to_physmap;
>      } u;
>  };
> 
> diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst
> index 4346cbe..d40bac6 100644
> --- a/xen/include/xlat.lst
> +++ b/xen/include/xlat.lst
> @@ -57,6 +57,7 @@
>  ?	grant_entry_v2			grant_table.h
>  ?	gnttab_swap_grant_ref		grant_table.h
>  !	dm_op_buf			hvm/dm_op.h
> +?	dm_op_add_to_physmap		hvm/dm_op.h
>  ?	dm_op_create_ioreq_server	hvm/dm_op.h
>  ?	dm_op_destroy_ioreq_server	hvm/dm_op.h
>  ?	dm_op_get_ioreq_server_info	hvm/dm_op.h
> --
> 2.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-12 12:45 ` [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
@ 2018-01-15 13:38   ` Paul Durrant
  2018-01-17 18:09   ` Daniel De Graaf
  2018-01-18  9:29   ` Jan Beulich
  2 siblings, 0 replies; 14+ messages in thread
From: Paul Durrant @ 2018-01-15 13:38 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, Tim (Xen.org),
	George Dunlap, Ross Lagerwall, Jan Beulich, Ian Jackson,
	Daniel De Graaf

> -----Original Message-----
> From: Ross Lagerwall [mailto:ross.lagerwall@citrix.com]
> Sent: 12 January 2018 12:45
> To: xen-devel@lists.xen.org
> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>; Paul Durrant
> <Paul.Durrant@citrix.com>; Daniel De Graaf <dgdegra@tycho.nsa.gov>; Ian
> Jackson <Ian.Jackson@citrix.com>; Wei Liu <wei.liu2@citrix.com>; Andrew
> Cooper <Andrew.Cooper3@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>; Jan Beulich <jbeulich@suse.com>; Konrad
> Rzeszutek Wilk <konrad.wilk@oracle.com>; Stefano Stabellini
> <sstabellini@kernel.org>; Tim (Xen.org) <tim@xen.org>
> Subject: [PATCH v3 6/6] x86/domctl: Remove
> XEN_DOMCTL_pin_mem_cacheattr
> 
> Remove the implementation of XEN_DOMCTL_pin_mem_cacheattr since it
> has
> been replaced by a dmop. Change xc_domain_pin_memory_cacheattr() so
> that it is only defined when XC_WANT_COMPAT_DEVICEMODEL_API is set
> and
> have it call the new dmop.  Leave the definitions of
> XEN_DOMCTL_MEM_CACHEATTR_* since they are still used by QEMU.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> ---
> 
> New in v3.
> 
>  tools/flask/policy/modules/xen.if               |  4 ++--
>  tools/libs/devicemodel/include/xendevicemodel.h |  2 +-
>  tools/libxc/include/xenctrl.h                   |  6 ------
>  tools/libxc/include/xenctrl_compat.h            |  3 +++
>  tools/libxc/xc_devicemodel_compat.c             |  8 ++++++++
>  tools/libxc/xc_domain.c                         | 15 ---------------
>  xen/arch/x86/domctl.c                           |  8 --------
>  xen/include/public/domctl.h                     |  7 +------
>  xen/include/public/hvm/dm_op.h                  | 10 +++++++++-
>  xen/xsm/flask/hooks.c                           |  3 ---
>  xen/xsm/flask/policy/access_vectors             |  2 --
>  11 files changed, 24 insertions(+), 44 deletions(-)
> 
> diff --git a/tools/flask/policy/modules/xen.if
> b/tools/flask/policy/modules/xen.if
> index cb48a6c..459880b 100644
> --- a/tools/flask/policy/modules/xen.if
> +++ b/tools/flask/policy/modules/xen.if
> @@ -57,7 +57,7 @@ define(`create_domain_common', `
>  	allow $1 $2:shadow enable;
>  	allow $1 $2:mmu { map_read map_write adjust memorymap
> physmap pinpage mmuext_op updatemp };
>  	allow $1 $2:grant setup;
> -	allow $1 $2:hvm { cacheattr getparam hvmctl sethvmc
> +	allow $1 $2:hvm { getparam hvmctl sethvmc
>  			setparam nested altp2mhvm altp2mhvm_op dm };
>  ')
> 
> @@ -151,7 +151,7 @@ define(`device_model', `
> 
>  	allow $1 $2_target:domain { getdomaininfo shutdown };
>  	allow $1 $2_target:mmu { map_read map_write adjust physmap
> target_hack };
> -	allow $1 $2_target:hvm { getparam setparam hvmctl cacheattr dm };
> +	allow $1 $2_target:hvm { getparam setparam hvmctl dm };
>  ')
> 
>  # make_device_model(priv, dm_dom, hvm_dom)
> diff --git a/tools/libs/devicemodel/include/xendevicemodel.h
> b/tools/libs/devicemodel/include/xendevicemodel.h
> index 9e60288..892e770 100644
> --- a/tools/libs/devicemodel/include/xendevicemodel.h
> +++ b/tools/libs/devicemodel/include/xendevicemodel.h
> @@ -347,7 +347,7 @@ int xendevicemodel_add_to_physmap(
>   * @parm domid the domain id to be serviced
>   * @parm start Start gfn
>   * @parm end End gfn
> - * @parm type XEN_DOMCTL_MEM_CACHEATTR_*
> + * @parm type XEN_DMOP_MEM_CACHEATTR_*
>   * @return 0 on success, -1 on failure.
>   */
>  int xendevicemodel_pin_memory_cacheattr(
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index 09e1363..aa9472d 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -1472,12 +1472,6 @@ int xc_domain_iomem_permission(xc_interface
> *xch,
>                                 unsigned long nr_mfns,
>                                 uint8_t allow_access);
> 
> -int xc_domain_pin_memory_cacheattr(xc_interface *xch,
> -                                   uint32_t domid,
> -                                   uint64_t start,
> -                                   uint64_t end,
> -                                   uint32_t type);
> -
>  unsigned long xc_make_page_below_4G(xc_interface *xch, uint32_t
> domid,
>                                      unsigned long mfn);
> 
> diff --git a/tools/libxc/include/xenctrl_compat.h
> b/tools/libxc/include/xenctrl_compat.h
> index a655e47..464f645 100644
> --- a/tools/libxc/include/xenctrl_compat.h
> +++ b/tools/libxc/include/xenctrl_compat.h
> @@ -164,6 +164,9 @@ int xc_hvm_set_mem_type(
>  int xc_hvm_inject_trap(
>      xc_interface *xch, uint32_t domid, int vcpu, uint8_t vector,
>      uint8_t type, uint32_t error_code, uint8_t insn_len, uint64_t cr2);
> +int xc_domain_pin_memory_cacheattr(
> +    xc_interface *xch, uint32_t domid, uint64_t start, uint64_t end,
> +    uint32_t type);
> 
>  #endif /* XC_WANT_COMPAT_DEVICEMODEL_API */
> 
> diff --git a/tools/libxc/xc_devicemodel_compat.c
> b/tools/libxc/xc_devicemodel_compat.c
> index dbd1785..a46011c 100644
> --- a/tools/libxc/xc_devicemodel_compat.c
> +++ b/tools/libxc/xc_devicemodel_compat.c
> @@ -128,6 +128,14 @@ int xc_hvm_inject_trap(
>                                         type, error_code, insn_len, cr2);
>  }
> 
> +int xc_domain_pin_memory_cacheattr(
> +    xc_interface *xch, uint32_t domid, uint64_t start, uint64_t end,
> +    uint32_t type)
> +{
> +    return xendevicemodel_pin_memory_cacheattr(xch->dmod, domid,
> start, end,
> +                                               type);
> +}
> +
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/tools/libxc/xc_domain.c b/tools/libxc/xc_domain.c
> index 3ccd27f..bef25b6 100644
> --- a/tools/libxc/xc_domain.c
> +++ b/tools/libxc/xc_domain.c
> @@ -719,21 +719,6 @@ int xc_domain_setmaxmem(xc_interface *xch,
>      return do_domctl(xch, &domctl);
>  }
> 
> -int xc_domain_pin_memory_cacheattr(xc_interface *xch,
> -                                   uint32_t domid,
> -                                   uint64_t start,
> -                                   uint64_t end,
> -                                   uint32_t type)
> -{
> -    DECLARE_DOMCTL;
> -    domctl.cmd = XEN_DOMCTL_pin_mem_cacheattr;
> -    domctl.domain = domid;
> -    domctl.u.pin_mem_cacheattr.start = start;
> -    domctl.u.pin_mem_cacheattr.end = end;
> -    domctl.u.pin_mem_cacheattr.type = type;
> -    return do_domctl(xch, &domctl);
> -}
> -
>  #if defined(__i386__) || defined(__x86_64__)
>  int xc_domain_set_memory_map(xc_interface *xch,
>                                 uint32_t domid,
> diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
> index 5973d9f..50172bf 100644
> --- a/xen/arch/x86/domctl.c
> +++ b/xen/arch/x86/domctl.c
> @@ -23,7 +23,6 @@
>  #include <asm/irq.h>
>  #include <asm/hvm/hvm.h>
>  #include <asm/hvm/support.h>
> -#include <asm/hvm/cacheattr.h>
>  #include <asm/processor.h>
>  #include <asm/acpi.h> /* for hvm_acpi_power_button */
>  #include <xen/hypercall.h> /* for arch_do_domctl */
> @@ -857,13 +856,6 @@ long arch_do_domctl(
>          break;
>      }
> 
> -    case XEN_DOMCTL_pin_mem_cacheattr:
> -        ret = hvm_set_mem_pinned_cacheattr(
> -            d, domctl->u.pin_mem_cacheattr.start,
> -            domctl->u.pin_mem_cacheattr.end,
> -            domctl->u.pin_mem_cacheattr.type);
> -        break;
> -
>      case XEN_DOMCTL_set_ext_vcpucontext:
>      case XEN_DOMCTL_get_ext_vcpucontext:
>      {
> diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
> index 9ae72959..4f0d76f 100644
> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -597,10 +597,6 @@ struct xen_domctl_ioport_mapping {
>  #define XEN_DOMCTL_MEM_CACHEATTR_WB  6
>  #define XEN_DOMCTL_MEM_CACHEATTR_UCM 7
>  #define XEN_DOMCTL_DELETE_MEM_CACHEATTR (~(uint32_t)0)
> -struct xen_domctl_pin_mem_cacheattr {
> -    uint64_aligned_t start, end;
> -    uint32_t type; /* XEN_DOMCTL_MEM_CACHEATTR_* */
> -};
> 
> 
>  /* XEN_DOMCTL_set_ext_vcpucontext */
> @@ -1148,7 +1144,7 @@ struct xen_domctl {
>  #define XEN_DOMCTL_bind_pt_irq                   38
>  #define XEN_DOMCTL_memory_mapping                39
>  #define XEN_DOMCTL_ioport_mapping                40
> -#define XEN_DOMCTL_pin_mem_cacheattr             41
> +/* #define XEN_DOMCTL_pin_mem_cacheattr          41 Obsolete - use dmop
> */
>  #define XEN_DOMCTL_set_ext_vcpucontext           42
>  #define XEN_DOMCTL_get_ext_vcpucontext           43
>  #define XEN_DOMCTL_set_opt_feature               44 /* Obsolete IA64 only */
> @@ -1225,7 +1221,6 @@ struct xen_domctl {
>          struct xen_domctl_bind_pt_irq       bind_pt_irq;
>          struct xen_domctl_memory_mapping    memory_mapping;
>          struct xen_domctl_ioport_mapping    ioport_mapping;
> -        struct xen_domctl_pin_mem_cacheattr pin_mem_cacheattr;
>          struct xen_domctl_ext_vcpucontext   ext_vcpucontext;
>          struct xen_domctl_set_target        set_target;
>          struct xen_domctl_subscribe         subscribe;
> diff --git a/xen/include/public/hvm/dm_op.h
> b/xen/include/public/hvm/dm_op.h
> index c2525b4..929146b 100644
> --- a/xen/include/public/hvm/dm_op.h
> +++ b/xen/include/public/hvm/dm_op.h
> @@ -395,7 +395,15 @@ struct xen_dm_op_add_to_physmap {
>  struct xen_dm_op_pin_memory_cacheattr {
>      uint64_aligned_t start; /* Start gfn. */
>      uint64_aligned_t end;   /* End gfn. */
> -    uint32_t type;          /* XEN_DOMCTL_MEM_CACHEATTR_* */
> +/* Caching types: these happen to be the same as x86 MTRR/PAT type
> codes. */
> +#define XEN_DMOP_MEM_CACHEATTR_UC  0
> +#define XEN_DMOP_MEM_CACHEATTR_WC  1
> +#define XEN_DMOP_MEM_CACHEATTR_WT  4
> +#define XEN_DMOP_MEM_CACHEATTR_WP  5
> +#define XEN_DMOP_MEM_CACHEATTR_WB  6
> +#define XEN_DMOP_MEM_CACHEATTR_UCM 7
> +#define XEN_DMOP_DELETE_MEM_CACHEATTR (~(uint32_t)0)
> +    uint32_t type;          /* XEN_DMOP_MEM_CACHEATTR_* */
>      uint32_t pad;
>  };
> 
> diff --git a/xen/xsm/flask/hooks.c b/xen/xsm/flask/hooks.c
> index 19ceacf..835b3d1 100644
> --- a/xen/xsm/flask/hooks.c
> +++ b/xen/xsm/flask/hooks.c
> @@ -693,9 +693,6 @@ static int flask_domctl(struct domain *d, int cmd)
>      case XEN_DOMCTL_mem_sharing_op:
>          return current_has_perm(d, SECCLASS_HVM, HVM__MEM_SHARING);
> 
> -    case XEN_DOMCTL_pin_mem_cacheattr:
> -        return current_has_perm(d, SECCLASS_HVM, HVM__CACHEATTR);
> -
>      case XEN_DOMCTL_sendtrigger:
>          return current_has_perm(d, SECCLASS_DOMAIN, DOMAIN__TRIGGER);
> 
> diff --git a/xen/xsm/flask/policy/access_vectors
> b/xen/xsm/flask/policy/access_vectors
> index d0a1ec5..50dfc36 100644
> --- a/xen/xsm/flask/policy/access_vectors
> +++ b/xen/xsm/flask/policy/access_vectors
> @@ -264,8 +264,6 @@ class hvm
>  # HVMOP_get_param
>      getparam
>      bind_irq
> -# XEN_DOMCTL_pin_mem_cacheattr
> -    cacheattr
>  # HVMOP_get_mem_type,
>  # HVMOP_set_mem_access, HVMOP_get_mem_access,
> HVMOP_pagetable_dying
>      hvmctl
> --
> 2.9.5


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-12 12:45 ` [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
  2018-01-15 13:38   ` Paul Durrant
@ 2018-01-17 18:09   ` Daniel De Graaf
  2018-01-18  9:29   ` Jan Beulich
  2 siblings, 0 replies; 14+ messages in thread
From: Daniel De Graaf @ 2018-01-17 18:09 UTC (permalink / raw)
  To: Ross Lagerwall, xen-devel
  Cc: Stefano Stabellini, Wei Liu, George Dunlap, Andrew Cooper,
	Ian Jackson, Tim Deegan, Paul Durrant, Jan Beulich

On 01/12/2018 07:45 AM, Ross Lagerwall wrote:
> Remove the implementation of XEN_DOMCTL_pin_mem_cacheattr since it has
> been replaced by a dmop. Change xc_domain_pin_memory_cacheattr() so
> that it is only defined when XC_WANT_COMPAT_DEVICEMODEL_API is set and
> have it call the new dmop.  Leave the definitions of
> XEN_DOMCTL_MEM_CACHEATTR_* since they are still used by QEMU.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap
  2018-01-12 12:45 ` [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
  2018-01-15 13:33   ` Paul Durrant
@ 2018-01-18  9:24   ` Jan Beulich
  2018-01-18  9:32     ` Ross Lagerwall
  1 sibling, 1 reply; 14+ messages in thread
From: Jan Beulich @ 2018-01-18  9:24 UTC (permalink / raw)
  To: Ross Lagerwall
  Cc: TimDeegan, Stefano Stabellini, Wei Liu, George Dunlap,
	Andrew Cooper, IanJackson, xen-devel, Paul Durrant

>>> On 12.01.18 at 13:45, <ross.lagerwall@citrix.com> wrote:
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -640,6 +640,42 @@ static int dm_op(const struct dmop_args *op_args)
>          break;
>      }
>  
> +    case XEN_DMOP_add_to_physmap:
> +    {
> +        struct xen_dm_op_add_to_physmap *data =
> +            &op.u.add_to_physmap;
> +        struct xen_add_to_physmap xatp = {
> +            .domid = op_args->domid,
> +            .size = data->size,
> +            .space = XENMAPSPACE_gmfn_range,
> +            .idx = data->src_gfn,
> +            .gpfn = data->dst_gfn,
> +        };
> +
> +        if ( data->pad )
> +        {
> +            rc = -EINVAL;
> +            break;
> +        }
> +
> +        if ( xatp.size != data->size )
> +        {
> +            rc = -EOVERFLOW;
> +            break;

I guess this is fine for now, but clearly not really necessary, as the
continuation logic could take care of the situation. Please add a
comment to this effect.

> --- a/xen/include/public/hvm/dm_op.h
> +++ b/xen/include/public/hvm/dm_op.h
> @@ -368,6 +368,24 @@ struct xen_dm_op_remote_shutdown {
>                             /* (Other reason values are not blocked) */
>  };
>  
> +/*
> + * XEN_DMOP_add_to_physmap : Sets the GFNs at which a page range appears in
> + *                           the specified guest's address space. Identical to
> + *                           XENMEM_add_to_physmap with
> + *                           space == XENMAPSPACE_gmfn_range.
> + */
> +#define XEN_DMOP_add_to_physmap 17
> +
> +struct xen_dm_op_add_to_physmap {
> +    /* Number of GFNs to process. */
> +    uint32_t size;
> +    uint32_t pad;
> +    /* Starting GFN of the source mapping page(s). */
> +    uint64_aligned_t src_gfn;
> +    /* Starting GFN where the source mapping page(s) should appear. */
> +    uint64_aligned_t dst_gfn;
> +};

So why again is this "add-to-physmap"? It's moving memory around,
isn't it? The comment also could be more clear in this regard.
Everything else looks fine to me now.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-12 12:45 ` [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
  2018-01-15 13:38   ` Paul Durrant
  2018-01-17 18:09   ` Daniel De Graaf
@ 2018-01-18  9:29   ` Jan Beulich
  2 siblings, 0 replies; 14+ messages in thread
From: Jan Beulich @ 2018-01-18  9:29 UTC (permalink / raw)
  To: Ross Lagerwall
  Cc: Tim Deegan, Stefano Stabellini, Wei Liu, George Dunlap,
	AndrewCooper, IanJackson, xen-devel, Paul Durrant,
	Daniel De Graaf

>>> On 12.01.18 at 13:45, <ross.lagerwall@citrix.com> wrote:
> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -597,10 +597,6 @@ struct xen_domctl_ioport_mapping {
>  #define XEN_DOMCTL_MEM_CACHEATTR_WB  6
>  #define XEN_DOMCTL_MEM_CACHEATTR_UCM 7
>  #define XEN_DOMCTL_DELETE_MEM_CACHEATTR (~(uint32_t)0)
> -struct xen_domctl_pin_mem_cacheattr {
> -    uint64_aligned_t start, end;
> -    uint32_t type; /* XEN_DOMCTL_MEM_CACHEATTR_* */
> -};
>  
>  
>  /* XEN_DOMCTL_set_ext_vcpucontext */
> @@ -1148,7 +1144,7 @@ struct xen_domctl {
>  #define XEN_DOMCTL_bind_pt_irq                   38
>  #define XEN_DOMCTL_memory_mapping                39
>  #define XEN_DOMCTL_ioport_mapping                40
> -#define XEN_DOMCTL_pin_mem_cacheattr             41
> +/* #define XEN_DOMCTL_pin_mem_cacheattr          41 Obsolete - use dmop */

"Obsolete" is wrong imo if the implementation is gone. Also I think
you need to bump the interface version when you remove
something here.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap
  2018-01-18  9:24   ` Jan Beulich
@ 2018-01-18  9:32     ` Ross Lagerwall
  2018-01-18  9:40       ` Jan Beulich
  0 siblings, 1 reply; 14+ messages in thread
From: Ross Lagerwall @ 2018-01-18  9:32 UTC (permalink / raw)
  To: Jan Beulich
  Cc: TimDeegan, Stefano Stabellini, Wei Liu, George Dunlap,
	Andrew Cooper, IanJackson, xen-devel, Paul Durrant

On 01/18/2018 09:24 AM, Jan Beulich wrote:
>>>> On 12.01.18 at 13:45, <ross.lagerwall@citrix.com> wrote:
>> --- a/xen/arch/x86/hvm/dm.c
>> +++ b/xen/arch/x86/hvm/dm.c
>> @@ -640,6 +640,42 @@ static int dm_op(const struct dmop_args *op_args)
>>           break;
>>       }
>>   
>> +    case XEN_DMOP_add_to_physmap:
>> +    {
>> +        struct xen_dm_op_add_to_physmap *data =
>> +            &op.u.add_to_physmap;
>> +        struct xen_add_to_physmap xatp = {
>> +            .domid = op_args->domid,
>> +            .size = data->size,
>> +            .space = XENMAPSPACE_gmfn_range,
>> +            .idx = data->src_gfn,
>> +            .gpfn = data->dst_gfn,
>> +        };
>> +
>> +        if ( data->pad )
>> +        {
>> +            rc = -EINVAL;
>> +            break;
>> +        }
>> +
>> +        if ( xatp.size != data->size )
>> +        {
>> +            rc = -EOVERFLOW;
>> +            break;
> 
> I guess this is fine for now, but clearly not really necessary, as the
> continuation logic could take care of the situation. Please add a
> comment to this effect.

Oh, I didn't think of using the continuation logic for that. I'll use it 
then.

> 
>> --- a/xen/include/public/hvm/dm_op.h
>> +++ b/xen/include/public/hvm/dm_op.h
>> @@ -368,6 +368,24 @@ struct xen_dm_op_remote_shutdown {
>>                              /* (Other reason values are not blocked) */
>>   };
>>   
>> +/*
>> + * XEN_DMOP_add_to_physmap : Sets the GFNs at which a page range appears in
>> + *                           the specified guest's address space. Identical to
>> + *                           XENMEM_add_to_physmap with
>> + *                           space == XENMAPSPACE_gmfn_range.
>> + */
>> +#define XEN_DMOP_add_to_physmap 17
>> +
>> +struct xen_dm_op_add_to_physmap {
>> +    /* Number of GFNs to process. */
>> +    uint32_t size;
>> +    uint32_t pad;
>> +    /* Starting GFN of the source mapping page(s). */
>> +    uint64_aligned_t src_gfn;
>> +    /* Starting GFN where the source mapping page(s) should appear. */
>> +    uint64_aligned_t dst_gfn;
>> +};
> 
> So why again is this "add-to-physmap"? It's moving memory around,
> isn't it? The comment also could be more clear in this regard.
> Everything else looks fine to me now.
> 

Do you have a preference for what to call it?

-- 
Ross Lagerwall

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

* Re: [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap
  2018-01-18  9:32     ` Ross Lagerwall
@ 2018-01-18  9:40       ` Jan Beulich
  0 siblings, 0 replies; 14+ messages in thread
From: Jan Beulich @ 2018-01-18  9:40 UTC (permalink / raw)
  To: Ross Lagerwall
  Cc: TimDeegan, Stefano Stabellini, Wei Liu, George Dunlap,
	Andrew Cooper, IanJackson, xen-devel, Paul Durrant

>>> On 18.01.18 at 10:32, <ross.lagerwall@citrix.com> wrote:
> On 01/18/2018 09:24 AM, Jan Beulich wrote:
>>>>> On 12.01.18 at 13:45, <ross.lagerwall@citrix.com> wrote:
>>> --- a/xen/include/public/hvm/dm_op.h
>>> +++ b/xen/include/public/hvm/dm_op.h
>>> @@ -368,6 +368,24 @@ struct xen_dm_op_remote_shutdown {
>>>                              /* (Other reason values are not blocked) */
>>>   };
>>>   
>>> +/*
>>> + * XEN_DMOP_add_to_physmap : Sets the GFNs at which a page range appears in
>>> + *                           the specified guest's address space. Identical to
>>> + *                           XENMEM_add_to_physmap with
>>> + *                           space == XENMAPSPACE_gmfn_range.
>>> + */
>>> +#define XEN_DMOP_add_to_physmap 17
>>> +
>>> +struct xen_dm_op_add_to_physmap {
>>> +    /* Number of GFNs to process. */
>>> +    uint32_t size;
>>> +    uint32_t pad;
>>> +    /* Starting GFN of the source mapping page(s). */
>>> +    uint64_aligned_t src_gfn;
>>> +    /* Starting GFN where the source mapping page(s) should appear. */
>>> +    uint64_aligned_t dst_gfn;
>>> +};
>> 
>> So why again is this "add-to-physmap"? It's moving memory around,
>> isn't it? The comment also could be more clear in this regard.
>> Everything else looks fine to me now.
> 
> Do you have a preference for what to call it?

Best I can think of is XEN_DMOP_move_gfns, but I don't like it
very much, hence I didn't suggest it in my earlier reply.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2018-01-18  9:40 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-12 12:45 [PATCH v3 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 2/6] x86/hvm: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
2018-01-15 13:33   ` Paul Durrant
2018-01-18  9:24   ` Jan Beulich
2018-01-18  9:32     ` Ross Lagerwall
2018-01-18  9:40       ` Jan Beulich
2018-01-12 12:45 ` [PATCH v3 3/6] x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 4/6] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 5/6] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr Ross Lagerwall
2018-01-12 12:45 ` [PATCH v3 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
2018-01-15 13:38   ` Paul Durrant
2018-01-17 18:09   ` Daniel De Graaf
2018-01-18  9:29   ` Jan Beulich

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.