From: Laszlo Ersek <lersek@redhat.com>
To: Jan Beulich <JBeulich@novell.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Drew Jones <drjones@redhat.com>,
"xen-devel@lists.xensource.com" <xen-devel@lists.xensource.com>
Subject: Re: [RFC PATCH linux-2.6.18-xen] pciback: clean up (MSI-X vec, entrynr) list when resetting PCI device
Date: Wed, 01 Jun 2011 17:27:15 +0200 [thread overview]
Message-ID: <4DE65A53.9020909@redhat.com> (raw)
In-Reply-To: <4DE66FDF0200007800044EC7@vpn.id2.novell.com>
On 06/01/11 16:59, Jan Beulich wrote:
>>>> On 01.06.11 at 16:12, Laszlo Ersek<lersek@redhat.com> wrote:
>> On 06/01/11 14:56, Jan Beulich wrote:
>>>>>> On 01.06.11 at 12:05, Laszlo Ersek<lersek@redhat.com> wrote:
>>
>>>> domU: igbvf_shutdown()
>>>> igbvf_suspend()
>>>> pci_disable_device()
>>>> pcibios_disable_device()
>>>> pcibios_disable_resources()
>>>> pci_write_config_word(
>>>> dev, PCI_COMMAND,
>>>> orig& ~(PCI_COMMAND_IO | PCI_COMMAND_MEMORY)
>>>> )
>>>> ...
>>>> pcifront_bus_write()
>>>> do_pci_op(XEN_PCI_OP_conf_write)
>>>> dom0: pciback_do_op()
>>>> pciback_config_write()
>>>> conf_space_write()
>>>> command_write() [via PCI_COMMAND funcptr]
>>>> pci_disable_device()
>>>> disable_msi_mode()
>>>> dev->msix_enabled = 0;
>>>>
>>> So I wonder whether you shouldn't fix
>>> pci_disable_device() instead, or alternatively move the vector
>>> de-allocation (and then for MSI and MSI-X) into disable_msi_mode().
>>
>> Yes, I did think of that, however IMO that would introduce exactly the
>> problem that you describe below. If either pci_disable_device() or
>> disable_msi_mode() frees the vector, then re-enabling the device can
>> face yet another stumbling block.
>
> Why - pci_enable_msi{,x}() call msi{,x}_capability_init(), which
> obtains the vectors.
Which can fail. I imagined there was a conscious deliberation in the
background: hold on to the vectors we already have, just enable/disable
generation of the MSIs in the device.
> The problem is that calling disable_msi_mode() alone is always a
> mistake, this should have been a static function just like its
> counterpart, enable_msi_mode().
Well this would unify the "disposition" and the "generation", and
dev->msix_enabled would have a clear meaning.
>>> While the approach you take covers the guest shutdown/restart
>>> case, what if the guest called its pci_disable_device() at runtime,
>>> expecting to be able to call pci_enable_{device,msi,msix}() on it
>>> again later on? Your newly added function would also be called here,
>>
>> May I ask how? The function is only called from pciback_reset_device(),
>
> I was just looking at the call tree you provided (and which is still
> quoted at the top). Oh - you're referring to Dom0 calling the
> function, whereas I wrote about what happens when guest calls
> its version of it.
> Yeah, when the domain is gone you have this problem. But if you
> properly removed the vectors while the domain is still there, you
> shouldn't.
> For that situation this was the natural place, but you're dealing
> with an alive domain not being cleaned up after properly during
> certain operations, and deferring the cleanup until the domain is
> gone is only going to call for further problems (as outlined earlier,
> and who knows what other cases we didn't consider).
The original idea (probably the most straightforward one) was to modify
the igbvf driver (ie. the domU) so that it would call igbvf_remove()
from igbvf_shutdown(), instead of the current igbvf_suspend();
restricted to the case when the code runs in a PV domU. igbvf_remove()
calls igbvf_reset_interrupt_capability(), which in turn calls
pci_disable_msix(). The latter percolates through the entire stack and
does the right thing.
Or, as you say above, the guest's generic MSI-X massaging PCI code could
be modified.
We didn't want to leave this to the guest, however. It's not that I
intentionally try to postpone the cleanup until after the domain has
vanished; it's rather the domU can't be expected / trusted to do the
cleanup itself in all cases.
(I realize we can't talk about "security" in this case at all, since
passthrough-to-PV doesn't cross the IOMMU and "has the potential to
access the DMA address space of dom0, which is a potential security
concern" anyway. Or some such.)
> Hence while I realize that from a pragmatic point of view your
> approach may seem acceptable, it only fixing a particular aspect
> of a more general problem is not really something I like.
Thank you for the review :)
lacos
next prev parent reply other threads:[~2011-06-01 15:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-01 10:05 [RFC PATCH linux-2.6.18-xen] pciback: clean up (MSI-X vec, entrynr) list when resetting PCI device Laszlo Ersek
2011-06-01 11:02 ` Laszlo Ersek
2011-06-01 14:31 ` Konrad Rzeszutek Wilk
2011-06-01 16:18 ` Paolo Bonzini
2011-06-01 17:32 ` Laszlo Ersek
2011-06-01 18:13 ` 2.6.38 (FC15) with PCI passthrough fails mysteriously with iommu=soft Konrad Rzeszutek Wilk
2011-06-02 7:42 ` Laszlo Ersek
2011-06-02 20:49 ` Pasi Kärkkäinen
2011-06-01 12:56 ` [RFC PATCH linux-2.6.18-xen] pciback: clean up (MSI-X vec, entrynr) list when resetting PCI device Jan Beulich
2011-06-01 14:12 ` Laszlo Ersek
2011-06-01 14:59 ` Jan Beulich
2011-06-01 15:27 ` Laszlo Ersek [this message]
2011-06-01 16:07 ` Jan Beulich
2011-06-01 16:25 ` Andrew Jones
2011-06-01 16:27 ` Paolo Bonzini
2011-06-01 16:16 ` Paolo Bonzini
2011-06-01 14:51 ` Konrad Rzeszutek Wilk
2011-06-01 15:01 ` Konrad Rzeszutek Wilk
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=4DE65A53.9020909@redhat.com \
--to=lersek@redhat.com \
--cc=JBeulich@novell.com \
--cc=drjones@redhat.com \
--cc=pbonzini@redhat.com \
--cc=xen-devel@lists.xensource.com \
/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).