Add dmops to allow use of VGA with restricted QEMU
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.
Ross Lagerwall (5):
xen/mm: Make xenmem_add_to_physmap public
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 | 36 +++++++++++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 27 +++++++++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 5 ++++ xen/arch/x86/hvm/dm.c | 29 ++++++++++++++++++++ xen/common/memory.c | 5 ++-- xen/include/public/hvm/dm_op.h | 28 +++++++++++++++++++ xen/include/xen/mm.h | 3 +++ xen/include/xlat.lst | 2 ++ 9 files changed, 133 insertions(+), 4 deletions(-)
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 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
Re: [PATCH v1 1/5] xen/mm: Make xenmem_add_to_physmap global
Quoted 14 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 18 October 2017 15:04
To: Xen-devel <[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 v1 1/5] xen/mm: Makexenmem_add_to_physmapglobal
Quoted 3 lines
Make it global in preparation to be called by a new dmop.
Signed-off-by Ross Lagerwall <[email protected]>
Quoted 45 lines
--- 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
PATCH 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.
--- xen/arch/x86/hvm/dm.c | 17 +++++++++++++++++ xen/include/public/hvm/dm_op.h | 14 ++++++++++++++ xen/include/xlat.lst | 1 + 3 files changed, 32 insertions(+)
xen/arch/x86/hvm/dm.c +17 -0
@@ -640,6 +640,22 @@ static int dm_op(const struct dmop_args *op_args)break ; } +case XEN_DMOP_add_to_physmap: + { +const struct xen_dm_op_add_to_physmap *data = + &op.u.add_to_physmap; +struct xen_add_to_physmap xatp = { + .domid = op_args->domid, + .space = XENMAPSPACE_gmfn, + .idx = data->idx, + .gpfn = data->gpfn, + }; + + rc =xenmem_add_to_physmap (d, &xatp, + XENMEM_add_to_physmap >>MEMOP_EXTENT_SHIFT ); +break ; + } +default : rc = -EOPNOTSUPP ;break ;
@@ -669,6 +685,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 +14 -0
@@ -368,6 +368,19 @@ struct xen_dm_op_remote_shutdown {/* (Other reason values are not blocked) */ }; +/* +* XEN_DMOP_add_to_physmap : Sets the GPFN at which a particular page appears +* in the specified guest's pseudophysical address +* space. Identical to XENMEM_add_to_physmap with +* space == XENMAPSPACE_gmfn. +*/ +#define XEN_DMOP_add_to_physmap 17 + +struct xen_dm_op_add_to_physmap { +uint64_aligned_t idx;/* Index into GMFN space. */ +uint64_aligned_t gpfn;/* GPFN in domid where the GMFN should appear. */ +}; +struct xen_dm_op {uint32_t op;uint32_t pad;
@@ -389,6 +402,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
Re: [PATCH v1 2/5] xen: Provide XEN_DMOP_add_to_physmap
Quoted 36 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 18 October 2017 15:04
To: Xen-devel <[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 v1 2/5] xen: ProvideXEN_DMOP_add_to_physmapProvide
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.Signed-off-by Ross Lagerwall <[email protected]>--- xen/arch/x86/hvm/dm.c | 17 +++++++++++++++++ xen/include/public/hvm/dm_op.h | 14 ++++++++++++++ xen/include/xlat.lst | 1 + 3 files changed, 32 insertions(+)xen/arch/x86/hvm/dm.c +1
-0@@ -640,6 +640,22 @@ static int dm_op(const struct dmop_args *op_args)break ; } +case XEN_DMOP_add_to_physmap:
xen/arch/x86/hvm/dm.c static int dm_op(const struct dmop_args *op_args) · line 653
Quoted 10 lines
xen/arch/x86/hvm/dm.c +10
-0+ { +const struct xen_dm_op_add_to_physmap *data = + &op.u.add_to_physmap; +struct xen_add_to_physmap xatp = { + .domid = op_args->domid, + .space = XENMAPSPACE_gmfn, + .idx = data->idx, + .gpfn = data->gpfn, + }; +
Where does xatp.size get set? Looks like you're missing a parameter.
Paul
Quoted 67 lines
xen/arch/x86/hvm/dm.c +6
-0+ rc =xenmem_add_to_physmap (d, &xatp, + XENMEM_add_to_physmap >>MEMOP_EXTENT_SHIFT ); +break ; + } +default : rc = -EOPNOTSUPP ;break ;@@ -669,6 +685,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,19 @@ struct xen_dm_op_remote_shutdown {/* (Other reason values are not blocked) */ }; +/* +* XEN_DMOP_add_to_physmap : Sets the GPFN at which a particular page appears
+ * in the specified guest's pseudophysical address + * space. Identical to XENMEM_add_to_physmap with + * space == XENMAPSPACE_gmfn.+ */
xen/include/public/hvm/dm_op.h +5
-0+#define XEN_DMOP_add_to_physmap 17 + +struct xen_dm_op_add_to_physmap { +uint64_aligned_t idx;/* Index into GMFN space. */ +uint64_aligned_t gpfn;/* GPFN in domid where the GMFN should appear. */
xen/include/public/hvm/dm_op.h +3
-0+}; +struct xen_dm_op {uint32_t op;uint32_t pad;@@ -389,6 +402,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 v1 2/5] xen: Provide XEN_DMOP_add_to_physmap
Quoted 64 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Paul Durrant
Sent: 20 October 2017 10:16
To: Ross Lagerwall <[email protected]>; Xen-devel <xen- [email protected]>
Cc: Stefano Stabellini <[email protected]>; Wei Liu <[email protected]>; Konrad Rzeszutek Wilk <[email protected]>; Andrew Cooper <[email protected]>; Tim (Xen.org) <[email protected]>; George Dunlap <[email protected]>; Ross Lagerwall <[email protected]>; Jan Beulich <[email protected]>; Ian Jackson <[email protected]>
Subject: Re: [Xen-devel] [PATCH v1 2/5] xen: ProvideXEN_DMOP_add_to_physmapQuoted 36 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 18 October 2017 15:04
To: Xen-devel <[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 v1 2/5] xen: ProvideXEN_DMOP_add_to_physmapProvide
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.Signed-off-by Ross Lagerwall <[email protected]>--- xen/arch/x86/hvm/dm.c | 17 +++++++++++++++++ xen/include/public/hvm/dm_op.h | 14 ++++++++++++++ xen/include/xlat.lst | 1 + 3 files changed, 32 insertions(+)xen/arch/x86/hvm/dm.c +1
-0@@ -640,6 +640,22 @@ static int dm_op(const struct dmop_args *op_args)break ; } +case XEN_DMOP_add_to_physmap:xen/arch/x86/hvm/dm.c static int dm_op(const struct dmop_args *op_args) · line 653
Quoted 10 lines
xen/arch/x86/hvm/dm.c +10
-0+ { +const struct xen_dm_op_add_to_physmap *data = + &op.u.add_to_physmap; +struct xen_add_to_physmap xatp = { + .domid = op_args->domid, + .space = XENMAPSPACE_gmfn, + .idx = data->idx, + .gpfn = data->gpfn, + }; +Where does xatp.size get set? Looks like you're missing a parameter.
Quoted 5 lines
Paul
xen/arch/x86/hvm/dm.c static int dm_op(const struct dmop_args *op_args) · line 655
Quoted 2 lines
xen/arch/x86/hvm/dm.c +2
-0+ rc = xenmem_add_to_physmap(d, &xatp, + XENMEM_add_to_physmap >>
MEMOP_EXTENT_SHIFT);
... Also looking at this slightly odd argument, assuming that the additional size parameter could be arbitrarily large, you're going to need to handle continuations.
Paul
Quoted 66 lines
Quoted 20 lines
xen/arch/x86/hvm/dm.c +4
-0+break ; + } +default : rc = -EOPNOTSUPP ;break ;@@ -669,6 +685,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 +0
-0xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 372
Quoted 5 lines
xen/include/public/hvm/dm_op.h +2
-0@@ -368,6 +368,19 @@ struct xen_dm_op_remote_shutdown {/* (Other reason values are not blocked) */ }; +/* +* XEN_DMOP_add_to_physmap : Sets the GPFN at which a particular page
Quoted 40 lines
appears
+ * in the specified guest's pseudophysical address + * space. Identical to XENMEM_add_to_physmap with + * space == XENMAPSPACE_gmfn.+ */
xen/include/public/hvm/dm_op.h +5
-0+#define XEN_DMOP_add_to_physmap 17 + +struct xen_dm_op_add_to_physmap { +uint64_aligned_t idx;/* Index into GMFN space. */ +uint64_aligned_t gpfn;/* GPFN in domid where the GMFN should appear. */
xen/include/public/hvm/dm_op.h +3
-0+}; +struct xen_dm_op {uint32_t op;uint32_t pad;@@ -389,6 +402,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 8 lines
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
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v1 2/5] xen: Provide XEN_DMOP_add_to_physmap
In reply to Paul DurrantQuoted 1 line · Paul Durrant
Quoted 1 line
-----Original Message-----
snip>> diff --git a/xen/arch/x86/hvm/dm.c b/xen/arch/x86/hvm/dm.c
Quoted 7 lines
Quoted 7 lines
index 32ade95..432a863 100644
xen/arch/x86/hvm/dm.c +0
-0@@ -640,6 +640,22 @@ static int dm_op(const struct dmop_args *op_args)break ; }
Quoted 14 lines
xen/arch/x86/hvm/dm.c static int dm_op(const struct dmop_args *op_args) · line 653
Quoted 11 lines
xen/arch/x86/hvm/dm.c +11
-0+case XEN_DMOP_add_to_physmap: + { +const struct xen_dm_op_add_to_physmap *data = + &op.u.add_to_physmap; +struct xen_add_to_physmap xatp = { + .domid = op_args->domid, + .space = XENMAPSPACE_gmfn, + .idx = data->idx, + .gpfn = data->gpfn, + }; +Where does xatp.size get set? Looks like you're missing a parameter.
xatp.size is only used for XENMAPSPACE_gmfn_range which is not supported by this interface. size gets set to 0 by the C99 designated initializer.
Based on your other comments, would it make sense to instead use XENMAPSPACE_gmfn_range and have the caller set the size?
As it is currently, QEMU does only populate VRAM one page at a time (using xen_xc_domain_add_to_physmap) so it is already slow but it could be improved.
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
Re: [PATCH v1 2/5] xen: Provide XEN_DMOP_add_to_physmap
Quoted 38 lines
-----Original Message-----
From: Ross Lagerwall [mailto:[email protected]]
Sent: 20 October 2017 10:37
To: Paul Durrant <[email protected]>; Xen-devel <xen- [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]>; Jan Beulich <[email protected]>
Subject: Re: [Xen-devel] [PATCH v1 2/5] xen: ProvideXEN_DMOP_add_to_physmapQuoted 1 line · Paul Durrant
Quoted 1 line
-----Original Message-----
snip>> diff --git
a/xen/arch/x86/hvm/dm.cb/xen/arch/x86/hvm/dm.cQuoted 4 lines
xen/arch/x86/hvm/dm.c static int dm_op(const struct dmop_args
Quoted 4 lines
index 32ade95..432a863 100644
xen/arch/x86/hvm/dm.c +0
-0@@ -640,6 +640,22 @@ static int dm_op(const struct dmop_args
*op_args)Quoted 15 lines
Quoted 14 lines
xen/arch/x86/hvm/dm.c +11
-0break ; } +case XEN_DMOP_add_to_physmap: + { +const struct xen_dm_op_add_to_physmap *data = + &op.u.add_to_physmap; +struct xen_add_to_physmap xatp = { + .domid = op_args->domid, + .space = XENMAPSPACE_gmfn, + .idx = data->idx, + .gpfn = data->gpfn, + }; +
Quoted 8 lines
Quoted 2 lines
Where does xatp.size get set? Looks like you're missing a parameter.
xatp.size is only used for
XENMAPSPACE_gmfn_rangewhich is not supported
by this interface. size gets set to 0 by the C99 designated initializer.Based on your other comments, would it make sense to instead use
XENMAPSPACE_gmfn_rangeand have the caller set the size?
Yes... my eyes had read XENMAPSPACE_gmfn_range in the first place, hence my confusion over the size parameter.
Quoted 3 lines
As it is currently, QEMU does only populate VRAM one page at a time (using
xen_xc_domain_add_to_physmap)
Ouch, yes, I'd forgotten that.
Quoted 2 lines
so it is already slow but it could
be improved.
Indeed. I think we should shoot for a better semantic given that it's a new op.
Paul
Quoted 3 lines
--
Ross Lagerwall
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
PATCH 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.
--- xen/arch/x86/hvm/dm.c | 12 ++++++++++++ xen/include/public/hvm/dm_op.h | 14 ++++++++++++++ xen/include/xlat.lst | 1 + 3 files changed, 27 insertions(+)
xen/arch/x86/hvm/dm.c +12 -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>
@@ -656,6 +657,16 @@ 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; + + rc =hvm_set_mem_pinned_cacheattr (d, data->start, data->end, + data->type); +break ; + } +default : rc = -EOPNOTSUPP ;break ;
@@ -686,6 +697,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
@@ -381,6 +381,19 @@ struct xen_dm_op_add_to_physmap {uint64_aligned_t gpfn;/* GPFN in domid where the GMFN 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;
@@ -403,6 +416,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
Re: [PATCH v1 3/5] xen: Provide XEN_DMOP_pin_memory_cacheattr
Quoted 39 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 18 October 2017 15:04
To: Xen-devel <[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 v1 3/5] xen: ProvideXEN_DMOP_pin_memory_cacheattrProvide
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]>--- xen/arch/x86/hvm/dm.c | 12 ++++++++++++ xen/include/public/hvm/dm_op.h | 14 ++++++++++++++ xen/include/xlat.lst | 1 + 3 files changed, 27 insertions(+)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> #include <xsm/xsm.h>
xen/arch/x86/hvm/dm.c static int dm_op(const struct dmop_args *op_args) · line 664
Quoted 8 lines
xen/arch/x86/hvm/dm.c +5
-0@@ -656,6 +657,16 @@ 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; +
You need to check data->pad is 0 here.
Paul
Quoted 66 lines
xen/arch/x86/hvm/dm.c +6
-0+ rc =hvm_set_mem_pinned_cacheattr (d, data->start, data->end, + data->type); +break ; + } +default : rc = -EOPNOTSUPP ;break ;@@ -686,6 +697,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@@ -381,6 +381,19 @@ struct xen_dm_op_add_to_physmap {uint64_aligned_t gpfn;/* GPFN in domid where the GMFN 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@@ -403,6 +416,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
PATCH 4/5 tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
In reply to Ross Lagerwall--- tools/libs/devicemodel/Makefile | 2 +- tools/libs/devicemodel/core.c | 17 +++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 13 +++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 5 +++++ 4 files changed, 36 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 +17 -0
@@ -564,6 +564,23 @@ int xendevicemodel_shutdown(return xendevicemodel_op (dmod, domid,1 , &op,sizeof (op)); } +int xendevicemodel_add_to_physmap ( +xendevicemodel_handle *dmod,domid_t domid,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->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 +13 -0
@@ -326,6 +326,19 @@ int xendevicemodel_shutdown( xendevicemodel_handle *dmod, domid_t domid, unsigned int reason);/** +* Sets the GPFN at which a particular page 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 idx Index into GMFN space +* @parm gpfn GPFN in domid where the GMFN should appear +* @return 0 on success, -1 on failure. +*/ +int xendevicemodel_add_to_physmap ( +xendevicemodel_handle *dmod,domid_t domid,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
Re: [PATCH v1 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
Ross Lagerwall writes ("[PATCH v1 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap"):
Quoted 1 line
Signed-off-by Ross Lagerwall <[email protected]>
I have looked at the hypervisor patches but I am not qualified to assess the security properties of the new DMOPs.
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v1 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
In reply to Ross LagerwallQuoted 37 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 18 October 2017 15:04
To: Xen-devel <[email protected]>
Cc: Ross Lagerwall <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>
Subject: [Xen-devel] [PATCH v1 4/5] tools: libxendevicemodel: Providexendevicemodel_add_to_physmapSigned-off-by Ross Lagerwall <[email protected]>--- tools/libs/devicemodel/Makefile | 2 +- tools/libs/devicemodel/core.c | 17 +++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 13 +++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 5 +++++ 4 files changed, 36 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 +0
-0
tools/libs/devicemodel/core.c int xendevicemodel_shutdown( · line 569
Quoted 6 lines
tools/libs/devicemodel/core.c +2
-0@@ -564,6 +564,23 @@ int xendevicemodel_shutdown(return xendevicemodel_op (dmod, domid,1 , &op,sizeof (op)); } +int xendevicemodel_add_to_physmap ( +xendevicemodel_handle *dmod,domid_t domid,uint64_t idx,uint64_t gpfn)
Do you really want this to be single page? Populating VRAM is not going to be fast if you need to make 16MB / 4K hypercalls to do it.
Paul
Quoted 63 lines
tools/libs/devicemodel/core.c +15
-0+{ +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->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 +13
-0@@ -326,6 +326,19 @@ int xendevicemodel_shutdown( xendevicemodel_handle *dmod, domid_t domid, unsigned int reason);/** +* Sets the GPFN at which a particular page 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 idx Index into GMFN space +* @parm gpfn GPFN in domid where the GMFN should appear +* @return 0 on success, -1 on failure. +*/ +int xendevicemodel_add_to_physmap ( +xendevicemodel_handle *dmod,domid_t domid,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 v1 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
Quoted 40 lines · Paul Durrant
Quoted 40 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 18 October 2017 15:04
To: Xen-devel <[email protected]>
Cc: Ross Lagerwall <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>
Subject: [Xen-devel] [PATCH v1 4/5] tools: libxendevicemodel: Providexendevicemodel_add_to_physmapSigned-off-by Ross Lagerwall <[email protected]>--- tools/libs/devicemodel/Makefile | 2 +- tools/libs/devicemodel/core.c | 17 +++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 13 +++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 5 +++++ 4 files changed, 36 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 +0
-0@@ -564,6 +564,23 @@ int xendevicemodel_shutdown(return xendevicemodel_op (dmod, domid,1 , &op,sizeof (op)); }
Quoted 5 lines
tools/libs/devicemodel/core.c int xendevicemodel_shutdown( · line 569
Quoted 3 lines
tools/libs/devicemodel/core.c +2
-0+int xendevicemodel_add_to_physmap ( +xendevicemodel_handle *dmod,domid_t domid,uint64_t idx,uint64_t gpfn)Do you really want this to be single page? Populating VRAM is not going to be fast if you need to make 16MB / 4K hypercalls to do it.
This. Since we're introducing a new interface please consider giving it the ability to batch.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v1 4/5] tools: libxendevicemodel: Provide xendevicemodel_add_to_physmap
Quoted 1 line · Wei Liu
On Fri, Oct 20, 2017 at 10:22:55AM +0100, Paul Durrant wrote:
...
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
CFLAGS += -Werror -Wmissing-prototypes
tools/libs/devicemodel/core.c +0
-0@@ -564,6 +564,23 @@ int xendevicemodel_shutdown(return xendevicemodel_op (dmod, domid,1 , &op,sizeof (op)); }
Quoted 9 lines
Quoted 5 lines
tools/libs/devicemodel/core.c int xendevicemodel_shutdown( · line 569
Quoted 3 lines
tools/libs/devicemodel/core.c +2
-0+int xendevicemodel_add_to_physmap ( +xendevicemodel_handle *dmod,domid_t domid,uint64_t idx,uint64_t gpfn)Do you really want this to be single page? Populating VRAM is not going to be fast if you need to make 16MB / 4K hypercalls to do it.
This. Since we're introducing a new interface please consider giving it the ability to batch.
Yes indeed. I sent a v2 of this patch series a few days ago which changes it to operate on a range.
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xen.org/xen-devel
PATCH 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
@@ -581,6 +581,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
@@ -339,6 +339,20 @@ int xendevicemodel_add_to_physmap( xendevicemodel_handle *dmod, domid_t domid, uint64_t idx, 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 v1 5/5] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr
Ross Lagerwall writes ("[PATCH v1 5/5] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr"):
Quoted 1 line
Signed-off-by Ross Lagerwall <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
Re: [PATCH v1 5/5] tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr
In reply to Ross LagerwallQuoted 11 lines
-----Original Message-----
From: Xen-devel [mailto:[email protected]] On Behalf Of Ross Lagerwall
Sent: 18 October 2017 15:04
To: Xen-devel <[email protected]>
Cc: Ross Lagerwall <[email protected]>; Ian Jackson <[email protected]>; Wei Liu <[email protected]>
Subject: [Xen-devel] [PATCH v1 5/5] tools: libxendevicemodel: Providexendevicemodel_pin_memory_cacheattrSigned-off-by Ross Lagerwall <[email protected]>
Quoted 81 lines
--- 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@@ -581,6 +581,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@@ -339,6 +339,20 @@ int xendevicemodel_add_to_physmap( xendevicemodel_handle *dmod, domid_t domid, uint64_t idx, 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
-1@@ -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
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