All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrew Cooper <andrew.cooper3@citrix.com>
To: Razvan Cojocaru <rcojocaru@bitdefender.com>, xen-devel@lists.xen.org
Cc: keir@xen.org, jbeulich@suse.com
Subject: Re: [PATCH V2] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL
Date: Fri, 8 Apr 2016 14:06:54 +0100	[thread overview]
Message-ID: <5707ACEE.6010807@citrix.com> (raw)
In-Reply-To: <1460118913-5321-1-git-send-email-rcojocaru@bitdefender.com>

On 08/04/16 13:35, Razvan Cojocaru wrote:
> It is meaningless (and potentially dangerous - see hvmemul_virtual_to_linear())
> to set mem_access_emulate_each_rep before xc_monitor_enable() (which allocates
> vcpu->arch.vm_event) has been called, so return an error from the
> XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP hypercall when that is the case.
>
> Signed-off-by: Razvan Cojocaru <rcojocaru@bitdefender.com>
>
> ---
> Changes since V1:
>  - Fixed the if() condition.
>  - Introduced an rc return variable to simplify the code.
> ---
>  xen/include/asm-x86/monitor.h | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/xen/include/asm-x86/monitor.h b/xen/include/asm-x86/monitor.h
> index 0954b59..a66760d 100644
> --- a/xen/include/asm-x86/monitor.h
> +++ b/xen/include/asm-x86/monitor.h
> @@ -32,19 +32,29 @@
>  static inline
>  int arch_monitor_domctl_op(struct domain *d, struct xen_domctl_monitor_op *mop)
>  {
> +    int rc = 0;
> +
>      switch ( mop->op )
>      {
>      case XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP:
>          domain_pause(d);
> -        d->arch.mem_access_emulate_each_rep = !!mop->event;
> +        /*
> +         * Enabling mem_access_emulate_each_rep without a vm_event subscriber
> +         * is meaningless.
> +         */
> +        if ( d->vcpu && d->vcpu[0]->arch.vm_event )

Sorry - I forgot to mention this before, but this check is slightly
buggy.  You want

if ( d->max_vcpus && d->vcpu[0] && d->vcpu[0]->arch.vm_event )

d->max_vcpus being non-zero guarentees that d->vcpu has been allocated,
but you still need to check that d->vcpu[0] has been allocated before
following the pointer.

With that fixed, Reviewed-by: Andrew Cooper <andrew.cooper3@citirx.com>

> +            d->arch.mem_access_emulate_each_rep = !!mop->event;
> +        else
> +            rc = -EINVAL;
> +
>          domain_unpause(d);
>          break;
>  
>      default:
> -        return -EOPNOTSUPP;
> +        rc = -EOPNOTSUPP;
>      }
>  
> -    return 0;
> +    return rc;
>  }
>  
>  int arch_monitor_domctl_event(struct domain *d,


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

      reply	other threads:[~2016-04-08 13:06 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-08 12:35 [PATCH V2] x86/monitor: Disallow setting mem_access_emulate_each_rep when vm_event is NULL Razvan Cojocaru
2016-04-08 13:06 ` Andrew Cooper [this message]

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=5707ACEE.6010807@citrix.com \
    --to=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=keir@xen.org \
    --cc=rcojocaru@bitdefender.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.