]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
iommu: tidy up iommu_use_hap_pt() and need_iommu_pt_sync() macros
authorPaul Durrant <paul.durrant@citrix.com>
Wed, 25 Sep 2019 14:12:49 +0000 (16:12 +0200)
committerJan Beulich <jbeulich@suse.com>
Wed, 25 Sep 2019 14:12:49 +0000 (16:12 +0200)
Thes macros really ought to live in the common xen/iommu.h header rather
then being distributed amongst architecture specific iommu headers and
xen/sched.h. This patch moves them there.

NOTE: Disabling 'sharept' in the command line iommu options should really
      be hard error on ARM (as opposed to just being ignored), so define
      'iommu_hap_pt_share' to be true for ARM (via ARM-selected
      CONFIG_IOMMU_FORCE_PT_SHARE).

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/Kconfig
xen/drivers/passthrough/Kconfig
xen/include/asm-arm/iommu.h
xen/include/asm-x86/iommu.h
xen/include/xen/iommu.h
xen/include/xen/sched.h

index c2db2a69534b7063ff383b3ecd8217de10cb4264..a51aa7bfa8fcfb1568121fbe4cd3c4f8ece8ac4b 100644 (file)
@@ -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
index a3c06491be42e05186a8e5f9584c9429ffafd494..61f944639e562fc6a46020c7595d6c3445040385 100644 (file)
@@ -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
index 1577e83d2b9f41fb6de154ca057a59eaa54d8cda..77a94b29ebd808d938aa15713ab78d382f39c066 100644 (file)
@@ -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);
 
index 5071afd6a5aac9e7b52789c9ab3bc30a600cb0cb..85741f7c9647798887fa4602df62454c9e6e81c5 100644 (file)
@@ -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 *);
index dfec0ca3fc56938256108be6bd3adadc8c4871f4..42a92a33794c12f410d6b75e9ab7d33f477a8a39 100644 (file)
@@ -56,7 +56,9 @@ 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_IOMMU_FORCE_PT_SHARE)
+#define iommu_hap_pt_share true
+#elif defined(CONFIG_HVM)
 extern bool iommu_hap_pt_share;
 #else
 #define iommu_hap_pt_share false
@@ -288,6 +290,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);
index ae1faf70d3b152a80161a14adfd90dcb6dbf70f7..a6896221f90acd7cebe142d51a2178df384e4f73 100644 (file)
@@ -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);