Re: [Xen-devel] [PATCH v4 7/8] dm_op: convert HVMOP_inject_trap and HVMOP_inject_msi
> -Original Message- > From: Andrew Cooper > Sent: 20 January 2017 18:34 > To: Paul Durrant; xen-de...@lists.xenproject.org > Cc: Daniel De Graaf ; Ian Jackson > > Subject: Re: [PATCH v4 7/8] dm_op: convert HVMOP_inject_trap and > HVMOP_inject_msi > > On 17/01/17 17:29, Paul Durrant wrote: > > diff --git a/xen/include/public/hvm/dm_op.h > b/xen/include/public/hvm/dm_op.h > > index 8e9bef1..abe8bbe 100644 > > --- a/xen/include/public/hvm/dm_op.h > > +++ b/xen/include/public/hvm/dm_op.h > > @@ -273,6 +273,52 @@ struct xen_dm_op_set_mem_type { > > uint64_aligned_t first_pfn; > > }; > > > > +/* > > + * XEN_DMOP_inject_trap: Inject a trap into a VCPU, which will get taken > up > > + * when it is next scheduled. > > + * > > + * Note that the caller should know enough of the state of the CPU before > > + * injecting, to know what the effect of injecting the trap will be. > > + */ > > +#define XEN_DMOP_inject_trap 13 > > + > > +struct xen_dm_op_inject_trap { > > Along with internal fixing of the (mis)use of the term trap inside the > hypervisor, please s/trap/event/ in this new API. > Ok. > > +/* IN - index of vCPU */ > > +uint32_t vcpuid; > > +/* IN - interrupt vector */ > > +uint8_t vector; > > +/* IN - trap type (DMOP_TRAP_* ) */ > > +uint8_t type; > > +/* NB. This enumeration precisely matches hvm.h:X86_EVENTTYPE_* */ > > +# define XEN_DMOP_TRAP_ext_int0 /* external interrupt */ > > +# define XEN_DMOP_TRAP_nmi2 /* nmi */ > > +# define XEN_DMOP_TRAP_hw_exc 3 /* hardware exception */ > > +# define XEN_DMOP_TRAP_sw_int 4 /* software interrupt (CD nn) */ > > +# define XEN_DMOP_TRAP_pri_sw_exc 5 /* ICEBP (F1) */ > > +# define XEN_DMOP_TRAP_sw_exc 6 /* INT3 (CC), INTO (CE) */ > > +/* IN - enstruction length */ > > What is an enstruction? :) > That would be an historic speeling mistake that I cut'n'pasted :-) > Otherwise, Reviewed-by: Andrew Cooper Ta, Paul ___ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v4 7/8] dm_op: convert HVMOP_inject_trap and HVMOP_inject_msi
On 17/01/17 17:29, Paul Durrant wrote: > diff --git a/xen/include/public/hvm/dm_op.h b/xen/include/public/hvm/dm_op.h > index 8e9bef1..abe8bbe 100644 > --- a/xen/include/public/hvm/dm_op.h > +++ b/xen/include/public/hvm/dm_op.h > @@ -273,6 +273,52 @@ struct xen_dm_op_set_mem_type { > uint64_aligned_t first_pfn; > }; > > +/* > + * XEN_DMOP_inject_trap: Inject a trap into a VCPU, which will get taken up > + * when it is next scheduled. > + * > + * Note that the caller should know enough of the state of the CPU before > + * injecting, to know what the effect of injecting the trap will be. > + */ > +#define XEN_DMOP_inject_trap 13 > + > +struct xen_dm_op_inject_trap { Along with internal fixing of the (mis)use of the term trap inside the hypervisor, please s/trap/event/ in this new API. > +/* IN - index of vCPU */ > +uint32_t vcpuid; > +/* IN - interrupt vector */ > +uint8_t vector; > +/* IN - trap type (DMOP_TRAP_* ) */ > +uint8_t type; > +/* NB. This enumeration precisely matches hvm.h:X86_EVENTTYPE_* */ > +# define XEN_DMOP_TRAP_ext_int0 /* external interrupt */ > +# define XEN_DMOP_TRAP_nmi2 /* nmi */ > +# define XEN_DMOP_TRAP_hw_exc 3 /* hardware exception */ > +# define XEN_DMOP_TRAP_sw_int 4 /* software interrupt (CD nn) */ > +# define XEN_DMOP_TRAP_pri_sw_exc 5 /* ICEBP (F1) */ > +# define XEN_DMOP_TRAP_sw_exc 6 /* INT3 (CC), INTO (CE) */ > +/* IN - enstruction length */ What is an enstruction? :) Otherwise, Reviewed-by: Andrew Cooper___ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
Re: [Xen-devel] [PATCH v4 7/8] dm_op: convert HVMOP_inject_trap and HVMOP_inject_msi
On 01/17/2017 12:29 PM, Paul Durrant wrote: NOTE: This patch also modifies the types of the 'vector', 'type' and 'insn_len' arguments of xc_hvm_inject_trap() from uint32_t to uint8_t. In practice the values passed were always truncated to 8 bits. Suggested-by: Jan BeulichSigned-off-by: Paul Durrant Acked-by: Daniel De Graaf ___ Xen-devel mailing list Xen-devel@lists.xen.org https://lists.xen.org/xen-devel
[Xen-devel] [PATCH v4 7/8] dm_op: convert HVMOP_inject_trap and HVMOP_inject_msi
NOTE: This patch also modifies the types of the 'vector', 'type' and 'insn_len' arguments of xc_hvm_inject_trap() from uint32_t to uint8_t. In practice the values passed were always truncated to 8 bits. Suggested-by: Jan BeulichSigned-off-by: Paul Durrant --- Reviewed-by: Jan Beulich Cc: Daniel De Graaf Cc: Ian Jackson Acked-by: Wei Liu Cc: Andrew Cooper v3: - Fixed prefixing and padding. v2: - Addressed several comments from Jan. --- tools/flask/policy/modules/xen.if | 2 +- tools/libxc/include/xenctrl.h | 4 +- tools/libxc/xc_misc.c | 64 +++ xen/arch/x86/hvm/dm.c | 49 xen/arch/x86/hvm/hvm.c | 76 - xen/include/public/hvm/dm_op.h | 48 +++ xen/include/public/hvm/hvm_op.h | 45 -- xen/include/xsm/dummy.h | 6 --- xen/include/xsm/xsm.h | 6 --- xen/xsm/dummy.c | 1 - xen/xsm/flask/hooks.c | 6 --- xen/xsm/flask/policy/access_vectors | 5 +-- 12 files changed, 124 insertions(+), 188 deletions(-) diff --git a/tools/flask/policy/modules/xen.if b/tools/flask/policy/modules/xen.if index 092a6c5..45e5cea 100644 --- a/tools/flask/policy/modules/xen.if +++ b/tools/flask/policy/modules/xen.if @@ -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 send_irq dm }; + allow $1 $2_target:hvm { getparam setparam hvmctl cacheattr dm }; ') # make_device_model(priv, dm_dom, hvm_dom) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 13431bb..539cc69 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1641,8 +1641,8 @@ int xc_hvm_set_mem_type( * resumes. */ int xc_hvm_inject_trap( -xc_interface *xch, domid_t dom, int vcpu, uint32_t vector, -uint32_t type, uint32_t error_code, uint32_t insn_len, +xc_interface *xch, domid_t dom, int vcpu, uint8_t vector, +uint8_t type, uint32_t error_code, uint8_t insn_len, uint64_t cr2); /* diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c index 5b06d6b..98ab826 100644 --- a/tools/libxc/xc_misc.c +++ b/tools/libxc/xc_misc.c @@ -527,29 +527,20 @@ int xc_hvm_set_pci_link_route( } int xc_hvm_inject_msi( -xc_interface *xch, domid_t dom, uint64_t addr, uint32_t data) +xc_interface *xch, domid_t dom, uint64_t msi_addr, uint32_t msi_data) { -DECLARE_HYPERCALL_BUFFER(struct xen_hvm_inject_msi, arg); -int rc; - -arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg)); -if ( arg == NULL ) -{ -PERROR("Could not allocate memory for xc_hvm_inject_msi hypercall"); -return -1; -} +struct xen_dm_op op; +struct xen_dm_op_inject_msi *data; -arg->domid = dom; -arg->addr = addr; -arg->data = data; +memset(, 0, sizeof(op)); -rc = xencall2(xch->xcall, __HYPERVISOR_hvm_op, - HVMOP_inject_msi, - HYPERCALL_BUFFER_AS_ARG(arg)); +op.op = XEN_DMOP_inject_msi; +data = _msi; -xc_hypercall_buffer_free(xch, arg); +data->addr = msi_addr; +data->data = msi_data; -return rc; +return do_dm_op(xch, dom, 1, , sizeof(op)); } int xc_hvm_track_dirty_vram( @@ -608,35 +599,26 @@ int xc_hvm_set_mem_type( } int xc_hvm_inject_trap( -xc_interface *xch, domid_t dom, int vcpu, uint32_t vector, -uint32_t type, uint32_t error_code, uint32_t insn_len, +xc_interface *xch, domid_t dom, int vcpu, uint8_t vector, +uint8_t type, uint32_t error_code, uint8_t insn_len, uint64_t cr2) { -DECLARE_HYPERCALL_BUFFER(struct xen_hvm_inject_trap, arg); -int rc; - -arg = xc_hypercall_buffer_alloc(xch, arg, sizeof(*arg)); -if ( arg == NULL ) -{ -PERROR("Could not allocate memory for xc_hvm_inject_trap hypercall"); -return -1; -} +struct xen_dm_op op; +struct xen_dm_op_inject_trap *data; -arg->domid = dom; -arg->vcpuid = vcpu; -arg->vector = vector; -arg->type= type; -arg->error_code = error_code; -arg->insn_len= insn_len; -arg->cr2 = cr2; +memset(, 0, sizeof(op)); -rc = xencall2(xch->xcall, __HYPERVISOR_hvm_op, - HVMOP_inject_trap, - HYPERCALL_BUFFER_AS_ARG(arg)); +op.op = XEN_DMOP_inject_trap; +data = _trap; -xc_hypercall_buffer_free(xch, arg); +data->vcpuid = vcpu; +data->vector = vector; +data->type = type; +data->error_code = error_code; +