All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/5] Add dmops to allow use of VGA with restricted QEMU
@ 2017-10-23  9:05 Ross Lagerwall
  2017-10-23  9:05 ` [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
                   ` (4 more replies)
  0 siblings, 5 replies; 17+ messages in thread
From: Ross Lagerwall @ 2017-10-23  9:05 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall, Paul Durrant, Ian Jackson

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 v2:
* Address Paul's comments - mainly making add_to_physmap operate on a
  range.

Ross Lagerwall (5):
  xen/mm: Make xenmem_add_to_physmap global
  xen: Provide XEN_DMOP_add_to_physmap
  xen: Provide XEN_DMOP_pin_memory_cacheattr
  tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
  tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr

 tools/libs/devicemodel/Makefile                 |  2 +-
 tools/libs/devicemodel/core.c                   | 40 ++++++++++++++++++++
 tools/libs/devicemodel/include/xendevicemodel.h | 29 +++++++++++++++
 tools/libs/devicemodel/libxendevicemodel.map    |  6 +++
 xen/arch/x86/hvm/dm.c                           | 49 +++++++++++++++++++++++++
 xen/common/memory.c                             |  5 +--
 xen/include/public/hvm/dm_op.h                  | 31 ++++++++++++++++
 xen/include/xen/mm.h                            |  3 ++
 xen/include/xlat.lst                            |  2 +
 9 files changed, 163 insertions(+), 4 deletions(-)

-- 
2.9.5


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

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

