From: Rick Song <songwenjun@huawei.com>
To: will.deacon@arm.com, robin.murphy@arm.com, joro@8bytes.org,
linux-arm-kernel@lists.infradead.org,
iommu@lists.linux-foundation.org, alex.williamson@redhat.com,
kvm@vger.kernel.org, songwenjun@huawei.com
Subject: [RFC,v1,2/2] vfio/iommu-type1: set only stage 2 translation
Date: Fri, 21 Oct 2016 12:39:24 +0800 [thread overview]
Message-ID: <1477024764-79882-2-git-send-email-songwenjun@huawei.com> (raw)
In-Reply-To: <1477024764-79882-1-git-send-email-songwenjun@huawei.com>
Normally, VFIO should use only stage 2 translation of
iommu, to create the address mapping. If nesting translation
is disabled from VFIO core, enable iommu domain only stage 2
attribute, otherwise, enable iommu domain nesting attribute.
Signed-off-by: Rick Song <songwenjun@huawei.com>
---
drivers/vfio/vfio_iommu_type1.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 2ba1942..c0265fe 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -741,7 +741,7 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
struct vfio_group *group, *g;
struct vfio_domain *domain, *d;
struct bus_type *bus = NULL;
- int ret;
+ int attr, ret;
mutex_lock(&iommu->lock);
@@ -775,13 +775,22 @@ static int vfio_iommu_type1_attach_group(void *iommu_data,
goto out_free;
}
+ /*
+ * Set iommu nesting domain attribute if nesting translation
+ * is enabled from iommu vfio, otherwise set iommu only stage
+ * 2 domain attribute.
+ */
+ attr = 1;
if (iommu->nesting) {
- int attr = 1;
-
ret = iommu_domain_set_attr(domain->domain, DOMAIN_ATTR_NESTING,
&attr);
if (ret)
goto out_domain;
+ } else {
+ ret = iommu_domain_set_attr(domain->domain, DOMAIN_ATTR_S2,
+ &attr);
+ if (ret)
+ goto out_domain;
}
ret = iommu_attach_group(domain->domain, iommu_group);
--
1.9.1
next prev parent reply other threads:[~2016-10-21 4:39 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-21 4:39 [RFC,v1,1/2] iommu/arm-smmu: support s2 domain attribute Rick Song
2016-10-21 4:39 ` Rick Song [this message]
[not found] ` <1477024764-79882-2-git-send-email-songwenjun-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2016-10-21 14:27 ` [RFC,v1,2/2] vfio/iommu-type1: set only stage 2 translation Alex Williamson
[not found] ` <20161021082703.4890c419-1yVPhWWZRC1BDLzU/O5InQ@public.gmane.org>
2016-10-21 14:48 ` Robin Murphy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1477024764-79882-2-git-send-email-songwenjun@huawei.com \
--to=songwenjun@huawei.com \
--cc=alex.williamson@redhat.com \
--cc=iommu@lists.linux-foundation.org \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=robin.murphy@arm.com \
--cc=will.deacon@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).