linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] Device isolation infrastructure v2
@ 2011-12-15  6:25 David Gibson
  2011-12-15  6:25 ` [PATCH 1/3] device_isolation: Infrastructure for managing device isolation groups David Gibson
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: David Gibson @ 2011-12-15  6:25 UTC (permalink / raw)
  To: alex.williamson
  Cc: aik, benh, joerg.roedel, dwmw2, chrisw, agraf, scottwood, B08248,
	rusty, iommu, qemu-devel, linux-kernel

Here's the second spin of my preferred approach to handling grouping
of devices for safe assignment to guests.

Changes since v1:
 * Many name changes and file moves for improved consistency
 * Bugfixes and cleanups
 * The interface to the next layer up is considerably fleshed out,
   although it still needs work.
 * Example initialization of groups for p5ioc2 and p7ioc.

TODO:
 * Need sample initialization of groups for intel and/or amd iommus
 * Use of sysfs attributes to control group permission is probably a
   mistake.  Although it seems a bit odd, registering a chardev for
   each group is probably better, because perms can be set from udev
   rules, just like everything else.
 * Need more details of what the binder structure will need to
   contain.
 * Handle complete removal of groups.
 * Clarify what will need to happen on the hot unplug path.


^ permalink raw reply	[flat|nested] 27+ messages in thread
* RFC: Device isolation groups
@ 2012-02-01  4:46 David Gibson
  2012-02-01  4:46 ` [PATCH 2/3] device_isolation: Support isolation on POWER p5ioc2 bridges David Gibson
  0 siblings, 1 reply; 27+ messages in thread
From: David Gibson @ 2012-02-01  4:46 UTC (permalink / raw)
  To: dwmw2, iommu
  Cc: aik, benh, qemu-devel, alex.williamson, joerg.roedel, kvm, linux-kernel

This patch series introduces a new infrastructure to the driver core
for representing "device isolation groups".  That is, groups of
devices which can be "isolated" in such a way that the rest of the
system can be protected from them, even in the presence of userspace
or a guest OS directly driving the devices.

Isolation will typically be due to an IOMMU which can safely remap DMA
and interrupts coming from these devices.  We need to represent whole
groups, rather than individual devices, because there are a number of
cases where the group can be isolated as a whole, but devices within
it cannot be safely isolated from each other - this usually occurs
because the IOMMU cannot reliably distinguish which device in the
group initiated a transaction.  In other words, isolation groups
represent the minimum safe granularity for passthrough to guests or
userspace.

This series provides the core infraustrcture for tracking isolation
groups, and example implementations initializing the groups
appropriately for two PCI bridges (which include IOMMUs) found on IBM
POWER systems.

Actually using the group information is not included here, but David
Woodhouse has expressed an interest in using a structure like this to
represent operations in iommu_ops more correctly.

Some tracking of groups is a prerequisite for safe passthrough of
devices to guests or userspace, such as done by VFIO.  Current VFIO
patches use the iommu_ops->device_group mechanism for this.  However,
that mechanism is awkward, because without an in-kernel concrete
representation of groups, enumerating a group requires traversing
every device on a given bus type.  It also fails to cover some very
plausible IOMMU topologies, because its groups cannot span devices on
multiple bus types.


^ permalink raw reply	[flat|nested] 27+ messages in thread
* [PATCH 2/3] device_isolation: Support isolation on POWER p5ioc2 bridges
@ 2011-12-15  6:09 David Gibson
  0 siblings, 0 replies; 27+ messages in thread
From: David Gibson @ 2011-12-15  6:09 UTC (permalink / raw)
  To: alex.williamson
  Cc: aik, benh, joerg.roedel, dwmw2, chrisw, agraf, scottwood, B08248,
	iommu, qemu-devel, linux-kernel

This patch adds code to the code for the powernv platform to create
and populate isolation groups on hardware using the p5ioc2 PCI host
bridge used on some IBM POWER systems.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
---
 arch/powerpc/platforms/powernv/pci-p5ioc2.c |   14 +++++++++++++-
 arch/powerpc/platforms/powernv/pci.h        |    3 +++
 2 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/arch/powerpc/platforms/powernv/pci-p5ioc2.c b/arch/powerpc/platforms/powernv/pci-p5ioc2.c