* [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global
  2017-10-23  9:05 [PATCH v2 0/5] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
@ 2017-10-23  9:05 ` Ross Lagerwall
  2017-10-23 11:56   ` Paul Durrant
  2017-11-21 16:01   ` Jan Beulich
  2017-10-23  9:05 ` [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 17+ messages in thread
From: Ross Lagerwall @ 2017-10-23  9:05 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	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>
---
 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 ad987e0..c4f05c7 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.xen.org
https://lists.xen.org/xen-devel

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

* [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
  2017-10-23  9:05 [PATCH v2 0/5] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
  2017-10-23  9:05 ` [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
@ 2017-10-23  9:05 ` Ross Lagerwall
  2017-10-23 12:03   ` Paul Durrant
  2017-11-21 16:28   ` Jan Beulich
  2017-10-23  9:05 ` [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 17+ messages in thread
From: Ross Lagerwall @ 2017-10-23  9:05 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Ross Lagerwall, 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 v2:
* Make it operate on a range.

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

diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
index 32ade95..0027567 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -640,6 +640,36 @@ 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->idx,
+            .gpfn = data->gpfn,
+        };
+
+        if ( data->pad0 || data->pad1 )
+        {
+            rc = -EINVAL;
+            break;
+        }
+
+        rc = xenmem_add_to_physmap(d, &xatp, 0);
+        if ( rc > 0 )
+        {
+            data->size -= rc;
+            data->idx += rc;
+            data->gpfn += rc;
+            const_op = false;
+            rc = -ERESTART;
+        }
+        break;
+    }
+
     default:
         rc = -EOPNOTSUPP;
         break;
@@ -669,6 +699,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..f685110 100644
--- a/xen/include/public/hvm/dm_op.h
+++ b/xen/include/public/hvm/dm_op.h
@@ -368,6 +368,22 @@ struct xen_dm_op_remote_shutdown {
                            /* (Other reason values are not blocked) */
 };
 
+/*
+ * XEN_DMOP_add_to_physmap : Sets the GPFNs at which a page range appears in
+ *                           the specified guest's pseudophysical 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 {
+    uint16_t size;         /* Number of GMFNs to process. */
+    uint16_t pad0;
+    uint32_t pad1;
+    uint64_aligned_t idx;  /* Index into GMFN space. */
+    uint64_aligned_t gpfn; /* Starting GPFN where the GMFNs should appear. */
+};
+
 struct xen_dm_op {
     uint32_t op;
     uint32_t pad;
@@ -389,6 +405,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.xen.org
https://lists.xen.org/xen-devel

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

* [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr
  2017-10-23  9:05 [PATCH v2 0/5] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
  2017-10-23  9:05 ` [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
  2017-10-23  9:05 ` [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
@ 2017-10-23  9:05 ` Ross Lagerwall
  2017-10-23 12:06   ` Paul Durrant
  2017-11-22 10:23   ` Jan Beulich
  2017-10-23  9:05 ` [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap Ross Lagerwall
  2017-10-23  9:05 ` [PATCH v2 5/5] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr Ross Lagerwall
  4 siblings, 2 replies; 17+ messages in thread
From: Ross Lagerwall @ 2017-10-23  9:05 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, Tim Deegan,
	Ross Lagerwall, 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>
---

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 0027567..42d02cc 100644
--- a/xen/arch/x86/hvm/dm.c
+++ b/xen/arch/x86/hvm/dm.c
@@ -21,6 +21,7 @@
 
 #include <asm/hap.h>
 #include <asm/hvm/ioreq.h>
+#include <asm/hvm/cacheattr.h>
 #include <asm/shadow.h>
 
 #include <xsm/xsm.h>
@@ -670,6 +671,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;
@@ -700,6 +717,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 f685110..f9c86b8 100644
--- a/xen/include/public/hvm/dm_op.h
+++ b/xen/include/public/hvm/dm_op.h
@@ -384,6 +384,19 @@ struct xen_dm_op_add_to_physmap {
     uint64_aligned_t gpfn; /* Starting GPFN where the GMFNs should appear. */
 };
 
+/*
+ * 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;
@@ -406,6 +419,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.xen.org
https://lists.xen.org/xen-devel

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

* [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
  2017-10-23  9:05 [PATCH v2 0/5] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
                   ` (2 preceding siblings ...)
  2017-10-23  9:05 ` [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
@ 2017-10-23  9:05 ` Ross Lagerwall
  2017-10-23 11:21   ` Ian Jackson
  2017-10-23 12:09   ` Paul Durrant
  2017-10-23  9:05 ` [PATCH v2 5/5] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr Ross Lagerwall
  4 siblings, 2 replies; 17+ messages in thread
From: Ross Lagerwall @ 2017-10-23  9:05 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall, Ian Jackson, Wei Liu

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

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

 tools/libs/devicemodel/Makefile                 |  2 +-
 tools/libs/devicemodel/core.c                   | 21 +++++++++++++++++++++
 tools/libs/devicemodel/include/xendevicemodel.h | 15 +++++++++++++++
 tools/libs/devicemodel/libxendevicemodel.map    |  5 +++++
 4 files changed, 42 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 b66d4f9..07953d3 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -564,6 +564,27 @@ int xendevicemodel_shutdown(
     return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
 }
 
+int xendevicemodel_add_to_physmap(
+    xendevicemodel_handle *dmod, domid_t domid, uint16_t size, uint64_t idx,
+    uint64_t gpfn)
+{
+    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->pad0 = 0;
+    data->pad1 = 0;
+    data->idx = idx;
+    data->gpfn = gpfn;
+
+    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..6967e58 100644
--- a/tools/libs/devicemodel/include/xendevicemodel.h
+++ b/tools/libs/devicemodel/include/xendevicemodel.h
@@ -326,6 +326,21 @@ int xendevicemodel_shutdown(
     xendevicemodel_handle *dmod, domid_t domid, unsigned int reason);
 
 /**
+ * Sets the GPFNs at which a page range appears in the domain's
+ * pseudophysical address space.
+ *
+ * @parm dmod a handle to an open devicemodel interface.
+ * @parm domid the domain id to be serviced
+ * @parm size Number of GMFNs to process
+ * @parm idx Index into GMFN space
+ * @parm gpfn Starting GPFN where the GMFNs should appear
+ * @return 0 on success, -1 on failure.
+ */
+int xendevicemodel_add_to_physmap(
+    xendevicemodel_handle *dmod, domid_t domid, uint16_t size, uint64_t idx,
+    uint64_t gpfn);
+
+/**
  * 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.xen.org
https://lists.xen.org/xen-devel

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

* [PATCH v2 5/5] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr
  2017-10-23  9:05 [PATCH v2 0/5] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
                   ` (3 preceding siblings ...)
  2017-10-23  9:05 ` [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap Ross Lagerwall
@ 2017-10-23  9:05 ` Ross Lagerwall
  4 siblings, 0 replies; 17+ messages in thread
From: Ross Lagerwall @ 2017-10-23  9:05 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 07953d3..e496fc9 100644
--- a/tools/libs/devicemodel/core.c
+++ b/tools/libs/devicemodel/core.c
@@ -585,6 +585,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 6967e58..d82535b 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 gpfn);
 
 /**
+ * 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.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
  2017-10-23  9:05 ` [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap Ross Lagerwall
@ 2017-10-23 11:21   ` Ian Jackson
  2017-10-23 12:09   ` Paul Durrant
  1 sibling, 0 replies; 17+ messages in thread
From: Ian Jackson @ 2017-10-23 11:21 UTC (permalink / raw)
  To: Ross Lagerwall; +Cc: Wei Liu, xen-devel

Ross Lagerwall writes ("[PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap"):
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

Assuming the hypervisor parts go in:

Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>

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

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

* Re: [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global
  2017-10-23  9:05 ` [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
@ 2017-10-23 11:56   ` Paul Durrant
  2017-11-21 16:01   ` Jan Beulich
  1 sibling, 0 replies; 17+ messages in thread
From: Paul Durrant @ 2017-10-23 11:56 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	Andrew Cooper, Tim (Xen.org),
	George Dunlap, Ross Lagerwall, Jan Beulich, Ian Jackson

> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
> Ross Lagerwall
> Sent: 23 October 2017 10:05
> To: xen-devel@lists.xen.org
> Cc: Stefano Stabellini <sstabellini@kernel.org>; Wei Liu
> <wei.liu2@citrix.com>; Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>;
> George Dunlap <George.Dunlap@citrix.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Tim
> (Xen.org) <tim@xen.org>; Ross Lagerwall <ross.lagerwall@citrix.com>; Jan
> Beulich <jbeulich@suse.com>
> Subject: [Xen-devel] [PATCH v2 1/5] xen/mm: Make
> xenmem_add_to_physmap global
> 
> Make it global in preparation to be called by a new dmop.
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>
> 
> ---

You need to delete the above '---' otherwise this R-b will not get carried through into the commit.

  Paul

> Reviewed-by: Paul Durrant <paul.durrant@citrix.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 ad987e0..c4f05c7 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.xen.org
> https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
  2017-10-23  9:05 ` [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
@ 2017-10-23 12:03   ` Paul Durrant
  2017-10-23 12:18     ` Jan Beulich
  2017-10-23 12:18     ` Ross Lagerwall
  2017-11-21 16:28   ` Jan Beulich
  1 sibling, 2 replies; 17+ messages in thread
From: Paul Durrant @ 2017-10-23 12:03 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	Andrew Cooper, Tim (Xen.org),
	George Dunlap, Ross Lagerwall, Jan Beulich, Ian Jackson

> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
> Ross Lagerwall
> Sent: 23 October 2017 10:05
> To: xen-devel@lists.xen.org
> Cc: Stefano Stabellini <sstabellini@kernel.org>; Wei Liu
> <wei.liu2@citrix.com>; Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>;
> George Dunlap <George.Dunlap@citrix.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Tim
> (Xen.org) <tim@xen.org>; Ross Lagerwall <ross.lagerwall@citrix.com>; Jan
> Beulich <jbeulich@suse.com>
> Subject: [Xen-devel] [PATCH v2 2/5] xen: 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>

...with one observation below...

> ---
> 
> Changed in v2:
> * Make it operate on a range.
> 
>  xen/arch/x86/hvm/dm.c          | 31 +++++++++++++++++++++++++++++++
>  xen/include/public/hvm/dm_op.h | 17 +++++++++++++++++
>  xen/include/xlat.lst           |  1 +
>  3 files changed, 49 insertions(+)
> 
> diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
> index 32ade95..0027567 100644
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -640,6 +640,36 @@ 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->idx,
> +            .gpfn = data->gpfn,
> +        };
> +
> +        if ( data->pad0 || data->pad1 )
> +        {
> +            rc = -EINVAL;
> +            break;
> +        }
> +
> +        rc = xenmem_add_to_physmap(d, &xatp, 0);
> +        if ( rc > 0 )
> +        {
> +            data->size -= rc;
> +            data->idx += rc;
> +            data->gpfn += rc;
> +            const_op = false;
> +            rc = -ERESTART;
> +        }
> +        break;
> +    }
> +
>      default:
>          rc = -EOPNOTSUPP;
>          break;
> @@ -669,6 +699,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..f685110 100644
> --- a/xen/include/public/hvm/dm_op.h
> +++ b/xen/include/public/hvm/dm_op.h
> @@ -368,6 +368,22 @@ struct xen_dm_op_remote_shutdown {
>                             /* (Other reason values are not blocked) */
>  };
> 
> +/*
> + * XEN_DMOP_add_to_physmap : Sets the GPFNs at which a page range
> appears in
> + *                           the specified guest's pseudophysical 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 {
> +    uint16_t size;         /* Number of GMFNs to process. */
> +    uint16_t pad0;
> +    uint32_t pad1;

I think you can lose pad1 by putting idx and gpfn above size rather than below (since IIRC we only need pad up to the next 4 byte boundary).

  Paul

> +    uint64_aligned_t idx;  /* Index into GMFN space. */
> +    uint64_aligned_t gpfn; /* Starting GPFN where the GMFNs should
> appear. */
> +};
> +
>  struct xen_dm_op {
>      uint32_t op;
>      uint32_t pad;
> @@ -389,6 +405,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.xen.org
> https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr
  2017-10-23  9:05 ` [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
@ 2017-10-23 12:06   ` Paul Durrant
  2017-11-22 10:23   ` Jan Beulich
  1 sibling, 0 replies; 17+ messages in thread
From: Paul Durrant @ 2017-10-23 12:06 UTC (permalink / raw)
  To: xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	Andrew Cooper, Tim (Xen.org),
	George Dunlap, Ross Lagerwall, Jan Beulich, Ian Jackson

> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
> Ross Lagerwall
> Sent: 23 October 2017 10:05
> To: xen-devel@lists.xen.org
> Cc: Stefano Stabellini <sstabellini@kernel.org>; Wei Liu
> <wei.liu2@citrix.com>; Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>;
> George Dunlap <George.Dunlap@citrix.com>; Andrew Cooper
> <Andrew.Cooper3@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Tim
> (Xen.org) <tim@xen.org>; Ross Lagerwall <ross.lagerwall@citrix.com>; Jan
> Beulich <jbeulich@suse.com>
> Subject: [Xen-devel] [PATCH v2 3/5] xen: Provide
> XEN_DMOP_pin_memory_cacheattr
> 
> 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>

> ---
> 
> 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 0027567..42d02cc 100644
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -21,6 +21,7 @@
> 
>  #include <asm/hap.h>
>  #include <asm/hvm/ioreq.h>
> +#include <asm/hvm/cacheattr.h>
>  #include <asm/shadow.h>
> 
>  #include <xsm/xsm.h>
> @@ -670,6 +671,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;
> @@ -700,6 +717,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 f685110..f9c86b8 100644
> --- a/xen/include/public/hvm/dm_op.h
> +++ b/xen/include/public/hvm/dm_op.h
> @@ -384,6 +384,19 @@ struct xen_dm_op_add_to_physmap {
>      uint64_aligned_t gpfn; /* Starting GPFN where the GMFNs should appear.
> */
>  };
> 
> +/*
> + * 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;
> @@ -406,6 +419,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.xen.org
> https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
  2017-10-23  9:05 ` [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap Ross Lagerwall
  2017-10-23 11:21   ` Ian Jackson
@ 2017-10-23 12:09   ` Paul Durrant
  1 sibling, 0 replies; 17+ messages in thread
From: Paul Durrant @ 2017-10-23 12:09 UTC (permalink / raw)
  To: xen-devel; +Cc: Ross Lagerwall, Wei Liu, Ian Jackson

> -----Original Message-----
> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
> Ross Lagerwall
> Sent: 23 October 2017 10:05
> To: xen-devel@lists.xen.org
> Cc: Ross Lagerwall <ross.lagerwall@citrix.com>; Ian Jackson
> <Ian.Jackson@citrix.com>; Wei Liu <wei.liu2@citrix.com>
> Subject: [Xen-devel] [PATCH v2 4/5] tools: libxendevicemodel: Provide
> xendevicemodel_add_to_physmap
> 
> Signed-off-by: Ross Lagerwall <ross.lagerwall@citrix.com>

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

> ---
> 
> Changed in v2:
> * Make it operate on a range.
> 
>  tools/libs/devicemodel/Makefile                 |  2 +-
>  tools/libs/devicemodel/core.c                   | 21 +++++++++++++++++++++
>  tools/libs/devicemodel/include/xendevicemodel.h | 15 +++++++++++++++
>  tools/libs/devicemodel/libxendevicemodel.map    |  5 +++++
>  4 files changed, 42 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 b66d4f9..07953d3 100644
> --- a/tools/libs/devicemodel/core.c
> +++ b/tools/libs/devicemodel/core.c
> @@ -564,6 +564,27 @@ int xendevicemodel_shutdown(
>      return xendevicemodel_op(dmod, domid, 1, &op, sizeof(op));
>  }
> 
> +int xendevicemodel_add_to_physmap(
> +    xendevicemodel_handle *dmod, domid_t domid, uint16_t size, uint64_t
> idx,
> +    uint64_t gpfn)
> +{
> +    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->pad0 = 0;
> +    data->pad1 = 0;
> +    data->idx = idx;
> +    data->gpfn = gpfn;
> +
> +    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..6967e58 100644
> --- a/tools/libs/devicemodel/include/xendevicemodel.h
> +++ b/tools/libs/devicemodel/include/xendevicemodel.h
> @@ -326,6 +326,21 @@ int xendevicemodel_shutdown(
>      xendevicemodel_handle *dmod, domid_t domid, unsigned int reason);
> 
>  /**
> + * Sets the GPFNs at which a page range appears in the domain's
> + * pseudophysical address space.
> + *
> + * @parm dmod a handle to an open devicemodel interface.
> + * @parm domid the domain id to be serviced
> + * @parm size Number of GMFNs to process
> + * @parm idx Index into GMFN space
> + * @parm gpfn Starting GPFN where the GMFNs should appear
> + * @return 0 on success, -1 on failure.
> + */
> +int xendevicemodel_add_to_physmap(
> +    xendevicemodel_handle *dmod, domid_t domid, uint16_t size, uint64_t
> idx,
> +    uint64_t gpfn);
> +
> +/**
>   * 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.xen.org
> https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

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

* Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
  2017-10-23 12:03   ` Paul Durrant
@ 2017-10-23 12:18     ` Jan Beulich
  2017-10-23 12:19       ` Paul Durrant
  2017-10-23 12:18     ` Ross Lagerwall
  1 sibling, 1 reply; 17+ messages in thread
From: Jan Beulich @ 2017-10-23 12:18 UTC (permalink / raw)
  To: Paul Durrant
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	Andrew Cooper, Tim(Xen.org),
	George Dunlap, xen-devel, Ross Lagerwall, Ian Jackson

>>> On 23.10.17 at 14:03, <Paul.Durrant@citrix.com> wrote:
>> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
>> Ross Lagerwall
>> Sent: 23 October 2017 10:05
>> --- a/xen/include/public/hvm/dm_op.h
>> +++ b/xen/include/public/hvm/dm_op.h
>> @@ -368,6 +368,22 @@ struct xen_dm_op_remote_shutdown {
>>                             /* (Other reason values are not blocked) */
>>  };
>> 
>> +/*
>> + * XEN_DMOP_add_to_physmap : Sets the GPFNs at which a page range
>> appears in
>> + *                           the specified guest's pseudophysical 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 {
>> +    uint16_t size;         /* Number of GMFNs to process. */
>> +    uint16_t pad0;
>> +    uint32_t pad1;
> 
> I think you can lose pad1 by putting idx and gpfn above size rather than 
> below (since IIRC we only need pad up to the next 4 byte boundary).

No, tail padding would then still be wanted, I think.

Jan


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

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

* Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
  2017-10-23 12:03   ` Paul Durrant
  2017-10-23 12:18     ` Jan Beulich
@ 2017-10-23 12:18     ` Ross Lagerwall
  1 sibling, 0 replies; 17+ messages in thread
From: Ross Lagerwall @ 2017-10-23 12:18 UTC (permalink / raw)
  To: Paul Durrant, xen-devel
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	Andrew Cooper, Tim (Xen.org),
	George Dunlap, Jan Beulich, Ian Jackson

On 10/23/2017 01:03 PM, Paul Durrant wrote:
snip>> +/*
>> + * XEN_DMOP_add_to_physmap : Sets the GPFNs at which a page range
>> appears in
>> + *                           the specified guest's pseudophysical 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 {
>> +    uint16_t size;         /* Number of GMFNs to process. */
>> +    uint16_t pad0;
>> +    uint32_t pad1;
> 
> I think you can lose pad1 by putting idx and gpfn above size rather than below (since IIRC we only need pad up to the next 4 byte boundary).
> 
Nope, the build fails unless I pad it to an 8 byte boundary. This is 
also why I added padding to struct xen_dm_op_pin_memory_cacheattr...

-- 
Ross Lagerwall

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

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

* Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
  2017-10-23 12:18     ` Jan Beulich
@ 2017-10-23 12:19       ` Paul Durrant
  0 siblings, 0 replies; 17+ messages in thread
From: Paul Durrant @ 2017-10-23 12:19 UTC (permalink / raw)
  To: 'Jan Beulich'
  Cc: Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	Andrew Cooper, Tim (Xen.org),
	George Dunlap, xen-devel, Ross Lagerwall, Ian Jackson

> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 23 October 2017 13:18
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>; George Dunlap
> <George.Dunlap@citrix.com>; Ian Jackson <Ian.Jackson@citrix.com>; Ross
> Lagerwall <ross.lagerwall@citrix.com>; Wei Liu <wei.liu2@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: [Xen-devel] [PATCH v2 2/5] xen: Provide
> XEN_DMOP_add_to_physmap
> 
> >>> On 23.10.17 at 14:03, <Paul.Durrant@citrix.com> wrote:
> >> From: Xen-devel [mailto:xen-devel-bounces@lists.xen.org] On Behalf Of
> >> Ross Lagerwall
> >> Sent: 23 October 2017 10:05
> >> --- a/xen/include/public/hvm/dm_op.h
> >> +++ b/xen/include/public/hvm/dm_op.h
> >> @@ -368,6 +368,22 @@ struct xen_dm_op_remote_shutdown {
> >>                             /* (Other reason values are not blocked) */
> >>  };
> >>
> >> +/*
> >> + * XEN_DMOP_add_to_physmap : Sets the GPFNs at which a page range
> >> appears in
> >> + *                           the specified guest's pseudophysical 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 {
> >> +    uint16_t size;         /* Number of GMFNs to process. */
> >> +    uint16_t pad0;
> >> +    uint32_t pad1;
> >
> > I think you can lose pad1 by putting idx and gpfn above size rather than
> > below (since IIRC we only need pad up to the next 4 byte boundary).
> 
> No, tail padding would then still be wanted, I think.

Ok.  I stand corrected :-)

  Paul

> 
> Jan


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

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

* Re: [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global
  2017-10-23  9:05 ` [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
  2017-10-23 11:56   ` Paul Durrant
@ 2017-11-21 16:01   ` Jan Beulich
  1 sibling, 0 replies; 17+ messages in thread
From: Jan Beulich @ 2017-11-21 16:01 UTC (permalink / raw)
  To: Ross Lagerwall
  Cc: Tim Deegan, Stefano Stabellini, Wei Liu, KonradRzeszutek Wilk,
	George Dunlap, Andrew Cooper, IanJackson, xen-devel

>>> On 23.10.17 at 11:05, <ross.lagerwall@citrix.com> 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>

Misplaced tag.

I'd prefer if the function was made non-static in the patch which
needs it so, but anyway
Acked-by: Jan Beulich <jbeulich@suse.com>

Jan


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

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

* Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
  2017-10-23  9:05 ` [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
  2017-10-23 12:03   ` Paul Durrant
@ 2017-11-21 16:28   ` Jan Beulich
  1 sibling, 0 replies; 17+ messages in thread
From: Jan Beulich @ 2017-11-21 16:28 UTC (permalink / raw)
  To: Ross Lagerwall
  Cc: Tim Deegan, Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, xen-devel

>>> On 23.10.17 at 11:05, <ross.lagerwall@citrix.com> wrote:

First of all, instead of xen: please consider using something more
specific, like x86/hvm:.

> --- a/xen/include/public/hvm/dm_op.h
> +++ b/xen/include/public/hvm/dm_op.h
> @@ -368,6 +368,22 @@ struct xen_dm_op_remote_shutdown {
>                             /* (Other reason values are not blocked) */
>  };
>  
> +/*
> + * XEN_DMOP_add_to_physmap : Sets the GPFNs at which a page range appears in
> + *                           the specified guest's pseudophysical address

Talking of "pseudophysical" is at least confusing for HVM guests. So
far it was my understanding that such exists for PV guests only.

> + *                           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 {
> +    uint16_t size;         /* Number of GMFNs to process. */

Why limit this to 16 bits?

> +    uint16_t pad0;
> +    uint32_t pad1;
> +    uint64_aligned_t idx;  /* Index into GMFN space. */

Why would you call this "idx"? The other interface and its naming
should have no significance here. So perhaps "src_gfn" and ...

> +    uint64_aligned_t gpfn; /* Starting GPFN where the GMFNs should appear. */

... "dst_gfn"?

Jan


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

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

* Re: [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr
  2017-10-23  9:05 ` [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
  2017-10-23 12:06   ` Paul Durrant
@ 2017-11-22 10:23   ` Jan Beulich
  1 sibling, 0 replies; 17+ messages in thread
From: Jan Beulich @ 2017-11-22 10:23 UTC (permalink / raw)
  To: Ross Lagerwall
  Cc: Tim Deegan, Stefano Stabellini, Wei Liu, Konrad Rzeszutek Wilk,
	George Dunlap, Andrew Cooper, Ian Jackson, xen-devel

>>> On 23.10.17 at 11:05, <ross.lagerwall@citrix.com> wrote:
> --- a/xen/arch/x86/hvm/dm.c
> +++ b/xen/arch/x86/hvm/dm.c
> @@ -21,6 +21,7 @@
>  
>  #include <asm/hap.h>
>  #include <asm/hvm/ioreq.h>
> +#include <asm/hvm/cacheattr.h>
>  #include <asm/shadow.h>

With this addition moved up a line to result in a properly sorted set
Reviewed-by: Jan Beulich <jbeulich@suse.com>

However, the series should be extended by a patch removing the
no longer needed domctl (wiring the libxc function through to the
libxendevicemodel one if necessary), at once converting the
XEN_DOMCTL_MEM_CACHEATTR_* values to ones with names
suitable for use with this new interface (compatibility defines
in domctl.h would need to be retained until both qemu-s have had
their patches applied).

Jan


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

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

end of thread, other threads:[~2017-11-22 10:23 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-23  9:05 [PATCH v2 0/5] Add dmops to allow use of VGA with restricted QEMU Ross Lagerwall
2017-10-23  9:05 ` [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global Ross Lagerwall
2017-10-23 11:56   ` Paul Durrant
2017-11-21 16:01   ` Jan Beulich
2017-10-23  9:05 ` [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap Ross Lagerwall
2017-10-23 12:03   ` Paul Durrant
2017-10-23 12:18     ` Jan Beulich
2017-10-23 12:19       ` Paul Durrant
2017-10-23 12:18     ` Ross Lagerwall
2017-11-21 16:28   ` Jan Beulich
2017-10-23  9:05 ` [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr Ross Lagerwall
2017-10-23 12:06   ` Paul Durrant
2017-11-22 10:23   ` Jan Beulich
2017-10-23  9:05 ` [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap Ross Lagerwall
2017-10-23 11:21   ` Ian Jackson
2017-10-23 12:09   ` Paul Durrant
2017-10-23  9:05 ` [PATCH v2 5/5] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr 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.