xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Paul Durrant <Paul.Durrant@citrix.com>
To: Jan Beulich <JBeulich@suse.com>,
	xen-devel <xen-devel@lists.xenproject.org>
Cc: Andrew Cooper <Andrew.Cooper3@citrix.com>
Subject: Re: [PATCH 4/4] x86/vMSI-X: use generic intercept handler in place of MMIO one
Date: Mon, 13 Jun 2016 08:36:17 +0000	[thread overview]
Message-ID: <317fbd54e379469491996b4a1dea3c91@AMSPEX02CL03.citrite.net> (raw)
In-Reply-To: <575831B702000078000F30AE@prv-mh.provo.novell.com>

> -----Original Message-----
> From: Jan Beulich [mailto:JBeulich@suse.com]
> Sent: 08 June 2016 13:55
> To: xen-devel
> Cc: Andrew Cooper; Paul Durrant
> Subject: [PATCH 4/4] x86/vMSI-X: use generic intercept handler in place of
> MMIO one
> 
> This allows us to see the full ioreq without having to peek into state
> which is supposedly private to the emulation framework.
> 
> Suggested-by: Paul Durrant <Paul.Durrant@citrix.com>
> Signed-off-by: Jan Beulich <jbeulich@suse.com>

Reviewed-by: Paul Durrant <paul.durrant@citrix.com>

