From: "Marek Marczykowski-Górecki" <marmarek@invisiblethingslab.com>
To: Wei Liu <wei.liu2@citrix.com>
Cc: "Simon Gaiser" <simon@invisiblethingslab.com>,
xen-devel@lists.xenproject.org,
"Roger Pau Monné" <roger.pau@citrix.com>,
"Jan Beulich" <jbeulich@suse.com>,
"Andrew Cooper" <andrew.cooper3@citrix.com>
Subject: Re: [PATCH v3 4/6] xen/x86: Allow stubdom access to irq created for msi.
Date: Mon, 28 Jan 2019 21:30:28 +0100 [thread overview]
Message-ID: <20190128203028.GB21228@mail-itl> (raw)
In-Reply-To: <20190128145000.anm6g3svz5adk5fo@zion.uk.xensource.com>
[-- Attachment #1.1: Type: text/plain, Size: 3166 bytes --]
On Mon, Jan 28, 2019 at 02:50:00PM +0000, Wei Liu wrote:
> On Sat, Jan 26, 2019 at 03:31:15AM +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.
> >
> > This is not needed for PCI INTx, because 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).
> >
> > 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>
> > ---
> > Changes in v3:
> > - extend commit message
> >
> > With this patch, stubdomain will be able to create and map multiple irq
> > (DoS possibility?), as only target domain is validated in practice. Is
> > that ok? If not, what additional limits could be applied here?
> > In INTx case the problem doesn't apply, because toolstack grant access
> > to particular IRQ and no allocation happen on stubdomain request. But in
> > MSI case, it isn't that easy as IRQ number isn't known before (as
> > explained in the commit message).
> > ---
> > xen/arch/x86/irq.c | 23 +++++++++++++++++++++++
> > xen/arch/x86/physdev.c | 9 +++++++++
> > 2 files changed, 32 insertions(+)
> >
> > diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
> > index 8b44d6c..67c67d4 100644
> > --- a/xen/arch/x86/irq.c
> > +++ b/xen/arch/x86/irq.c
> > @@ -2674,6 +2674,21 @@ int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p,
> > {
> > case MAP_PIRQ_TYPE_MULTI_MSI:
> > irq = create_irq(NUMA_NO_NODE);
> > + if ( !(irq < nr_irqs_gsi || irq >= nr_irqs) &&
> > + current->domain->target == d )
> > + {
> > + ret = irq_permit_access(current->domain, irq);
> > + if ( ret ) {
> > + dprintk(XENLOG_G_ERR,
> > + "dom%d: can't grant it's stubdom (%d) access to "
> > + "irq %d for msi: %d!\n",
> > + d->domain_id,
> > + current->domain->domain_id,
> > + irq,
> > + ret);
> > + return ret;
>
> Don't you need to deallocate the irq before returning?
Yes, indeed.
--
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-01-28 20:30 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-26 2:31 [PATCH v3 0/6] Fix PCI passthrough for HVM with stubdomain Marek Marczykowski-Górecki
2019-01-26 2:31 ` [PATCH v3 1/6] libxl: do not attach xen-pciback to HVM domain, if stubdomain is in use Marek Marczykowski-Górecki
2019-01-28 14:24 ` Wei Liu
2019-01-26 2:31 ` [PATCH v3 2/6] libxl: attach PCI device to qemu only after setting pciback/pcifront Marek Marczykowski-Górecki
2019-01-28 14:24 ` Wei Liu
2019-01-26 2:31 ` [PATCH v3 3/6] libxl: don't try to manipulate json config for stubdomain Marek Marczykowski-Górecki
2019-01-28 14:41 ` Wei Liu
2019-01-28 21:11 ` Marek Marczykowski-Górecki
2019-01-26 2:31 ` [PATCH v3 4/6] xen/x86: Allow stubdom access to irq created for msi Marek Marczykowski-Górecki
2019-01-28 14:50 ` Wei Liu
2019-01-28 20:30 ` Marek Marczykowski-Górecki [this message]
2019-01-26 2:31 ` [PATCH v3 5/6] xen/x86: add PHYSDEVOP_msi_msix_set_enable Marek Marczykowski-Górecki
2019-01-28 14:57 ` Wei Liu
2019-01-30 13:51 ` Roger Pau Monné
[not found] ` <AE0ECAE80200006E0063616D@prv1-mh.provo.novell.com>
2019-01-30 14:39 ` Jan Beulich
2019-02-01 21:58 ` Daniel De Graaf
2019-01-26 2:31 ` [PATCH v3 6/6] tools/libxc: add wrapper for PHYSDEVOP_msi_msix_set_enable Marek Marczykowski-Górecki
2019-01-28 14:43 ` Wei Liu
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=20190128203028.GB21228@mail-itl \
--to=marmarek@invisiblethingslab.com \
--cc=andrew.cooper3@citrix.com \
--cc=jbeulich@suse.com \
--cc=roger.pau@citrix.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.