linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: David Woodhouse <dwmw2@infradead.org>
Cc: Jason Andryuk <jandryuk@gmail.com>, <josef@oderland.se>,
	<boris.ostrovsky@oracle.com>, <helgaas@kernel.org>,
	<jgross@suse.com>, <linux-pci@vger.kernel.org>, <maz@kernel.org>,
	<tglx@linutronix.de>, <xen-devel@lists.xenproject.org>
Subject: Re: [PATCH] PCI/MSI: Fix masking MSI/MSI-X on Xen PV
Date: Mon, 25 Oct 2021 16:12:34 +0200	[thread overview]
Message-ID: <YXa7UtYyX7y+cCwU@MacBook-Air-de-Roger.local> (raw)
In-Reply-To: <acaca10c50155b75c82c6370236231856b30ade4.camel@infradead.org>

On Mon, Oct 25, 2021 at 02:02:38PM +0100, David Woodhouse wrote:
> On Mon, 2021-10-25 at 14:58 +0200, Roger Pau Monné wrote:
> > On Mon, Oct 25, 2021 at 12:53:31PM +0100, David Woodhouse wrote:
> > > On Mon, 2021-10-25 at 13:43 +0200, Roger Pau Monné wrote:
> > > > It's kind of optional for HVM guests, as it depends on
> > > > XENFEAT_hvm_pirqs, which sadly gets unconditionally set for HVM
> > > > guests, thus dropping any benefits from having hardware assisted APIC
> > > > virtualization or posted interrupts support.
> > > 
> > > Indeed. After implementing PIRQ support for Xen guests running under
> > > KVM, I spent a "happy" couple of days swearing at it because it
> > > actually *worked* if something would just *unmask* the f***ing MSI, but
> > > the guest inexplicably (to me) didn't do that.
> > > 
> > > Took me a while to work out that Xen itself is *snooping* on the MSI
> > > table writes even while they are *masked*, to capture the magic MSI
> > > message (with vector==0) which means it's actually a PIRQ# in the
> > > destination ID bits, and then magically unmask the MSI when the guest
> > > binds that PIRQ to an event channel.
> > > 
> > > I did not enjoy implementing that part.
> > 
> > I can see that. It's even better because none of this is actually
> > documented.
> 
> Indeed. I still haven't worked out if/how Xen actually *masks* the
> corresponding MSI-X again. It can't do so when the evtchn is masked,
> since that's just a bit in the shinfo page. So while the evtchn is
> masked, the MSI can still be screaming into the void?

I think so, it's quite weird because as a side effect of this mangling
Xen is transforming an edge triggered interrupt to a level triggered
one, as masked event channels belonging to MSI vectors will get set to
pending.

So it's not entirely screaming into the void because it will get
(wrongly) set as pending when masked.

> Perhaps it does so when the PIRQ is unbound from the evtchn?
> 
> > > FWIW the *guest* could potentlaly be smarter here and elect not to use
> > > PIRQs when hardware assisted vAPIC is present. Aren't there some bits
> > > in the CPUID that Xen advertises, which indicate that? 
> > 
> > Yes, it's in leaf 0x40000x04. FWIW, I would also be fine with removing
> > XENFEAT_hvm_pirqs, as I don't think diverging from the hardware
> > specifications gives us much benefit. We avoid a couple of vm exits
> > for sure, but the cost of having all those modifications in guest
> > OSes is not worth it.
> 
> These days with posted interrupts, it doesn't even save us any vmexits;
> it's all that additional guest complexity just to give us *more*
> vmexits than we would have had :)

Oh indeed. I was thinking about hardware without APIC hw
virtualization or posted interrupts.

Roger.

  reply	other threads:[~2021-10-25 14:12 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18  6:22 [PATCH] PCI/MSI: Re-add checks for skip masking MSI-X on Xen PV Josef Johansson
2021-10-19 19:57 ` Bjorn Helgaas
2021-10-19 20:15   ` Josef Johansson
2021-10-19 20:29     ` Bjorn Helgaas
2021-10-19 21:48       ` [PATCH v2] " Josef Johansson
2021-10-20 12:51         ` Marc Zyngier
2021-10-20 14:03           ` Jason Andryuk
2021-10-21  8:25             ` Josef Johansson
2021-10-24 18:55               ` Josef Johansson
2021-10-25  1:25                 ` [PATCH] PCI/MSI: Fix masking MSI/MSI-X " Jason Andryuk
2021-10-25  7:44                   ` David Woodhouse
2021-10-25 11:43                     ` Roger Pau Monné
2021-10-25 11:53                       ` David Woodhouse
2021-10-25 12:58                         ` Roger Pau Monné
2021-10-25 13:02                           ` David Woodhouse
2021-10-25 14:12                             ` Roger Pau Monné [this message]
2021-10-25 12:31                     ` Jason Andryuk
2021-10-25 12:27                   ` Jason Andryuk
2021-10-25 16:46                     ` Josef Johansson
2021-10-26 21:17                       ` Josef Johansson
2021-10-27  8:45                   ` Thomas Gleixner
2021-10-27  9:50                     ` [PATCH] PCI/MSI: Move non-mask check back into low level accessors Thomas Gleixner
2021-10-27  9:54                       ` Josef Johansson
2021-10-27 12:01                         ` Josef Johansson
2021-10-27 15:29                           ` Josef Johansson
2021-11-03 23:26                             ` Thomas Gleixner
2021-11-03 23:27                               ` [PATCH v2] " Thomas Gleixner
2021-11-09 14:53                                 ` Thomas Gleixner
2021-11-10 13:31                                   ` Josef Johansson
2021-11-10 16:05                                     ` Josef Johansson
2021-11-03 23:45                             ` [PATCH] " Thomas Gleixner
2021-11-04  9:00                               ` Josef Johansson
2021-11-04 17:12                               ` Peter Zijlstra
2021-11-04 17:31                               ` Vincent Guittot
2021-11-10 20:30                               ` Josef Johansson
2021-11-10 23:13                                 ` Josef Johansson
2021-10-27  9:57                       ` David Woodhouse
2021-10-25  1:25                 ` [PATCH v2] PCI/MSI: Re-add checks for skip masking MSI-X on Xen PV Jason Andryuk
2021-10-25 19:21                   ` Josef Johansson
2021-10-27  6:24                     ` David Woodhouse
2021-10-27  8:13                       ` Josef Johansson
2021-10-27  8:26                         ` David Woodhouse

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=YXa7UtYyX7y+cCwU@MacBook-Air-de-Roger.local \
    --to=roger.pau@citrix.com \
    --cc=boris.ostrovsky@oracle.com \
    --cc=dwmw2@infradead.org \
    --cc=helgaas@kernel.org \
    --cc=jandryuk@gmail.com \
    --cc=jgross@suse.com \
    --cc=josef@oderland.se \
    --cc=linux-pci@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=xen-devel@lists.xenproject.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 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).