public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sheng Yang <sheng@linux.intel.com>
To: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Avi Kivity <avi@redhat.com>,
	kvm@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>
Subject: Re: [PATCH 6/8] KVM: assigned dev: Preparation for mask support in userspace
Date: Sun, 24 Oct 2010 20:19:09 +0800	[thread overview]
Message-ID: <201010242019.09655.sheng@linux.intel.com> (raw)
In-Reply-To: <20101022145313.GA24078@amt.cnet>

On Friday 22 October 2010 22:53:13 Marcelo Tosatti wrote:
> On Wed, Oct 20, 2010 at 04:26:30PM +0800, Sheng Yang wrote:
> > The feature wouldn't be enabled until later patch set msix_flags_enabled.
> > It would be enabled along with mask support in kernel.
> > 
> > Signed-off-by: Sheng Yang <sheng@linux.intel.com>
> > ---
> > 
> >  arch/x86/include/asm/kvm_host.h |    2 ++
> >  include/linux/kvm.h             |    6 +++++-
> >  include/linux/kvm_host.h        |    1 +
> >  virt/kvm/assigned-dev.c         |   39
> >  +++++++++++++++++++++++++++++++++++++++ 4 files changed, 47
> >  insertions(+), 1 deletions(-)
> > 
> > diff --git a/arch/x86/include/asm/kvm_host.h
> > b/arch/x86/include/asm/kvm_host.h index e209078..2bb69ba 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -456,6 +456,8 @@ struct kvm_arch {
> > 
> >  	/* fields used by HYPER-V emulation */
> >  	u64 hv_guest_os_id;
> >  	u64 hv_hypercall;
> > 
> > +
> > +	bool msix_flags_enabled;
> > 
> >  };
> >  
> >  struct kvm_vm_stat {
> > 
> > diff --git a/include/linux/kvm.h b/include/linux/kvm.h
> > index 919ae53..a699ec9 100644
> > --- a/include/linux/kvm.h
> > +++ b/include/linux/kvm.h
> > @@ -787,11 +787,15 @@ struct kvm_assigned_msix_nr {
> > 
> >  };
> >  
> >  #define KVM_MAX_MSIX_PER_DEV		256
> > 
> > +
> > +#define KVM_MSIX_FLAG_MASK	1
> > +
> > 
> >  struct kvm_assigned_msix_entry {
> >  
> >  	__u32 assigned_dev_id;
> >  	__u32 gsi;
> >  	__u16 entry; /* The index of entry in the MSI-X table */
> > 
> > -	__u16 padding[3];
> > +	__u16 flags;
> > +	__u16 padding[2];
> > 
> >  };
> >  
> >  #endif /* __LINUX_KVM_H */
> > 
> > diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
> > index 30f83cd..81a6284 100644
> > --- a/include/linux/kvm_host.h
> > +++ b/include/linux/kvm_host.h
> > @@ -438,6 +438,7 @@ struct kvm_irq_ack_notifier {
> > 
> >  };
> >  
> >  #define KVM_ASSIGNED_MSIX_PENDING		0x1
> > 
> > +#define KVM_ASSIGNED_MSIX_MASK			0x2
> > 
> >  struct kvm_guest_msix_entry {
> >  
> >  	u32 vector;
> >  	u16 entry;
> > 
> > diff --git a/virt/kvm/assigned-dev.c b/virt/kvm/assigned-dev.c
> > index 7c98928..bf96ea7 100644
> > --- a/virt/kvm/assigned-dev.c
> > +++ b/virt/kvm/assigned-dev.c
> > 
> > @@ -666,11 +666,35 @@ msix_nr_out:
> >  	return r;
> >  
> >  }
> > 
> > +static void update_msix_mask(struct kvm_assigned_dev_kernel
> > *assigned_dev, +			     int index)
> > +{
> > +	int irq;
> > +	struct irq_desc *desc;
> > +
> > +	if (!assigned_dev->dev->msix_enabled ||
> > +	    !(assigned_dev->irq_requested_type & KVM_DEV_IRQ_HOST_MSIX))
> > +		return;
> > +
> > +	irq = assigned_dev->host_msix_entries[index].vector;
> > +	BUG_ON(irq == 0);
> > +	desc = irq_to_desc(irq);
> > +	BUG_ON(!desc->msi_desc);
> > +
> > +	if (assigned_dev->guest_msix_entries[index].flags &
> > +			KVM_ASSIGNED_MSIX_MASK) {
> > +		desc->chip->mask(irq);
> > +		flush_work(&assigned_dev->interrupt_work);
> > +	} else
> > +		desc->chip->unmask(irq);
> > +}
> 
> Bypassing irq handling code like this is wrong (see all the state
> keeping in kernel/irq/handle.c).

Would check it.
> 
> You need a guarantee that MSIX per-vector mask is used for
> disable_irq/enable_irq, right? I can't see how this provides it.

This one meant to directly operate the mask/unmask bit of the MSI-X table, to 
emulate the mask/unmask behavior that guest want. In the previous patch I used 
enable_irq()/disable_irq(), but they won't directly operate the MSI-X table unless 
it's necessary, and Michael want to read the table in userspace then he prefer 
using mask/unmask directly.

--
regards
Yang, Sheng

  reply	other threads:[~2010-10-24 12:19 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-20  8:26 [PATCH 0/8][v2] MSI-X mask emulation support for assigned device Sheng Yang
2010-10-20  8:26 ` [PATCH 1/8] PCI: MSI: Move MSI-X entry definition to pci_regs.h Sheng Yang
2010-10-20 11:07   ` Matthew Wilcox
2010-10-20  8:26 ` [PATCH 2/8] irq: Export irq_to_desc() to modules Sheng Yang
2010-10-20  8:26 ` [PATCH 3/8] KVM: x86: Enable ENABLE_CAP capability for x86 Sheng Yang
2010-10-20  8:26 ` [PATCH 4/8] KVM: Move struct kvm_io_device to kvm_host.h Sheng Yang
2010-10-20  8:26 ` [PATCH 5/8] KVM: Add kvm_get_irq_routing_entry() func Sheng Yang
2010-10-20  8:53   ` Avi Kivity
2010-10-20  8:58     ` Sheng Yang
2010-10-20  9:13     ` Sheng Yang
2010-10-20  9:17       ` Sheng Yang
2010-10-20  9:32         ` Avi Kivity
2010-10-20  8:26 ` [PATCH 6/8] KVM: assigned dev: Preparation for mask support in userspace Sheng Yang
2010-10-20  9:30   ` Avi Kivity
2010-10-22 14:53   ` Marcelo Tosatti
2010-10-24 12:19     ` Sheng Yang [this message]
2010-10-24 12:23       ` Michael S. Tsirkin
2010-10-28  8:21         ` Sheng Yang
2010-10-20  8:26 ` [PATCH 7/8] KVM: assigned dev: Introduce io_device for MSI-X MMIO accessing Sheng Yang
2010-10-20  9:46   ` Avi Kivity
2010-10-20 10:33     ` Michael S. Tsirkin
2010-10-21  6:46     ` Sheng Yang
2010-10-21  9:27       ` Avi Kivity
2010-10-21  9:24         ` Michael S. Tsirkin
2010-10-21  9:47           ` Avi Kivity
2010-10-21 10:51             ` Michael S. Tsirkin
2010-10-20 22:35   ` Michael S. Tsirkin
2010-10-21  7:44     ` Sheng Yang
2010-10-20  8:26 ` [PATCH 8/8] KVM: Emulation MSI-X mask bits for assigned devices Sheng Yang
2010-10-20  9:49   ` Avi Kivity
2010-10-20 22:24   ` Michael S. Tsirkin
2010-10-21  8:30   ` Sheng Yang
2010-10-21  8:39     ` Michael S. Tsirkin
2010-10-22  4:42       ` Sheng Yang
2010-10-22 10:17         ` Michael S. Tsirkin
2010-10-22 13:30           ` Sheng Yang
2010-10-22 14:32             ` Michael S. Tsirkin
2010-10-20  9:51 ` [PATCH 0/8][v2] MSI-X mask emulation support for assigned device Avi Kivity
2010-10-20 10:44   ` Michael S. Tsirkin
2010-10-20 10:59     ` Avi Kivity
2010-10-20 13:43       ` Michael S. Tsirkin
2010-10-20 14:58         ` Alex Williamson
2010-10-20 14:58           ` Michael S. Tsirkin
2010-10-20 15:12             ` Alex Williamson
2010-10-20 15:17         ` Avi Kivity
2010-10-20 15:22           ` Alex Williamson
2010-10-20 15:26             ` Avi Kivity
2010-10-20 15:38               ` Alex Williamson
2010-10-20 14:47     ` Alex Williamson
2010-10-20 14:46       ` Michael S. Tsirkin
2010-10-20 15:07         ` Alex Williamson
2010-10-20 15:13           ` Michael S. Tsirkin
2010-10-20 20:13             ` Alex Williamson
2010-10-20 22:06               ` Michael S. Tsirkin
2010-10-20 15:23       ` Avi Kivity
2010-10-20 15:38         ` Alex Williamson
2010-10-20 15:54           ` Avi Kivity
2010-10-20 15:59             ` Michael S. Tsirkin
2010-10-20 16:13               ` Avi Kivity
2010-10-20 17:11                 ` Michael S. Tsirkin
2010-10-20 18:31               ` Alex Williamson
2010-10-21  7:41   ` Sheng Yang
2010-10-20 19:02 ` Marcelo Tosatti
2010-10-21  7:10   ` Sheng Yang
2010-10-21  8:21     ` Michael S. Tsirkin
2010-10-20 22:20 ` Michael S. Tsirkin

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=201010242019.09655.sheng@linux.intel.com \
    --to=sheng@linux.intel.com \
    --cc=avi@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=mst@redhat.com \
    --cc=mtosatti@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox