From: James Sewart via iommu <iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
To: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org
Subject: [RFC] iommu/vt-d: Group and domain relationship
Date: Tue, 30 Oct 2018 14:18:54 +0000 [thread overview]
Message-ID: <44573340-5652-42F1-A4B8-102AEF5C162A@arista.com> (raw)
Hey,
I’ve been investigating the relationship between iommu groups and domains
on our systems and have a few question. Why does the intel iommu code not
allow allocating IOMMU_DOMAIN_DMA? Returning NULL when given this domain
type has the side effect that the default_domain for an iommu group is not
set, which, when using for e.g. dma_map_ops.map_page, means a domain is
allocated per device.
This seems to be the opposite behaviour to the AMD iommu code which
supports allocating an IOMMU_DOMAIN_DMA and will only look to the iommu
group if a domain is not attached to the device rather than allocating a
new one. On AMD every device in an iommu group will share the same domain.
Appended is what I think a patch to implement domain_alloc for
IOMMU_DOMAIN_DMA and also IOMMU_DOMAIN_IDENTITY would look like. Testing
shows each device in a group will share a domain by default, it also
allows allocating a new dma domain that can be successfully attached to a
group with iommu_attach_group.
Looking for comment on why the behaviour is how it is currently and if
there are any issues with the solution I’ve been testing.
Cheers,
James.
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
index bff2abd6..3a58389f 100644
--- a/drivers/iommu/intel-iommu.c
+++ b/drivers/iommu/intel-iommu.c
@@ -5170,10 +5170,15 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)
struct dmar_domain *dmar_domain;
struct iommu_domain *domain;
- if (type != IOMMU_DOMAIN_UNMANAGED)
+ if (type == IOMMU_DOMAIN_UNMANAGED)
+ dmar_domain = alloc_domain(DOMAIN_FLAG_VIRTUAL_MACHINE);
+ else if(type == IOMMU_DOMAIN_DMA)
+ dmar_domain = alloc_domain(0);
+ else if(type == IOMMU_DOMAIN_IDENTITY)
+ dmar_domain = alloc_domain(DOMAIN_FLAG_STATIC_IDENTITY);
+ else
return NULL;
- dmar_domain = alloc_domain(DOMAIN_FLAG_VIRTUAL_MACHINE);
if (!dmar_domain) {
pr_err("Can't allocate dmar_domain\n");
return NULL;
@@ -5186,9 +5191,12 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type)
domain_update_iommu_cap(dmar_domain);
domain = &dmar_domain->domain;
- domain->geometry.aperture_start = 0;
- domain->geometry.aperture_end = __DOMAIN_MAX_ADDR(dmar_domain->gaw);
- domain->geometry.force_aperture = true;
+
+ if (type == IOMMU_DOMAIN_UNMANAGED) {
+ domain->geometry.aperture_start = 0;
+ domain->geometry.aperture_end = __DOMAIN_MAX_ADDR(dmar_domain->gaw);
+ domain->geometry.force_aperture = true;
+ }
return domain;
}
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
next reply other threads:[~2018-10-30 14:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-30 14:18 James Sewart via iommu [this message]
[not found] ` <44573340-5652-42F1-A4B8-102AEF5C162A-nzgTgzXrdUbQT0dZR+AlfA@public.gmane.org>
2018-11-02 2:41 ` [RFC] iommu/vt-d: Group and domain relationship Lu Baolu
[not found] ` <5695aa18-3248-b611-a286-111de7e5a8f5-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-11-06 10:40 ` James Sewart via iommu
[not found] ` <CALwnD_qUhQu-fwOObth-DWzSNoARZ_ERuNwyS8r73C0yhw7jGQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2018-11-07 2:10 ` Lu Baolu
[not found] ` <b92b1739-dc3e-9515-a6f1-e4c00f53882b-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-11-07 17:55 ` James Sewart via iommu
[not found] ` <A393DB8A-BFC6-40C2-B9E8-6667A927957E-nzgTgzXrdUbQT0dZR+AlfA@public.gmane.org>
2018-11-08 1:42 ` Lu Baolu
[not found] ` <14cb4192-8557-72e1-ef26-4155b2cd7e63-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2018-11-08 11:30 ` James Sewart via iommu
[not found] ` <9B06CA0B-A5F8-41FC-8F5E-6D7BE94FCC14-nzgTgzXrdUbQT0dZR+AlfA@public.gmane.org>
2018-11-09 6:54 ` Liu, Yi L
[not found] ` <A2975661238FB949B60364EF0F2C257439D6122B-0J0gbvR4kTg/UvCtAeCM4rfspsVTdybXVpNB7YpNyf8@public.gmane.org>
2018-11-09 11:37 ` James Sewart via iommu
2018-11-09 19:09 ` Jacob Pan
2018-11-12 11:15 ` James Sewart via iommu
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=44573340-5652-42F1-A4B8-102AEF5C162A@arista.com \
--to=iommu-cuntk1mwbs9qetfly7kem3xjstq8ys+chz5vsktnxna@public.gmane.org \
--cc=jamessewart-nzgTgzXrdUbQT0dZR+AlfA@public.gmane.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.