diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-11 14:49:24 +0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-10-11 14:49:24 +0400 |
commit | 27a9716bc80448f7e98fb1fb316daba241a4c539 (patch) | |
tree | d9a82dc1e1eddd1ff2a27d558149ad8323975134 /drivers/vfio/vfio_iommu_type1.c | |
parent | e98d6e7f7625ed60c7bc1d39aeb2375ed3918fd5 (diff) | |
parent | 93899a679fd6b2534b5c297d9316bae039ebcbe1 (diff) | |
download | linux-27a9716bc80448f7e98fb1fb316daba241a4c539.tar.xz |
Merge tag 'vfio-v3.18-rc1' of git://github.com/awilliam/linux-vfio
Pull VFIO updates from Alex Williamson:
- Nested IOMMU extension to type1 (Will Deacon)
- Restore MSIx message before enabling (Gavin Shan)
- Fix remove path locking (Alex Williamson)
* tag 'vfio-v3.18-rc1' of git://github.com/awilliam/linux-vfio:
vfio-pci: Fix remove path locking
drivers/vfio: Export vfio_spapr_iommu_eeh_ioctl() with GPL
vfio/pci: Restore MSIx message prior to enabling
PCI: Export MSI message relevant functions
vfio/iommu_type1: add new VFIO_TYPE1_NESTING_IOMMU IOMMU type
iommu: introduce domain attribute for nesting IOMMUs
Diffstat (limited to 'drivers/vfio/vfio_iommu_type1.c')
-rw-r--r-- | drivers/vfio/vfio_iommu_type1.c | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c index 0734fbe5b651..583ccdb2c58f 100644 --- a/drivers/vfio/vfio_iommu_type1.c +++ b/drivers/vfio/vfio_iommu_type1.c @@ -57,7 +57,8 @@ struct vfio_iommu { struct list_head domain_list; struct mutex lock; struct rb_root dma_list; - bool v2; + bool v2; + bool nesting; }; struct vfio_domain { @@ -705,6 +706,15 @@ static int vfio_iommu_type1_attach_group(void *iommu_data, goto out_free; } + if (iommu->nesting) { + int attr = 1; + + ret = iommu_domain_set_attr(domain->domain, DOMAIN_ATTR_NESTING, + &attr); + if (ret) + goto out_domain; + } + ret = iommu_attach_group(domain->domain, iommu_group); if (ret) goto out_domain; @@ -819,17 +829,26 @@ static void *vfio_iommu_type1_open(unsigned long arg) { struct vfio_iommu *iommu; - if (arg != VFIO_TYPE1_IOMMU && arg != VFIO_TYPE1v2_IOMMU) - return ERR_PTR(-EINVAL); - iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); if (!iommu) return ERR_PTR(-ENOMEM); + switch (arg) { + case VFIO_TYPE1_IOMMU: + break; + case VFIO_TYPE1_NESTING_IOMMU: + iommu->nesting = true; + case VFIO_TYPE1v2_IOMMU: + iommu->v2 = true; + break; + default: + kfree(iommu); + return ERR_PTR(-EINVAL); + } + INIT_LIST_HEAD(&iommu->domain_list); iommu->dma_list = RB_ROOT; mutex_init(&iommu->lock); - iommu->v2 = (arg == VFIO_TYPE1v2_IOMMU); return iommu; } @@ -885,6 +904,7 @@ static long vfio_iommu_type1_ioctl(void *iommu_data, switch (arg) { case VFIO_TYPE1_IOMMU: case VFIO_TYPE1v2_IOMMU: + case VFIO_TYPE1_NESTING_IOMMU: return 1; case VFIO_DMA_CC_IOMMU: if (!iommu) |