Add dmops to allow use of VGA with restricted QEMU
v2 cover Add dmops to allow use of VGA with restricted QEMU
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(-)
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/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.
---
--- xen/common/memory.c | 5 ++--- xen/include/xen/mm.h | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-)
xen/common/memory.c +2 -3
@@ -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 ;
xen/include/xen/mm.h +3 -0
@@ -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,
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 2/5 xen: Provide XEN_DMOP_add_to_physmap
In reply to Ross LagerwallProvide 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.
---
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(+)
xen/arch/x86/hvm/dm.c +31 -0
@@ -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,
xen/include/public/hvm/dm_op.h +17 -0
@@ -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; };
xen/include/xlat.lst +1 -0
@@ -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
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 3/5 xen: Provide XEN_DMOP_pin_memory_cacheattr
In reply to Ross LagerwallProvide 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.
---
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(+)
xen/arch/x86/hvm/dm.c +18 -0
@@ -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,
xen/include/public/hvm/dm_op.h +14 -0
@@ -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; };
xen/include/xlat.lst +1 -0
@@ -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
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 4/5 tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
In reply to Ross Lagerwall---
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(-)
tools/libs/devicemodel/Makefile +1 -1
@@ -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
tools/libs/devicemodel/core.c +21 -0
@@ -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);
tools/libs/devicemodel/include/xendevicemodel.h +15 -0
@@ -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. *
tools/libs/devicemodel/libxendevicemodel.map +5 -0
@@ -27,3 +27,8 @@ VERS_1.1 { global: xendevicemodel_shutdown; } VERS_1.0; + +VERS_1.2 { + global: + xendevicemodel_add_to_physmap; +} VERS_1.1;
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH v2 5/5 tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr
In reply to Ross Lagerwall---
--- tools/libs/devicemodel/core.c | 19 +++++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 14 ++++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 1 + 3 files changed, 34 insertions(+)
tools/libs/devicemodel/core.c +19 -0
@@ -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);
tools/libs/devicemodel/include/xendevicemodel.h +14 -0
@@ -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. *
tools/libs/devicemodel/libxendevicemodel.map +1 -0
@@ -31,4 +31,5 @@ VERS_1.1 { VERS_1.2 { global: xendevicemodel_add_to_physmap; + xendevicemodel_pin_memory_cacheattr; } VERS_1.1;
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
In reply to Ross LagerwallRoss Lagerwall writes ("[PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap"):
Quoted 1 line
Signed-off-by Ross Lagerwall <[email protected]>
Assuming the hypervisor parts go in:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global
In reply to Ross LagerwallQuoted 14 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 23 October 2017 10:05
To: [email protected]
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; Tim (Xen.org) <[email protected]>; Ross Lagerwall <[email protected]>; Jan Beulich <[email protected]>
Subject: [Xen-devel] [PATCH v2 1/5] xen/mm: Makexenmem_add_to_physmapglobal
Quoted 5 lines
Make it global in preparation to be called by a new dmop.
Signed-off-by Ross Lagerwall <[email protected]>---
You need to delete the above '---' otherwise this R-b will not get carried through into the commit.
Paul
Quoted 46 lines
Reviewed-by Paul Durrant <[email protected]>--- xen/common/memory.c | 5 ++--- xen/include/xen/mm.h | 3 +++ 2 files changed, 5 insertions(+), 3 deletions(-)xen/common/memory.c +0
-0@@ -741,9 +741,8 @@ static long
memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange _t) arg)return rc;}
xen/common/memory.c +1
-3-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,xen/common/memory.c +1
-0+ unsigned int start) {unsigned int done =0 ;long rc =0 ;xen/include/xen/mm.h +3
-0@@ -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_checkguest_remove_page(struct domain *d, unsigned long
gmfn);
int__must_checksteal_page(struct domain *d, structpage_info*page,
--
2.9.5
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
In reply to Ross LagerwallQuoted 14 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 23 October 2017 10:05
To: [email protected]
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; Tim (Xen.org) <[email protected]>; Ross Lagerwall <[email protected]>; Jan Beulich <[email protected]>
Subject: [Xen-devel] [PATCH v2 2/5] xen: ProvideXEN_DMOP_add_to_physmap
Quoted 7 lines
Provide
XEN_DMOP_add_to_physmap, a limited version ofXENMEM_add_to_physmapto allow a deprivileged QEMU to move VRAM when a
guest programs its BAR. It is equivalent toXENMEM_add_to_physmapwith space ==XENMAPSPACE_gmfn_range.Signed-off-by Ross Lagerwall <[email protected]>
...with one observation below...
Quoted 75 lines
---
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(+)xen/arch/x86/hvm/dm.c +31
-0@@ -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,xen/include/public/hvm/dm_op.h +2
-0@@ -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.+ */
xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 382
Quoted 6 lines
xen/include/public/hvm/dm_op.h +6
-0+#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
Quoted 32 lines
xen/include/public/hvm/dm_op.h +2
-0+uint64_aligned_t idx;/* Index into GMFN space. */ +uint64_aligned_t gpfn;/* Starting GPFN where the GMFNs should appear. */
xen/include/public/hvm/dm_op.h +3
-0+}; +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; };xen/include/xlat.lst +1
-1@@ -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
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr
In reply to Ross LagerwallQuoted 14 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 23 October 2017 10:05
To: [email protected]
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; George Dunlap <[email protected]>; Andrew Cooper <[email protected]>; Ian Jackson <[email protected]>; Tim (Xen.org) <[email protected]>; Ross Lagerwall <[email protected]>; Jan Beulich <[email protected]>
Subject: [Xen-devel] [PATCH v2 3/5] xen: ProvideXEN_DMOP_pin_memory_cacheattr
Quoted 6 lines
Provide
XEN_DMOP_pin_memory_cacheattrto allow a deprivileged QEMU to
pin the caching type of RAM after moving the VRAM. It is equivalent toXEN_DOMCTL_pin_memory_cacheattr.Signed-off-by Ross Lagerwall <[email protected]>
Quoted 103 lines
---
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(+)xen/arch/x86/hvm/dm.c +18
-0@@ -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,xen/include/public/hvm/dm_op.h +13
-0@@ -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;xen/include/public/hvm/dm_op.h +1
-0@@ -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; };xen/include/xlat.lst +1
-1@@ -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
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
In reply to Ross LagerwallQuoted 11 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 23 October 2017 10:05
To: [email protected]
Cc: Ross Lagerwall <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>
Subject: [Xen-devel] [PATCH v2 4/5] tools: libxendevicemodel: Providexendevicemodel_add_to_physmapSigned-off-by Ross Lagerwall <[email protected]>
Quoted 105 lines
---
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(-)tools/libs/devicemodel/Makefile +1
-1@@ -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-prototypestools/libs/devicemodel/core.c +21
-0@@ -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);tools/libs/devicemodel/include/xendevicemodel.h +15
-0@@ -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. *
tools/libs/devicemodel/libxendevicemodel.map +5
-1@@ -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
Quoted 4 lines
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
In reply to Paul DurrantQuoted 10 lines
Quoted 10 lines
Quoted 1 line · On 23.10.17 at 14:03, <[email protected]> wrote:
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 23 October 2017 10:05xen/include/public/hvm/dm_op.h +0
-0@@ -368,6 +368,22 @@ struct xen_dm_op_remote_shutdown {/* (Other reason values are not blocked) */ };
Quoted 16 lines
xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 382
Quoted 13 lines
xen/include/public/hvm/dm_op.h +2
-0+/* +* 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.+ */
xen/include/public/hvm/dm_op.h +6
-0+#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
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
In reply to Paul DurrantOn 10/23/2017 01:03 PM, Paul Durrant wrote:
snip>> +/*
Quoted 6 lines
Quoted 6 lines
+ *
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.+ */
Quoted 9 lines
xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 382
Quoted 6 lines
xen/include/public/hvm/dm_op.h +6
-0+#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...
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
In reply to Jan BeulichQuoted 39 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 23 October 2017 13:18
To: Paul Durrant <[email protected]>
Cc: Andrew Cooper <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Ross Lagerwall <[email protected]>; Wei Liu <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]; Konrad Rzeszutek Wilk <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: RE: [Xen-devel] [PATCH v2 2/5] xen: ProvideXEN_DMOP_add_to_physmapQuoted 10 lines
Quoted 10 lines
Quoted 1 line · On 23.10.17 at 14:03, <[email protected]> wrote:
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 23 October 2017 10:05xen/include/public/hvm/dm_op.h +0
-0@@ -368,6 +368,22 @@ struct xen_dm_op_remote_shutdown {/* (Other reason values are not blocked) */ };Quoted 16 lines
xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 382
Quoted 13 lines
xen/include/public/hvm/dm_op.h +2
-0+/* +* 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.+ */
xen/include/public/hvm/dm_op.h +6
-0+#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).
Quoted 1 line
No, tail padding would then still be wanted, I think.
Ok. I stand corrected :-)
Paul
Quoted 2 lines
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 1/5] xen/mm: Make xenmem_add_to_physmap global
In reply to Ross LagerwallQuoted 7 lines
Quoted 1 line
Quoted 1 line · On 23.10.17 at 11:05, <[email protected]> wrote:
Make it global in preparation to be called by a new dmop.
Signed-off-by Ross Lagerwall <[email protected]>---
Reviewed-by Paul Durrant <[email protected]>
Misplaced tag.
I'd prefer if the function was made non-static in the patch which needs it so, but anyway
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 2/5] xen: Provide XEN_DMOP_add_to_physmap
In reply to Ross LagerwallQuoted 1 line
Quoted 1 line
Quoted 1 line · On 23.10.17 at 11:05, <[email protected]> wrote:
First of all, instead of xen: please consider using something more specific, like x86/hvm:.
xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 373
Quoted 9 lines
xen/include/public/hvm/dm_op.h +3
-0@@ -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.
xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 380
Quoted 7 lines
xen/include/public/hvm/dm_op.h +7
-0+* 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?
xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 383
Quoted 3 lines
xen/include/public/hvm/dm_op.h +3
-0+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 ...
xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 384
Quoted 1 line
xen/include/public/hvm/dm_op.h +1
-0+uint64_aligned_t gpfn;/* Starting GPFN where the GMFNs should appear. */
... "dst_gfn"?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v2 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr
In reply to Ross Lagerwallxen/arch/x86/hvm/dm.c line 25
Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 23.10.17 at 11:05, <[email protected]> wrote:
xen/arch/x86/hvm/dm.c +1
-0@@ -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
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
[email protected]
https://lists.xen.org/xen-devel