From: Alex Williamson <alex.williamson@redhat.com>
To: Andreas Hartmann <andihartmann@01019freenet.de>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH] uio_pci_generic does not export memory resources
Date: Sat, 09 Jun 2012 08:50:55 -0600 [thread overview]
Message-ID: <1339253455.26976.165.camel@ul30vt> (raw)
In-Reply-To: <201206090928.q599SXSV003324@mail.maya.org>
On Sat, 2012-06-09 at 11:28 +0200, Andreas Hartmann wrote:
> Alex Williamson wrote:
> > On Fri, 2012-06-08 at 18:16 +0200, Andreas Hartmann wrote:
> [...]
> >> Besides the problem with AMD IOMMU, which requires to unbind a whole
> >> group of devices in some cases (PCI passthrough - not PCIe), it's really
> >> cool! And it's usable now!
> >
> > If you're feeling adventurous (and know that this may not make it
> > upstream), you can do something like this:
>
> Hmm, even without this patch, it's not necessary to bind all devices to
> pci-stub. Just to remember:
>
> -[0000:00]-+-14.0 Advanced Micro Devices [AMD] nee ATI SBx00 SMBus Controller
> +-14.1 Advanced Micro Devices [AMD] nee ATI SB7x0/SB8x0/SB9x0 IDE Controller
> +-14.2 Advanced Micro Devices [AMD] nee ATI SBx00 Azalia (Intel HDA)
> +-14.3 Advanced Micro Devices [AMD] nee ATI SB7x0/SB8x0/SB9x0 LPC host controller
> +-14.4-[06]--
> \-14.5 Advanced Micro Devices [AMD] nee ATI SB7x0/SB8x0/SB9x0 USB OHCI2 Controller
>
> Device 06:07.0 should be passed through.
>
> The devices 14.0, 14.3 and 14.4 need not to be bound to pci-stub - the
> VM starts (and seems to work fine) anyway. Maybe because there isn't
> any driver anyway for these devices?
Right, the actual rule is that any device you want to access needs to be
bound to vfio-pci. The remaining devices within the group can either be
bound to vfio-pci or pci-stub or no driver. The recommendation for
avoiding that no-driver case is because if later a driver is loaded into
the kernel that would attempt to bind to any of those no-driver devices,
you end up back in the situation of the security of the group being
violated and hit the BUGON you saw previously.
> The USB device seems to be an internal device only - all of my external
> USB jacks are working fine.
>
> The only thing I'm missing is the sound device.
>
> > diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c
> > index ab0dba0..5c26804 100644
> > --- a/drivers/pci/quirks.c
> > +++ b/drivers/pci/quirks.c
> > @@ -3161,11 +3161,22 @@ struct pci_dev *pci_get_dma_source(struct pci_dev *dev)
> > return pci_dev_get(dev);
> > }
> >
> > +static int pci_func_supports_acs(struct pci_dev *dev, u16 acs_flags)
> > +{
> > + return 1;
> > +}
> > +
> > static const struct pci_dev_acs_enabled {
> > u16 vendor;
> > u16 device;
> > int (*acs_enabled)(struct pci_dev *dev, u16 acs_flags);
> > } pci_dev_acs_enabled[] = {
> > + { 0x1002, 0x4385, pci_func_supports_acs },
> > + { 0x1002, 0x439c, pci_func_supports_acs },
> > + { 0x1002, 0x4383, pci_func_supports_acs },
> > + { 0x1002, 0x439d, pci_func_supports_acs },
> > + { 0x1002, 0x4384, pci_func_supports_acs },
> > + { 0x1002, 0x4399, pci_func_supports_acs },
> > { 0 }
> > };
>
> What's the risk of this patch? Machine crash? Data loss for an active
> file in an application? Complete filesystem damage? The latter would be
> worse.
What we're trying to prevent by testing whether devices support ACS is
peer-to-peer transactions that would not be translated via the IOMMU.
For instance, imagine if your WLAN controller behind 14.4 does a DMA
write to an address that happens to be within the MMIO resources of
device 14.2, the audio device. Instead of the transaction going up to
the IOMMU and resulting in a memory write, internal routing on device
14.x results in that transaction being redirected to the 14.2. So
you're looking at potential data loss from the guest as well as
corrupting device state in the host.
> > Hmm, I wonder if we should make a kernel boot parameter that allows
> > whitelisting some devices. I think it would have to taint the kernel
> > but there's probably sufficient interest for usability vs
> > supportability.
>
> Good idea. I would print an additional big fat warning of dataloss /
> filesystem damage / crash if this could be the case.
Well, outlining the risk above makes me a little more nervous about
making such a config option, even if it taints the kernel, available so
easily... :^\ Thanks,
Alex
next prev parent reply other threads:[~2012-06-09 14:51 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-08 11:56 [PATCH] uio_pci_generic does not export memory resources Dominic Eschweiler
2012-06-08 13:03 ` Michael S. Tsirkin
2012-06-08 13:16 ` Jan Kiszka
2012-06-08 14:16 ` Alex Williamson
2012-06-08 14:47 ` Dominic Eschweiler
2012-06-08 15:06 ` Alex Williamson
2012-06-08 16:16 ` Andreas Hartmann
2012-06-08 16:41 ` Alex Williamson
2012-06-09 9:28 ` Andreas Hartmann
2012-06-09 14:50 ` Alex Williamson [this message]
2012-06-09 16:25 ` Andreas Hartmann
2012-06-09 16:55 ` Alex Williamson
2012-06-10 7:21 ` Andreas Hartmann
2012-06-10 19:12 ` Andreas Hartmann
2012-06-10 14:12 ` Michael S. Tsirkin
2012-06-08 16:44 ` Hans J. Koch
2012-06-08 16:59 ` Jan Kiszka
2012-06-08 17:11 ` Alex Williamson
2012-06-10 14:18 ` Michael S. Tsirkin
2012-06-10 16:09 ` Alex Williamson
2012-06-10 16:44 ` Michael S. Tsirkin
2012-06-10 17:38 ` Alex Williamson
2012-06-10 18:43 ` Michael S. Tsirkin
2012-06-10 19:00 ` Michael S. Tsirkin
2012-06-10 19:11 ` Hans J. Koch
2012-06-10 19:16 ` Michael S. Tsirkin
2012-06-10 20:19 ` Hans J. Koch
2012-06-10 19:01 ` Hans J. Koch
2012-06-08 14:28 ` Dominic Eschweiler
2012-06-08 15:18 ` Hans J. Koch
2012-06-08 15:45 ` Dominic Eschweiler
2012-06-08 15:57 ` Hans J. Koch
2012-06-08 16:23 ` Dominic Eschweiler
2012-06-08 16:37 ` Hans J. Koch
2012-06-08 17:07 ` Dominic Eschweiler
2012-06-08 17:11 ` Hans J. Koch
2012-06-08 16:39 ` Michael S. Tsirkin
2012-06-08 16:07 ` Hans J. Koch
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=1339253455.26976.165.camel@ul30vt \
--to=alex.williamson@redhat.com \
--cc=andihartmann@01019freenet.de \
--cc=jan.kiszka@siemens.com \
--cc=kvm@vger.kernel.org \
--cc=mst@redhat.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