index 4c80f7c..24847a9 100644
--- a/arch/powerpc/platforms/powernv/pci-p5ioc2.c
+++ b/arch/powerpc/platforms/powernv/pci-p5ioc2.c
@@ -20,6 +20,7 @@
 #include <linux/irq.h>
 #include <linux/io.h>
 #include <linux/msi.h>
+#include <linux/device_isolation.h>
 
 #include <asm/sections.h>
 #include <asm/io.h>
@@ -88,10 +89,21 @@ static void pnv_pci_init_p5ioc2_msis(struct pnv_phb *phb) { }
 static void __devinit pnv_pci_p5ioc2_dma_dev_setup(struct pnv_phb *phb,
 						   struct pci_dev *pdev)
 {
-	if (phb->p5ioc2.iommu_table.it_map == NULL)
+	if (phb->p5ioc2.iommu_table.it_map == NULL) {
 		iommu_init_table(&phb->p5ioc2.iommu_table, phb->hose->node);
+#ifdef CONFIG_DEVICE_ISOLATION
+		phb->p5ioc2.di_group = kzalloc(sizeof(*(phb->p5ioc2.di_group)),
+					       GFP_KERNEL);
+		BUG_ON(!phb->p5ioc2.di_group ||
+		       (device_isolation_group_init(phb->p5ioc2.di_group,
+						    "p5ioc2:%llx", phb->opal_id) < 0));
+#endif
+	}
 
 	set_iommu_table_base(&pdev->dev, &phb->p5ioc2.iommu_table);
+#ifdef CONFIG_DEVICE_ISOLATION
+	device_isolation_dev_add(phb->p5ioc2.di_group, &pdev->dev);
+#endif
 }
 
 static void __init pnv_pci_init_p5ioc2_phb(struct device_node *np,
diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h
index 28ae4ca..a2dc071 100644
--- a/arch/powerpc/platforms/powernv/pci.h
+++ b/arch/powerpc/platforms/powernv/pci.h
@@ -77,6 +77,9 @@ struct pnv_phb {
 	union {
 		struct {
 			struct iommu_table iommu_table;
+#ifdef CONFIG_DEVICE_ISOLATION
+			struct device_isolation_group *di_group;
+#endif
 		} p5ioc2;
 
 		struct {
-- 
1.7.7.3


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2012-02-01 19:15 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-15  6:25 [RFC] Device isolation infrastructure v2 David Gibson
2011-12-15  6:25 ` [PATCH 1/3] device_isolation: Infrastructure for managing device isolation groups David Gibson
2011-12-15  6:25 ` [PATCH 2/3] device_isolation: Support isolation on POWER p5ioc2 bridges David Gibson
2011-12-15  6:25 ` [PATCH 3/3] device_isolation: Support isolation on POWER p7ioc (IODA) bridges David Gibson
2011-12-15 18:05 ` [RFC] Device isolation infrastructure v2 Alex Williamson
2011-12-15 22:39   ` Alex Williamson
2011-12-16  1:40   ` David Gibson
2011-12-16  4:49     ` Alex Williamson
2011-12-16  6:00       ` David Gibson
2011-12-16 14:53   ` Joerg Roedel
2011-12-19  0:11     ` David Gibson
2011-12-19 15:41       ` Joerg Roedel
2011-12-21  3:32         ` [Qemu-devel] " David Gibson
2011-12-21  4:30           ` Alex Williamson
2011-12-21  6:12             ` Aaron Fabbri
2012-01-25  3:13             ` David Gibson
2012-01-25 23:44               ` Alex Williamson
2012-01-30 23:22                 ` David Gibson
2011-12-21 16:46           ` Joerg Roedel
2011-12-19 15:46       ` David Woodhouse
2011-12-19 22:31         ` David Gibson
2011-12-19 22:56           ` David Woodhouse
2011-12-20  0:25             ` David Gibson
  -- strict thread matches above, loose matches on Subject: below --
2012-02-01  4:46 RFC: Device isolation groups David Gibson
2012-02-01  4:46 ` [PATCH 2/3] device_isolation: Support isolation on POWER p5ioc2 bridges David Gibson
2012-02-01 18:58   ` Alex Williamson
2012-02-01 19:15     ` Alex Williamson
2011-12-15  6:09 David Gibson

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).