From: Marek Marczykowski <marmarek@invisiblethingslab.com>
To: Jan Beulich <JBeulich@suse.com>
Cc: Kevin Tian <kevin.tian@intel.com>,
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>,
Simon Gaiser <simon@invisiblethingslab.com>,
Julien Grall <julien.grall@arm.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
xen-devel <xen-devel@lists.xenproject.org>,
Brian Woods <brian.woods@amd.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: Re: [PATCH v4.1 4/6] xen/x86: Allow stubdom access to irq created for msi.
Date: Wed, 27 Feb 2019 16:18:51 +0100 [thread overview]
Message-ID: <20190227151851.GF19265@mail-itl> (raw)
In-Reply-To: <5C766F8A020000780021AA64@prv1-mh.provo.novell.com>
[-- Attachment #1.1: Type: text/plain, Size: 3543 bytes --]
On Wed, Feb 27, 2019 at 04:07:54AM -0700, Jan Beulich wrote:
> >>> On 08.02.19 at 11:17, <marmarek@invisiblethingslab.com> wrote:
> > There is one code path where I haven't managed to properly extract
> > possible stubdomain in use:
> > pci_remove_device()
> > -> pci_cleanup_msi()
> > -> msi_free_irqs()
> > -> msi_free_irq()
> > -> destroy_irq()
> >
> > For now I've hardcoded hardware_domain there (in msi_free_irqs). Can it happen
> > when device is still assigned to some domU?
>
> In case this question is still open: No, it can't with current code,
> and provided Dom0 behaves correctly.
Thanks for confirmation.
> > @@ -368,13 +369,13 @@ static int __init hpet_assign_irq(struct hpet_event_channel *ch)
> > {
> > int irq;
> >
> > - if ( (irq = create_irq(NUMA_NO_NODE)) < 0 )
> > + if ( (irq = create_irq(NUMA_NO_NODE, hardware_domain)) < 0 )
> > return irq;
> >
> > ch->msi.irq = irq;
> > if ( hpet_setup_msi_irq(ch) )
> > {
> > - destroy_irq(irq);
> > + destroy_irq(irq, hardware_domain);
> > return -EINVAL;
> > }
>
> Why don't you take the opportunity here (and elsewhere) and properly
> remove hwdom access to such internal-to-Xen IRQs? Simply pass NULL
> here, and skip permission granting in this case (create_irq() already
> checks for NULL anyway).
Already queued for v5, per Roger's review.
> > @@ -190,19 +190,19 @@ int create_irq(nodeid_t node)
> > desc->arch.used = IRQ_UNUSED;
> > irq = ret;
> > }
> > - else if ( hardware_domain )
> > + else if ( dm_domain )
> > {
> > - ret = irq_permit_access(hardware_domain, irq);
> > + ret = irq_permit_access(dm_domain, irq);
>
> Doesn't this imply that Dom0 has no way of cleaning up after the
> guest/stubdom pair? IOW I wonder whether both dm and hwdom
> should be granted access.
See discussion with Roger on this very patch.
In short: since permissions are stored in domain struct, not irq, there
is not much to cleanup after domain destruction. Also, toolstack in dom0
has no idea about IRQs allocated by stubdomain, so it couldn't do such
cleanup anyway.
> > @@ -2095,7 +2099,9 @@ int map_domain_pirq(
> > irq = info->arch.irq;
> > }
> > msi_desc->irq = -1;
> > - msi_free_irq(msi_desc);
> > + msi_free_irq(msi_desc,
> > + current->domain->target == d ? current->domain
> > + : hardware_domain);
>
> Note how ->irq gets set to -1 prior to the call (and also in at least
> one other instance), which will lead to skipping of the destroy_irq()
> call, and hence skipping of the permission removal. Or wait, that's
> going to be taken care of in the caller as it seems. If this is also
> your understanding, then please add a sentence to the description
> pointing this out. The split logic isn't really helpful here (I know it
> was me who wrote it, in an attempt to avoid re-writing everything
> basically from scratch).
Yes, that matches my understanding - the caller will call on error
destroy_irq(), if it called create_irq() before (which may not always be
the case - and I think this is why it isn't destroyed here).
--
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-27 15:19 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 [this message]
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
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=20190227151851.GF19265@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=brian.woods@amd.com \
--cc=julien.grall@arm.com \
--cc=kevin.tian@intel.com \
--cc=konrad.wilk@oracle.com \
--cc=roger.pau@citrix.com \
--cc=simon@invisiblethingslab.com \
--cc=sstabellini@kernel.org \
--cc=suravee.suthikulpanit@amd.com \
--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.