All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jan Beulich" <JBeulich@suse.com>
To: Tamas K Lengyel <tamas.lengyel@zentific.com>
Cc: tim@xen.org, kevin.tian@intel.com, wei.liu2@citrix.com,
	ian.campbell@citrix.com, rcojocaru@bitdefender.com,
	stefano.stabellini@eu.citrix.com, eddie.dong@intel.com,
	ian.jackson@eu.citrix.com, xen-devel@lists.xen.org,
	steve@zentific.com, andres@lagarcavilla.org,
	jun.nakajima@intel.com, rshriram@cs.ubc.ca, keir@xen.org,
	dgdegra@tycho.nsa.gov, yanghy@cn.fujitsu.com
Subject: Re: [RFC PATCH V3 10/12] xen: Introduce monitor_op domctl
Date: Wed, 04 Feb 2015 09:34:09 +0000	[thread overview]
Message-ID: <54D1F5A1020000780005CB23@mail.emea.novell.com> (raw)
In-Reply-To: <1422567998-29995-11-git-send-email-tamas.lengyel@zentific.com>

>>> On 29.01.15 at 22:46, <tamas.lengyel@zentific.com> wrote:
> --- /dev/null
> +++ b/xen/arch/x86/monitor.c
> @@ -0,0 +1,197 @@
> +/*
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public
> + * License v2 as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
> + * General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public
> + * License along with this program; if not, write to the
> + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
> + * Boston, MA 021110-1307, USA.
> + */
> +
> +#include <xen/config.h>
> +#include <xen/sched.h>
> +#include <xen/mm.h>
> +#include <asm/domain.h>
> +
> +#define DISABLE_OPTION(option)          \
> +    if ( !option->enabled )             \
> +        return -EFAULT;                 \
> +    memset(option, 0, sizeof(*option))

This needs to be wrapped in either ({ }) or do { } while (0), allowing
you to drop currently necessary (but suggested to be omitted by
./CODING_STYLE) braces around (some of) its uses below.

> +int monitor_domctl(struct xen_domctl_monitor_op *domctl, struct domain *d)
> +{
> +    /*
> +     * At the moment only HVM domains are supported. However, event delivery
> +     * could be extended to PV domains. See comments below.
> +     */
> +    if ( !is_hvm_domain(d) )
> +        return -ENOSYS;
> +
> +    if ( domctl->op != XEN_DOMCTL_MONITOR_OP_ENABLE &&
> +         domctl->op != XEN_DOMCTL_MONITOR_OP_DISABLE )
> +        return -EFAULT;
> +
> +    switch ( domctl->subop )
> +    {
> +    case XEN_DOMCTL_MONITOR_SUBOP_MOV_TO_CR0:
> +    {
> +        /* Note: could be supported on PV domains. */
> +        struct mov_to_cr0 *options = &d->arch.monitor_options.mov_to_cr0;
> +
> +        if ( domctl->op == XEN_DOMCTL_MONITOR_OP_ENABLE )
> +        {
> +            if ( options->enabled )
> +                return -EBUSY;
> +
> +            options->enabled = 1;
> +            options->sync = domctl->options.mov_to_cr0.sync;
> +            options->onchangeonly = domctl->options.mov_to_cr0.onchangeonly;

Shouldn't you set "->enabled" last, after a suitable barrier (and with
the consuming sides using suitable barriers too)? Or are you missing
a domain_pause() here?

> +        }
> +        else
> +        {
> +            DISABLE_OPTION(options);
> +        }
> +        break;
> +    }
> +    case XEN_DOMCTL_MONITOR_SUBOP_MOV_TO_CR3:

Please consistently have blank lines between individual, not falling
through cases.

> +    default:
> +        return -EFAULT;

Certainly not.

> @@ -1179,6 +1180,16 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
>      }
>      break;
>  
> +    case XEN_DOMCTL_monitor_op:
> +    {
> +        ret = -EPERM;
> +        if ( current->domain == d )
> +            break;
> +
> +        ret = monitor_domctl(&op->u.monitor_op, d);
> +    }
> +    break;

