OSDN Git Service

iommu/arm-smmu: Don't group PCI devices
authorMitchel Humpherys <mitchelh@codeaurora.org>
Tue, 26 Jul 2016 18:03:48 +0000 (11:03 -0700)
committerLiam Mark <lmark@codeaurora.org>
Mon, 1 Aug 2016 20:48:50 +0000 (13:48 -0700)
commit6fbe4a9662e808bf381a834d85c4b5e08f9241df
tree5879ae26211ed19ad12664f17298d5bbffd95a2a
parent9e4b3ba4afcff08bce320513610955391ab95806
iommu/arm-smmu: Don't group PCI devices

In general, the IOMMU framework likes to group PCI devices together.
This prevents someone from assigning them to separate VMs using VFIO,
for example.  The reason they shouldn't go to separate VMs is because
there could be DMA aliasing between endpoint devices, and because the
root complex device can access anything that endpoint devices can
access.

Unfortunately, this makes things difficult in the DMA layer since the
IOMMU framework freaks out if you try to attach a single device that is
also part of a group.  First instinct might be to start using
iommu_attach_group instead of iommu_attach_device in the DMA layer but
that has problems of its own (it attaches *everyone* in the group as
soon as one client attaches).  Besides all that, it's also a bit
annoying to have the root complex device in group since, in our
platform, it doesn't actually have any stream IDs assigned to it and it
doesn't do any DMA of its own, so it doesn't really make any logical
sense to attach it.

As a compromise, we can stop grouping PCI devices together by allocating
a new domain for each one.  By doing so we no longer need to call
iommu_attach_group in the DMA layer, avoid the issues described above.

It should be noted that with this patch in place we can't securely do
any direct DMA assignment of PCI endpoint devices to separate VMs.

CRs-Fixed: 1036401
Change-Id: I9528b61a695dc7840e1c6f80af18044340f5c6c4
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
drivers/iommu/arm-smmu.c