All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU
@ 2018-01-23 15:22 Ross Lagerwall
  2018-01-23 15:22 ` [PATCH v4 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Ross Lagerwall @ 2018-01-23 15:22 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 v4:
* Rename add_to_physmap -> relocate_memory.
* Use continutation instead of erroring in relocate_memory.
* Bump domctl interface version.

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_relocate_memory
  x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr
  tools: libxendevicemodel: Provide xendevicemodel_relocate_memory
  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 | 28 ++++++++++++++
 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                           | 50 +++++++++++++++++++++++++
 xen/common/memory.c                             |  5 +--
 xen/include/public/domctl.h                     |  9 +----
 xen/include/public/hvm/dm_op.h                  | 40 ++++++++++++++++++++
 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, 186 insertions(+), 47 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] 18+ messages in thread

* [PATCH v4 1/6] xen/mm: Make xenmem_add_to_physmap global
  2018-01-23 15:22 [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
@ 2018-01-23 15:22 ` Ross Lagerwall
  2018-01-23 15:49   ` Wei Liu
  2018-01-23 15:22 ` [PATCH v4 2/6] x86/hvm: Provide XEN_DMOP_relocate_memory Ross Lagerwall
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Ross Lagerwall @ 2018-01-23 15:22 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 c2797ba..09549ab 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -770,9 +770,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] 18+ messages in thread