Pointless braces.

> --- a/xen/common/vm_event.c
> +++ b/xen/common/vm_event.c
> @@ -617,16 +617,10 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec,
>          switch( vec->op )
>          {
>          case XEN_DOMCTL_VM_EVENT_OP_MONITOR_ENABLE:
> -        case XEN_DOMCTL_VM_EVENT_OP_MONITOR_ENABLE_INTROSPECTION:
>          {
>              rc = vm_event_enable(d, vec, ved, _VPF_mem_access,
>                                      HVM_PARAM_MONITOR_RING_PFN,
>                                      mem_access_notification);
> -
> -            if ( vec->op == XEN_DOMCTL_VM_EVENT_OP_MONITOR_ENABLE_INTROSPECTION
> -                 && !rc )
> -                p2m_setup_introspection(d);
> -
>          }
>          break;

The braces should now be removed too.

> @@ -635,7 +629,6 @@ int vm_event_domctl(struct domain *d, xen_domctl_vm_event_op_t *vec,
>              if ( ved->ring_page )
>              {
>                  rc = vm_event_disable(d, ved);
> -                d->arch.hvm_domain.introspection_enabled = 0;
>              }

And again. Please go through all of the modification the series makes
and adjust for coding style.

> --- a/xen/include/asm-x86/domain.h
> +++ b/xen/include/asm-x86/domain.h
> @@ -236,6 +236,41 @@ struct time_scale {
>      u32 mul_frac;
>  };
>  
> +/************************************************/
> +/*            monitor event options             */
> +/************************************************/
> +struct mov_to_cr0 {
> +    uint8_t enabled;
> +    uint8_t sync;
> +    uint8_t onchangeonly;
> +};
> +
> +struct mov_to_cr3 {
> +    uint8_t enabled;
> +    uint8_t sync;
> +    uint8_t onchangeonly;
> +};
> +
> +struct mov_to_cr4 {
> +    uint8_t enabled;
> +    uint8_t sync;
> +    uint8_t onchangeonly;
> +};

As long as they're identical, these should just be a single
struct mov_to_cr, allowing (afaict) further abstraction elsewhere.

> +struct mov_to_msr {
> +    uint8_t enabled;
> +    uint8_t extended_capture;
> +};
> +
> +struct singlestep {
> +    uint8_t enabled;
> +};
> +
> +struct software_breakpoint {
> +    uint8_t enabled;
> +};

These may also better be a common struct debug_event.

> +
> +
>  struct pv_domain

Just a single blank line please.

> --- /dev/null
> +++ b/xen/include/asm-x86/monitor.h
> @@ -0,0 +1,9 @@
> +#ifndef __ASM_X86_MONITOR_H__
> +#define __ASM_X86_MONITOR_H__
> +
> +#include <xen/config.h>

Not needed anywhere. Please drop such inclusions from the series.

> @@ -1001,6 +1000,58 @@ struct xen_domctl_psr_cmt_op {
>  typedef struct xen_domctl_psr_cmt_op xen_domctl_psr_cmt_op_t;
>  DEFINE_XEN_GUEST_HANDLE(xen_domctl_psr_cmt_op_t);
>  
> +/*  XEN_DOMCTL_MONITOR_*
> + *
> + * Enable/disable monitoring various VM events.
> + * This domctl configures what events will be reported to helper apps
> + * via the ring buffer "MONITOR". The ring has to be first enabled
> + * with the domctl XEN_DOMCTL_VM_EVENT_OP_MONITOR.
> + *
> + * NOTICE: mem_access events are also delivered via the "MONITOR" ring buffer;
> + * however, enabling/disabling those events is performed with the use of
> + * memory_op hypercalls!
> + *
> + */

Stray blank comment line.

> +struct xen_domctl_monitor_op {
> +    uint32_t op; /* XEN_DOMCTL_MONITOR_OP_* */
> +    uint32_t subop; /* XEN_DOMCTL_MONITOR_SUBOP_* */
> +
> +    /*
> +     * Further options when issuing XEN_DOMCTL_MONITOR_OP_ENABLE.
> +     */
> +    union {
> +        struct {
> +            uint8_t sync; /* Pause vCPU until response */
> +            uint8_t onchangeonly; /* Send event only on a change of value */
> +            uint8_t pad[6];
> +        } mov_to_cr0, mov_to_cr3, mov_to_cr4;
> +
> +        /* Enable the capture of msr events on
> +            MSR_IA32_SYSENTER_EIP
> +            MSR_IA32_SYSENTER_ESP
> +            MSR_IA32_SYSENTER_CS
> +            MSR_IA32_MC0_CTL
> +            MSR_STAR
> +            MSR_LSTAR */

Coding style.

> --- a/xen/include/public/hvm/params.h
> +++ b/xen/include/public/hvm/params.h
> @@ -162,21 +162,6 @@
>   */
>  #define HVM_PARAM_ACPI_IOPORTS_LOCATION 19
>  
> -/* Enable blocking memory events, async or sync (pause vcpu until response) 
> - * onchangeonly indicates messages only on a change of value */
> -#define HVM_PARAM_MEMORY_EVENT_CR0          20
> -#define HVM_PARAM_MEMORY_EVENT_CR3          21
> -#define HVM_PARAM_MEMORY_EVENT_CR4          22
> -#define HVM_PARAM_MEMORY_EVENT_INT3         23
> -#define HVM_PARAM_MEMORY_EVENT_SINGLE_STEP  25
> -#define HVM_PARAM_MEMORY_EVENT_MSR          30

I'm not sure if HVM param slots can be re-used. If they can, leaving a
note that the deleted numbers are available for re-sue would be nice.
If they can't, leaving a note that they shouldn't be re-used would
seem mandatory.

Jan

  parent reply	other threads:[~2015-02-04  9:34 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-29 21:46 [RFC PATCH V3 00/12] xen: Clean-up of mem_event subsystem Tamas K Lengyel
2015-01-29 21:46 ` [RFC PATCH V3 01/12] xen/mem_event: Cleanup of mem_event structures Tamas K Lengyel
2015-02-02 17:19   ` Ian Campbell
2015-02-03  9:17     ` Jan Beulich
2015-02-05 12:12       ` Tamas K Lengyel
2015-02-05 12:13     ` Tamas K Lengyel
2015-02-03 15:32   ` Jan Beulich
2015-01-29 21:46 ` [RFC PATCH V3 02/12] xen/mem_event: Rename the mem_event ring from 'access' to 'monitor' Tamas K Lengyel
2015-02-02 17:22   ` Ian Campbell
2015-02-03 15:37   ` Jan Beulich
2015-02-05 14:24     ` Tamas K Lengyel
2015-01-29 21:46 ` [RFC PATCH V3 03/12] xen/mem_paging: Convert mem_event_op to mem_paging_op Tamas K Lengyel
2015-02-02 17:23   ` Ian Campbell
2015-02-03 15:41   ` Jan Beulich
2015-01-29 21:46 ` [RFC PATCH V3 04/12] xen/mem_access: Merge mem_event sanity check into mem_access check Tamas K Lengyel
2015-01-29 21:46 ` [RFC PATCH V3 05/12] xen: Introduce vm_event Tamas K Lengyel
2015-01-30 17:25   ` Daniel De Graaf
2015-01-31 13:24     ` Tamas K Lengyel
2015-02-02 19:35       ` Daniel De Graaf
2015-02-06 14:04         ` Tamas K Lengyel
2015-02-02 17:27   ` Ian Campbell
2015-02-03 15:54   ` Jan Beulich
2015-02-06 13:54     ` Tamas K Lengyel
2015-02-06 13:58       ` Andrew Cooper
2015-02-06 14:01         ` Tamas K Lengyel
2015-01-29 21:46 ` [RFC PATCH V3 06/12] xen: migrate mem_event to vm_event Tamas K Lengyel
2015-02-02 17:27   ` Ian Campbell
2015-02-03 16:22   ` Jan Beulich
2015-01-29 21:46 ` [RFC PATCH V3 07/12] xen: Remove mem_event Tamas K Lengyel
2015-01-30 17:25   ` Daniel De Graaf
2015-02-02 17:29   ` Ian Campbell
2015-02-03 16:26   ` Jan Beulich
2015-02-06 12:54     ` Tamas K Lengyel
2015-02-06 14:18       ` Jan Beulich
2015-02-06 16:13         ` Tamas K Lengyel
2015-01-29 21:46 ` [RFC PATCH V3 08/12] tools/tests: Clean-up tools/tests/xen-access Tamas K Lengyel
2015-02-02 17:30   ` Ian Campbell
2015-01-29 21:46 ` [RFC PATCH V3 09/12] x86/hvm: factor out and rename vm_event related functions into separate file Tamas K Lengyel
2015-02-04  5:54   ` Tian, Kevin
2015-02-04  9:14   ` Jan Beulich
2015-01-29 21:46 ` [RFC PATCH V3 10/12] xen: Introduce monitor_op domctl Tamas K Lengyel
2015-01-30  7:58   ` Razvan Cojocaru
2015-01-30 10:38     ` Tamas K Lengyel
2015-01-30 11:07       ` Razvan Cojocaru
2015-01-30 11:15         ` Tamas K Lengyel
2015-01-30 11:24           ` Tamas K Lengyel
2015-01-30 11:33           ` Razvan Cojocaru
2015-01-30 11:45             ` Tamas K Lengyel
2015-01-30 12:24               ` Razvan Cojocaru
2015-01-30 12:36                 ` Tamas K Lengyel
2015-02-02 17:32   ` Ian Campbell
2015-02-04  5:57   ` Tian, Kevin
2015-02-04  9:34   ` Jan Beulich [this message]
2015-02-05 14:15     ` Tamas K Lengyel
2015-02-09 18:45       ` Tamas K Lengyel
2015-01-29 21:46 ` [RFC PATCH V3 11/12] xen/vm_event: Decouple vm_event and mem_access Tamas K Lengyel
2015-02-04  9:47   ` Jan Beulich
2015-02-06 13:10     ` Tamas K Lengyel
2015-02-06 14:20       ` Jan Beulich
2015-02-06 16:12         ` Tamas K Lengyel
2015-01-29 21:46 ` [RFC PATCH V3 12/12] xen/vm_event: Check for VM_EVENT_FLAG_DUMMY only in Debug builds Tamas K Lengyel
2015-02-04  5:59   ` Tian, Kevin
2015-02-06 13:20     ` Tamas K Lengyel
2015-02-04  9:49   ` Jan Beulich
2015-02-06 13:22     ` Tamas K Lengyel
2015-02-02 17:33 ` [RFC PATCH V3 00/12] xen: Clean-up of mem_event subsystem Ian Campbell

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=54D1F5A1020000780005CB23@mail.emea.novell.com \
    --to=jbeulich@suse.com \
    --cc=andres@lagarcavilla.org \
    --cc=dgdegra@tycho.nsa.gov \
    --cc=eddie.dong@intel.com \
    --cc=ian.campbell@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=jun.nakajima@intel.com \
    --cc=keir@xen.org \
    --cc=kevin.tian@intel.com \
    --cc=rcojocaru@bitdefender.com \
    --cc=rshriram@cs.ubc.ca \
    --cc=stefano.stabellini@eu.citrix.com \
    --cc=steve@zentific.com \
    --cc=tamas.lengyel@zentific.com \
    --cc=tim@xen.org \
    --cc=wei.liu2@citrix.com \
    --cc=xen-devel@lists.xen.org \
    --cc=yanghy@cn.fujitsu.com \
    /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.