* [PATCH v5 0/2] Support for nesting IOMMUs in VFIO
@ 2014-09-25 17:44 Will Deacon
[not found] ` <1411667101-26197-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Will Deacon @ 2014-09-25 17:44 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA; +Cc: Will Deacon
Hello,
This is version five of the patches I previously posted here:
RFCv1: http://permalink.gmane.org/gmane.linux.kernel.iommu/5552
RFCv2: http://permalink.gmane.org/gmane.linux.kernel.iommu/5700
v3: http://permalink.gmane.org/gmane.linux.kernel.iommu/6230
v4: http://permalink.gmane.org/gmane.linux.kernel.iommu/6590
Changes since v4 are:
- Move temporary attr variable into local scope (suggested by Alex)
- Fix memory leak of iommu on open failure
- Added Joerg's ack to the second patch
- Dropped the arm-smmu patch remove the series, as I'll push this
separately
Thanks,
Will
Will Deacon (2):
iommu: introduce domain attribute for nesting IOMMUs
vfio/iommu_type1: add new VFIO_TYPE1_NESTING_IOMMU IOMMU type
drivers/vfio/vfio_iommu_type1.c | 30 +++++++++++++++++++++++++-----
include/linux/iommu.h | 1 +
include/uapi/linux/vfio.h | 3 +++
3 files changed, 29 insertions(+), 5 deletions(-)
--
2.1.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v5 1/2] iommu: introduce domain attribute for nesting IOMMUs
[not found] ` <1411667101-26197-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
@ 2014-09-25 17:45 ` Will Deacon
2014-09-25 17:45 ` [PATCH v5 2/2] vfio/iommu_type1: add new VFIO_TYPE1_NESTING_IOMMU IOMMU type Will Deacon
2014-09-30 0:21 ` [PATCH v5 0/2] Support for nesting IOMMUs in VFIO Alex Williamson
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2014-09-25 17:45 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA; +Cc: Will Deacon
Some IOMMUs, such as the ARM SMMU, support two stages of translation.
The idea behind such a scheme is to allow a guest operating system to
use the IOMMU for DMA mappings in the first stage of translation, with
the hypervisor then installing mappings in the second stage to provide
isolation of the DMA to the physical range assigned to that virtual
machine.
In order to allow IOMMU domains to be used for second-stage translation,
this patch adds a new iommu_attr (IOMMU_ATTR_NESTING) for setting
second-stage domains prior to device attach. The attribute can also be
queried to see if a domain is actually making use of nesting.
Cc: Alex Williamson <alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Acked-by: Joerg Roedel <jroedel-l3A5Bk7waGM@public.gmane.org>
Signed-off-by: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
---
include/linux/iommu.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index 20f9a527922a..7b02bcc85b9e 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -80,6 +80,7 @@ enum iommu_attr {
DOMAIN_ATTR_FSL_PAMU_STASH,
DOMAIN_ATTR_FSL_PAMU_ENABLE,
DOMAIN_ATTR_FSL_PAMUV1,
+ DOMAIN_ATTR_NESTING, /* two stages of translation */
DOMAIN_ATTR_MAX,
};
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v5 2/2] vfio/iommu_type1: add new VFIO_TYPE1_NESTING_IOMMU IOMMU type
[not found] ` <1411667101-26197-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
2014-09-25 17:45 ` [PATCH v5 1/2] iommu: introduce domain attribute for nesting IOMMUs Will Deacon
@ 2014-09-25 17:45 ` Will Deacon
2014-09-30 0:21 ` [PATCH v5 0/2] Support for nesting IOMMUs in VFIO Alex Williamson
2 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2014-09-25 17:45 UTC (permalink / raw)
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA; +Cc: Will Deacon
VFIO allows devices to be safely handed off to userspace by putting
them behind an IOMMU configured to ensure DMA and interrupt isolation.
This enables userspace KVM clients, such as kvmtool and qemu, to further
map the device into a virtual machine.
With IOMMUs such as the ARM SMMU, it is then possible to provide SMMU
translation services to the guest operating system, which are nested
with the existing translation installed by VFIO. However, enabling this
feature means that the IOMMU driver must be informed that the VFIO domain
is being created for the purposes of nested translation.
This patch adds a new IOMMU type (VFIO_TYPE1_NESTING_IOMMU) to the VFIO
type-1 driver. The new IOMMU type acts identically to the
VFIO_TYPE1v2_IOMMU type, but additionally sets the DOMAIN_ATTR_NESTING
attribute on its IOMMU domains.
Cc: Joerg Roedel <joro-zLv9SwRftAIdnm+yROfE0A@public.gmane.org>
Cc: Alex Williamson <alex.williamson-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Signed-off-by: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
---
drivers/vfio/vfio_iommu_type1.c | 30 +++++++++++++++++++++++++-----
include/uapi/linux/vfio.h | 3 +++
2 files changed, 28 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)
diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h
index 6612974c64bf..29715d27548f 100644
--- a/include/uapi/linux/vfio.h
+++ b/include/uapi/linux/vfio.h
@@ -33,6 +33,9 @@
/* Check if EEH is supported */
#define VFIO_EEH 5
+/* Two-stage IOMMU */
+#define VFIO_TYPE1_NESTING_IOMMU 6 /* Implies v2 */
+
/*
* The IOCTL interface is designed for extensibility by embedding the
* structure length (argsz) and flags into structures passed between
--
2.1.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v5 0/2] Support for nesting IOMMUs in VFIO
[not found] ` <1411667101-26197-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
2014-09-25 17:45 ` [PATCH v5 1/2] iommu: introduce domain attribute for nesting IOMMUs Will Deacon
2014-09-25 17:45 ` [PATCH v5 2/2] vfio/iommu_type1: add new VFIO_TYPE1_NESTING_IOMMU IOMMU type Will Deacon
@ 2014-09-30 0:21 ` Alex Williamson
2 siblings, 0 replies; 4+ messages in thread
From: Alex Williamson @ 2014-09-30 0:21 UTC (permalink / raw)
To: Will Deacon; +Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA
On Thu, 2014-09-25 at 18:44 +0100, Will Deacon wrote:
> Hello,
>
> This is version five of the patches I previously posted here:
>
> RFCv1: http://permalink.gmane.org/gmane.linux.kernel.iommu/5552
> RFCv2: http://permalink.gmane.org/gmane.linux.kernel.iommu/5700
> v3: http://permalink.gmane.org/gmane.linux.kernel.iommu/6230
> v4: http://permalink.gmane.org/gmane.linux.kernel.iommu/6590
>
> Changes since v4 are:
>
> - Move temporary attr variable into local scope (suggested by Alex)
> - Fix memory leak of iommu on open failure
> - Added Joerg's ack to the second patch
> - Dropped the arm-smmu patch remove the series, as I'll push this
> separately
>
> Thanks,
>
> Will
>
>
> Will Deacon (2):
> iommu: introduce domain attribute for nesting IOMMUs
> vfio/iommu_type1: add new VFIO_TYPE1_NESTING_IOMMU IOMMU type
>
> drivers/vfio/vfio_iommu_type1.c | 30 +++++++++++++++++++++++++-----
> include/linux/iommu.h | 1 +
> include/uapi/linux/vfio.h | 3 +++
> 3 files changed, 29 insertions(+), 5 deletions(-)
>
Applied to linux-vfio.git/next for 3.18. Thanks!
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2014-09-30 0:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-25 17:44 [PATCH v5 0/2] Support for nesting IOMMUs in VFIO Will Deacon
[not found] ` <1411667101-26197-1-git-send-email-will.deacon-5wv7dgnIgG8@public.gmane.org>
2014-09-25 17:45 ` [PATCH v5 1/2] iommu: introduce domain attribute for nesting IOMMUs Will Deacon
2014-09-25 17:45 ` [PATCH v5 2/2] vfio/iommu_type1: add new VFIO_TYPE1_NESTING_IOMMU IOMMU type Will Deacon
2014-09-30 0:21 ` [PATCH v5 0/2] Support for nesting IOMMUs in VFIO Alex Williamson
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).