[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 2/9] vm_event: Define VM_EVENT type


  • To: Petre Pircalabu <ppircalabu@xxxxxxxxxxxxxxx>, <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Fri, 31 May 2019 16:26:57 -0700
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=andrew.cooper3@xxxxxxxxxx; spf=Pass smtp.mailfrom=Andrew.Cooper3@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxxxxxxxxxxxxx
  • Autocrypt: addr=andrew.cooper3@xxxxxxxxxx; prefer-encrypt=mutual; keydata= mQINBFLhNn8BEADVhE+Hb8i0GV6mihnnr/uiQQdPF8kUoFzCOPXkf7jQ5sLYeJa0cQi6Penp VtiFYznTairnVsN5J+ujSTIb+OlMSJUWV4opS7WVNnxHbFTPYZVQ3erv7NKc2iVizCRZ2Kxn srM1oPXWRic8BIAdYOKOloF2300SL/bIpeD+x7h3w9B/qez7nOin5NzkxgFoaUeIal12pXSR Q354FKFoy6Vh96gc4VRqte3jw8mPuJQpfws+Pb+swvSf/i1q1+1I4jsRQQh2m6OTADHIqg2E ofTYAEh7R5HfPx0EXoEDMdRjOeKn8+vvkAwhviWXTHlG3R1QkbE5M/oywnZ83udJmi+lxjJ5 YhQ5IzomvJ16H0Bq+TLyVLO/VRksp1VR9HxCzItLNCS8PdpYYz5TC204ViycobYU65WMpzWe LFAGn8jSS25XIpqv0Y9k87dLbctKKA14Ifw2kq5OIVu2FuX+3i446JOa2vpCI9GcjCzi3oHV e00bzYiHMIl0FICrNJU0Kjho8pdo0m2uxkn6SYEpogAy9pnatUlO+erL4LqFUO7GXSdBRbw5 gNt25XTLdSFuZtMxkY3tq8MFss5QnjhehCVPEpE6y9ZjI4XB8ad1G4oBHVGK5LMsvg22PfMJ ISWF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WrhBLXDiYlyJT6zOV2yZFuW47VrLsjYnHwn27hmxTC/7tvG3euCklmkn9Sl9IAKFu29RSo d5bD8kMSCYsTqtTfT6W4A3qHGvIDta3ptLYpIAOD2sY3GYq2nf3Bbzx81wZK14JdDDHUX2Rs 6+ahAA==
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Razvan Cojocaru <rcojocaru@xxxxxxxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>, George Dunlap <George.Dunlap@xxxxxxxxxxxxx>, Tim Deegan <tim@xxxxxxx>, Ian Jackson <ian.jackson@xxxxxxxxxxxxx>, Julien Grall <julien.grall@xxxxxxx>, Tamas K Lengyel <tamas@xxxxxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>
  • Delivery-date: Fri, 31 May 2019 23:27:15 +0000
  • Ironport-sdr: efAsx6Eh8Nz4Cyjl7tnZYGXToLE+bXB1ltQTbS41+Edx8hjL3Mbrydy5VP8QGbhXhvXu7X2QZV KtS0l30oPrREpMi4bop7xGI3yymok7bUZ2+hcLeJ2IAMmG3j6nkAAsxPeG15Si/xSJ9B3YSVmf XN4ogMw9P+rtlzAaXyyAJkno4FZVXXxImqxagE7zaIok2p39mOjNiEp+YV2Ie+7fEMBC+Krp+D V3AUxSx3nNJPYDb3maT8WtAY670jlQomgh8ZnRkA9is4+8wld+c2v8JW/uoQXnrp6xjU/5+3S4 bbM=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Openpgp: preference=signencrypt

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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.