All of lore.kernel.org
 help / color / mirror / Atom feed
From: George Dunlap <george.dunlap@eu.citrix.com>
To: Razvan Cojocaru <rcojocaru@bitdefender.com>, xen-devel@lists.xen.org
Cc: kevin.tian@intel.com, keir@xen.org, eddie.dong@intel.com,
	stefano.stabellini@eu.citrix.com, jun.nakajima@intel.com,
	andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com,
	Aravind.Gopalakrishnan@amd.com, jbeulich@suse.com,
	tlengyel@novetta.com, wei.liu2@citrix.com,
	boris.ostrovsky@oracle.com, suravee.suthikulpanit@amd.com,
	ian.campbell@citrix.com
Subject: Re: [PATCH V3 2/3] xen/vm_event: Support for guest-requested events
Date: Tue, 7 Jul 2015 12:01:25 +0100	[thread overview]
Message-ID: <559BB185.5040708@eu.citrix.com> (raw)
In-Reply-To: <1436197873-4559-3-git-send-email-rcojocaru@bitdefender.com>

On 07/06/2015 04:51 PM, Razvan Cojocaru wrote:
> Added support for a new class of vm_events: VM_EVENT_REASON_REQUEST,
> sent via HVMOP_request_vm_event. The guest can request that a
> generic vm_event (containing only the vm_event-filled guest registers
> as information) be sent to userspace by setting up the correct
> registers and doing a VMCALL. For example, for a 32-bit guest, this
> means: EAX = 34 (hvmop), EBX = 24 (HVMOP_guest_request_vm_event),
> ECX = 0 (NULL required for the hypercall parameter, reserved).
> 
> Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
> 
> ---
> Changes since V2:
>  - Renamed xc_monitor_requested() to xc_monitor_guest_request().
>  - Renamed 'requested' or 'request' to 'guest_request' (consistency).
>  - Removed the emoved #if defined(__XEN__) || defined(__XEN_TOOLS__)
>    restriction to defining HVMOP_guest_request_vm_event.
>  - Now requiring NULL as the hypercall parameter.
>  - Changed the type of struct monitor's bitfields from uint16_t to
>    unsigned int.
> ---
>  tools/libxc/include/xenctrl.h   |    2 ++
>  tools/libxc/xc_monitor.c        |   15 +++++++++++++++
>  xen/arch/x86/hvm/event.c        |   16 ++++++++++++++++
>  xen/arch/x86/hvm/hvm.c          |    8 +++++++-
>  xen/arch/x86/monitor.c          |   16 ++++++++++++++++
>  xen/include/asm-x86/domain.h    |   16 +++++++++-------
>  xen/include/asm-x86/hvm/event.h |    1 +
>  xen/include/public/domctl.h     |    6 ++++++
>  xen/include/public/hvm/hvm_op.h |    2 ++
>  xen/include/public/vm_event.h   |    2 ++
>  10 files changed, 76 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
> index d1d2ab3..4ce519a 100644
> --- a/tools/libxc/include/xenctrl.h
> +++ b/tools/libxc/include/xenctrl.h
> @@ -2384,6 +2384,8 @@ int xc_monitor_mov_to_msr(xc_interface *xch, domid_t domain_id, bool enable,
>  int xc_monitor_singlestep(xc_interface *xch, domid_t domain_id, bool enable);
>  int xc_monitor_software_breakpoint(xc_interface *xch, domid_t domain_id,
>                                     bool enable);
> +int xc_monitor_guest_request(xc_interface *xch, domid_t domain_id,
> +                             bool enable, bool sync);
>  
>  /***
>   * Memory sharing operations.
> diff --git a/tools/libxc/xc_monitor.c b/tools/libxc/xc_monitor.c
> index 63013de..d979122 100644
> --- a/tools/libxc/xc_monitor.c
> +++ b/tools/libxc/xc_monitor.c
> @@ -105,3 +105,18 @@ int xc_monitor_singlestep(xc_interface *xch, domid_t domain_id,
>  
>      return do_domctl(xch, &domctl);
>  }
> +
> +int xc_monitor_guest_request(xc_interface *xch, domid_t domain_id, bool enable,
> +                             bool sync)
> +{
> +    DECLARE_DOMCTL;
> +
> +    domctl.cmd = XEN_DOMCTL_monitor_op;
> +    domctl.domain = domain_id;
> +    domctl.u.monitor_op.op = enable ? XEN_DOMCTL_MONITOR_OP_ENABLE
> +                                    : XEN_DOMCTL_MONITOR_OP_DISABLE;
> +    domctl.u.monitor_op.event = XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST;
> +    domctl.u.monitor_op.u.guest_request.sync = sync;
> +
> +    return do_domctl(xch, &domctl);
> +}
> diff --git a/xen/arch/x86/hvm/event.c b/xen/arch/x86/hvm/event.c
> index 5341937..17638ea 100644
> --- a/xen/arch/x86/hvm/event.c
> +++ b/xen/arch/x86/hvm/event.c
> @@ -126,6 +126,22 @@ void hvm_event_msr(unsigned int msr, uint64_t value)
>          hvm_event_traps(1, &req);
>  }
>  
> +void hvm_event_guest_request(void)
> +{
> +    struct vcpu *curr = current;
> +    struct arch_domain *currad = &curr->domain->arch;
> +
> +    if ( currad->monitor.guest_request_enabled )
> +    {
> +        vm_event_request_t req = {
> +            .reason = VM_EVENT_REASON_GUEST_REQUEST,
> +            .vcpu_id = curr->vcpu_id,
> +        };
> +
> +        hvm_event_traps(currad->monitor.guest_request_sync, &req);
> +    }
> +}
> +
>  int hvm_event_int3(unsigned long gla)
>  {
>      int rc = 0;
> diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
> index 535d622..536d1c8 100644
> --- a/xen/arch/x86/hvm/hvm.c
> +++ b/xen/arch/x86/hvm/hvm.c
> @@ -5974,7 +5974,6 @@ static int hvmop_get_param(
>  #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 = 0;
> @@ -6388,6 +6387,13 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
>          break;
>      }
>  
> +    case HVMOP_guest_request_vm_event:
> +        if ( guest_handle_is_null(arg) )
> +            hvm_event_guest_request();
> +        else
> +            rc = -EINVAL;
> +        break;
> +
>      default:
>      {
>          gdprintk(XENLOG_DEBUG, "Bad HVM op %ld.\n", op);
> diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c
> index 896acf7..f8df7d2 100644
> --- a/xen/arch/x86/monitor.c
> +++ b/xen/arch/x86/monitor.c
> @@ -161,6 +161,22 @@ int monitor_domctl(struct domain *d, struct xen_domctl_monitor_op *mop)
>          break;
>      }
>  
> +    case XEN_DOMCTL_MONITOR_EVENT_GUEST_REQUEST:
> +    {
> +        bool_t status = ad->monitor.guest_request_enabled;
> +
> +        rc = status_check(mop, status);
> +        if ( rc )
> +            return rc;
> +
> +        ad->monitor.guest_request_sync = mop->u.guest_request.sync;
> +
> +        domain_pause(d);
> +        ad->monitor.guest_request_enabled = !status;

If I'm reading this right, what this hypercall does is *toggle* guest
requests?

Wouldn't it make more sense to either set it or clear it, rather than
have the caller need to keep track (or guess) what state it's in?

 -George

  parent reply	other threads:[~2015-07-07 11:01 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 15:51 [PATCH V3 0/3] Vm_event memory introspection helpers Razvan Cojocaru
2015-07-06 15:51 ` [PATCH V3 1/3] xen/mem_access: Support for memory-content hiding Razvan Cojocaru
2015-07-06 16:50   ` Lengyel, Tamas
2015-07-06 18:27     ` Razvan Cojocaru
2015-07-06 18:30       ` Lengyel, Tamas
2015-07-07  8:10         ` Razvan Cojocaru
2015-07-07 12:04           ` Lengyel, Tamas
2015-07-07 12:33             ` Razvan Cojocaru
2015-07-07 13:09             ` Razvan Cojocaru
2015-07-07 13:15               ` Lengyel, Tamas
2015-07-07 13:21                 ` Razvan Cojocaru
2015-07-07 13:27                   ` Lengyel, Tamas
2015-07-07 10:51   ` George Dunlap
2015-07-07 13:27   ` Jan Beulich
2015-07-07 15:32     ` Razvan Cojocaru
2015-07-07 15:40       ` Jan Beulich
2015-07-07 16:20         ` Razvan Cojocaru
2015-07-07 16:24           ` Jan Beulich
2015-07-06 15:51 ` [PATCH V3 2/3] xen/vm_event: Support for guest-requested events Razvan Cojocaru
2015-07-06 16:55   ` Lengyel, Tamas
2015-07-06 17:57   ` Wei Liu
2015-07-07 11:01   ` George Dunlap [this message]
2015-07-07 11:59     ` Razvan Cojocaru
2015-07-07 13:30   ` Jan Beulich
2015-07-07 14:26     ` Daniel De Graaf
2015-07-06 15:51 ` [PATCH V3 3/3] xen/vm_event: Deny register writes if refused by vm_event reply Razvan Cojocaru
2015-07-06 17:05   ` Lengyel, Tamas
2015-07-06 17:16     ` Razvan Cojocaru
2015-07-07  9:06     ` Razvan Cojocaru
2015-07-07 12:55       ` Lengyel, Tamas
2015-07-07 13:21         ` Razvan Cojocaru
2015-07-07 13:26           ` Lengyel, Tamas
2015-07-07 11:05   ` George Dunlap
2015-07-07 13:42   ` Jan Beulich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=559BB185.5040708@eu.citrix.com \
    --to=george.dunlap@eu.citrix.com \
    --cc=Aravind.Gopalakrishnan@amd.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=eddie.dong@intel.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jbeulich@suse.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=tlengyel@novetta.com \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.