iommu: Move initialization earlier
Subsystems (8)
A message that is not in the archive (sent off-list or not yet received): 1367824921-27151-1-git-send-email-y
PATCH 1/5 iommu: Move initialization earlier
From: Alexey Kardashevskiy <[email protected]>
The iommu_init() call initializes IOMMU internal structures and data required for the API to function such as iommu_group_alloc(). It is registered as a subsys_initcall.
One of the IOMMU users is a PCI subsystem on POWER which discovers new IOMMU tables during the PCI scan so the most logical place to call iommu_group_alloc() is when a new group is just discovered. However PCI scan is done from subsys_initcall hook as well, which makes use of the IOMMU API impossible.
This moves IOMMU subsystem initialization one step earlier.
--- drivers/iommu/iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/iommu.c +1 -1
@@ -890,7 +890,7 @@ static int __init iommu_init(void)return 0 ; } -subsys_initcall (iommu_init); +arch_initcall (iommu_init);int iommu_domain_get_attr (struct iommu_domain *domain,enum iommu_attr attr,void *data)
Signature · 1 line
1.7.10.4
PATCH 2/5 KVM: PPC: iommu: Add missing kvm_iommu_map_pages/kvm_iommu_unmap_pages
In reply to a message not in the archiveFrom: Alexey Kardashevskiy <[email protected]>
The IOMMU API implements groups creating/deletion, device binding and IOMMU map/unmap operations.
The PowerPC implementation uses most of the API except map/unmap operations, which are implemented on POWER using hypercalls.
However, in order to link a kernel with the CONFIG_IOMMU_API enabled, the empty kvm_iommu_map_pages/kvm_iommu_unmap_pages have to be defined, so this defines them.
--- arch/powerpc/include/asm/kvm_host.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/powerpc/include/asm/kvm_host.h +14 -0
@@ -603,4 +603,18 @@ struct kvm_vcpu_arch {#define __KVM_HAVE_ARCH_WQP +#ifdef CONFIG_IOMMU_API +/* POWERPC does not use IOMMU API for mapping/unmapping */ +static inline int kvm_iommu_map_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{ +return 0 ; +} + +static inline void kvm_iommu_unmap_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{ +} +#endif /* CONFIG_IOMMU_API */ +#endif /* __POWERPC_KVM_HOST_H__ */
Signature · 1 line
1.7.10.4
Re: [PATCH 2/5] KVM: PPC: iommu: Add missing kvm_iommu_map_pages/kvm_iommu_unmap_pages
Quoted 32 lines · On Mon, 2013-05-06 at 17:21 +1000, [email protected] wrote:
From: Alexey Kardashevskiy <[email protected]>
The IOMMU API implements groups creating/deletion, device binding and IOMMU map/unmap operations.
The PowerPC implementation uses most of the API except map/unmap operations, which are implemented on POWER using hypercalls.
However, in order to link a kernel with the
CONFIG_IOMMU_APIenabled, the empty kvm_iommu_map_pages/kvm_iommu_unmap_pages have to be defined, so this defines them.Signed-off-by Alexey Kardashevskiy <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/include/asm/kvm_host.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/powerpc/include/asm/kvm_host.h +5
-0@@ -603,4 +603,18 @@ struct kvm_vcpu_arch {#define __KVM_HAVE_ARCH_WQP +#ifdef CONFIG_IOMMU_API +/* POWERPC does not use IOMMU API for mapping/unmapping */ +static inline int kvm_iommu_map_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{
arch/powerpc/include/asm/kvm_host.h struct kvm_vcpu_arch { · line 620
Quoted 10 lines
arch/powerpc/include/asm/kvm_host.h +9
-0+return 0 ; +} + +static inline void kvm_iommu_unmap_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{ +} +#endif /* CONFIG_IOMMU_API */ +#endif /* __POWERPC_KVM_HOST_H__ */
This is no longer needed, Gleb applied my patch for 3.10 that make all of KVM device assignment dependent on a build config option and the top level kvm_host.h now includes this when that is not set. Thanks,
Alex
Re: [PATCH 2/5] KVM: PPC: iommu: Add missing kvm_iommu_map_pages/kvm_iommu_unmap_pages
Quoted 39 lines · Alex Williamson
Quoted 38 lines · On Mon, 2013-05-06 at 17:21 +1000, [email protected] wrote:
From: Alexey Kardashevskiy <[email protected]>
The IOMMU API implements groups creating/deletion, device binding and IOMMU map/unmap operations.
The PowerPC implementation uses most of the API except map/unmap operations, which are implemented on POWER using hypercalls.
However, in order to link a kernel with the
CONFIG_IOMMU_APIenabled, the empty kvm_iommu_map_pages/kvm_iommu_unmap_pages have to be defined, so this defines them.Signed-off-by Alexey Kardashevskiy <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/include/asm/kvm_host.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/powerpc/include/asm/kvm_host.h +11
-0@@ -603,4 +603,18 @@ struct kvm_vcpu_arch {#define __KVM_HAVE_ARCH_WQP +#ifdef CONFIG_IOMMU_API +/* POWERPC does not use IOMMU API for mapping/unmapping */ +static inline int kvm_iommu_map_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{ +return 0 ; +} + +static inline void kvm_iommu_unmap_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{
Quoted 8 lines
arch/powerpc/include/asm/kvm_host.h struct kvm_vcpu_arch { · line 620
Quoted 4 lines
arch/powerpc/include/asm/kvm_host.h +3
-0+} +#endif /* CONFIG_IOMMU_API */ +#endif /* __POWERPC_KVM_HOST_H__ */ This is no longer needed, Gleb applied my patch for 3.10 that make all of KVM device assignment dependent on a build config option and the top level
kvm_host.hnow includes this when that is not set. Thanks,
Cannot find it, could you point me please where it is on github or git.kernel.org? Thanks.
Signature · 1 line
Alexey
Re: [PATCH 2/5] KVM: PPC: iommu: Add missing kvm_iommu_map_pages/kvm_iommu_unmap_pages
Quoted 49 lines · Alexey Kardashevskiy
Quoted 39 lines · Alex Williamson
Quoted 38 lines · On Mon, 2013-05-06 at 17:21 +1000, [email protected] wrote:
From: Alexey Kardashevskiy <[email protected]>
The IOMMU API implements groups creating/deletion, device binding and IOMMU map/unmap operations.
The PowerPC implementation uses most of the API except map/unmap operations, which are implemented on POWER using hypercalls.
However, in order to link a kernel with the
CONFIG_IOMMU_APIenabled, the empty kvm_iommu_map_pages/kvm_iommu_unmap_pages have to be defined, so this defines them.Signed-off-by Alexey Kardashevskiy <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/include/asm/kvm_host.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/powerpc/include/asm/kvm_host.h +11
-0@@ -603,4 +603,18 @@ struct kvm_vcpu_arch {#define __KVM_HAVE_ARCH_WQP +#ifdef CONFIG_IOMMU_API +/* POWERPC does not use IOMMU API for mapping/unmapping */ +static inline int kvm_iommu_map_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{ +return 0 ; +} + +static inline void kvm_iommu_unmap_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{Quoted 8 lines
arch/powerpc/include/asm/kvm_host.h struct kvm_vcpu_arch { · line 620
Quoted 4 lines
arch/powerpc/include/asm/kvm_host.h +3
-0+} +#endif /* CONFIG_IOMMU_API */ +#endif /* __POWERPC_KVM_HOST_H__ */ This is no longer needed, Gleb applied my patch for 3.10 that make all of KVM device assignment dependent on a build config option and the top level
kvm_host.hnow includes this when that is not set. Thanks,
Quoted 2 lines
Cannot find it, could you point me please where it is on github or git.kernel.org? Thanks.
Re: [PATCH 2/5] KVM: PPC: iommu: Add missing kvm_iommu_map_pages/kvm_iommu_unmap_pages
Quoted 50 lines · Alex Williamson
Quoted 49 lines · Alexey Kardashevskiy
Quoted 47 lines · Alex Williamson
Quoted 32 lines · On Mon, 2013-05-06 at 17:21 +1000, [email protected] wrote:
From: Alexey Kardashevskiy <[email protected]>
The IOMMU API implements groups creating/deletion, device binding and IOMMU map/unmap operations.
The PowerPC implementation uses most of the API except map/unmap operations, which are implemented on POWER using hypercalls.
However, in order to link a kernel with the
CONFIG_IOMMU_APIenabled, the empty kvm_iommu_map_pages/kvm_iommu_unmap_pages have to be defined, so this defines them.Signed-off-by Alexey Kardashevskiy <[email protected]>Cc David Gibson <[email protected]>Signed-off-by Paul Mackerras <[email protected]>--- arch/powerpc/include/asm/kvm_host.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+)arch/powerpc/include/asm/kvm_host.h +5
-0@@ -603,4 +603,18 @@ struct kvm_vcpu_arch {#define __KVM_HAVE_ARCH_WQP +#ifdef CONFIG_IOMMU_API +/* POWERPC does not use IOMMU API for mapping/unmapping */ +static inline int kvm_iommu_map_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{arch/powerpc/include/asm/kvm_host.h struct kvm_vcpu_arch { · line 620
Quoted 10 lines
arch/powerpc/include/asm/kvm_host.h +9
-0+return 0 ; +} + +static inline void kvm_iommu_unmap_pages (struct kvm *kvm, +struct kvm_memory_slot *slot) +{ +} +#endif /* CONFIG_IOMMU_API */ +#endif /* __POWERPC_KVM_HOST_H__ */ This is no longer needed, Gleb applied my patch for 3.10 that make all of KVM device assignment dependent on a build config option and the top level
kvm_host.hnow includes this when that is not set. Thanks,
Quoted 4 lines
Quoted 2 lines
Cannot find it, could you point me please where it is on github or git.kernel.org? Thanks.
Yes, I confirm, this is patch is not need any more. Thanks!
Signature · 1 line
Alexey
PATCH 3/5 powerpc/vfio: Enable on POWERNV platform
In reply to a message not in the archiveFrom: Alexey Kardashevskiy <[email protected]>
This initializes IOMMU groups based on the IOMMU configuration discovered during the PCI scan on POWERNV (POWER non virtualized) platform. The IOMMU groups are to be used later by the VFIO driver, which is used for PCI pass through.
It also implements an API for mapping/unmapping pages for guest PCI drivers and providing DMA window properties. This API is going to be used later by QEMU-VFIO to handle h_put_tce hypercalls from the KVM guest.
The iommu_put_tce_user_mode() does only a single page mapping as an API for adding many mappings at once is going to be added later.
Although this driver has been tested only on the POWERNV platform, it should work on any platform which supports TCE tables. As h_put_tce hypercall is received by the host kernel and processed by the QEMU (what involves calling the host kernel again), performance is not the best - circa 220MB/s on 10Gb ethernet network.
To enable VFIO on POWER, enable SPAPR_TCE_IOMMU config option and configure VFIO as required.
--- arch/powerpc/include/asm/iommu.h | 26 +++ arch/powerpc/kernel/iommu.c | 319 +++++++++++++++++++++++++++ arch/powerpc/platforms/powernv/pci-ioda.c | 1 + arch/powerpc/platforms/powernv/pci-p5ioc2.c | 5 +- arch/powerpc/platforms/powernv/pci.c | 2 + drivers/iommu/Kconfig | 8 + 6 files changed, 360 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/iommu.h +26 -0
@@ -76,6 +76,9 @@ struct iommu_table {struct iommu_pool large_pool;struct iommu_pool pools[IOMMU_NR_POOLS ];unsigned long *it_map;/* A simple allocation bitmap for now */ +#ifdef CONFIG_IOMMU_API +struct iommu_group *it_group; +#endif };struct scatterlist ;
@@ -98,6 +101,8 @@ extern void iommu_free_table(struct iommu_table *tbl, const char *node_name);*/ extern struct iommu_table *iommu_init_table (struct iommu_table * tbl,int nid); +extern void iommu_register_group (struct iommu_table *tbl, +int pci_domain_number,unsigned long pe_num); extern int iommu_map_sg(struct device *dev, struct iommu_table *tbl, struct scatterlist *sglist, int nelems,
@@ -147,5 +152,26 @@ static inline void iommu_restore(void) }#endif +/* The API to support IOMMU operations for VFIO */ +extern int iommu_tce_clear_param_check (struct iommu_table *tbl, +unsigned long ioba,unsigned long tce_value, +unsigned long npages); +extern int iommu_tce_put_param_check (struct iommu_table *tbl, +unsigned long ioba,unsigned long tce); +extern int iommu_tce_build (struct iommu_table *tbl,unsigned long entry, +unsigned long hwaddr,enum dma_data_direction direction); +extern unsigned long iommu_clear_tce (struct iommu_table *tbl, +unsigned long entry); +extern int iommu_clear_tces_and_put_pages (struct iommu_table *tbl, +unsigned long entry,unsigned long pages); +extern int iommu_put_tce_user_mode (struct iommu_table *tbl, +unsigned long entry,unsigned long tce); + +extern void iommu_flush_tce (struct iommu_table *tbl); +extern int iommu_take_ownership (struct iommu_table *tbl); +extern void iommu_release_ownership (struct iommu_table *tbl); + +extern enum dma_data_direction iommu_tce_direction (unsigned long tce); +#endif /* __KERNEL__ */ #endif /* _ASM_IOMMU_H */
arch/powerpc/kernel/iommu.c +319 -0
340 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci-ioda.c +1 -0
@@ -522,6 +522,7 @@ static void pnv_pci_ioda_setup_dma_pe(struct pnv_phb *phb, | TCE_PCI_SWINV_PAIR; }iommu_init_table (tbl, phb->hose->node); +iommu_register_group (tbl,pci_domain_nr (pe->pbus), pe->pe_number);if (pe->pdev)set_iommu_table_base (&pe->pdev->dev, tbl);
arch/powerpc/platforms/powernv/pci-p5ioc2.c +4 -1
@@ -87,8 +87,11 @@ static void pnv_pci_init_p5ioc2_msis(struct pnv_phb *phb) { }static void 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); +iommu_register_group (&phb->p5ioc2.iommu_table, +pci_domain_nr (phb->hose->bus), phb->opal_id); + }set_iommu_table_base (&pdev->dev, &phb->p5ioc2.iommu_table); }
arch/powerpc/platforms/powernv/pci.c +2 -0
@@ -20,6 +20,7 @@#include <linux/irq.h> #include <linux/io.h> #include <linux/msi.h> +#include <linux/iommu.h> #include <asm/sections.h> #include <asm/io.h>
@@ -483,6 +484,7 @@ static struct iommu_table *pnv_pci_setup_bml_iommu(struct pci_controller *hose)pnv_pci_setup_iommu_table (tbl,__va (be64_to_cpup (basep)),be32_to_cpup (sizep),0 );iommu_init_table (tbl, hose->node); +iommu_register_group (tbl,pci_domain_nr (hose->bus),0 );/* Deal with SW invalidated TCEs when needed (BML way) */ swinvp = of_get_property(hose->dn, "linux,tce-sw-invalidate-info",
drivers/iommu/Kconfig +8 -0
@@ -187,4 +187,12 @@ config EXYNOS_IOMMU_DEBUG Say N unless you need kernel log message for IOMMU debugging +config SPAPR_TCE_IOMMU + bool "sPAPR TCE IOMMU Support" + depends on PPC_POWERNV + select IOMMU_API + help + Enables bits of IOMMU API required by VFIO. The iommu_ops + is not implemented as it is not necessary for VFIO. + endif # IOMMU_SUPPORT
Signature · 1 line
1.7.10.4
PATCH 4/5 powerpc/vfio: Implement IOMMU driver for VFIO
In reply to a message not in the archiveFrom: Alexey Kardashevskiy <[email protected]>
VFIO implements platform independent stuff such as a PCI driver, BAR access (via read/write on a file descriptor or direct mapping when possible) and IRQ signaling.
The platform dependent part includes IOMMU initialization and handling. This implements an IOMMU driver for VFIO which does mapping/unmapping pages for the guest IO and provides information about DMA window (required by a POWER guest).
---
Change log:
* no more PPC versions for vfio_iommu_spapr_tce_dma_(un)map ("type1" structs reused)
* documentation updated
* containter enable/disable ioctls added
* request_module(spapr_iommu) added
* various locks fixed
* multiple TCE mapping support (no clients for that for now as SPAPR does it in a different way)
--- Documentation/vfio.txt | 63 ++++++ drivers/vfio/Kconfig | 6 + drivers/vfio/Makefile | 1 + drivers/vfio/vfio.c | 1 + drivers/vfio/vfio_iommu_spapr_tce.c | 377 +++++++++++++++++++++++++++++++++++ include/uapi/linux/vfio.h | 34 ++++ 6 files changed, 482 insertions(+) create mode 100644 drivers/vfio/vfio_iommu_spapr_tce.c
Documentation/vfio.txt +63 -0
@@ -283,6 +283,69 @@ a direct pass through for VFIO_DEVICE_* ioctls. The read/write/mmap interfaces implement the device region access defined by the device's own VFIO_DEVICE_GET_REGION_INFO ioctl. + +PPC64 sPAPR implementation note +------------------------------------------------------------------------------- + +This implementation has some specifics: + +1) Only one IOMMU group per container is supported as an IOMMU group +represents the minimal entity which isolation can be guaranteed for and +groups are allocated statically, one per a Partitionable Endpoint (PE) +(PE is often a PCI domain but not always). + +2) The hardware supports so called DMA windows - the PCI address range +within which DMA transfer is allowed, any attempt to access address space +out of the window leads to the whole PE isolation. + +3) PPC64 guests are paravirtualized but not fully emulated. There is an API +to map/unmap pages for DMA, and it normally maps 1..32 pages per call and +currently there is no way to reduce the number of calls. In order to make things +faster, the map/unmap handling has been implemented in real mode which provides +an excellent performance which has limitations such as inability to do +locked pages accounting in real time. + +So 3 additional ioctls have been added: + + VFIO_IOMMU_SPAPR_TCE_GET_INFO - returns the size and the start + of the DMA window on the PCI bus. + + VFIO_IOMMU_ENABLE - enables the container. The locked pages accounting + is done at this point. This lets user first to know what + the DMA window is and adjust rlimit before doing any real job. + + VFIO_IOMMU_DISABLE - disables the container. + + +The code flow from the example above should be slightly changed: + + ..... + /* Add the group to the container */ + ioctl(group, VFIO_GROUP_SET_CONTAINER, &container); + + /* Enable the IOMMU model we want */ + ioctl(container, VFIO_SET_IOMMU, VFIO_SPAPR_TCE_IOMMU) + + /* Get addition sPAPR IOMMU info */ + vfio_iommu_spapr_tce_info spapr_iommu_info; + ioctl(container, VFIO_IOMMU_SPAPR_TCE_GET_INFO, &spapr_iommu_info); + + if (ioctl(container, VFIO_IOMMU_ENABLE)) + /* Cannot enable container, may be low rlimit */ + + /* Allocate some space and setup a DMA mapping */ + dma_map.vaddr = mmap(0, 1024 * 1024, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS, 0, 0); + + dma_map.size = 1024 * 1024; + dma_map.iova = 0; /* 1MB starting at 0x0 from device view */ + dma_map.flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE; + + /* Check here is .iova/.size are within DMA window from spapr_iommu_info */ + + ioctl(container, VFIO_IOMMU_MAP_DMA, &dma_map); + ..... + ------------------------------------------------------------------------------- [1] VFIO was originally an acronym for "Virtual Function I/O" in its
drivers/vfio/Kconfig +6 -0
@@ -3,10 +3,16 @@ config VFIO_IOMMU_TYPE1 depends on VFIO default n +config VFIO_IOMMU_SPAPR_TCE + tristate + depends on VFIO && SPAPR_TCE_IOMMU + default n + menuconfig VFIO tristate "VFIO Non-Privileged userspace driver framework" depends on IOMMU_API select VFIO_IOMMU_TYPE1 if X86 + select VFIO_IOMMU_SPAPR_TCE if PPC_POWERNV help VFIO provides a framework for secure userspace device drivers. See Documentation/vfio.txt for more details.
drivers/vfio/Makefile +1 -0
@@ -1,3 +1,4 @@ obj-$(CONFIG_VFIO) += vfio.o obj-$(CONFIG_VFIO_IOMMU_TYPE1) += vfio_iommu_type1.o +obj-$(CONFIG_VFIO_IOMMU_SPAPR_TCE) += vfio_iommu_spapr_tce.o obj-$(CONFIG_VFIO_PCI) += pci/
drivers/vfio/vfio.c +1 -0
@@ -1376,6 +1376,7 @@ static int __init vfio_init(void)* drivers. */ request_module_nowait ("vfio_iommu_type1" ); +request_module_nowait ("vfio_iommu_spapr_tce" );return 0 ;
drivers/vfio/vfio_iommu_spapr_tce.c new file +377 -0
377 lines not on this page · raw message
include/uapi/linux/vfio.h +34 -0
@@ -22,6 +22,7 @@/* Extensions */ #define VFIO_TYPE1_IOMMU 1 +#define VFIO_SPAPR_TCE_IOMMU 2/* * The IOCTL interface is designed for extensibility by embedding the
@@ -365,4 +366,37 @@ struct vfio_iommu_type1_dma_unmap {#define VFIO_IOMMU_UNMAP_DMA _IO(VFIO_TYPE, VFIO_BASE + 14) +/* +* IOCTLs to enable/disable IOMMU container usage. +* No parameters are supported. +*/ +#define VFIO_IOMMU_ENABLE _IO(VFIO_TYPE, VFIO_BASE + 15) +#define VFIO_IOMMU_DISABLE _IO(VFIO_TYPE, VFIO_BASE + 16) + +/* -------- Additional API for SPAPR TCE (Server POWERPC) IOMMU -------- */ + +/* +* The SPAPR TCE info struct provides the information about the PCI bus +* address ranges available for DMA, these values are programmed into +* the hardware so the guest has to know that information. +* +* The DMA 32 bit window start is an absolute PCI bus address. +* The IOVA address passed via map/unmap ioctls are absolute PCI bus +* addresses too so the window works as a filter rather than an offset +* for IOVA addresses. +* +* A flag will need to be added if other page sizes are supported, +* so as defined here, it is always 4k. +*/ +struct vfio_iommu_spapr_tce_info { +__u32 argsz; +__u32 flags;/* reserved for future use */ +__u32 dma32_window_start;/* 32 bit window start (bytes) */ +__u32 dma32_window_size;/* 32 bit window size (bytes) */ +}; + +#define VFIO_IOMMU_SPAPR_TCE_GET_INFO _IO(VFIO_TYPE, VFIO_BASE + 12) + +/* ***************************************************************** */ +#endif /* _UAPIVFIO_H */
Signature · 1 line
1.7.10.4
PATCH 5/5 powerpc/vfio: Enable on pSeries platform
In reply to a message not in the archiveFrom: Alexey Kardashevskiy <[email protected]>
The enables VFIO on the pSeries platform, enabling user space programs to access PCI devices directly.
--- arch/powerpc/platforms/pseries/iommu.c | 4 ++++ drivers/iommu/Kconfig | 2 +- drivers/vfio/Kconfig | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-)
arch/powerpc/platforms/pseries/iommu.c +4 -0
@@ -613,6 +613,7 @@ static void pci_dma_bus_setup_pSeries(struct pci_bus *bus)iommu_table_setparms (pci->phb, dn, tbl); pci->iommu_table =iommu_init_table (tbl, pci->phb->node); +iommu_register_group (tbl,pci_domain_nr (bus),0 );/* Divide the rest (1.75GB) among the children */ pci->phb->dma_window_size =0x80000000ul ;
@@ -657,6 +658,7 @@ static void pci_dma_bus_setup_pSeriesLP(struct pci_bus *bus) ppci->phb->node);iommu_table_setparms_lpar (ppci->phb, pdn, tbl, dma_window); ppci->iommu_table =iommu_init_table (tbl, ppci->phb->node); +iommu_register_group (tbl,pci_domain_nr (bus),0 );pr_debug (" created table: %p\n" , ppci->iommu_table); } }
@@ -683,6 +685,7 @@ static void pci_dma_dev_setup_pSeries(struct pci_dev *dev) phb->node);iommu_table_setparms (phb, dn, tbl);PCI_DN (dn)->iommu_table =iommu_init_table (tbl, phb->node); +iommu_register_group (tbl,pci_domain_nr (phb->bus),0 );set_iommu_table_base (&dev->dev,PCI_DN (dn)->iommu_table);return ; }
@@ -1145,6 +1148,7 @@ static void pci_dma_dev_setup_pSeriesLP(struct pci_dev *dev) pci->phb->node);iommu_table_setparms_lpar (pci->phb, pdn, tbl, dma_window); pci->iommu_table =iommu_init_table (tbl, pci->phb->node); +iommu_register_group (tbl,pci_domain_nr (pci->phb->bus),0 );pr_debug (" created table: %p\n" , pci->iommu_table); }else {pr_debug (" found DMA window, table: %p\n" , pci->iommu_table);
drivers/iommu/Kconfig +1 -1
@@ -189,7 +189,7 @@ config EXYNOS_IOMMU_DEBUG config SPAPR_TCE_IOMMU bool "sPAPR TCE IOMMU Support" - depends on PPC_POWERNV + depends on PPC_POWERNV || PPC_PSERIES select IOMMU_API help Enables bits of IOMMU API required by VFIO. The iommu_ops
drivers/vfio/Kconfig +1 -1
@@ -12,7 +12,7 @@ menuconfig VFIO tristate "VFIO Non-Privileged userspace driver framework" depends on IOMMU_API select VFIO_IOMMU_TYPE1 if X86 - select VFIO_IOMMU_SPAPR_TCE if PPC_POWERNV + select VFIO_IOMMU_SPAPR_TCE if (PPC_POWERNV || PPC_PSERIES) help VFIO provides a framework for secure userspace device drivers. See Documentation/vfio.txt for more details.
Signature · 1 line
1.7.10.4