Message ID | 1501003615-15274-10-git-send-email-olekstysh@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Jul 25, 2017 at 08:26:51PM +0300, Oleksandr Tyshchenko wrote: > 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 and as the result > the IOMMU is expected to be used for this domain. > > The primary aim of this knowledge is to help the IOMMUs that don't > share page tables with the CPU on ARM be ready before P2M code starts > updating IOMMU mapping. > So, if this flag is set the non-shared 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*. > > In order to retain the current behavior for x86 still call > iommu_domain_init() with use_iommu flag being forced to false. > > Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> > CC: Jan Beulich <jbeulich@suse.com> > CC: Julien Grall <julien.grall@arm.com> > CC: Ian Jackson <ian.jackson@eu.citrix.com> > CC: Wei Liu <wei.liu2@citrix.com> > > --- > Changes in V1: > - Treat use_iommu flag as the ARM decision only. Don't use > common domain creation flag for it, use ARM config instead. > - Clarify patch subject/description. > > Changes in V2: > - Cosmetic fixes. > --- > tools/libxl/libxl_arm.c | 8 ++++++++ Acked-by: Wei Liu <wei.liu2@citrix.com>
Hi, Wei On Fri, Jul 28, 2017 at 7:16 PM, Wei Liu <wei.liu2@citrix.com> wrote: > On Tue, Jul 25, 2017 at 08:26:51PM +0300, Oleksandr Tyshchenko wrote: >> 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 and as the result >> the IOMMU is expected to be used for this domain. >> >> The primary aim of this knowledge is to help the IOMMUs that don't >> share page tables with the CPU on ARM be ready before P2M code starts >> updating IOMMU mapping. >> So, if this flag is set the non-shared 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*. >> >> In order to retain the current behavior for x86 still call >> iommu_domain_init() with use_iommu flag being forced to false. >> >> Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com> >> CC: Jan Beulich <jbeulich@suse.com> >> CC: Julien Grall <julien.grall@arm.com> >> CC: Ian Jackson <ian.jackson@eu.citrix.com> >> CC: Wei Liu <wei.liu2@citrix.com> >> >> --- >> Changes in V1: >> - Treat use_iommu flag as the ARM decision only. Don't use >> common domain creation flag for it, use ARM config instead. >> - Clarify patch subject/description. >> >> Changes in V2: >> - Cosmetic fixes. >> --- >> tools/libxl/libxl_arm.c | 8 ++++++++ > > Acked-by: Wei Liu <wei.liu2@citrix.com> Great. Thank you.
Hi Oleksandr, On 25/07/17 18:26, Oleksandr Tyshchenko wrote: > diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c > index ec19310..3079bbe 100644 > --- a/xen/arch/arm/domain.c > +++ b/xen/arch/arm/domain.c > @@ -569,7 +569,7 @@ 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 ) > + if ( (rc = iommu_domain_init(d, !!config->use_iommu)) != 0 ) NIT: !! is not necessary as the parameter is a bool :). Acked-by: Julien Grall <julien.grall@arm.com> > goto fail; > > if ( (rc = p2m_init(d)) != 0 ) Cheers,
Hi, Julien On Thu, Aug 3, 2017 at 2:33 PM, Julien Grall <julien.grall@arm.com> wrote: > Hi Oleksandr, > > On 25/07/17 18:26, Oleksandr Tyshchenko wrote: >> >> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c >> index ec19310..3079bbe 100644 >> --- a/xen/arch/arm/domain.c >> +++ b/xen/arch/arm/domain.c >> @@ -569,7 +569,7 @@ 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 ) >> + if ( (rc = iommu_domain_init(d, !!config->use_iommu)) != 0 ) > > > NIT: !! is not necessary as the parameter is a bool :). Shall I drop "!!"? > > Acked-by: Julien Grall <julien.grall@arm.com> Thank you! > >> goto fail; >> >> if ( (rc = p2m_init(d)) != 0 ) > > > Cheers, > > -- > Julien Grall
On 03/08/17 13:31, Oleksandr Tyshchenko wrote: > Hi, Julien > > On Thu, Aug 3, 2017 at 2:33 PM, Julien Grall <julien.grall@arm.com> wrote: >> Hi Oleksandr, >> >> On 25/07/17 18:26, Oleksandr Tyshchenko wrote: >>> >>> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c >>> index ec19310..3079bbe 100644 >>> --- a/xen/arch/arm/domain.c >>> +++ b/xen/arch/arm/domain.c >>> @@ -569,7 +569,7 @@ 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 ) >>> + if ( (rc = iommu_domain_init(d, !!config->use_iommu)) != 0 ) >> >> >> NIT: !! is not necessary as the parameter is a bool :). > Shall I drop "!!"? Yes please. > >> >> Acked-by: Julien Grall <julien.grall@arm.com> > Thank you! > >> >>> goto fail; >>> >>> if ( (rc = p2m_init(d)) != 0 ) >> >> >> Cheers, >> >> -- >> Julien Grall > > >
diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index d842d88..cb9fe05 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -78,6 +78,14 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, return ERROR_FAIL; } + if (d_config->num_dtdevs || d_config->num_pcidevs) + xc_config->use_iommu = 1; + else + xc_config->use_iommu = 0; + + LOG(DEBUG, "IOMMU %s expected to be used for this domain", + xc_config->use_iommu ? "is" : "isn't"); + return 0; } diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c index ec19310..3079bbe 100644 --- a/xen/arch/arm/domain.c +++ b/xen/arch/arm/domain.c @@ -569,7 +569,7 @@ 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 ) + if ( (rc = iommu_domain_init(d, !!config->use_iommu)) != 0 ) goto fail; if ( (rc = p2m_init(d)) != 0 ) diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index bd974fb..b1fae45 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -322,6 +322,11 @@ struct xen_arch_domainconfig { * */ uint32_t clock_frequency; + /* + * IN + * IOMMU is expected to be used for this domain. + */ + uint8_t use_iommu; }; #endif /* __XEN__ || __XEN_TOOLS__ */