* [PATCH v4 2/6] x86/hvm: Provide XEN_DMOP_relocate_memory
  2018-01-23 15:22 [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
  2018-01-23 15:22 ` [PATCH v4 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
@ 2018-01-23 15:22 ` Ross Lagerwall
  2018-01-24  8:09   ` Jan Beulich
  2018-01-23 15:22 ` [PATCH v4 3/6] x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
                   ` (4 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Ross Lagerwall @ 2018-01-23 15:22 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_relocate_memory, 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 v4:
* Renamed add_to_physmap to relocate_memory.
* Instead of checking for overflow, handle using continuation.

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          | 32 ++++++++++++++++++++++++++++++++
 xen/include/public/hvm/dm_op.h | 18 ++++++++++++++++++
 xen/include/xlat.lst           |  1 +
 3 files changed, 51 insertions(+)

diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index a787f43..a5773e3 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -640,6 +640,37 @@ static int dm_op(const struct dmop_args *op_args)
         break;
     }
 
+    case XEN_DMOP_relocate_memory:
+    {
+        struct xen_dm_op_relocate_memory *data = &op.u.relocate_memory;
+        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;
+        }
+
+        rc = xenmem_add_to_physmap(d, &xatp, 0);
+        if ( rc == 0 && data->size != xatp.size )
+            rc = xatp.size;
+        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 +700,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_relocate_memory;
 
 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..35d1346 100644
--- a/xen/include/public/hvm/dm_op.h
+++ b/xen/include/public/hvm/dm_op.h
@@ -368,6 +368,23 @@ struct xen_dm_op_remote_shutdown {
                            /* (Other reason values are not blocked) */
 };
 
+/*
+ * XEN_DMOP_relocate_memory : Relocate GFNs for the specified guest.
+ *                            Identical to XENMEM_add_to_physmap with
+ *                            space == XENMAPSPACE_gmfn_range.
+ */
+#define XEN_DMOP_relocate_memory 17
+
+struct xen_dm_op_relocate_memory {
+    /* Number of GFNs to process. */
+    uint32_t size;
+    uint32_t pad;
+    /* Starting GFN to relocate. */
+    uint64_aligned_t src_gfn;
+    /* Starting GFN where GFNs should be relocated. */
+    uint64_aligned_t dst_gfn;
+};
+
 struct xen_dm_op {
     uint32_t op;
     uint32_t pad;
@@ -389,6 +406,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_relocate_memory relocate_memory;
     } u;
 };
 
diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst
index 4346cbe..b3d00b7 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_relocate_memory		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] 18+ messages in thread

* [PATCH v4 3/6] x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr
  2018-01-23 15:22 [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
  2018-01-23 15:22 ` [PATCH v4 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
  2018-01-23 15:22 ` [PATCH v4 2/6] x86/hvm: Provide XEN_DMOP_relocate_memory Ross Lagerwall
@ 2018-01-23 15:22 ` Ross Lagerwall
  2018-01-23 15:22 ` [PATCH v4 4/6] tools: libxendevicemodel: Provide xendevicemodel_relocate_memory Ross Lagerwall
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: Ross Lagerwall @ 2018-01-23 15:22 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 a5773e3..8083ded 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>
 
@@ -671,6 +672,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;
@@ -701,6 +718,7 @@ CHECK_dm_op_inject_event;
 CHECK_dm_op_inject_msi;
 CHECK_dm_op_remote_shutdown;
 CHECK_dm_op_relocate_memory;
+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 35d1346..5c10ec3 100644
--- a/xen/include/public/hvm/dm_op.h
+++ b/xen/include/public/hvm/dm_op.h
@@ -385,6 +385,19 @@ struct xen_dm_op_relocate_memory {
     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;
@@ -407,6 +420,7 @@ struct xen_dm_op {
                 map_mem_type_to_ioreq_server;
         struct xen_dm_op_remote_shutdown remote_shutdown;
         struct xen_dm_op_relocate_memory relocate_memory;
+        struct xen_dm_op_pin_memory_cacheattr pin_memory_cacheattr;
     } u;
 };
 
diff --git a/xen/include/xlat.lst b/xen/include/xlat.lst
index b3d00b7..3690b97 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] 18+ messages in thread

* [PATCH v4 4/6] tools: libxendevicemodel: Provide xendevicemodel_relocate_memory
  2018-01-23 15:22 [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
                   ` (2 preceding siblings ...)
  2018-01-23 15:22 ` [PATCH v4 3/6] x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
@ 2018-01-23 15:22 ` Ross Lagerwall
  2018-01-23 15:22 ` [PATCH v4 5/6] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr Ross Lagerwall
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 18+ messages in thread
From: Ross Lagerwall @ 2018-01-23 15:22 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 v4:
* Rename add_to_physmap to relocate_memory to match hypervisor
  interface.

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 | 14 ++++++++++++++
 tools/libs/devicemodel/libxendevicemodel.map    |  5 +++++
 4 files changed, 40 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..4ae15e1 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_relocate_memory(
+    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_relocate_memory *data;
+
+    memset(&op, 0, sizeof(op));
+
+    op.op = XEN_DMOP_relocate_memory;
+    data = &op.u.relocate_memory;
+
+    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..e5e047e 100644
--- a/tools/libs/devicemodel/include/xendevicemodel.h
+++ b/tools/libs/devicemodel/include/xendevicemodel.h
@@ -325,6 +325,20 @@ int xendevicemodel_inject_event(
 int xendevicemodel_shutdown(
     xendevicemodel_handle *dmod, domid_t domid, unsigned int reason);
 
+/*
+ * Relocate GFNs for the specified domain.
+ *
+ * @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 to relocate
+ * @parm dst_gfn Starting GFN where GFNs should be relocated
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_relocate_memory(
+    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..4c967b3 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_relocate_memory;
+} 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] 18+ messages in thread

* [PATCH v4 5/6] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr
  2018-01-23 15:22 [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
                   ` (3 preceding siblings ...)
  2018-01-23 15:22 ` [PATCH v4 4/6] tools: libxendevicemodel: Provide xendevicemodel_relocate_memory Ross Lagerwall
@ 2018-01-23 15:22 ` Ross Lagerwall
  2018-01-23 15:22 ` [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
  2018-03-05 14:40 ` [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Anthony PERARD
  6 siblings, 0 replies; 18+ messages in thread
From: Ross Lagerwall @ 2018-01-23 15:22 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 4ae15e1..23924e9 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -584,6 +584,25 @@ int xendevicemodel_relocate_memory(
     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 e5e047e..9b89f32 100644
--- a/tools/libs/devicemodel/include/xendevicemodel.h
+++ b/tools/libs/devicemodel/include/xendevicemodel.h
@@ -340,6 +340,20 @@ int xendevicemodel_relocate_memory(
     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 4c967b3..04797b2 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_relocate_memory;
+		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] 18+ messages in thread

* [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-23 15:22 [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
                   ` (4 preceding siblings ...)
  2018-01-23 15:22 ` [PATCH v4 5/6] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr Ross Lagerwall
@ 2018-01-23 15:22 ` Ross Lagerwall
  2018-01-23 15:44   ` Wei Liu
  2018-01-24  8:00   ` Jan Beulich
  2018-03-05 14:40 ` [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Anthony PERARD
  6 siblings, 2 replies; 18+ messages in thread
From: Ross Lagerwall @ 2018-01-23 15:22 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>
Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
---

Changed in v4:
* Bump interface version.
* Clarified comment.

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                     |  9 ++-------
 xen/include/public/hvm/dm_op.h                  | 10 +++++++++-
 xen/xsm/flask/hooks.c                           |  3 ---
 xen/xsm/flask/policy/access_vectors             |  2 --
 11 files changed, 25 insertions(+), 45 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 9b89f32..7629c35 100644
--- a/tools/libs/devicemodel/include/xendevicemodel.h
+++ b/tools/libs/devicemodel/include/xendevicemodel.h
@@ -346,7 +346,7 @@ int xendevicemodel_relocate_memory(
  * @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 ecb0312..6a4347e 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1473,12 +1473,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 8169284..da0aa2f 100644
--- a/tools/libxc/xc_domain.c
+++ b/tools/libxc/xc_domain.c
@@ -720,21 +720,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 2585d4e..e68c7be 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 */
@@ -859,13 +858,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 a8921dd..30674d6 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -38,7 +38,7 @@
 #include "hvm/save.h"
 #include "memory.h"
 
-#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f
+#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010
 
 /*
  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
@@ -598,10 +598,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 */
@@ -1149,7 +1145,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 Removed - 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 */
@@ -1226,7 +1222,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 5c10ec3..3c6ebb5 100644
--- a/xen/include/public/hvm/dm_op.h
+++ b/xen/include/public/hvm/dm_op.h
@@ -394,7 +394,15 @@ struct xen_dm_op_relocate_memory {
 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] 18+ messages in thread

* Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-23 15:22 ` [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
@ 2018-01-23 15:44   ` Wei Liu
  2018-01-23 15:47     ` Ross Lagerwall
  2018-01-23 17:16     ` Jan Beulich
  2018-01-24  8:00   ` Jan Beulich
  1 sibling, 2 replies; 18+ messages in thread
From: Wei Liu @ 2018-01-23 15:44 UTC (permalink / raw)
  To: Ross Lagerwall
  Cc: Tim Deegan, Stefano Stabellini, Wei Liu, George Dunlap,
	Andrew Cooper, Ian Jackson, xen-devel, Paul Durrant, Jan Beulich,
	Daniel De Graaf

On Tue, Jan 23, 2018 at 03:22:46PM +0000, 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>
> Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
> ---
> 
> Changed in v4:
> * Bump interface version.
> * Clarified comment.
> 
> 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 ---------------

These changes LGTM.

>      {
> diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
> index a8921dd..30674d6 100644
> --- a/xen/include/public/domctl.h
> +++ b/xen/include/public/domctl.h
> @@ -38,7 +38,7 @@
>  #include "hvm/save.h"
>  #include "memory.h"
>  
> -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f
> +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010
>  

We bumped this to 0f in this development window so there is no need to
do it again.

>  /*
>   * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
> @@ -598,10 +598,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)

Any reason to not remove these #define's?

Wei.

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

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

* Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-23 15:44   ` Wei Liu
@ 2018-01-23 15:47     ` Ross Lagerwall
  2018-01-23 15:49       ` Wei Liu
  2018-01-23 17:16     ` Jan Beulich
  1 sibling, 1 reply; 18+ messages in thread
From: Ross Lagerwall @ 2018-01-23 15:47 UTC (permalink / raw)
  To: Wei Liu
  Cc: Tim Deegan, Stefano Stabellini, George Dunlap, Andrew Cooper,
	Ian Jackson, xen-devel, Paul Durrant, Jan Beulich,
	Daniel De Graaf

On 01/23/2018 03:44 PM, Wei Liu wrote:
> On Tue, Jan 23, 2018 at 03:22:46PM +0000, 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.
>>
snip>> diff --git a/xen/include/public/domctl.h 
b/xen/include/public/domctl.h
>> index a8921dd..30674d6 100644
>> --- a/xen/include/public/domctl.h
>> +++ b/xen/include/public/domctl.h
>> @@ -38,7 +38,7 @@
>>   #include "hvm/save.h"
>>   #include "memory.h"
>>   
>> -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f
>> +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010
>>   
> 
> We bumped this to 0f in this development window so there is no need to
> do it again.

OK.

> 
>>   /*
>>    * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
>> @@ -598,10 +598,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)
> 
> Any reason to not remove these #define's?
> 

They're still used by QEMU at the moment. Removing them now would break 
the build. They can be removed once QEMU(s) have been switch to use the 
new XEN_DMOP_* #defines.

-- 
Ross Lagerwall

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

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

* Re: [PATCH v4 1/6] xen/mm: Make xenmem_add_to_physmap global
  2018-01-23 15:22 ` [PATCH v4 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
@ 2018-01-23 15:49   ` Wei Liu
  0 siblings, 0 replies; 18+ messages in thread
From: Wei Liu @ 2018-01-23 15:49 UTC (permalink / raw)
  To: Ross Lagerwall
  Cc: Tim Deegan, Stefano Stabellini, Wei Liu, George Dunlap,
	Andrew Cooper, Ian Jackson, xen-devel, Jan Beulich

On Tue, Jan 23, 2018 at 03:22:41PM +0000, Ross Lagerwall wrote:
> 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>

Acked-by: Wei Liu <wei.liu2@citrix.com>

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

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

* Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-23 15:47     ` Ross Lagerwall
@ 2018-01-23 15:49       ` Wei Liu
  0 siblings, 0 replies; 18+ messages in thread
From: Wei Liu @ 2018-01-23 15:49 UTC (permalink / raw)
  To: Ross Lagerwall
  Cc: Tim Deegan, Stefano Stabellini, Wei Liu, George Dunlap,
	Andrew Cooper, Ian Jackson, xen-devel, Paul Durrant, Jan Beulich,
	Daniel De Graaf

On Tue, Jan 23, 2018 at 03:47:52PM +0000, Ross Lagerwall wrote:
> On 01/23/2018 03:44 PM, Wei Liu wrote:
> > On Tue, Jan 23, 2018 at 03:22:46PM +0000, 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.
> > > 
> snip>> diff --git a/xen/include/public/domctl.h
> b/xen/include/public/domctl.h
> > > index a8921dd..30674d6 100644
> > > --- a/xen/include/public/domctl.h
> > > +++ b/xen/include/public/domctl.h
> > > @@ -38,7 +38,7 @@
> > >   #include "hvm/save.h"
> > >   #include "memory.h"
> > > -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f
> > > +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010
> > 
> > We bumped this to 0f in this development window so there is no need to
> > do it again.
> 
> OK.
> 
> > 
> > >   /*
> > >    * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
> > > @@ -598,10 +598,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)
> > 
> > Any reason to not remove these #define's?
> > 
> 
> They're still used by QEMU at the moment. Removing them now would break the
> build. They can be removed once QEMU(s) have been switch to use the new
> XEN_DMOP_* #defines.
> 

OK.

With the version bump removed:

Reviewed-by: Wei Liu <wei.liu2@citrix.com>

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

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

* Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-23 15:44   ` Wei Liu
  2018-01-23 15:47     ` Ross Lagerwall
@ 2018-01-23 17:16     ` Jan Beulich
  2018-01-23 17:49       ` Wei Liu
  1 sibling, 1 reply; 18+ messages in thread
From: Jan Beulich @ 2018-01-23 17:16 UTC (permalink / raw)
  To: ross.lagerwall, wei.liu2
  Cc: tim, sstabellini, George.Dunlap, andrew.cooper3, ian.jackson,
	xen-devel, paul.durrant, dgdegra

>>> Wei Liu <wei.liu2@citrix.com> 01/23/18 4:44 PM >>>
On Tue, Jan 23, 2018 at 03:22:46PM +0000, Ross Lagerwall wrote:
>> --- a/xen/include/public/domctl.h
>> +++ b/xen/include/public/domctl.h
>> @@ -38,7 +38,7 @@
>>  #include "hvm/save.h"
>>  #include "memory.h"
>>  
>> -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f
>> +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010
>>  
>
>We bumped this to 0f in this development window so there is no need to
>do it again.

As pointed out elsewhere (at least on two other threads meanwhile) whether
to bump _again_ depends on the backporting plans of the domctl changes
in the shim series. If 4.10 is to obtain those eventually, it should be _just_
that one change which goes under interface version 0xf.

Jan


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

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

* Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-23 17:16     ` Jan Beulich
@ 2018-01-23 17:49       ` Wei Liu
  0 siblings, 0 replies; 18+ messages in thread
From: Wei Liu @ 2018-01-23 17:49 UTC (permalink / raw)
  To: Jan Beulich
  Cc: tim, sstabellini, wei.liu2, George.Dunlap, andrew.cooper3,
	ian.jackson, xen-devel, ross.lagerwall, paul.durrant, dgdegra

On Tue, Jan 23, 2018 at 10:16:45AM -0700, Jan Beulich wrote:
> >>> Wei Liu <wei.liu2@citrix.com> 01/23/18 4:44 PM >>>
> On Tue, Jan 23, 2018 at 03:22:46PM +0000, Ross Lagerwall wrote:
> >> --- a/xen/include/public/domctl.h
> >> +++ b/xen/include/public/domctl.h
> >> @@ -38,7 +38,7 @@
> >>  #include "hvm/save.h"
> >>  #include "memory.h"
> >>  
> >> -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f
> >> +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010
> >>  
> >
> >We bumped this to 0f in this development window so there is no need to
> >do it again.
> 
> As pointed out elsewhere (at least on two other threads meanwhile) whether
> to bump _again_ depends on the backporting plans of the domctl changes
> in the shim series. If 4.10 is to obtain those eventually, it should be _just_
> that one change which goes under interface version 0xf.

OK. This makes sense.  My Rb still stands.

Wei.

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

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

* Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
  2018-01-23 15:22 ` [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
  2018-01-23 15:44   ` Wei Liu
@ 2018-01-24  8:00   ` Jan Beulich
  1 sibling, 0 replies; 18+ messages in thread
From: Jan Beulich @ 2018-01-24  8:00 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 23.01.18 at 16:22, <ross.lagerwall@citrix.com> 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>
> Reviewed-by: Paul Durrant <paul.durrant@citrix.com>
> Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>

Non-XSM hypervisor parts
Acked-by: Jan Beulich <jbeulich@suse.com>



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

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

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

>>> On 23.01.18 at 16:22, <ross.lagerwall@citrix.com> wrote:
> Provide XEN_DMOP_relocate_memory, 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 v4:
> * Renamed add_to_physmap to relocate_memory.
> * Instead of checking for overflow, handle using continuation.

Strictly speaking at least the latter change should have resulted in
Paul's R-b to be dropped. But I'm pretty sure he's happy for it to
be kept.

> --- a/xen/include/public/hvm/dm_op.h
> +++ b/xen/include/public/hvm/dm_op.h
> @@ -368,6 +368,23 @@ struct xen_dm_op_remote_shutdown {
>                             /* (Other reason values are not blocked) */
>  };
>  
> +/*
> + * XEN_DMOP_relocate_memory : Relocate GFNs for the specified guest.
> + *                            Identical to XENMEM_add_to_physmap with
> + *                            space == XENMAPSPACE_gmfn_range.
> + */
> +#define XEN_DMOP_relocate_memory 17
> +
> +struct xen_dm_op_relocate_memory {
> +    /* Number of GFNs to process. */
> +    uint32_t size;
> +    uint32_t pad;
> +    /* Starting GFN to relocate. */
> +    uint64_aligned_t src_gfn;
> +    /* Starting GFN where GFNs should be relocated. */
> +    uint64_aligned_t dst_gfn;
> +};

Sadly additions after the initial introduction of dmop have been
done without IN / OUT annotations, so I assume you not noticing
such no neighboring declarations lead to you not adding any such
here. I think we want to clarify though that due to the way
the continuation logic above works, all fields are IN/OUT, with
their ultimate OUT state undefined. I don't see a major problem
adding a suitable comment while committing. With that added
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan


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

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

* Re: [PATCH v4 2/6] x86/hvm: Provide XEN_DMOP_relocate_memory
  2018-01-24  8:09   ` Jan Beulich
@ 2018-01-24  9:20     ` Paul Durrant
  0 siblings, 0 replies; 18+ messages in thread
From: Paul Durrant @ 2018-01-24  9:20 UTC (permalink / raw)
  To: 'Jan Beulich', Ross Lagerwall
  Cc: Stefano Stabellini, Wei Liu, Andrew Cooper, Tim (Xen.org),
	George Dunlap, xen-devel, Ian Jackson

> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 24 January 2018 08:10
> To: Ross Lagerwall <ross.lagerwall@citrix.com>
> Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>; Paul Durrant
> <Paul.Durrant@citrix.com>; Wei Liu <wei.liu2@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>;
> Stefano Stabellini <sstabellini@kernel.org>; xen-devel@lists.xen.org; Konrad
> Rzeszutek Wilk <konrad.wilk@oracle.com>; Tim (Xen.org) <tim@xen.org>
> Subject: Re: [PATCH v4 2/6] x86/hvm: Provide
> XEN_DMOP_relocate_memory
> 
> >>> On 23.01.18 at 16:22, <ross.lagerwall@citrix.com> wrote:
> > Provide XEN_DMOP_relocate_memory, 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 v4:
> > * Renamed add_to_physmap to relocate_memory.
> > * Instead of checking for overflow, handle using continuation.
> 
> Strictly speaking at least the latter change should have resulted in
> Paul's R-b to be dropped. But I'm pretty sure he's happy for it to
> be kept.

FAOD, I am.

  Paul

> 
> > --- a/xen/include/public/hvm/dm_op.h
> > +++ b/xen/include/public/hvm/dm_op.h
> > @@ -368,6 +368,23 @@ struct xen_dm_op_remote_shutdown {
> >                             /* (Other reason values are not blocked) */
> >  };
> >
> > +/*
> > + * XEN_DMOP_relocate_memory : Relocate GFNs for the specified guest.
> > + *                            Identical to XENMEM_add_to_physmap with
> > + *                            space == XENMAPSPACE_gmfn_range.
> > + */
> > +#define XEN_DMOP_relocate_memory 17
> > +
> > +struct xen_dm_op_relocate_memory {
> > +    /* Number of GFNs to process. */
> > +    uint32_t size;
> > +    uint32_t pad;
> > +    /* Starting GFN to relocate. */
> > +    uint64_aligned_t src_gfn;
> > +    /* Starting GFN where GFNs should be relocated. */
> > +    uint64_aligned_t dst_gfn;
> > +};
> 
> Sadly additions after the initial introduction of dmop have been
> done without IN / OUT annotations, so I assume you not noticing
> such no neighboring declarations lead to you not adding any such
> here. I think we want to clarify though that due to the way
> the continuation logic above works, all fields are IN/OUT, with
> their ultimate OUT state undefined. I don't see a major problem
> adding a suitable comment while committing. With that added
> Reviewed-by: Jan Beulich <jbeulich@suse.com>
> 
> Jan


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

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

* Re: [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU
  2018-01-23 15:22 [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
                   ` (5 preceding siblings ...)
  2018-01-23 15:22 ` [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
@ 2018-03-05 14:40 ` Anthony PERARD
  2018-03-05 15:13   ` Ross Lagerwall
  6 siblings, 1 reply; 18+ messages in thread
From: Anthony PERARD @ 2018-03-05 14:40 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: Paul Durrant, Ian Jackson, Jan Beulich, xen-devel

On Tue, Jan 23, 2018 at 03:22:40PM +0000, Ross Lagerwall wrote:
> 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.

Hi Ross,

Is there a patch for QEMU somewhere for the new dmops? Right now, QEMU
can not be build without magic (-DXC_WANT_COMPAT_DEVICEMODEL_API), there
is this error:
hw/i386/xen/xen-hvm.c:411:5: error: implicit declaration of function ‘xc_domain_pin_memory_cacheattr’

Thanks,

-- 
Anthony PERARD

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

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

* Re: [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU
  2018-03-05 14:40 ` [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Anthony PERARD
@ 2018-03-05 15:13   ` Ross Lagerwall
  0 siblings, 0 replies; 18+ messages in thread
From: Ross Lagerwall @ 2018-03-05 15:13 UTC (permalink / raw)
  To: Anthony PERARD; +Cc: Paul Durrant, Ian Jackson, Jan Beulich, xen-devel

On 03/05/2018 02:40 PM, Anthony PERARD wrote:
> On Tue, Jan 23, 2018 at 03:22:40PM +0000, Ross Lagerwall wrote:
>> 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.
> 
> Hi Ross,
> 
> Is there a patch for QEMU somewhere for the new dmops? Right now, QEMU
> can not be build without magic (-DXC_WANT_COMPAT_DEVICEMODEL_API), there
> is this error:
> hw/i386/xen/xen-hvm.c:411:5: error: implicit declaration of function ‘xc_domain_pin_memory_cacheattr’
> 

That magic is passed when building QEMU within the Xen tree (I don't 
know why, it's ugly) so this is presumably when building QEMU by hand 
outside of the Xen build system?

The patch to make QEMU use the new dmops will be part of the next 
version of Ian's "xen: xen-domid-restrict improvements" patch series. In 
the meantime, you can find the patch here:

https://github.com/rosslagerwall/qemu/commit/37d58e0c8e9c6df7f7e2464a37d1de2675da7e81

Cheers,
-- 
Ross Lagerwall

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

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

end of thread, other threads:[~2018-03-05 15:13 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-23 15:22 [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
2018-01-23 15:22 ` [PATCH v4 1/6] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
2018-01-23 15:49   ` Wei Liu
2018-01-23 15:22 ` [PATCH v4 2/6] x86/hvm: Provide XEN_DMOP_relocate_memory Ross Lagerwall
2018-01-24  8:09   ` Jan Beulich
2018-01-24  9:20     ` Paul Durrant
2018-01-23 15:22 ` [PATCH v4 3/6] x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
2018-01-23 15:22 ` [PATCH v4 4/6] tools: libxendevicemodel: Provide xendevicemodel_relocate_memory Ross Lagerwall
2018-01-23 15:22 ` [PATCH v4 5/6] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr Ross Lagerwall
2018-01-23 15:22 ` [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr Ross Lagerwall
2018-01-23 15:44   ` Wei Liu
2018-01-23 15:47     ` Ross Lagerwall
2018-01-23 15:49       ` Wei Liu
2018-01-23 17:16     ` Jan Beulich
2018-01-23 17:49       ` Wei Liu
2018-01-24  8:00   ` Jan Beulich
2018-03-05 14:40 ` [PATCH v4 0/6] Add dmops to allow use of VGA with restricted QEMU Anthony PERARD
2018-03-05 15:13   ` Ross Lagerwall

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.