Message ID | 20190913094741.31451-6-paul.durrant@citrix.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | add per-domain IOMMU control | expand |
On 13.09.2019 11:47, Paul Durrant wrote: > --- a/xen/include/xen/iommu.h > +++ b/xen/include/xen/iommu.h > @@ -56,8 +56,10 @@ extern bool_t iommu_enable, iommu_enabled; > extern bool_t force_iommu, iommu_verbose, iommu_igfx; > extern bool_t iommu_snoop, iommu_qinval, iommu_intremap, iommu_intpost; > > -#ifdef CONFIG_HVM > +#if defined(CONFIG_HVM) > extern bool iommu_hap_pt_share; > +#elif defined(CONFIG_IOMMU_FORCE_PT_SHARE) > +#define iommu_hap_pt_share true > #else > #define iommu_hap_pt_share false > #endif The ordering is wrong here - Arm unconditionally defines HVM, and hence it now also setting IOMMU_FORCE_PT_SHARE won't be accounted for this way. I'd be happy to adjust this on commit, but I'm afraid I'm still unhappy about patch 3 (but I guess at this point I'll better propose a replacement than ask you for going through another round). Jan
> -----Original Message----- > From: Jan Beulich <jbeulich@suse.com> > Sent: 13 September 2019 11:05 > To: Paul Durrant <Paul.Durrant@citrix.com> > Cc: xen-devel@lists.xenproject.org; Julien Grall <julien.grall@arm.com>; Andrew Cooper > <Andrew.Cooper3@citrix.com>; Roger Pau Monne <roger.pau@citrix.com>; Volodymyr Babchuk > <Volodymyr_Babchuk@epam.com>; George Dunlap <George.Dunlap@citrix.com>; Ian Jackson > <Ian.Jackson@citrix.com>; Stefano Stabellini <sstabellini@kernel.org>; Konrad Rzeszutek Wilk > <konrad.wilk@oracle.com>; Tim (Xen.org) <tim@xen.org>; Wei Liu <wl@xen.org> > Subject: Re: [PATCH v10 5/6] iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync() macros > > On 13.09.2019 11:47, Paul Durrant wrote: > > --- a/xen/include/xen/iommu.h > > +++ b/xen/include/xen/iommu.h > > @@ -56,8 +56,10 @@ extern bool_t iommu_enable, iommu_enabled; > > extern bool_t force_iommu, iommu_verbose, iommu_igfx; > > extern bool_t iommu_snoop, iommu_qinval, iommu_intremap, iommu_intpost; > > > > -#ifdef CONFIG_HVM > > +#if defined(CONFIG_HVM) > > extern bool iommu_hap_pt_share; > > +#elif defined(CONFIG_IOMMU_FORCE_PT_SHARE) > > +#define iommu_hap_pt_share true > > #else > > #define iommu_hap_pt_share false > > #endif > > The ordering is wrong here - Arm unconditionally defines HVM, and > hence it now also setting IOMMU_FORCE_PT_SHARE won't be accounted > for this way. Ah yes, good point. > I'd be happy to adjust this on commit, but I'm afraid > I'm still unhappy about patch 3 (but I guess at this point I'll > better propose a replacement than ask you for going through another > round). > That would be helpful. Paul
> -----Original Message----- > From: Jan Beulich <jbeulich@suse.com> > Sent: 13 September 2019 11:05 > To: Paul Durrant <Paul.Durrant@citrix.com> > Cc: xen-devel@lists.xenproject.org; Julien Grall <julien.grall@arm.com>; Andrew Cooper > <Andrew.Cooper3@citrix.com>; Roger Pau Monne <roger.pau@citrix.com>; Volodymyr Babchuk > <Volodymyr_Babchuk@epam.com>; George Dunlap <George.Dunlap@citrix.com>; Ian Jackson > <Ian.Jackson@citrix.com>; Stefano Stabellini <sstabellini@kernel.org>; Konrad Rzeszutek Wilk > <konrad.wilk@oracle.com>; Tim (Xen.org) <tim@xen.org>; Wei Liu <wl@xen.org> > Subject: Re: [PATCH v10 5/6] iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync() macros > > On 13.09.2019 11:47, Paul Durrant wrote: > > --- a/xen/include/xen/iommu.h > > +++ b/xen/include/xen/iommu.h > > @@ -56,8 +56,10 @@ extern bool_t iommu_enable, iommu_enabled; > > extern bool_t force_iommu, iommu_verbose, iommu_igfx; > > extern bool_t iommu_snoop, iommu_qinval, iommu_intremap, iommu_intpost; > > > > -#ifdef CONFIG_HVM > > +#if defined(CONFIG_HVM) > > extern bool iommu_hap_pt_share; > > +#elif defined(CONFIG_IOMMU_FORCE_PT_SHARE) > > +#define iommu_hap_pt_share true > > #else > > #define iommu_hap_pt_share false > > #endif > > The ordering is wrong here - Arm unconditionally defines HVM, and > hence it now also setting IOMMU_FORCE_PT_SHARE won't be accounted > for this way. I'd be happy to adjust this on commit, but I'm afraid > I'm still unhappy about patch 3 (but I guess at this point I'll > better propose a replacement than ask you for going through another > round). > Actually I'm going to send a v11 anyway, as there are issues with the abi-check (now that Ian has fixed the script). Paul > Jan
diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig index c2db2a6953..a51aa7bfa8 100644 --- a/xen/arch/arm/Kconfig +++ b/xen/arch/arm/Kconfig @@ -20,6 +20,7 @@ config ARM select HAS_DEVICE_TREE select HAS_PASSTHROUGH select HAS_PDX + select IOMMU_FORCE_PT_SHARE config ARCH_DEFCONFIG string diff --git a/xen/drivers/passthrough/Kconfig b/xen/drivers/passthrough/Kconfig index a3c06491be..61f944639e 100644 --- a/xen/drivers/passthrough/Kconfig +++ b/xen/drivers/passthrough/Kconfig @@ -13,3 +13,6 @@ config ARM_SMMU Say Y here if your SoC includes an IOMMU device implementing the ARM SMMU architecture. endif + +config IOMMU_FORCE_PT_SHARE + bool diff --git a/xen/include/asm-arm/iommu.h b/xen/include/asm-arm/iommu.h index 1577e83d2b..77a94b29eb 100644 --- a/xen/include/asm-arm/iommu.h +++ b/xen/include/asm-arm/iommu.h @@ -20,9 +20,6 @@ struct arch_iommu void *priv; }; -/* Always share P2M Table between the CPU and the IOMMU */ -#define iommu_use_hap_pt(d) is_iommu_enabled(d) - const struct iommu_ops *iommu_get_ops(void); void iommu_set_ops(const struct iommu_ops *ops); diff --git a/xen/include/asm-x86/iommu.h b/xen/include/asm-x86/iommu.h index 5071afd6a5..85741f7c96 100644 --- a/xen/include/asm-x86/iommu.h +++ b/xen/include/asm-x86/iommu.h @@ -86,10 +86,6 @@ struct iommu_init_ops { extern const struct iommu_init_ops *iommu_init_ops; -/* Are we using the domain P2M table as its IOMMU pagetable? */ -#define iommu_use_hap_pt(d) \ - (hap_enabled(d) && is_iommu_enabled(d) && iommu_hap_pt_share) - void iommu_update_ire_from_apic(unsigned int apic, unsigned int reg, unsigned int value); unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg); int iommu_setup_hpet_msi(struct msi_desc *); diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h index be7af49c1e..28522f299f 100644 --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -56,8 +56,10 @@ extern bool_t iommu_enable, iommu_enabled; extern bool_t force_iommu, iommu_verbose, iommu_igfx; extern bool_t iommu_snoop, iommu_qinval, iommu_intremap, iommu_intpost; -#ifdef CONFIG_HVM +#if defined(CONFIG_HVM) extern bool iommu_hap_pt_share; +#elif defined(CONFIG_IOMMU_FORCE_PT_SHARE) +#define iommu_hap_pt_share true #else #define iommu_hap_pt_share false #endif @@ -279,6 +281,17 @@ struct domain_iommu { #define iommu_set_feature(d, f) set_bit(f, dom_iommu(d)->features) #define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features) +/* Are we using the domain P2M table as its IOMMU pagetable? */ +#define iommu_use_hap_pt(d) \ + (hap_enabled(d) && is_iommu_enabled(d) && iommu_hap_pt_share) + +/* Does the IOMMU pagetable need to be kept synchronized with the P2M */ +#ifdef CONFIG_HAS_PASSTHROUGH +#define need_iommu_pt_sync(d) (dom_iommu(d)->need_sync) +#else +#define need_iommu_pt_sync(d) ({ (void)(d); false; }) +#endif + int __must_check iommu_suspend(void); void iommu_resume(void); void iommu_crash_shutdown(void); diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index ae1faf70d3..a6896221f9 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -965,12 +965,6 @@ static inline bool is_hwdom_pinned_vcpu(const struct vcpu *v) cpumask_weight(v->cpu_hard_affinity) == 1); } -#ifdef CONFIG_HAS_PASSTHROUGH -#define need_iommu_pt_sync(d) (dom_iommu(d)->need_sync) -#else -#define need_iommu_pt_sync(d) false -#endif - static inline bool is_vcpu_online(const struct vcpu *v) { return !test_bit(_VPF_down, &v->pause_flags);