> 
> --- a/xen/arch/x86/hvm/vmsi.c
> +++ b/xen/arch/x86/hvm/vmsi.c
> @@ -199,9 +199,8 @@ static struct msi_desc *msixtbl_addr_to_
>      return NULL;
>  }
> 
> -static int msixtbl_read(
> -    struct vcpu *v, unsigned long address,
> -    unsigned int len, unsigned long *pval)
> +static int msixtbl_read(const struct hvm_io_handler *handler,
> +                        uint64_t address, uint32_t len, uint64_t *pval)
>  {
>      unsigned long offset;
>      struct msixtbl_entry *entry;
> @@ -213,7 +212,7 @@ static int msixtbl_read(
> 
>      rcu_read_lock(&msixtbl_rcu_lock);
> 
> -    entry = msixtbl_find_entry(v, address);
> +    entry = msixtbl_find_entry(current, address);
>      if ( !entry )
>          goto out;
>      offset = address & (PCI_MSIX_ENTRY_SIZE - 1);
> @@ -333,23 +332,29 @@ out:
>      return r;
>  }
> 
> -static int msixtbl_range(struct vcpu *v, unsigned long addr)
> +static int _msixtbl_write(const struct hvm_io_handler *handler,
> +                         uint64_t address, uint32_t len, uint64_t val)
>  {
> +    return msixtbl_write(current, address, len, val);
> +}
> +
> +static bool_t msixtbl_range(const struct hvm_io_handler *handler,
> +                            const ioreq_t *r)
> +{
> +    struct vcpu *curr = current;
> +    unsigned long addr = r->addr;
>      const struct msi_desc *desc;
> -    const ioreq_t *r;
> +
> +    ASSERT(r->type == IOREQ_TYPE_COPY);
> 
>      rcu_read_lock(&msixtbl_rcu_lock);
> -    desc = msixtbl_addr_to_desc(msixtbl_find_entry(v, addr), addr);
> +    desc = msixtbl_addr_to_desc(msixtbl_find_entry(curr, addr), addr);
>      rcu_read_unlock(&msixtbl_rcu_lock);
> 
>      if ( desc )
>          return 1;
> 
> -    r = &v->arch.hvm_vcpu.hvm_io.io_req;
> -    if ( r->state != STATE_IOREQ_READY || r->addr != addr )
> -        return 0;
> -    ASSERT(r->type == IOREQ_TYPE_COPY);
> -    if ( r->dir == IOREQ_WRITE )
> +    if ( r->state == STATE_IOREQ_READY && r->dir == IOREQ_WRITE )
>      {
>          unsigned int size = r->size;
> 
> @@ -368,8 +373,8 @@ static int msixtbl_range(struct vcpu *v,
>                    PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET) &&
>                   !(data & PCI_MSIX_VECTOR_BITMASK) )
>              {
> -                v->arch.hvm_vcpu.hvm_io.msix_snoop_address = addr;
> -                v->arch.hvm_vcpu.hvm_io.msix_snoop_gpa = 0;
> +                curr->arch.hvm_vcpu.hvm_io.msix_snoop_address = addr;
> +                curr->arch.hvm_vcpu.hvm_io.msix_snoop_gpa = 0;
>              }
>          }
>          else if ( (size == 4 || size == 8) &&
> @@ -386,9 +391,9 @@ static int msixtbl_range(struct vcpu *v,
>              BUILD_BUG_ON((PCI_MSIX_ENTRY_VECTOR_CTRL_OFFSET + 4) &
>                           (PCI_MSIX_ENTRY_SIZE - 1));
> 
> -            v->arch.hvm_vcpu.hvm_io.msix_snoop_address =
> +            curr->arch.hvm_vcpu.hvm_io.msix_snoop_address =
>                  addr + size * r->count - 4;
> -            v->arch.hvm_vcpu.hvm_io.msix_snoop_gpa =
> +            curr->arch.hvm_vcpu.hvm_io.msix_snoop_gpa =
>                  r->data + size * r->count - 4;
>          }
>      }
> @@ -396,10 +401,10 @@ static int msixtbl_range(struct vcpu *v,
>      return 0;
>  }
> 
> -static const struct hvm_mmio_ops msixtbl_mmio_ops = {
> -    .check = msixtbl_range,
> +static const struct hvm_io_ops msixtbl_mmio_ops = {
> +    .accept = msixtbl_range,
>      .read = msixtbl_read,
> -    .write = msixtbl_write
> +    .write = _msixtbl_write
>  };
> 
>  static void add_msixtbl_entry(struct domain *d,
> @@ -544,13 +549,20 @@ found:
> 
>  void msixtbl_init(struct domain *d)
>  {
> +    struct hvm_io_handler *handler;
> +
>      if ( !has_hvm_container_domain(d) || !has_vlapic(d) ||
>           d->arch.hvm_domain.msixtbl_list.next )
>          return;
> 
>      INIT_LIST_HEAD(&d->arch.hvm_domain.msixtbl_list);
> 
> -    register_mmio_handler(d, &msixtbl_mmio_ops);
> +    handler = hvm_next_io_handler(d);
> +    if ( handler )
> +    {
> +        handler->type = IOREQ_TYPE_COPY;
> +        handler->ops = &msixtbl_mmio_ops;
> +    }
>  }
> 
>  void msixtbl_pt_cleanup(struct domain *d)
> 


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

  reply	other threads:[~2016-06-13  8:36 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-08 12:48 [PATCH 0/4] x86/vMSI-X: misc improvements Jan Beulich
2016-06-08 12:52 ` [PATCH 1/4] x86/vMSI-X: defer intercept handler registration Jan Beulich
2016-06-17 16:13   ` Konrad Rzeszutek Wilk
2016-06-17 16:38     ` Jan Beulich
2016-06-21 17:11   ` Andrew Cooper
2016-06-08 12:53 ` [PATCH 2/4] x86/vMSI-X: drop list lock Jan Beulich
2016-06-21 17:26   ` Andrew Cooper
2016-06-08 12:54 ` [PATCH 3/4] x86/vMSI-X: drop pci_msix_get_table_len() Jan Beulich
2016-06-21 17:27   ` Andrew Cooper
2016-06-08 12:54 ` [PATCH 4/4] x86/vMSI-X: use generic intercept handler in place of MMIO one Jan Beulich
2016-06-13  8:36   ` Paul Durrant [this message]
2016-06-21 17:33   ` Andrew Cooper
2016-06-17  8:20 ` Ping: [PATCH 0/4] x86/vMSI-X: misc improvements 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=317fbd54e379469491996b4a1dea3c91@AMSPEX02CL03.citrite.net \
    --to=paul.durrant@citrix.com \
    --cc=Andrew.Cooper3@citrix.com \
    --cc=JBeulich@suse.com \
    --cc=xen-devel@lists.xenproject.org \
    --subject='Re: [PATCH 4/4] x86/vMSI-X: use generic intercept handler in place of MMIO one' \
    /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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).