From: Marek Marczykowski <marmarek@invisiblethingslab.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Stefano Stabellini <sstabellini@kernel.org>,
Wei Liu <wei.liu2@citrix.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>,
George Dunlap <George.Dunlap@eu.citrix.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Ian Jackson <Ian.Jackson@eu.citrix.com>, Tim Deegan <tim@xen.org>,
Julien Grall <julien.grall@arm.com>,
xen-devel <xen-devel@lists.xenproject.org>,
Daniel de Graaf <dgdegra@tycho.nsa.gov>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH v4 5/6] xen/x86: add PHYSDEVOP_msi_set_enable
Date: Thu, 28 Feb 2019 13:25:46 +0100 [thread overview]
Message-ID: <20190228122546.GN5348@mail-itl> (raw)
In-Reply-To: <5C77BEDD020000780021B030@prv1-mh.provo.novell.com>
[-- Attachment #1.1: Type: text/plain, Size: 3080 bytes --]
On Thu, Feb 28, 2019 at 03:58:37AM -0700, Jan Beulich wrote:
> >>> On 27.02.19 at 16:05, <marmarek@invisiblethingslab.com> wrote:
> > On Wed, Feb 27, 2019 at 04:41:37AM -0700, Jan Beulich wrote:
> >> >>> On 07.02.19 at 01:07, <marmarek@invisiblethingslab.com> wrote:
> >> > +int msi_msix_set_enable(struct pci_dev *pdev, int mode, int enable)
> >> > +{
> >> > + int ret;
> >> > +
> >> > + ret = xsm_msi_set_enable(XSM_DM_PRIV, pdev->domain,
> >> > + (pdev->seg << 16) | (pdev->bus << 8) | pdev->devfn,
> >> > + mode, enable);
> >> > + if ( ret )
> >> > + return ret;
> >> > +
> >> > + switch ( mode )
> >> > + {
> >> > + case PHYSDEVOP_MSI_SET_ENABLE_MSI:
> >> > + msi_set_enable(pdev, enable);
> >> > + break;
> >> > +
> >> > + case PHYSDEVOP_MSI_SET_ENABLE_MSIX:
> >> > + msix_set_enable(pdev, enable);
> >> > + break;
> >> > + }
> >>
> >> What about a call to pci_intx()?
> >
> > Should pci_intx(dev, !enable) be called in all those cases?
>
> Well, that depends whether Dom0 is involved, which is where the
> operation would normally be done. But since this is about bypassing
> pciback, I think it may be needed.
>
> >> And what about invocations for
> >> the wrong device (e.g. MSI-X request for MSI-X incapable device)?
> >
> > Looking at msi(x)_set_enable(), it is no-op for incapable devices, but
> > if the function would do anything else, indeed such check should be
> > added. Is pci_find_cap_offset(..., PCI_CAP_ID_MSI(X)) the correct way
> > of doing that?
>
> Well, for MSI-X you could simply check pdev->msix to be non-NULL.
> For MSI I think looking for the capability is your only choice.
>
> Another thing: You're also bypassing the MSI{,-X}-already-enabled
> checks that __pci_enable_msi{,x}() do, yet allowing to enable both
> on a device would be a security issue.
Ok.
> >> > + /* IN */
> >> > + uint16_t seg;
> >> > + uint8_t bus;
> >> > + uint8_t devfn;
> >> > + uint8_t mode;
> >> > + uint8_t enable;
> >>
> >> "mode" and "enable" don't really make clear which of the two is the
> >> boolean, and which is the operation. I'd anyway prefer a single
> >> flags field with descriptive #define-s, which will also make more
> >> obvious how to extend this if need be.
> >
> > You mean:
> >
> > #define PHYSDEVOP_MSI_CONTROL_ENABLE 1
> > #define PHYSDEVOP_MSI_CONTROL_MSI 2
> > #define PHYSDEVOP_MSI_CONTROL_MSIX 4
>
> Not exactly - you need just two flags: One selecting between
> enable and disable, and a second selecting between MSI and
> MSI-X. Otherwise, in your model, what do 0 or ENABLE alone
> mean?
I put 3 flags there for easier extending it in the future.
But maybe indeed two flags + error on any other bit set would be enough
too.
--
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
[-- Attachment #2: Type: text/plain, Size: 157 bytes --]
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
next prev parent reply other threads:[~2019-02-28 12:25 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-07 0:07 [PATCH v4 0/6] Fix PCI passthrough for HVM with stubdomain Marek Marczykowski-Górecki
2019-02-07 0:07 ` [PATCH v4 1/6] libxl: do not attach xen-pciback to HVM domain, if stubdomain is in use Marek Marczykowski-Górecki
2019-02-07 0:07 ` [PATCH v4 2/6] libxl: attach PCI device to qemu only after setting pciback/pcifront Marek Marczykowski-Górecki
2019-02-07 0:07 ` [PATCH v4 3/6] libxl: don't try to manipulate json config for stubdomain Marek Marczykowski-Górecki
2019-02-21 16:16 ` Wei Liu
2019-02-07 0:07 ` [PATCH v4 4/6] xen/x86: Allow stubdom access to irq created for msi Marek Marczykowski-Górecki
2019-02-07 9:57 ` Roger Pau Monné
2019-02-07 13:21 ` Marek Marczykowski-Górecki
2019-02-07 13:40 ` Roger Pau Monné
2019-02-07 14:52 ` Marek Marczykowski-Górecki
2019-02-07 14:57 ` Roger Pau Monné
2019-02-07 15:41 ` Marek Marczykowski-Górecki
2019-02-07 17:40 ` Roger Pau Monné
2019-02-07 17:51 ` Marek Marczykowski-Górecki
2019-02-08 9:35 ` Roger Pau Monné
2019-02-08 10:15 ` Marek Marczykowski-Górecki
2019-02-08 10:17 ` [PATCH v4.1 " Marek Marczykowski-Górecki
2019-02-21 16:47 ` Roger Pau Monné
2019-02-21 17:40 ` Marek Marczykowski-Górecki
2019-02-22 10:42 ` Roger Pau Monné
2019-02-22 11:11 ` Jan Beulich
2019-03-07 0:50 ` Marek Marczykowski-Górecki
2019-03-07 14:48 ` Roger Pau Monné
2019-03-07 22:28 ` Marek Marczykowski-Górecki
2019-03-08 10:26 ` Roger Pau Monné
2019-03-08 16:49 ` Marek Marczykowski-Górecki
2019-03-08 17:04 ` Jan Beulich
2019-03-08 12:33 ` Jan Beulich
2019-02-27 11:07 ` Jan Beulich
2019-02-27 15:18 ` Marek Marczykowski
2019-02-28 10:50 ` Jan Beulich
2019-02-28 11:41 ` Roger Pau Monné
2019-02-07 0:07 ` [PATCH v4 5/6] xen/x86: add PHYSDEVOP_msi_set_enable Marek Marczykowski-Górecki
2019-02-07 10:25 ` Roger Pau Monné
2019-02-27 11:41 ` Jan Beulich
2019-02-27 15:05 ` Marek Marczykowski
2019-02-28 10:58 ` Jan Beulich
2019-02-28 12:25 ` Marek Marczykowski [this message]
2019-03-03 1:10 ` Marek Marczykowski
2019-03-04 10:19 ` Roger Pau Monné
2019-03-04 10:22 ` Jan Beulich
2019-03-03 3:26 ` Marek Marczykowski
2019-02-07 0:07 ` [PATCH v4 6/6] tools/libxc: add wrapper for PHYSDEVOP_msi_set_enable 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=20190228122546.GN5348@mail-itl \
--to=marmarek@invisiblethingslab.com \
--cc=George.Dunlap@eu.citrix.com \
--cc=Ian.Jackson@eu.citrix.com \
--cc=JBeulich@suse.com \
--cc=andrew.cooper3@citrix.com \
--cc=dgdegra@tycho.nsa.gov \
--cc=julien.grall@arm.com \
--cc=konrad.wilk@oracle.com \
--cc=roger.pau@citrix.com \
--cc=sstabellini@kernel.org \
--cc=tim@xen.org \
--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.