[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH 2/9] vm_event: Define VM_EVENT type
On 30/05/2019 07:18, Petre Pircalabu wrote: > diff --git a/tools/libxc/xc_vm_event.c b/tools/libxc/xc_vm_event.c > index ea10366..3b1018b 100644 > --- a/tools/libxc/xc_vm_event.c > +++ b/tools/libxc/xc_vm_event.c > @@ -23,29 +23,54 @@ > #include "xc_private.h" > > int xc_vm_event_control(xc_interface *xch, uint32_t domain_id, unsigned int > op, > - unsigned int mode) > + unsigned int type) > { > DECLARE_DOMCTL; > > domctl.cmd = XEN_DOMCTL_vm_event_op; > domctl.domain = domain_id; > domctl.u.vm_event_op.op = op; > - domctl.u.vm_event_op.mode = mode; > + domctl.u.vm_event_op.type = type; > > return do_domctl(xch, &domctl); > } > > -void *xc_vm_event_enable(xc_interface *xch, uint32_t domain_id, int param, > +static int xc_vm_event_ring_pfn_param(int type, int *param) > +{ > + if ( !param ) > + return -EINVAL; > + > + switch ( type ) > + { > + case XEN_VM_EVENT_TYPE_PAGING: > + *param = HVM_PARAM_PAGING_RING_PFN; > + break; > + > + case XEN_VM_EVENT_TYPE_MONITOR: > + *param = HVM_PARAM_MONITOR_RING_PFN; > + break; > + > + case XEN_VM_EVENT_TYPE_SHARING: > + *param = HVM_PARAM_SHARING_RING_PFN; > + break; > + > + default: > + return -EINVAL; > + } > + > + return 0; > +} This is an internal helper, so can reasonably be expected to not be called with junk, and can do away with the param pointer. Something like static int xc_vm_event_ring_pfn_param(unsigned int type) { switch ( type ) { case XEN_VM_EVENT_TYPE_PAGING: return HVM_PARAM_PAGING_RING_PFN; ... default: return -EINVAL; } } will work fine because HVM_PARAM_* are all tiny unsigned integers in practice. It also has a more sensible API for the caller. > diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h > index 19486d5..19281fa 100644 > --- a/xen/include/public/domctl.h > +++ b/xen/include/public/domctl.h > @@ -769,80 +769,18 @@ struct xen_domctl_gdbsx_domstatus { > * VM event operations > */ > > -/* XEN_DOMCTL_vm_event_op */ > - > -/* > - * There are currently three rings available for VM events: > - * sharing, monitor and paging. This hypercall allows one to > - * control these rings (enable/disable), as well as to signal > - * to the hypervisor to pull responses (resume) from the given > - * ring. > +/* XEN_DOMCTL_vm_event_op. /* * XEN_DOMCTL_vm_event_op. * please, seeing as you're adjusting the comment. > + * Use for teardown/setup of helper<->hypervisor interface for paging, > + * access and sharing. > */ > #define XEN_VM_EVENT_ENABLE 0 > #define XEN_VM_EVENT_DISABLE 1 > #define XEN_VM_EVENT_RESUME 2 > #define XEN_VM_EVENT_GET_VERSION 3 > > -/* > - * Domain memory paging > - * Page memory in and out. > - * Domctl interface to set up and tear down the > - * pager<->hypervisor interface. Use XENMEM_paging_op* > - * to perform per-page operations. > - * > - * The XEN_VM_EVENT_PAGING_ENABLE domctl returns several > - * non-standard error codes to indicate why paging could not be enabled: > - * ENODEV - host lacks HAP support (EPT/NPT) or HAP is disabled in guest > - * EMLINK - guest has iommu passthrough enabled > - * EXDEV - guest has PoD enabled > - * EBUSY - guest has or had paging enabled, ring buffer still active > - */ > -#define XEN_DOMCTL_VM_EVENT_OP_PAGING 1 > - > -/* > - * Monitor helper. > - * > - * As with paging, use the domctl for teardown/setup of the > - * helper<->hypervisor interface. > - * > - * The monitor interface can be used to register for various VM events. For > - * example, there are HVM hypercalls to set the per-page access permissions > - * of every page in a domain. When one of these permissions--independent, > - * read, write, and execute--is violated, the VCPU is paused and a memory > event > - * is sent with what happened. The memory event handler can then resume the > - * VCPU and redo the access with a XEN_VM_EVENT_RESUME option. > - * > - * See public/vm_event.h for the list of available events that can be > - * subscribed to via the monitor interface. > - * > - * The XEN_VM_EVENT_MONITOR_* domctls returns > - * non-standard error codes to indicate why access could not be enabled: > - * ENODEV - host lacks HAP support (EPT/NPT) or HAP is disabled in guest > - * EBUSY - guest has or had access enabled, ring buffer still active > - * > - */ > -#define XEN_DOMCTL_VM_EVENT_OP_MONITOR 2 > - > -/* > - * Sharing ENOMEM helper. > - * > - * As with paging, use the domctl for teardown/setup of the > - * helper<->hypervisor interface. > - * > - * If setup, this ring is used to communicate failed allocations > - * in the unshare path. XENMEM_sharing_op_resume is used to wake up > - * vcpus that could not unshare. > - * > - * Note that shring can be turned on (as per the domctl below) > - * *without* this ring being setup. > - */ > -#define XEN_DOMCTL_VM_EVENT_OP_SHARING 3 > - > -/* Use for teardown/setup of helper<->hypervisor interface for paging, > - * access and sharing.*/ > struct xen_domctl_vm_event_op { > - uint32_t op; /* XEN_VM_EVENT_* */ > - uint32_t mode; /* XEN_DOMCTL_VM_EVENT_OP_* */ > + uint32_t op; /* XEN_VM_EVENT_* */ > + uint32_t type; /* XEN_VM_EVENT_TYPE_* */ Why did the vertical alignment change? > > union { > struct { > @@ -857,7 +795,10 @@ struct xen_domctl_vm_event_op { > * Memory sharing operations > */ > /* XEN_DOMCTL_mem_sharing_op. > - * The CONTROL sub-domctl is used for bringup/teardown. */ > + * The CONTROL sub-domctl is used for bringup/teardown. > + * Please note that mem sharing can be turned on *without* setting-up the > + * correspondin ring > + */ As a tangent, it can? how? (I'm entirely prepared to believe that this is how the code currently works, but I can't see how such a setup would plausibly work.) ~Andrew _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |