Add dmops to allow use of VGA with restricted QEMU
v4 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 v4:
* Rename add_to_physmap -> relocate_memory.
* Use continutation instead of erroring in relocate_memory.
* Bump domctl interface version.
Changes in v3:
* Address Jan's comments - primarily adding a new patch to remove the existing pin_mem_cacheattr domctl.
Changes in v2:
* Address Paul's comments - mainly making add_to_physmap operate on a range.
Ross Lagerwall (6):
xen/mm: Make xenmem_add_to_physmap global
x86/hvm: Provide XEN_DMOP_relocate_memory
x86/hvm: Provide XEN_DMOP_pin_memory_cacheattr
tools: libxendevicemodel: Provide xendevicemodel_relocate_memory
tools: libxendevicemodel: Provide xendevicemodel_pin_memory_cacheattr x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
tools/flask/policy/modules/xen.if | 4 +- tools/libs/devicemodel/Makefile | 2 +- tools/libs/devicemodel/core.c | 39 +++++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 28 ++++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 6 +++ tools/libxc/include/xenctrl.h | 6 --- tools/libxc/include/xenctrl_compat.h | 3 ++ tools/libxc/xc_devicemodel_compat.c | 8 ++++ tools/libxc/xc_domain.c | 15 -------- xen/arch/x86/domctl.c | 8 ---- xen/arch/x86/hvm/dm.c | 50 +++++++++++++++++++++++++ xen/common/memory.c | 5 +-- xen/include/public/domctl.h | 9 +---- xen/include/public/hvm/dm_op.h | 40 ++++++++++++++++++++ xen/include/xen/mm.h | 3 ++ xen/include/xlat.lst | 2 + xen/xsm/flask/hooks.c | 3 -- xen/xsm/flask/policy/access_vectors | 2 - 18 files changed, 186 insertions(+), 47 deletions(-)
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 1/6 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
@@ -770,9 +770,8 @@ static long memory_exchange(XEN_GUEST_HANDLE_PARAM(xen_memory_exchange_t) arg)return rc; } -static int xenmem_add_to_physmap (struct domain *d, -struct xen_add_to_physmap *xatp, -unsigned int start) +int xenmem_add_to_physmap (struct domain *d,struct xen_add_to_physmap *xatp, +unsigned int start) {unsigned int done =0 ;long rc =0 ;
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.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 2/6 x86/hvm: Provide XEN_DMOP_relocate_memory
In reply to Ross LagerwallProvide XEN_DMOP_relocate_memory, a limited version of XENMEM_add_to_physmap to allow a deprivileged QEMU to move VRAM when a guest programs its BAR. It is equivalent to XENMEM_add_to_physmap with space == XENMAPSPACE_gmfn_range.
---
Changed in v4:
* Renamed add_to_physmap to relocate_memory.
* Instead of checking for overflow, handle using continuation.
Changed in v3:
* Renamed idx -> src_gfn and gpfn -> dst_gfn.
* Increase the width of size and add an overflow check.
* Rework some of the descriptions.
* Dropped Paul's reviewed-by due to the above changes.
Changed in v2:
* Make it operate on a range.
xen/arch/x86/hvm/dm.c | 32 ++++++++++++++++++++++++++++++++ xen/include/public/hvm/dm_op.h | 18 ++++++++++++++++++ xen/include/xlat.lst | 1 + 3 files changed, 51 insertions(+)
xen/arch/x86/hvm/dm.c +32 -0
@@ -640,6 +640,37 @@ static int dm_op(const struct dmop_args *op_args)break ; } +case XEN_DMOP_relocate_memory: + { +struct xen_dm_op_relocate_memory *data = &op.u.relocate_memory; +struct xen_add_to_physmap xatp = { + .domid = op_args->domid, + .size = data->size, + .space = XENMAPSPACE_gmfn_range, + .idx = data->src_gfn, + .gpfn = data->dst_gfn, + }; + +if ( data->pad ) + { + rc = -EINVAL ; +break ; + } + + rc =xenmem_add_to_physmap (d, &xatp,0 ); +if ( rc ==0 && data->size != xatp.size ) + rc = xatp.size; +if ( rc >0 ) + { + data->size -= rc; + data->src_gfn += rc; + data->dst_gfn += rc; + const_op = false; + rc = -ERESTART ; + } +break ; + } +default : rc = -EOPNOTSUPP ;break ;
@@ -669,6 +700,7 @@ CHECK_dm_op_set_mem_type; CHECK_dm_op_inject_event; CHECK_dm_op_inject_msi; CHECK_dm_op_remote_shutdown; +CHECK_dm_op_relocate_memory; int compat_dm_op(domid_t domid, unsigned int nr_bufs,
xen/include/public/hvm/dm_op.h +18 -0
@@ -368,6 +368,23 @@ struct xen_dm_op_remote_shutdown {/* (Other reason values are not blocked) */ }; +/* +* XEN_DMOP_relocate_memory : Relocate GFNs for the specified guest. +* Identical to XENMEM_add_to_physmap with +* space == XENMAPSPACE_gmfn_range. +*/ +#define XEN_DMOP_relocate_memory 17 + +struct xen_dm_op_relocate_memory { +/* Number of GFNs to process. */ +uint32_t size; +uint32_t pad; +/* Starting GFN to relocate. */ +uint64_aligned_t src_gfn; +/* Starting GFN where GFNs should be relocated. */ +uint64_aligned_t dst_gfn; +}; +struct xen_dm_op {uint32_t op;uint32_t pad;
@@ -389,6 +406,7 @@ struct xen_dm_op {struct xen_dm_op_map_mem_type_to_ioreq_server map_mem_type_to_ioreq_server;struct xen_dm_op_remote_shutdown remote_shutdown; +struct xen_dm_op_relocate_memory relocate_memory; } u; };
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_relocate_memory hvm/dm_op.h ? dm_op_create_ioreq_server hvm/dm_op.h ? dm_op_destroy_ioreq_server hvm/dm_op.h ? dm_op_get_ioreq_server_info hvm/dm_op.h
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 3/6 x86/hvm: 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
@@ -20,6 +20,7 @@#include <xen/sched.h> #include <asm/hap.h> +#include <asm/hvm/cacheattr.h> #include <asm/hvm/ioreq.h> #include <asm/shadow.h>
@@ -671,6 +672,22 @@ static int dm_op(const struct dmop_args *op_args)break ; } +case XEN_DMOP_pin_memory_cacheattr: + { +const struct xen_dm_op_pin_memory_cacheattr *data = + &op.u.pin_memory_cacheattr; + +if ( data->pad ) + { + rc = -EINVAL ; +break ; + } + + rc =hvm_set_mem_pinned_cacheattr (d, data->start, data->end, + data->type); +break ; + } +default : rc = -EOPNOTSUPP ;break ;
@@ -701,6 +718,7 @@ CHECK_dm_op_inject_event; CHECK_dm_op_inject_msi; CHECK_dm_op_remote_shutdown; CHECK_dm_op_relocate_memory; +CHECK_dm_op_pin_memory_cacheattr; int compat_dm_op(domid_t domid, unsigned int nr_bufs,
xen/include/public/hvm/dm_op.h +14 -0
@@ -385,6 +385,19 @@ struct xen_dm_op_relocate_memory {uint64_aligned_t dst_gfn; }; +/* +* XEN_DMOP_pin_memory_cacheattr : Pin caching type of RAM space. +* Identical to XEN_DOMCTL_pin_mem_cacheattr. +*/ +#define XEN_DMOP_pin_memory_cacheattr 18 + +struct xen_dm_op_pin_memory_cacheattr { +uint64_aligned_t start;/* Start gfn. */ +uint64_aligned_t end;/* End gfn. */ +uint32_t type;/* XEN_DOMCTL_MEM_CACHEATTR_* */ +uint32_t pad; +}; +struct xen_dm_op {uint32_t op;uint32_t pad;
@@ -407,6 +420,7 @@ struct xen_dm_op { map_mem_type_to_ioreq_server;struct xen_dm_op_remote_shutdown remote_shutdown;struct xen_dm_op_relocate_memory relocate_memory; +struct xen_dm_op_pin_memory_cacheattr pin_memory_cacheattr; } u; };
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.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 4/6 tools: libxendevicemodel: Provide xendevicemodel_relocate_memory
In reply to Ross Lagerwall---
Changed in v4:
* Rename add_to_physmap to relocate_memory to match hypervisor interface.
Changed in v3:
* Match width of size with updated hypervisor interface.
* Match description with the one for the hypervisor interface.
Changed in v2:
* Make it operate on a range.
tools/libs/devicemodel/Makefile | 2 +- tools/libs/devicemodel/core.c | 20 ++++++++++++++++++++ tools/libs/devicemodel/include/xendevicemodel.h | 14 ++++++++++++++ tools/libs/devicemodel/libxendevicemodel.map | 5 +++++ 4 files changed, 40 insertions(+), 1 deletion(-)
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 +20 -0
@@ -564,6 +564,26 @@ int xendevicemodel_shutdown(return xendevicemodel_op (dmod, domid,1 , &op,sizeof (op)); } +int xendevicemodel_relocate_memory ( +xendevicemodel_handle *dmod,domid_t domid,uint32_t size,uint64_t src_gfn, +uint64_t dst_gfn) +{ +struct xen_dm_op op; +struct xen_dm_op_relocate_memory *data; + +memset (&op,0 ,sizeof (op)); + + op.op = XEN_DMOP_relocate_memory; + data = &op.u.relocate_memory; + + data->size = size; + data->pad =0 ; + data->src_gfn = src_gfn; + data->dst_gfn = dst_gfn; + +return xendevicemodel_op (dmod, domid,1 , &op,sizeof (op)); +} +int xendevicemodel_restrict (xendevicemodel_handle *dmod,domid_t domid) {return osdep_xendevicemodel_restrict (dmod, domid);
tools/libs/devicemodel/include/xendevicemodel.h +14 -0
@@ -325,6 +325,20 @@ int xendevicemodel_inject_event(int xendevicemodel_shutdown (xendevicemodel_handle *dmod,domid_t domid,unsigned int reason); +/* +* Relocate GFNs for the specified domain. +* +* @parm dmod a handle to an open devicemodel interface. +* @parm domid the domain id to be serviced +* @parm size Number of GFNs to process +* @parm src_gfn Starting GFN to relocate +* @parm dst_gfn Starting GFN where GFNs should be relocated +* @return 0 on success, -1 on failure. +*/ +int xendevicemodel_relocate_memory ( +xendevicemodel_handle *dmod,domid_t domid,uint32_t size,uint64_t src_gfn, +uint64_t dst_gfn); +/** * This function restricts the use of this handle to the specified * domain.
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_relocate_memory; +} VERS_1.1;
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 5/6 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
@@ -584,6 +584,25 @@ int xendevicemodel_relocate_memory(return xendevicemodel_op (dmod, domid,1 , &op,sizeof (op)); } +int xendevicemodel_pin_memory_cacheattr ( +xendevicemodel_handle *dmod,domid_t domid,uint64_t start,uint64_t end, +uint32_t type) +{ +struct xen_dm_op op; +struct xen_dm_op_pin_memory_cacheattr *data; + +memset (&op,0 ,sizeof (op)); + + op.op = XEN_DMOP_pin_memory_cacheattr; + data = &op.u.pin_memory_cacheattr; + + data->start = start; + data->end = end; + data->type = type; + +return xendevicemodel_op (dmod, domid,1 , &op,sizeof (op)); +} +int xendevicemodel_restrict (xendevicemodel_handle *dmod,domid_t domid) {return osdep_xendevicemodel_restrict (dmod, domid);
tools/libs/devicemodel/include/xendevicemodel.h +14 -0
@@ -340,6 +340,20 @@ int xendevicemodel_relocate_memory( uint64_t dst_gfn);/** +* Pins caching type of RAM space. +* +* @parm dmod a handle to an open devicemodel interface. +* @parm domid the domain id to be serviced +* @parm start Start gfn +* @parm end End gfn +* @parm type XEN_DOMCTL_MEM_CACHEATTR_* +* @return 0 on success, -1 on failure. +*/ +int xendevicemodel_pin_memory_cacheattr ( +xendevicemodel_handle *dmod,domid_t domid,uint64_t start,uint64_t end, +uint32_t type); + +/** * This function restricts the use of this handle to the specified * domain. *
tools/libs/devicemodel/libxendevicemodel.map +1 -0
@@ -31,4 +31,5 @@ VERS_1.1 { VERS_1.2 { global: xendevicemodel_relocate_memory; + xendevicemodel_pin_memory_cacheattr; } VERS_1.1;
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v4 6/6 x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
In reply to Ross LagerwallRemove the implementation of XEN_DOMCTL_pin_mem_cacheattr since it has been replaced by a dmop. Change xc_domain_pin_memory_cacheattr() so that it is only defined when XC_WANT_COMPAT_DEVICEMODEL_API is set and have it call the new dmop. Leave the definitions of XEN_DOMCTL_MEM_CACHEATTR_* since they are still used by QEMU.
---
Changed in v4:
* Bump interface version.
* Clarified comment.
New in v3.
tools/flask/policy/modules/xen.if | 4 ++-- tools/libs/devicemodel/include/xendevicemodel.h | 2 +- tools/libxc/include/xenctrl.h | 6 ------ tools/libxc/include/xenctrl_compat.h | 3 +++ tools/libxc/xc_devicemodel_compat.c | 8 ++++++++ tools/libxc/xc_domain.c | 15 --------------- xen/arch/x86/domctl.c | 8 -------- xen/include/public/domctl.h | 9 ++------- xen/include/public/hvm/dm_op.h | 10 +++++++++- xen/xsm/flask/hooks.c | 3 --- xen/xsm/flask/policy/access_vectors | 2 -- 11 files changed, 25 insertions(+), 45 deletions(-)
tools/flask/policy/modules/xen.if +2 -2
@@ -57,7 +57,7 @@ define(`create_domain_common', ` allow $1 $2:shadow enable; allow $1 $2:mmu { map_read map_write adjust memorymap physmap pinpage mmuext_op updatemp }; allow $1 $2:grant setup; - allow $1 $2:hvm { cacheattr getparam hvmctl sethvmc + allow $1 $2:hvm { getparam hvmctl sethvmc setparam nested altp2mhvm altp2mhvm_op dm }; ')
@@ -151,7 +151,7 @@ define(`device_model', ` allow $1 $2_target:domain { getdomaininfo shutdown }; allow $1 $2_target:mmu { map_read map_write adjust physmap target_hack }; - allow $1 $2_target:hvm { getparam setparam hvmctl cacheattr dm }; + allow $1 $2_target:hvm { getparam setparam hvmctl dm }; ') # make_device_model(priv, dm_dom, hvm_dom)
tools/libs/devicemodel/include/xendevicemodel.h +1 -1
@@ -346,7 +346,7 @@ int xendevicemodel_relocate_memory(* @parm domid the domain id to be serviced * @parm start Start gfn * @parm end End gfn -* @parm type XEN_DOMCTL_MEM_CACHEATTR_* +* @parm type XEN_DMOP_MEM_CACHEATTR_* * @return 0 on success, -1 on failure. */ int xendevicemodel_pin_memory_cacheattr(
tools/libxc/include/xenctrl.h +0 -6
@@ -1473,12 +1473,6 @@ int xc_domain_iomem_permission(xc_interface *xch,unsigned long nr_mfns, uint8_t allow_access); -int xc_domain_pin_memory_cacheattr (xc_interface *xch, -uint32_t domid, -uint64_t start, -uint64_t end, -uint32_t type); -unsigned long xc_make_page_below_4G (xc_interface *xch,uint32_t domid,unsigned long mfn);
tools/libxc/include/xenctrl_compat.h +3 -0
@@ -164,6 +164,9 @@ int xc_hvm_set_mem_type(int xc_hvm_inject_trap (xc_interface *xch,uint32_t domid,int vcpu,uint8_t vector,uint8_t type,uint32_t error_code,uint8_t insn_len,uint64_t cr2); +int xc_domain_pin_memory_cacheattr ( +xc_interface *xch,uint32_t domid,uint64_t start,uint64_t end, +uint32_t type);#endif /* XC_WANT_COMPAT_DEVICEMODEL_API */
tools/libxc/xc_devicemodel_compat.c +8 -0
@@ -128,6 +128,14 @@ int xc_hvm_inject_trap( type, error_code, insn_len, cr2); } +int xc_domain_pin_memory_cacheattr ( +xc_interface *xch,uint32_t domid,uint64_t start,uint64_t end, +uint32_t type) +{ +return xendevicemodel_pin_memory_cacheattr (xch->dmod, domid, start, end, + type); +} +/* * Local variables: * mode: C
tools/libxc/xc_domain.c +0 -15
@@ -720,21 +720,6 @@ int xc_domain_setmaxmem(xc_interface *xch,return do_domctl (xch, &domctl); } -int xc_domain_pin_memory_cacheattr (xc_interface *xch, -uint32_t domid, -uint64_t start, -uint64_t end, -uint32_t type) -{ -DECLARE_DOMCTL ; - domctl.cmd = XEN_DOMCTL_pin_mem_cacheattr; - domctl.domain = domid; - domctl.u.pin_mem_cacheattr.start = start; - domctl.u.pin_mem_cacheattr.end = end; - domctl.u.pin_mem_cacheattr.type = type; -return do_domctl (xch, &domctl); -} -#if defined(__i386__) || defined(__x86_64__) int xc_domain_set_memory_map(xc_interface *xch, uint32_t domid,
xen/arch/x86/domctl.c +0 -8
@@ -23,7 +23,6 @@#include <asm/irq.h> #include <asm/hvm/hvm.h> #include <asm/hvm/support.h> -#include <asm/hvm/cacheattr.h> #include <asm/processor.h> #include <asm/acpi.h> /* for hvm_acpi_power_button */ #include <xen/hypercall.h> /* for arch_do_domctl */
@@ -859,13 +858,6 @@ long arch_do_domctl(break ; } -case XEN_DOMCTL_pin_mem_cacheattr: - ret =hvm_set_mem_pinned_cacheattr ( - d, domctl->u.pin_mem_cacheattr.start, - domctl->u.pin_mem_cacheattr.end, - domctl->u.pin_mem_cacheattr.type); -break ; -case XEN_DOMCTL_set_ext_vcpucontext:case XEN_DOMCTL_get_ext_vcpucontext: {
xen/include/public/domctl.h +2 -7
@@ -38,7 +38,7 @@#include "hvm/save.h" #include "memory.h" -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010/* * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
@@ -598,10 +598,6 @@ struct xen_domctl_ioport_mapping {#define XEN_DOMCTL_MEM_CACHEATTR_WB 6#define XEN_DOMCTL_MEM_CACHEATTR_UCM 7#define XEN_DOMCTL_DELETE_MEM_CACHEATTR (~(uint32_t)0) -struct xen_domctl_pin_mem_cacheattr { -uint64_aligned_t start, end; -uint32_t type;/* XEN_DOMCTL_MEM_CACHEATTR_* */ -};/* XEN_DOMCTL_set_ext_vcpucontext */
@@ -1149,7 +1145,7 @@ struct xen_domctl {#define XEN_DOMCTL_bind_pt_irq 38#define XEN_DOMCTL_memory_mapping 39#define XEN_DOMCTL_ioport_mapping 40 -#define XEN_DOMCTL_pin_mem_cacheattr 41 +/* #define XEN_DOMCTL_pin_mem_cacheattr 41 Removed - use dmop */ #define XEN_DOMCTL_set_ext_vcpucontext 42#define XEN_DOMCTL_get_ext_vcpucontext 43#define XEN_DOMCTL_set_opt_feature 44/* Obsolete IA64 only */
@@ -1226,7 +1222,6 @@ struct xen_domctl {struct xen_domctl_bind_pt_irq bind_pt_irq;struct xen_domctl_memory_mapping memory_mapping;struct xen_domctl_ioport_mapping ioport_mapping; -struct xen_domctl_pin_mem_cacheattr pin_mem_cacheattr;struct xen_domctl_ext_vcpucontext ext_vcpucontext;struct xen_domctl_set_target set_target;struct xen_domctl_subscribe subscribe;
xen/include/public/hvm/dm_op.h +9 -1
@@ -394,7 +394,15 @@ struct xen_dm_op_relocate_memory {struct xen_dm_op_pin_memory_cacheattr {uint64_aligned_t start;/* Start gfn. */ uint64_aligned_t end;/* End gfn. */ -uint32_t type;/* XEN_DOMCTL_MEM_CACHEATTR_* */ +/* Caching types: these happen to be the same as x86 MTRR/PAT type codes. */ +#define XEN_DMOP_MEM_CACHEATTR_UC 0 +#define XEN_DMOP_MEM_CACHEATTR_WC 1 +#define XEN_DMOP_MEM_CACHEATTR_WT 4 +#define XEN_DMOP_MEM_CACHEATTR_WP 5 +#define XEN_DMOP_MEM_CACHEATTR_WB 6 +#define XEN_DMOP_MEM_CACHEATTR_UCM 7 +#define XEN_DMOP_DELETE_MEM_CACHEATTR (~(uint32_t)0) +uint32_t type;/* XEN_DMOP_MEM_CACHEATTR_* */ uint32_t pad; };
xen/xsm/flask/hooks.c +0 -3
@@ -693,9 +693,6 @@ static int flask_domctl(struct domain *d, int cmd)case XEN_DOMCTL_mem_sharing_op:return current_has_perm (d,SECCLASS_HVM ,HVM__MEM_SHARING ); -case XEN_DOMCTL_pin_mem_cacheattr: -return current_has_perm (d,SECCLASS_HVM ,HVM__CACHEATTR ); -case XEN_DOMCTL_sendtrigger:return current_has_perm (d,SECCLASS_DOMAIN ,DOMAIN__TRIGGER );
xen/xsm/flask/policy/access_vectors +0 -2
@@ -264,8 +264,6 @@ class hvm # HVMOP_get_param getparam bind_irq -# XEN_DOMCTL_pin_mem_cacheattr - cacheattr # HVMOP_get_mem_type, # HVMOP_set_mem_access, HVMOP_get_mem_access, HVMOP_pagetable_dying hvmctl
Signature · 7 lines
2.9.5 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
Quoted 15 lines · Ross Lagerwall
Remove the implementation of
XEN_DOMCTL_pin_mem_cacheattrsince it has been replaced by a dmop. Changexc_domain_pin_memory_cacheattr()so that it is only defined whenXC_WANT_COMPAT_DEVICEMODEL_APIis set and have it call the new dmop. Leave the definitions of XEN_DOMCTL_MEM_CACHEATTR_* since they are still used by QEMU.Signed-off-by Ross Lagerwall <[email protected]>Reviewed-by Paul Durrant <[email protected]>Acked-by Daniel De Graaf <[email protected]>---
Changed in v4:
* Bump interface version.
* Clarified comment.
Quoted 8 lines
New in v3.
tools/flask/policy/modules/xen.if | 4 ++-- tools/libs/devicemodel/include/xendevicemodel.h | 2 +- tools/libxc/include/xenctrl.h | 6 ------ tools/libxc/include/xenctrl_compat.h | 3 +++ tools/libxc/xc_devicemodel_compat.c | 8 ++++++++ tools/libxc/xc_domain.c | 15 ---------------
These changes LGTM.
xen/include/public/domctl.h line 42
Quoted 12 lines
{xen/include/public/domctl.h +1
-1@@ -38,7 +38,7 @@#include "hvm/save.h" #include "memory.h" -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010
We bumped this to 0f in this development window so there is no need to do it again.
xen/include/public/domctl.h struct xen_domctl_ioport_mapping { · line 600
Quoted 6 lines
xen/include/public/domctl.h +0
-0/* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. @@ -598,10 +598,6 @@ struct xen_domctl_ioport_mapping {#define XEN_DOMCTL_MEM_CACHEATTR_WB 6#define XEN_DOMCTL_MEM_CACHEATTR_UCM 7#define XEN_DOMCTL_DELETE_MEM_CACHEATTR (~(uint32_t)0)
Any reason to not remove these #define's?
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
Quoted 7 lines · Wei Liu
Quoted 6 lines · Ross Lagerwall
Remove the implementation of
XEN_DOMCTL_pin_mem_cacheattrsince it has been replaced by a dmop. Changexc_domain_pin_memory_cacheattr()so that it is only defined whenXC_WANT_COMPAT_DEVICEMODEL_APIis set and have it call the new dmop. Leave the definitions of XEN_DOMCTL_MEM_CACHEATTR_* since they are still used by QEMU.
snip>> diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
Quoted 7 lines
Quoted 7 lines
index a8921dd..30674d6 100644
xen/include/public/domctl.h +0
-0@@ -38,7 +38,7 @@#include "hvm/save.h" #include "memory.h"
Quoted 6 lines
xen/include/public/domctl.h line 42
Quoted 3 lines
xen/include/public/domctl.h +1
-1-#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010We bumped this to 0f in this development window so there is no need to do it again.
OK.
Quoted 10 lines
xen/include/public/domctl.h struct xen_domctl_ioport_mapping { · line 600
Quoted 7 lines
xen/include/public/domctl.h +0
-0/* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. @@ -598,10 +598,6 @@ struct xen_domctl_ioport_mapping {#define XEN_DOMCTL_MEM_CACHEATTR_WB 6#define XEN_DOMCTL_MEM_CACHEATTR_UCM 7#define XEN_DOMCTL_DELETE_MEM_CACHEATTR (~(uint32_t)0)Any reason to not remove these #define's?
They're still used by QEMU at the moment. Removing them now would break the build. They can be removed once QEMU(s) have been switch to use the new XEN_DMOP_* #defines.
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 1/6] xen/mm: Make xenmem_add_to_physmap global
In reply to Ross LagerwallQuoted 5 lines · Ross Lagerwall
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]>Acked-by Jan Beulich <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Wei Liu
Reviewed-byRe: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
In reply to Ross LagerwallQuoted 35 lines · Ross Lagerwall
Quoted 7 lines · Wei Liu
Quoted 6 lines · Ross Lagerwall
Remove the implementation of
XEN_DOMCTL_pin_mem_cacheattrsince it has been replaced by a dmop. Changexc_domain_pin_memory_cacheattr()so that it is only defined whenXC_WANT_COMPAT_DEVICEMODEL_APIis set and have it call the new dmop. Leave the definitions of XEN_DOMCTL_MEM_CACHEATTR_* since they are still used by QEMU.snip>> diff --git
a/xen/include/public/domctl.hb/xen/include/public/domctl.hQuoted 11 lines
xen/include/public/domctl.h line 40
Quoted 8 lines
index a8921dd..30674d6 100644
xen/include/public/domctl.h +1
-1@@ -38,7 +38,7 @@#include "hvm/save.h" #include "memory.h" -#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010We bumped this to 0f in this development window so there is no need to do it again.
OK.
Quoted 10 lines
xen/include/public/domctl.h struct xen_domctl_ioport_mapping { · line 600
Quoted 7 lines
xen/include/public/domctl.h +0
-0/* * NB. xen_domctl.domain is an IN/OUT parameter for this operation. @@ -598,10 +598,6 @@ struct xen_domctl_ioport_mapping {#define XEN_DOMCTL_MEM_CACHEATTR_WB 6#define XEN_DOMCTL_MEM_CACHEATTR_UCM 7#define XEN_DOMCTL_DELETE_MEM_CACHEATTR (~(uint32_t)0)Any reason to not remove these #define's?
Quoted 4 lines
They're still used by QEMU at the moment. Removing them now would break the build. They can be removed once QEMU(s) have been switch to use the new XEN_DMOP_* #defines.
OK.
With the version bump removed:
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
In reply to Wei LiuQuoted 1 line
Quoted 1 line
Quoted 1 line
Wei Liu <[email protected]> 01/23/18 4:44 PM >>>
Quoted 6 lines · Ross Lagerwall
Quoted 6 lines
xen/include/public/domctl.h +0
-0@@ -38,7 +38,7 @@#include "hvm/save.h" #include "memory.h"
Quoted 6 lines
xen/include/public/domctl.h line 42
Quoted 3 lines
xen/include/public/domctl.h +1
-1-#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010We bumped this to 0f in this development window so there is no need to do it again.
As pointed out elsewhere (at least on two other threads meanwhile) whether to bump _again_ depends on the backporting plans of the domctl changes in the shim series. If 4.10 is to obtain those eventually, it should be _just_ that one change which goes under interface version 0xf.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
Quoted 15 lines · Jan Beulich
Quoted 1 line
Quoted 1 line
Quoted 1 line
Wei Liu <[email protected]> 01/23/18 4:44 PM >>>
Quoted 6 lines · Ross Lagerwall
Quoted 6 lines
xen/include/public/domctl.h +0
-0@@ -38,7 +38,7 @@#include "hvm/save.h" #include "memory.h" Quoted 6 lines
xen/include/public/domctl.h line 42
Quoted 3 lines
xen/include/public/domctl.h +1
-1-#define XEN_DOMCTL_INTERFACE_VERSION 0x0000000f +#define XEN_DOMCTL_INTERFACE_VERSION 0x00000010We bumped this to 0f in this development window so there is no need to do it again.
Quoted 4 lines
As pointed out elsewhere (at least on two other threads meanwhile) whether to bump _again_ depends on the backporting plans of the domctl changes in the shim series. If 4.10 is to obtain those eventually, it should be _just_ that one change which goes under interface version
0xf.
OK. This makes sense. My Rb still stands.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 6/6] x86/domctl: Remove XEN_DOMCTL_pin_mem_cacheattr
In reply to Ross LagerwallQuoted 10 lines
Quoted 1 line
Quoted 1 line · On 23.01.18 at 16:22, <[email protected]> wrote:
Remove the implementation of
XEN_DOMCTL_pin_mem_cacheattrsince it has been replaced by a dmop. Changexc_domain_pin_memory_cacheattr()so that it is only defined whenXC_WANT_COMPAT_DEVICEMODEL_APIis set and have it call the new dmop. Leave the definitions of XEN_DOMCTL_MEM_CACHEATTR_* since they are still used by QEMU.Signed-off-by Ross Lagerwall <[email protected]>Reviewed-by Paul Durrant <[email protected]>Acked-by Daniel De Graaf <[email protected]>
Non-XSM hypervisor parts
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 2/6] x86/hvm: Provide XEN_DMOP_relocate_memory
In reply to Ross LagerwallQuoted 6 lines
Quoted 1 line
Quoted 1 line · On 23.01.18 at 16:22, <[email protected]> wrote:
Provide
XEN_DMOP_relocate_memory, 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.
Quoted 7 lines
Signed-off-by Ross Lagerwall <[email protected]>Reviewed-by Paul Durrant <[email protected]>---
Changed in v4:
* Renamedadd_to_physmaptorelocate_memory.
* Instead of checking for overflow, handle using continuation.
Strictly speaking at least the latter change should have resulted in Paul's R-b to be dropped. But I'm pretty sure he's happy for it to be kept.
Quoted 12 lines
xen/include/public/hvm/dm_op.h +6
-0@@ -368,6 +368,23 @@ struct xen_dm_op_remote_shutdown {/* (Other reason values are not blocked) */ }; +/* +* XEN_DMOP_relocate_memory : Relocate GFNs for the specified guest. +* Identical to XENMEM_add_to_physmap with +* space == XENMAPSPACE_gmfn_range. +*/ +#define XEN_DMOP_relocate_memory 17
xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 386
Quoted 10 lines
xen/include/public/hvm/dm_op.h +10
-0+ +struct xen_dm_op_relocate_memory { +/* Number of GFNs to process. */ +uint32_t size; +uint32_t pad; +/* Starting GFN to relocate. */ +uint64_aligned_t src_gfn; +/* Starting GFN where GFNs should be relocated. */ +uint64_aligned_t dst_gfn; +};
Sadly additions after the initial introduction of dmop have been done without IN / OUT annotations, so I assume you not noticing such no neighboring declarations lead to you not adding any such here. I think we want to clarify though that due to the way the continuation logic above works, all fields are IN/OUT, with their ultimate OUT state undefined. I don't see a major problem adding a suitable comment while committing. With that added
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [PATCH v4 2/6] x86/hvm: Provide XEN_DMOP_relocate_memory
Quoted 23 lines
-----Original Message-----
From: Jan Beulich [mailto:[email protected]]
Sent: 24 January 2018 08:10
To: Ross Lagerwall <[email protected]>
Cc: Andrew Cooper <[email protected]>; Paul Durrant <[email protected]>; Wei Liu <[email protected]>; George Dunlap <[email protected]>; Ian Jackson <[email protected]>; Stefano Stabellini <[email protected]>; [email protected]; Konrad Rzeszutek Wilk <[email protected]>; Tim (Xen.org) <[email protected]>
Subject: Re: [PATCH v4 2/6] x86/hvm: ProvideXEN_DMOP_relocate_memoryQuoted 3 lines
Quoted 1 line
Quoted 1 line · On 23.01.18 at 16:22, <[email protected]> wrote:
Provide
XEN_DMOP_relocate_memory, a limited version ofXENMEM_add_to_physmapto allow a deprivileged QEMU to move VRAMwhen a
Quoted 7 lines
guest programs its BAR. It is equivalent to
XENMEM_add_to_physmapwith space ==XENMAPSPACE_gmfn_range.Signed-off-by Ross Lagerwall <[email protected]>Reviewed-by Paul Durrant <[email protected]>---
Quoted 7 lines
Quoted 3 lines
Changed in v4:
* Renamedadd_to_physmaptorelocate_memory.
* Instead of checking for overflow, handle using continuation.Strictly speaking at least the latter change should have resulted in Paul's R-b to be dropped. But I'm pretty sure he's happy for it to be kept.
FAOD, I am.
Paul
Quoted 31 lines
Quoted 13 lines
xen/include/public/hvm/dm_op.h +6
-0@@ -368,6 +368,23 @@ struct xen_dm_op_remote_shutdown {/* (Other reason values are not blocked) */ }; +/* +* XEN_DMOP_relocate_memory : Relocate GFNs for the specified guest. +* Identical to XENMEM_add_to_physmap with +* space == XENMAPSPACE_gmfn_range. +*/ +#define XEN_DMOP_relocate_memory 17xen/include/public/hvm/dm_op.h struct xen_dm_op_remote_shutdown { · line 386
Quoted 10 lines
xen/include/public/hvm/dm_op.h +10
-0+ +struct xen_dm_op_relocate_memory { +/* Number of GFNs to process. */ +uint32_t size; +uint32_t pad; +/* Starting GFN to relocate. */ +uint64_aligned_t src_gfn; +/* Starting GFN where GFNs should be relocated. */ +uint64_aligned_t dst_gfn; +};Sadly additions after the initial introduction of dmop have been done without IN / OUT annotations, so I assume you not noticing such no neighboring declarations lead to you not adding any such here. I think we want to clarify though that due to the way the continuation logic above works, all fields are IN/OUT, with their ultimate OUT state undefined. I don't see a major problem adding a suitable comment while committing. With that added
Quoted 3 lines
Reviewed-by Jan Beulich <[email protected]>Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 3 lines · Ross Lagerwall
The recently added support for restricting QEMU prevents use of the VGA console. This series addresses that by adding a couple of new dmops. A corresponding patch for QEMU is needed to make use of the new dmops.
Hi Ross,
Is there a patch for QEMU somewhere for the new dmops? Right now, QEMU
can not be build without magic (-DXC_WANT_COMPAT_DEVICEMODEL_API), there
is this error:hw/i386/xen/xen-hvm.c:411:5: error: implicit declaration of function ‘xc_domain_pin_memory_cacheattr’
Thanks,
Signature · 6 lines
Anthony PERARD _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 5 lines · Anthony PERARD
Quoted 3 lines · Ross Lagerwall
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.
Quoted 7 lines
Hi Ross,
Is there a patch for QEMU somewhere for the new dmops? Right now, QEMU
can not be build without magic (-DXC_WANT_COMPAT_DEVICEMODEL_API), there
is this error:hw/i386/xen/xen-hvm.c:411:5: error: implicit declaration of function ‘xc_domain_pin_memory_cacheattr’
That magic is passed when building QEMU within the Xen tree (I don't know why, it's ugly) so this is presumably when building QEMU by hand outside of the Xen build system?
The patch to make QEMU use the new dmops will be part of the next version of Ian's "xen: xen-domid-restrict improvements" patch series. In the meantime, you can find the patch here:
https://github.com/rosslagerwall/qemu/commit/37d58e0c8e9c6df7f7e2464a37d1de2675da7e81
Cheers,
Signature · 6 lines
Ross Lagerwall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel