From: Oleksandr Tyshchenko <olekstysh@gmail.com>
To: xen-devel@lists.xenproject.org
Cc: sstabellini@kernel.org, vlad.babchuk@gmail.com, al1img@gmail.com,
andrii.anisov@gmail.com, olekstysh@gmail.com, andr2000@gmail.com,
julien.grall@arm.com, JBeulich@suse.com, joculator@gmail.com
Subject: [RFC PATCH 9/9] xen: Add use_iommu flag to createdomain domctl
Date: Wed, 15 Mar 2017 22:05:29 +0200 [thread overview]
Message-ID: <1489608329-7275-10-git-send-email-olekstysh@gmail.com> (raw)
In-Reply-To: <1489608329-7275-1-git-send-email-olekstysh@gmail.com>
From: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
This flag is intended to let Xen know that the guest has devices
which will most likely be used for passthrough.
The primary aim of this knowledge is to help the IOMMUs that don't
share page tables with the CPU be ready before P2M code starts
updating IOMMU mapping.
So, if this flag is set the unshared IOMMUs will populate their
page tables at the domain creation time and thereby will be able
to handle IOMMU mapping updates from *the very beginning*.
Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
---
tools/libxl/libxl_create.c | 5 +++++
xen/arch/arm/domain.c | 4 +++-
xen/arch/x86/domain.c | 4 +++-
xen/common/domctl.c | 5 ++++-
xen/include/public/domctl.h | 3 +++
xen/include/xen/sched.h | 3 +++
6 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index e741b9a..4393fa2 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -546,6 +546,11 @@ int libxl__domain_make(libxl__gc *gc, libxl_domain_config *d_config,
flags |= XEN_DOMCTL_CDF_hap;
}
+ /* TODO Are these assumptions enough to make decision about using IOMMU? */
+ if ((d_config->num_dtdevs && d_config->dtdevs) ||
+ (d_config->num_pcidevs && d_config->pcidevs))
+ flags |= XEN_DOMCTL_CDF_use_iommu;
+
/* Ultimately, handle is an array of 16 uint8_t, same as uuid */
libxl_uuid_copy(ctx, (libxl_uuid *)handle, &info->uuid);
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index bab62ee..940bb98 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -539,6 +539,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
struct xen_arch_domainconfig *config)
{
int rc, count = 0;
+ bool_t use_iommu;
BUILD_BUG_ON(GUEST_MAX_VCPUS < MAX_VIRT_CPUS);
d->arch.relmem = RELMEM_not_started;
@@ -550,7 +551,8 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
ASSERT(config != NULL);
/* p2m_init relies on some value initialized by the IOMMU subsystem */
- if ( (rc = iommu_domain_init(d, false)) != 0 )
+ use_iommu = !!(domcr_flags & DOMCRF_use_iommu);
+ if ( (rc = iommu_domain_init(d, use_iommu)) != 0 )
goto fail;
if ( (rc = p2m_init(d)) != 0 )
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 8ef4160..7d634ff 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -525,6 +525,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
{
bool paging_initialised = false;
int rc = -ENOMEM;
+ bool_t use_iommu;
if ( config == NULL && !is_idle_domain(d) )
return -EINVAL;
@@ -646,7 +647,8 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags,
if ( (rc = init_domain_irq_mapping(d)) != 0 )
goto fail;
- if ( (rc = iommu_domain_init(d, false)) != 0 )
+ use_iommu = !!(domcr_flags & DOMCRF_use_iommu);
+ if ( (rc = iommu_domain_init(d, use_iommu)) != 0 )
goto fail;
}
spin_lock_init(&d->arch.e820_lock);
diff --git a/xen/common/domctl.c b/xen/common/domctl.c
index 93e3029..56c4d38 100644
--- a/xen/common/domctl.c
+++ b/xen/common/domctl.c
@@ -505,7 +505,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
| XEN_DOMCTL_CDF_hap
| XEN_DOMCTL_CDF_s3_integrity
| XEN_DOMCTL_CDF_oos_off
- | XEN_DOMCTL_CDF_xs_domain)) )
+ | XEN_DOMCTL_CDF_xs_domain
+ | XEN_DOMCTL_CDF_use_iommu)) )
break;
dom = op->domain;
@@ -549,6 +550,8 @@ long do_domctl(XEN_GUEST_HANDLE_PARAM(xen_domctl_t) u_domctl)
domcr_flags |= DOMCRF_oos_off;
if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_xs_domain )
domcr_flags |= DOMCRF_xs_domain;
+ if ( op->u.createdomain.flags & XEN_DOMCTL_CDF_use_iommu )
+ domcr_flags |= DOMCRF_use_iommu;
d = domain_create(dom, domcr_flags, op->u.createdomain.ssidref,
&op->u.createdomain.config);
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 85cbb7c..a37a566 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -66,6 +66,9 @@ struct xen_domctl_createdomain {
/* Is this a xenstore domain? */
#define _XEN_DOMCTL_CDF_xs_domain 5
#define XEN_DOMCTL_CDF_xs_domain (1U<<_XEN_DOMCTL_CDF_xs_domain)
+ /* Should IOMMU page tables be populated at the domain creation time? */
+#define _XEN_DOMCTL_CDF_use_iommu 6
+#define XEN_DOMCTL_CDF_use_iommu (1U<<_XEN_DOMCTL_CDF_use_iommu)
uint32_t flags;
struct xen_arch_domainconfig config;
};
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 0929c0b..80e6fdc 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -561,6 +561,9 @@ struct domain *domain_create(domid_t domid, unsigned int domcr_flags,
/* DOMCRF_xs_domain: xenstore domain */
#define _DOMCRF_xs_domain 6
#define DOMCRF_xs_domain (1U<<_DOMCRF_xs_domain)
+ /* DOMCRF_use_iommu: Populate IOMMU page tables at the domain creation time */
+#define _DOMCRF_use_iommu 7
+#define DOMCRF_use_iommu (1U<<_DOMCRF_use_iommu)
/*
* rcu_lock_domain_by_id() is more efficient than get_domain_by_id().
--
2.7.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-03-15 20:06 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-15 20:05 [RFC PATCH 0/9] "Non-shared" IOMMU support on ARM Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 1/9] xen/device-tree: Add dt_count_phandle_with_args helper Oleksandr Tyshchenko
2017-03-16 15:39 ` Julien Grall
2017-03-17 11:24 ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 2/9] iommu: Add ability to map/unmap the number of pages Oleksandr Tyshchenko
2017-03-22 15:44 ` Jan Beulich
2017-03-22 18:01 ` Oleksandr Tyshchenko
2017-03-23 9:07 ` Jan Beulich
2017-03-23 12:47 ` Oleksandr Tyshchenko
2017-04-27 16:56 ` Oleksandr Tyshchenko
2017-04-28 6:23 ` Jan Beulich
2017-04-28 10:16 ` Oleksandr Tyshchenko
2017-04-28 10:29 ` Jan Beulich
2017-04-28 10:44 ` Oleksandr Tyshchenko
2017-04-19 17:31 ` Julien Grall
2017-04-21 11:46 ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 3/9] xen/arm: p2m: Add helper to convert p2m type to IOMMU flags Oleksandr Tyshchenko
2017-04-19 17:28 ` Julien Grall
2017-04-21 11:47 ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 4/9] xen/arm: p2m: Update IOMMU mapping whenever possible if page table is not shared Oleksandr Tyshchenko
2017-04-19 17:46 ` Julien Grall
2017-04-21 14:18 ` Oleksandr Tyshchenko
2017-04-21 16:27 ` Julien Grall
2017-04-21 18:44 ` Oleksandr Tyshchenko
2017-04-24 11:41 ` Julien Grall
2017-04-24 16:08 ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 5/9] iommu/arm: Re-define iommu_use_hap_pt(d) as iommu_hap_pt_share Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 6/9] iommu: Pass additional use_iommu argument to iommu_domain_init() Oleksandr Tyshchenko
2017-03-22 15:48 ` Jan Beulich
2017-03-23 12:50 ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 7/9] iommu/arm: Add alloc_page_table platform callback Oleksandr Tyshchenko
2017-03-22 15:49 ` Jan Beulich
2017-03-23 12:57 ` Oleksandr Tyshchenko
2017-03-15 20:05 ` [RFC PATCH 8/9] iommu: Split iommu_hwdom_init() into arch specific parts Oleksandr Tyshchenko
2017-03-22 15:54 ` Jan Beulich
2017-03-22 18:40 ` Oleksandr Tyshchenko
2017-03-23 9:08 ` Jan Beulich
2017-03-23 12:40 ` Oleksandr Tyshchenko
2017-03-23 13:28 ` Jan Beulich
2017-04-19 18:09 ` Julien Grall
2017-04-21 12:18 ` Oleksandr Tyshchenko
2017-03-15 20:05 ` Oleksandr Tyshchenko [this message]
2017-03-22 15:56 ` [RFC PATCH 9/9] xen: Add use_iommu flag to createdomain domctl Jan Beulich
2017-03-23 16:36 ` Oleksandr Tyshchenko
2017-03-23 17:05 ` Jan Beulich
2017-03-24 11:19 ` Oleksandr Tyshchenko
2017-03-24 11:38 ` Jan Beulich
2017-03-24 13:05 ` Oleksandr Tyshchenko
2017-04-19 18:26 ` Julien Grall
2017-04-21 14:41 ` Oleksandr Tyshchenko
2017-04-25 15:23 ` Wei Liu
2017-04-25 16:07 ` Oleksandr Tyshchenko
2017-04-26 10:05 ` Ian Jackson
2017-04-27 10:41 ` Oleksandr Tyshchenko
2017-03-16 15:31 ` [RFC PATCH 0/9] "Non-shared" IOMMU support on ARM Julien Grall
2017-03-17 11:24 ` Oleksandr Tyshchenko
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=1489608329-7275-10-git-send-email-olekstysh@gmail.com \
--to=olekstysh@gmail.com \
--cc=JBeulich@suse.com \
--cc=al1img@gmail.com \
--cc=andr2000@gmail.com \
--cc=andrii.anisov@gmail.com \
--cc=joculator@gmail.com \
--cc=julien.grall@arm.com \
--cc=sstabellini@kernel.org \
--cc=vlad.babchuk@gmail.com \
--cc=xen-devel@lists.xenproject.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 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).