From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Jan Beulich" Subject: [PATCH v2 07/11] hvmctl: convert HVMOP_set_mem_type Date: Fri, 24 Jun 2016 04:32:23 -0600 Message-ID: <576D285702000078000F8704@prv-mh.provo.novell.com> References: <576D25DA02000078000F86C2@prv-mh.provo.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__Part794F4E27.3__=" Return-path: Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bGOPU-00047j-PC for xen-devel@lists.xenproject.org; Fri, 24 Jun 2016 10:32:28 +0000 In-Reply-To: <576D25DA02000078000F86C2@prv-mh.provo.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" To: xen-devel Cc: Stefano Stabellini , Wei Liu , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , dgdegra@tycho.nsa.gov List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__Part794F4E27.3__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline This allows elimination of the (ab)use of the high operation number bits for encoding continuations. Also limiting "nr" at the libxc level to 32 bits (the high 32 bits of the previous 64-bit parameter got ignore so far). Signed-off-by: Jan Beulich Reviewed-by: Wei Liu Reviewed-by: Andrew Cooper --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1627,7 +1627,8 @@ int xc_hvm_modified_memory( * Allowed types are HVMMEM_ram_rw, HVMMEM_ram_ro, HVMMEM_mmio_dm */ int xc_hvm_set_mem_type( - xc_interface *xch, domid_t dom, hvmmem_type_t memtype, uint64_t = first_pfn, uint64_t nr); + xc_interface *xch, domid_t dom, hvmmem_type_t memtype, + uint64_t first_gfn, uint32_t nr); =20 /* * Injects a hardware/software CPU trap, to take effect the next time the = HVM=20 --- a/tools/libxc/xc_misc.c +++ b/tools/libxc/xc_misc.c @@ -568,30 +568,15 @@ int xc_hvm_modified_memory( } =20 int xc_hvm_set_mem_type( - xc_interface *xch, domid_t dom, hvmmem_type_t mem_type, uint64_t = first_pfn, uint64_t nr) + xc_interface *xch, domid_t dom, hvmmem_type_t mem_type, + uint64_t first_gfn, uint32_t nr) { - DECLARE_HYPERCALL_BUFFER(struct xen_hvm_set_mem_type, arg); - int rc; + DECLARE_HVMCTL(set_mem_type, dom, + .hvmmem_type =3D mem_type, + .first_gfn =3D first_gfn, + .nr =3D nr); =20 - arg =3D xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg)); - if ( arg =3D=3D NULL ) - { - PERROR("Could not allocate memory for xc_hvm_set_mem_type = hypercall"); - return -1; - } - - arg->domid =3D dom; - arg->hvmmem_type =3D mem_type; - arg->first_pfn =3D first_pfn; - arg->nr =3D nr; - - rc =3D xencall2(xch->xcall, __HYPERVISOR_hvm_op, - HVMOP_set_mem_type, - HYPERCALL_BUFFER_AS_ARG(arg)); - - xc_hypercall_buffer_free(xch, arg); - - return rc; + return do_hvmctl(xch, &hvmctl); } =20 int xc_hvm_inject_trap( --- a/xen/arch/x86/hvm/control.c +++ b/xen/arch/x86/hvm/control.c @@ -136,6 +136,70 @@ static int modified_memory(struct domain return 0; } =20 +static int set_mem_type(struct domain *d, + const struct xen_hvm_set_mem_type *op, uint64_t = *iter) +{ + /* Interface types to internal p2m types. */ + static const p2m_type_t memtype[] =3D { + [HVMMEM_ram_rw] =3D p2m_ram_rw, + [HVMMEM_ram_ro] =3D p2m_ram_ro, + [HVMMEM_mmio_dm] =3D p2m_mmio_dm, + [HVMMEM_unused] =3D p2m_invalid + }; + + if ( !is_hvm_domain(d) ) + return -EINVAL; + + if ( op->rsvd || op->nr < *iter || + ((op->first_gfn + op->nr - 1) < op->first_gfn) || + ((op->first_gfn + op->nr - 1) > domain_get_maximum_gpfn(d)) ) + return -EINVAL; + + if ( op->hvmmem_type >=3D ARRAY_SIZE(memtype) || + unlikely(op->hvmmem_type =3D=3D HVMMEM_unused) ) + return -EINVAL; + + while ( op->nr > *iter ) + { + unsigned long gfn =3D op->first_gfn + *iter; + p2m_type_t t; + int rc; + + get_gfn_unshare(d, gfn, &t); + + if ( p2m_is_paging(t) ) + { + put_gfn(d, gfn); + p2m_mem_paging_populate(d, gfn); + return -EAGAIN; + } + + if ( p2m_is_shared(t) ) + rc =3D -EAGAIN; + else if ( !p2m_is_ram(t) && + (!p2m_is_hole(t) || op->hvmmem_type !=3D HVMMEM_mmio_dm)= && + (t !=3D p2m_mmio_write_dm || op->hvmmem_type !=3D = HVMMEM_ram_rw) ) + rc =3D -EINVAL; + else + rc =3D p2m_change_type_one(d, gfn, t, memtype[op->hvmmem_type]= ); + + put_gfn(d, gfn); + + if ( rc ) + return rc; + + /* + * Check for continuation every once in a while, and if it's not = the + * last interation. + */ + if ( op->nr > ++*iter && !(*iter & 0xff) && + hypercall_preempt_check() ) + return -ERESTART; + } + + return 0; +} + long do_hvmctl(XEN_GUEST_HANDLE_PARAM(xen_hvmctl_t) u_hvmctl) { xen_hvmctl_t op; @@ -190,6 +254,10 @@ long do_hvmctl(XEN_GUEST_HANDLE_PARAM(xe rc =3D modified_memory(d, &op.u.modified_memory, &op.opaque); break; =20 + case XEN_HVMCTL_set_mem_type: + rc =3D set_mem_type(d, &op.u.set_mem_type, &op.opaque); + break; + default: rc =3D -EOPNOTSUPP; break; --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -5215,31 +5215,11 @@ static int do_altp2m_op( return rc; } =20 -/* - * Note that this value is effectively part of the ABI, even if we don't = need - * to make it a formal part of it: A guest suspended for migration in the - * middle of a continuation would fail to work if resumed on a hypervisor - * using a different value. - */ -#define HVMOP_op_mask 0xff - long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg) { - unsigned long start_iter, mask; long rc =3D 0; =20 - switch ( op & HVMOP_op_mask ) - { - default: - mask =3D ~0UL; - break; - case HVMOP_set_mem_type: - mask =3D HVMOP_op_mask; - break; - } - - start_iter =3D op & ~mask; - switch ( op &=3D mask ) + switch ( op ) { case HVMOP_create_ioreq_server: rc =3D hvmop_create_ioreq_server( @@ -5339,92 +5319,6 @@ long do_hvm_op(unsigned long op, XEN_GUE break; } =20 - case HVMOP_set_mem_type: - { - struct xen_hvm_set_mem_type a; - struct domain *d; - =20 - /* Interface types to internal p2m types */ - static const p2m_type_t memtype[] =3D { - [HVMMEM_ram_rw] =3D p2m_ram_rw, - [HVMMEM_ram_ro] =3D p2m_ram_ro, - [HVMMEM_mmio_dm] =3D p2m_mmio_dm, - [HVMMEM_unused] =3D p2m_invalid - }; - - if ( copy_from_guest(&a, arg, 1) ) - return -EFAULT; - - rc =3D rcu_lock_remote_domain_by_id(a.domid, &d); - if ( rc !=3D 0 ) - return rc; - - rc =3D -EINVAL; - if ( !is_hvm_domain(d) ) - goto setmemtype_fail; - - rc =3D xsm_hvm_control(XSM_DM_PRIV, d, op); - if ( rc ) - goto setmemtype_fail; - - rc =3D -EINVAL; - if ( a.nr < start_iter || - ((a.first_pfn + a.nr - 1) < a.first_pfn) || - ((a.first_pfn + a.nr - 1) > domain_get_maximum_gpfn(d)) ) - goto setmemtype_fail; - =20 - if ( a.hvmmem_type >=3D ARRAY_SIZE(memtype) || - unlikely(a.hvmmem_type =3D=3D HVMMEM_unused) ) - goto setmemtype_fail; - - while ( a.nr > start_iter ) - { - unsigned long pfn =3D a.first_pfn + start_iter; - p2m_type_t t; - - get_gfn_unshare(d, pfn, &t); - if ( p2m_is_paging(t) ) - { - put_gfn(d, pfn); - p2m_mem_paging_populate(d, pfn); - rc =3D -EAGAIN; - goto setmemtype_fail; - } - if ( p2m_is_shared(t) ) - { - put_gfn(d, pfn); - rc =3D -EAGAIN; - goto setmemtype_fail; - } - if ( !p2m_is_ram(t) && - (!p2m_is_hole(t) || a.hvmmem_type !=3D HVMMEM_mmio_dm) = && - (t !=3D p2m_mmio_write_dm || a.hvmmem_type !=3D = HVMMEM_ram_rw) ) - { - put_gfn(d, pfn); - goto setmemtype_fail; - } - - rc =3D p2m_change_type_one(d, pfn, t, memtype[a.hvmmem_type]);= - put_gfn(d, pfn); - if ( rc ) - goto setmemtype_fail; - - /* Check for continuation if it's not the last interation */ - if ( a.nr > ++start_iter && !(start_iter & HVMOP_op_mask) && - hypercall_preempt_check() ) - { - rc =3D -ERESTART; - goto setmemtype_fail; - } - } - - rc =3D 0; - - setmemtype_fail: - rcu_unlock_domain(d); - break; - } - case HVMOP_pagetable_dying: { struct xen_hvm_pagetable_dying a; @@ -5533,13 +5427,6 @@ long do_hvm_op(unsigned long op, XEN_GUE } } =20 - if ( rc =3D=3D -ERESTART ) - { - ASSERT(!(start_iter & mask)); - rc =3D hypercall_create_continuation(__HYPERVISOR_hvm_op, "lh", - op | start_iter, arg); - } - return rc; } =20 --- a/xen/include/public/hvm/control.h +++ b/xen/include/public/hvm/control.h @@ -77,6 +77,18 @@ struct xen_hvm_modified_memory { uint64_aligned_t first_gfn; }; =20 +/* XEN_HVMCTL_set_mem_type */ +/* Notify that a region of memory is to be treated in a specific way. */ +struct xen_hvm_set_mem_type { + /* Memory type. */ + uint16_t hvmmem_type; + uint16_t rsvd; + /* Number of pages. */ + uint32_t nr; + /* First GFN. */ + uint64_aligned_t first_gfn; +}; + struct xen_hvmctl { uint16_t interface_version; /* XEN_HVMCTL_INTERFACE_VERSION */ domid_t domain; @@ -86,6 +98,7 @@ struct xen_hvmctl { #define XEN_HVMCTL_set_pci_link_route 3 #define XEN_HVMCTL_track_dirty_vram 4 #define XEN_HVMCTL_modified_memory 5 +#define XEN_HVMCTL_set_mem_type 6 uint64_t opaque; /* Must be zero on initial invocation. = */ union { struct xen_hvm_set_pci_intx_level set_pci_intx_level; @@ -93,6 +106,7 @@ struct xen_hvmctl { struct xen_hvm_set_pci_link_route set_pci_link_route; struct xen_hvm_track_dirty_vram track_dirty_vram; struct xen_hvm_modified_memory modified_memory; + struct xen_hvm_set_mem_type set_mem_type; uint8_t pad[120]; } u; }; --- a/xen/include/public/hvm/hvm_op.h +++ b/xen/include/public/hvm/hvm_op.h @@ -95,26 +95,6 @@ typedef enum { #endif } hvmmem_type_t; =20 -/* Following tools-only interfaces may change in future. */ -#if defined(__XEN__) || defined(__XEN_TOOLS__) - -#define HVMOP_set_mem_type 8 -/* Notify that a region of memory is to be treated in a specific way. */ -struct xen_hvm_set_mem_type { - /* Domain to be updated. */ - domid_t domid; - /* Memory type */ - uint16_t hvmmem_type; - /* Number of pages. */ - uint32_t nr; - /* First pfn. */ - uint64_aligned_t first_pfn; -}; -typedef struct xen_hvm_set_mem_type xen_hvm_set_mem_type_t; -DEFINE_XEN_GUEST_HANDLE(xen_hvm_set_mem_type_t); - -#endif /* defined(__XEN__) || defined(__XEN_TOOLS__) */ - /* Hint from PV drivers for pagetable destruction. */ #define HVMOP_pagetable_dying 9 struct xen_hvm_pagetable_dying { --- a/xen/xsm/flask/policy/access_vectors +++ b/xen/xsm/flask/policy/access_vectors @@ -272,7 +272,7 @@ class hvm cacheattr # XEN_HVMCTL_track_dirty_vram trackdirtyvram -# XEN_HVMCTL_modified_memory, HVMOP_get_mem_type, HVMOP_set_mem_type, +# XEN_HVMCTL_modified_memory, HVMOP_get_mem_type, XEN_HVMCTL_set_mem_type,= # HVMOP_set_mem_access, HVMOP_get_mem_access, HVMOP_pagetable_dying, # HVMOP_inject_trap hvmctl --=__Part794F4E27.3__= Content-Type: text/plain; name="hvmctl-06.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="hvmctl-06.patch" hvmctl: convert HVMOP_set_mem_type=0A=0AThis allows elimination of the = (ab)use of the high operation number=0Abits for encoding continuations.=0A= =0AAlso limiting "nr" at the libxc level to 32 bits (the high 32 bits = of=0Athe previous 64-bit parameter got ignore so far).=0A=0ASigned-off-by: = Jan Beulich =0AReviewed-by: Wei Liu =0AReviewed-by: Andrew Cooper =0A=0A--- = a/tools/libxc/include/xenctrl.h=0A+++ b/tools/libxc/include/xenctrl.h=0A@@ = -1627,7 +1627,8 @@ int xc_hvm_modified_memory(=0A * Allowed types are = HVMMEM_ram_rw, HVMMEM_ram_ro, HVMMEM_mmio_dm=0A */=0A int xc_hvm_set_mem_t= ype(=0A- xc_interface *xch, domid_t dom, hvmmem_type_t memtype, = uint64_t first_pfn, uint64_t nr);=0A+ xc_interface *xch, domid_t dom, = hvmmem_type_t memtype,=0A+ uint64_t first_gfn, uint32_t nr);=0A =0A = /*=0A * Injects a hardware/software CPU trap, to take effect the next = time the HVM =0A--- a/tools/libxc/xc_misc.c=0A+++ b/tools/libxc/xc_misc.c= =0A@@ -568,30 +568,15 @@ int xc_hvm_modified_memory(=0A }=0A =0A int = xc_hvm_set_mem_type(=0A- xc_interface *xch, domid_t dom, hvmmem_type_t = mem_type, uint64_t first_pfn, uint64_t nr)=0A+ xc_interface *xch, = domid_t dom, hvmmem_type_t mem_type,=0A+ uint64_t first_gfn, uint32_t = nr)=0A {=0A- DECLARE_HYPERCALL_BUFFER(struct xen_hvm_set_mem_type, = arg);=0A- int rc;=0A+ DECLARE_HVMCTL(set_mem_type, dom,=0A+ = .hvmmem_type =3D mem_type,=0A+ .first_gfn =3D = first_gfn,=0A+ .nr =3D nr);=0A =0A- arg =3D = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg));=0A- if ( arg =3D=3D = NULL )=0A- {=0A- PERROR("Could not allocate memory for xc_hvm_set= _mem_type hypercall");=0A- return -1;=0A- }=0A-=0A- arg->domid= =3D dom;=0A- arg->hvmmem_type =3D mem_type;=0A- arg->first_p= fn =3D first_pfn;=0A- arg->nr =3D nr;=0A-=0A- rc =3D = xencall2(xch->xcall, __HYPERVISOR_hvm_op,=0A- HVMOP_set_me= m_type,=0A- HYPERCALL_BUFFER_AS_ARG(arg));=0A-=0A- = xc_hypercall_buffer_free(xch, arg);=0A-=0A- return rc;=0A+ return = do_hvmctl(xch, &hvmctl);=0A }=0A =0A int xc_hvm_inject_trap(=0A--- = a/xen/arch/x86/hvm/control.c=0A+++ b/xen/arch/x86/hvm/control.c=0A@@ = -136,6 +136,70 @@ static int modified_memory(struct domain=0A return = 0;=0A }=0A =0A+static int set_mem_type(struct domain *d,=0A+ = const struct xen_hvm_set_mem_type *op, uint64_t *iter)=0A+{=0A+ = /* Interface types to internal p2m types. */=0A+ static const = p2m_type_t memtype[] =3D {=0A+ [HVMMEM_ram_rw] =3D p2m_ram_rw,=0A+ = [HVMMEM_ram_ro] =3D p2m_ram_ro,=0A+ [HVMMEM_mmio_dm] =3D = p2m_mmio_dm,=0A+ [HVMMEM_unused] =3D p2m_invalid=0A+ };=0A+=0A+ = if ( !is_hvm_domain(d) )=0A+ return -EINVAL;=0A+=0A+ if ( = op->rsvd || op->nr < *iter ||=0A+ ((op->first_gfn + op->nr - 1) < = op->first_gfn) ||=0A+ ((op->first_gfn + op->nr - 1) > domain_get_ma= ximum_gpfn(d)) )=0A+ return -EINVAL;=0A+=0A+ if ( op->hvmmem_type= >=3D ARRAY_SIZE(memtype) ||=0A+ unlikely(op->hvmmem_type =3D=3D = HVMMEM_unused) )=0A+ return -EINVAL;=0A+=0A+ while ( op->nr > = *iter )=0A+ {=0A+ unsigned long gfn =3D op->first_gfn + = *iter;=0A+ p2m_type_t t;=0A+ int rc;=0A+=0A+ = get_gfn_unshare(d, gfn, &t);=0A+=0A+ if ( p2m_is_paging(t) )=0A+ = {=0A+ put_gfn(d, gfn);=0A+ p2m_mem_paging_populat= e(d, gfn);=0A+ return -EAGAIN;=0A+ }=0A+=0A+ if ( = p2m_is_shared(t) )=0A+ rc =3D -EAGAIN;=0A+ else if ( = !p2m_is_ram(t) &&=0A+ (!p2m_is_hole(t) || op->hvmmem_type = !=3D HVMMEM_mmio_dm) &&=0A+ (t !=3D p2m_mmio_write_dm || = op->hvmmem_type !=3D HVMMEM_ram_rw) )=0A+ rc =3D -EINVAL;=0A+ = else=0A+ rc =3D p2m_change_type_one(d, gfn, t, memtype[op->= hvmmem_type]);=0A+=0A+ put_gfn(d, gfn);=0A+=0A+ if ( rc = )=0A+ return rc;=0A+=0A+ /*=0A+ * Check for = continuation every once in a while, and if it's not the=0A+ * last = interation.=0A+ */=0A+ if ( op->nr > ++*iter && !(*iter & = 0xff) &&=0A+ hypercall_preempt_check() )=0A+ return = -ERESTART;=0A+ }=0A+=0A+ return 0;=0A+}=0A+=0A long do_hvmctl(XEN_GUE= ST_HANDLE_PARAM(xen_hvmctl_t) u_hvmctl)=0A {=0A xen_hvmctl_t op;=0A@@ = -190,6 +254,10 @@ long do_hvmctl(XEN_GUEST_HANDLE_PARAM(xe=0A rc = =3D modified_memory(d, &op.u.modified_memory, &op.opaque);=0A = break;=0A =0A+ case XEN_HVMCTL_set_mem_type:=0A+ rc =3D = set_mem_type(d, &op.u.set_mem_type, &op.opaque);=0A+ break;=0A+=0A = default:=0A rc =3D -EOPNOTSUPP;=0A break;=0A--- = a/xen/arch/x86/hvm/hvm.c=0A+++ b/xen/arch/x86/hvm/hvm.c=0A@@ -5215,31 = +5215,11 @@ static int do_altp2m_op(=0A return rc;=0A }=0A =0A-/*=0A- = * Note that this value is effectively part of the ABI, even if we don't = need=0A- * to make it a formal part of it: A guest suspended for migration = in the=0A- * middle of a continuation would fail to work if resumed on a = hypervisor=0A- * using a different value.=0A- */=0A-#define HVMOP_op_mask = 0xff=0A-=0A long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) = arg)=0A {=0A- unsigned long start_iter, mask;=0A long rc =3D 0;=0A = =0A- switch ( op & HVMOP_op_mask )=0A- {=0A- default:=0A- = mask =3D ~0UL;=0A- break;=0A- case HVMOP_set_mem_type:=0A- = mask =3D HVMOP_op_mask;=0A- break;=0A- }=0A-=0A- start_iter = =3D op & ~mask;=0A- switch ( op &=3D mask )=0A+ switch ( op )=0A = {=0A case HVMOP_create_ioreq_server:=0A rc =3D hvmop_create_ior= eq_server(=0A@@ -5339,92 +5319,6 @@ long do_hvm_op(unsigned long op, = XEN_GUE=0A break;=0A }=0A =0A- case HVMOP_set_mem_type:=0A- = {=0A- struct xen_hvm_set_mem_type a;=0A- struct domain = *d;=0A- =0A- /* Interface types to internal p2m types */=0A- = static const p2m_type_t memtype[] =3D {=0A- [HVMMEM_ram_r= w] =3D p2m_ram_rw,=0A- [HVMMEM_ram_ro] =3D p2m_ram_ro,=0A- = [HVMMEM_mmio_dm] =3D p2m_mmio_dm,=0A- [HVMMEM_unused] = =3D p2m_invalid=0A- };=0A-=0A- if ( copy_from_guest(&a, arg, = 1) )=0A- return -EFAULT;=0A-=0A- rc =3D rcu_lock_remote_d= omain_by_id(a.domid, &d);=0A- if ( rc !=3D 0 )=0A- = return rc;=0A-=0A- rc =3D -EINVAL;=0A- if ( !is_hvm_domain(d)= )=0A- goto setmemtype_fail;=0A-=0A- rc =3D xsm_hvm_contr= ol(XSM_DM_PRIV, d, op);=0A- if ( rc )=0A- goto setmemtype= _fail;=0A-=0A- rc =3D -EINVAL;=0A- if ( a.nr < start_iter = ||=0A- ((a.first_pfn + a.nr - 1) < a.first_pfn) ||=0A- = ((a.first_pfn + a.nr - 1) > domain_get_maximum_gpfn(d)) )=0A- = goto setmemtype_fail;=0A- =0A- if ( a.hvmmem_type >=3D = ARRAY_SIZE(memtype) ||=0A- unlikely(a.hvmmem_type =3D=3D = HVMMEM_unused) )=0A- goto setmemtype_fail;=0A-=0A- while = ( a.nr > start_iter )=0A- {=0A- unsigned long pfn =3D = a.first_pfn + start_iter;=0A- p2m_type_t t;=0A-=0A- = get_gfn_unshare(d, pfn, &t);=0A- if ( p2m_is_paging(t) )=0A- = {=0A- put_gfn(d, pfn);=0A- p2m_mem_pa= ging_populate(d, pfn);=0A- rc =3D -EAGAIN;=0A- = goto setmemtype_fail;=0A- }=0A- if ( p2m_is_shared(= t) )=0A- {=0A- put_gfn(d, pfn);=0A- = rc =3D -EAGAIN;=0A- goto setmemtype_fail;=0A- = }=0A- if ( !p2m_is_ram(t) &&=0A- (!p2m_is_hole(t= ) || a.hvmmem_type !=3D HVMMEM_mmio_dm) &&=0A- (t !=3D = p2m_mmio_write_dm || a.hvmmem_type !=3D HVMMEM_ram_rw) )=0A- = {=0A- put_gfn(d, pfn);=0A- goto setmemtype_fa= il;=0A- }=0A-=0A- rc =3D p2m_change_type_one(d, pfn, = t, memtype[a.hvmmem_type]);=0A- put_gfn(d, pfn);=0A- = if ( rc )=0A- goto setmemtype_fail;=0A-=0A- /* = Check for continuation if it's not the last interation */=0A- = if ( a.nr > ++start_iter && !(start_iter & HVMOP_op_mask) &&=0A- = hypercall_preempt_check() )=0A- {=0A- rc = =3D -ERESTART;=0A- goto setmemtype_fail;=0A- = }=0A- }=0A-=0A- rc =3D 0;=0A-=0A- setmemtype_fail:=0A- = rcu_unlock_domain(d);=0A- break;=0A- }=0A-=0A case = HVMOP_pagetable_dying:=0A {=0A struct xen_hvm_pagetable_dying = a;=0A@@ -5533,13 +5427,6 @@ long do_hvm_op(unsigned long op, XEN_GUE=0A = }=0A }=0A =0A- if ( rc =3D=3D -ERESTART )=0A- {=0A- = ASSERT(!(start_iter & mask));=0A- rc =3D hypercall_create_continuati= on(__HYPERVISOR_hvm_op, "lh",=0A- = op | start_iter, arg);=0A- }=0A-=0A return rc;=0A }=0A =0A--- = a/xen/include/public/hvm/control.h=0A+++ b/xen/include/public/hvm/control.h= =0A@@ -77,6 +77,18 @@ struct xen_hvm_modified_memory {=0A uint64_aligne= d_t first_gfn;=0A };=0A =0A+/* XEN_HVMCTL_set_mem_type */=0A+/* Notify = that a region of memory is to be treated in a specific way. */=0A+struct = xen_hvm_set_mem_type {=0A+ /* Memory type. */=0A+ uint16_t hvmmem_typ= e;=0A+ uint16_t rsvd;=0A+ /* Number of pages. */=0A+ uint32_t = nr;=0A+ /* First GFN. */=0A+ uint64_aligned_t first_gfn;=0A+};=0A+=0A= struct xen_hvmctl {=0A uint16_t interface_version; /* XEN_HVMCTL_IN= TERFACE_VERSION */=0A domid_t domain;=0A@@ -86,6 +98,7 @@ struct = xen_hvmctl {=0A #define XEN_HVMCTL_set_pci_link_route 3=0A = #define XEN_HVMCTL_track_dirty_vram 4=0A #define XEN_HVMCTL_mo= dified_memory 5=0A+#define XEN_HVMCTL_set_mem_type = 6=0A uint64_t opaque; /* Must be zero on initial = invocation. */=0A union {=0A struct xen_hvm_set_pci_intx_level = set_pci_intx_level;=0A@@ -93,6 +106,7 @@ struct xen_hvmctl {=0A = struct xen_hvm_set_pci_link_route set_pci_link_route;=0A struct = xen_hvm_track_dirty_vram track_dirty_vram;=0A struct xen_hvm_modifi= ed_memory modified_memory;=0A+ struct xen_hvm_set_mem_type = set_mem_type;=0A uint8_t pad[120];=0A } u;=0A };=0A--- = a/xen/include/public/hvm/hvm_op.h=0A+++ b/xen/include/public/hvm/hvm_op.h= =0A@@ -95,26 +95,6 @@ typedef enum {=0A #endif=0A } hvmmem_type_t;=0A = =0A-/* Following tools-only interfaces may change in future. */=0A-#if = defined(__XEN__) || defined(__XEN_TOOLS__)=0A-=0A-#define HVMOP_set_mem_typ= e 8=0A-/* Notify that a region of memory is to be treated in a specific = way. */=0A-struct xen_hvm_set_mem_type {=0A- /* Domain to be updated. = */=0A- domid_t domid;=0A- /* Memory type */=0A- uint16_t = hvmmem_type;=0A- /* Number of pages. */=0A- uint32_t nr;=0A- /* = First pfn. */=0A- uint64_aligned_t first_pfn;=0A-};=0A-typedef struct = xen_hvm_set_mem_type xen_hvm_set_mem_type_t;=0A-DEFINE_XEN_GUEST_HANDLE(xen= _hvm_set_mem_type_t);=0A-=0A-#endif /* defined(__XEN__) || defined(__XEN_TO= OLS__) */=0A-=0A /* Hint from PV drivers for pagetable destruction. */=0A = #define HVMOP_pagetable_dying 9=0A struct xen_hvm_pagetable_dying = {=0A--- a/xen/xsm/flask/policy/access_vectors=0A+++ b/xen/xsm/flask/policy/= access_vectors=0A@@ -272,7 +272,7 @@ class hvm=0A cacheattr=0A # = XEN_HVMCTL_track_dirty_vram=0A trackdirtyvram=0A-# XEN_HVMCTL_modified_= memory, HVMOP_get_mem_type, HVMOP_set_mem_type,=0A+# XEN_HVMCTL_modified_me= mory, HVMOP_get_mem_type, XEN_HVMCTL_set_mem_type,=0A # HVMOP_set_mem_acces= s, HVMOP_get_mem_access, HVMOP_pagetable_dying,=0A # HVMOP_inject_trap=0A = hvmctl=0A --=__Part794F4E27.3__= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Disposition: inline X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18KWGVuLWRldmVs IG1haWxpbmcgbGlzdApYZW4tZGV2ZWxAbGlzdHMueGVuLm9yZwpodHRwOi8vbGlzdHMueGVuLm9y Zy94ZW4tZGV2ZWwK --=__Part794F4E27.3__=--