All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Roger Pau Monné" <roger.pau@citrix.com>
To: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
Cc: Simon Gaiser <simon@invisiblethingslab.com>,
	xen-devel@lists.xenproject.org, Wei Liu <wei.liu2@citrix.com>,
	Jan Beulich <jbeulich@suse.com>,
	Andrew Cooper <andrew.cooper3@citrix.com>
Subject: Re: [PATCH v2 4/4] xen/x86: Allow stubdom access to irq created for msi.
Date: Wed, 16 Jan 2019 13:20:04 +0100	[thread overview]
Message-ID: <20190116122004.byvr2bttwkttofqs@mac> (raw)
In-Reply-To: <20190116105218.GM1205@mail-itl>

On Wed, Jan 16, 2019 at 11:52:18AM +0100, Marek Marczykowski-Górecki wrote:
> On Wed, Jan 16, 2019 at 10:21:29AM +0100, Roger Pau Monné wrote:
> > On Tue, Jan 15, 2019 at 04:36:31PM +0100, Marek Marczykowski-Górecki wrote:
> > > From: Simon Gaiser <simon@invisiblethingslab.com>
> > > 
> > > Stubdomains need to be given sufficient privilege over the guest which it
> > > provides emulation for in order for PCI passthrough to work correctly.
> > > When a HVM domain try to enable MSI, QEMU in stubdomain calls
> > > PHYSDEVOP_map_pirq, but later it needs to call XEN_DOMCTL_bind_pt_irq as
> > > part of xc_domain_update_msi_irq. Allow for that as part of
> > > PHYSDEVOP_map_pirq.
> > 
> > I see, that's not a problem AFAICT for PCI INTx because the IRQ in
> > that case is known beforehand, and the stubdomain is given permissions
> > over this IRQ by libxl__device_pci_add (there's a do_pci_add against
> > the stubdomain).
> 
> Exactly.

I would maybe consider adding something like this to the commit
message, so it's clear why PCI INTx works but not MSI interrupts.

> 
> > > 
> > > Based on https://github.com/OpenXT/xenclient-oe/blob/5e0e7304a5a3c75ef01240a1e3673665b2aaf05e/recipes-extended/xen/files/stubdomain-msi-irq-access.patch by Eric Chanudet <chanudete@ainfosec.com>.
> > > 
> > > Signed-off-by: Simon Gaiser <simon@invisiblethingslab.com>
> > > Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
> > > ---
> > > This is only one part of fixing MSI with QEMU in stubdomain. The other
> > > part is allowing stubdomain to actually enable MSI in PCI config space.
> > > QEMU does that through pcifront/back connected to the stubdomain (see
> > > hw/xen/xen_pt_msi.c:msi_msix_enable()), but pciback by default refuse
> > > write to that register.
> > > Easy, less safe solution: enable permissive mode for the device.
> > > Safer solution - enable access to this register for stubdomain only
> > > (pciback patch that add such flag + libxl patch to set it for relevant
> > >  devices)
> > > The whole story:
> > > https://www.qubes-os.org/news/2017/10/18/msi-support/
> > > 
> > > Any other ideas? Which one is preferred upstream?
> > 
> > IMO, and please correct me if I'm wrong, QEMU in the stubdomain will
> > receive the PCI config space write to enable MSI, and since this
> > stub-QEMU runs in PV mode I think it should use the PV way to enable
> > MSI, ie: the same that Linux pcifront uses to enable MSI for
> > passed-through devices.
> > 
> > Is this something that sounds sensible?
> 
> We've considered this option too. Let me quote Simon on that (from the
> link above):
> 
>     The enable command that pcifront sends is intended for the normal PV use
>     case where the device is passed to the VM itself (via pcifront) rather
>     than to the stub domain target. While the command is called enable_msi,
>     pciback does much more than simply setting the enable flag. It also
>     configures IRQ handling in the dom0 kernel, adapts the MSI masking, and
>     more. This makes sense in the PV case, but in the HVM case, the MSI
>     configuration is done by QEMU, so this most likely won’t work correctly.

Oh great, that's unfortunate. Both pciback functions end up calling
into msi_capability_init in the Linux kernel, which does indeed more
than just toggling the PCI config space enable bit.

OTOH adding a bypass to pciback so the stubdom is able to write to the
PCI register in order to toggle the enable bit seems quite clumsy. Not
to mention that you would be required to update Dom0 kernel in order to
fix the issue.

Do you think it makes sense to add a domctl to enable/disable MSI(X)?

This way the bug could be fixed by just updating Xen (and the
stubdomain).

Thanks, Roger.

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  reply	other threads:[~2019-01-16 12:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-15 15:36 [PATCH v2 0/4] Fix PCI passthrough for HVM with stubdomain Marek Marczykowski-Górecki
2019-01-15 15:36 ` [PATCH v2 1/4] libxl: do not attach xen-pciback to HVM domain, if stubdomain is in use Marek Marczykowski-Górecki
2019-01-16 16:47   ` Roger Pau Monné
2019-01-16 17:00     ` Marek Marczykowski-Górecki
2019-01-17  9:21       ` Roger Pau Monné
2019-01-17 13:32         ` Marek Marczykowski-Górecki
2019-01-15 15:36 ` [PATCH v2 2/4] libxl: attach PCI device to qemu only after setting pciback/pcifront Marek Marczykowski-Górecki
2019-01-17 10:29   ` Roger Pau Monné
2019-01-26  2:24     ` Marek Marczykowski-Górecki
2019-01-15 15:36 ` [PATCH v2 3/4] libxl: don't try to manipulate json config for stubdomain Marek Marczykowski-Górecki
2019-01-17 10:44   ` Roger Pau Monné
2019-01-15 15:36 ` [PATCH v2 4/4] xen/x86: Allow stubdom access to irq created for msi Marek Marczykowski-Górecki
2019-01-16  9:21   ` Roger Pau Monné
2019-01-16 10:52     ` Marek Marczykowski-Górecki
2019-01-16 12:20       ` Roger Pau Monné [this message]
     [not found]         ` <94C5C3AC020000F30063616D@prv1-mh.provo.novell.com>
2019-01-16 12:57           ` Jan Beulich
2019-01-16 13:07             ` Roger Pau Monné
2019-01-16 13:49         ` Marek Marczykowski-Górecki
2019-01-17  8:57           ` Roger Pau Monné
     [not found]             ` <FB0C9893020000480063616D@prv1-mh.provo.novell.com>
2019-01-17 11:52               ` Jan Beulich
2019-01-17 11:56                 ` Roger Pau Monné
2019-01-17 12:20                   ` Jan Beulich
2019-01-17 12:32                     ` Roger Pau Monné
     [not found]                       ` <21B633D80200008F0063616D@prv1-mh.provo.novell.com>
2019-01-17 13:12                         ` Jan Beulich
2019-01-25 19:43       ` Marek Marczykowski-Górecki
2019-01-25 20:04         ` Marek Marczykowski-Górecki

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=20190116122004.byvr2bttwkttofqs@mac \
    --to=roger.pau@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=marmarek@invisiblethingslab.com \
    --cc=simon@invisiblethingslab.com \
    --cc=wei.liu2@citrix.com \
    --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 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.