summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRahul Singh <rahul.singh@arm.com>2020-11-27 18:07:50 +0100
committerJan Beulich <jbeulich@suse.com>2020-11-27 18:07:50 +0100
commitf7d7d53f6464cff94ead4c15d21e79ce4d9173f5 (patch)
tree87507f73c027651aaac058df23beff9fa8cfe7a8
parentf7e77e55d33b7e52477d65f4c5e67281384b650f (diff)
xen/pci: solve compilation error on ARM with HAS_PCI enabled
If mem-sharing, mem-paging, or log-dirty functionality is not enabled for architecture when HAS_PCI is enabled, the compiler will throw an error. Move code to x86 specific file to fix compilation error. Also, modify the code to use likely() in place of unlikley() for each condition to make code more optimized. No functional change intended. Signed-off-by: Rahul Singh <rahul.singh@arm.com> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> Acked-by: Jan Beulich <jbeulich@suse.com>
-rw-r--r--xen/drivers/passthrough/pci.c8
-rw-r--r--xen/drivers/passthrough/x86/iommu.c13
-rw-r--r--xen/include/xen/iommu.h2
3 files changed, 16 insertions, 7 deletions
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index ab590ca398..705137f8be 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -23,7 +23,6 @@
#include <xen/iommu.h>
#include <xen/irq.h>
#include <xen/param.h>
-#include <xen/vm_event.h>
#include <xen/delay.h>
#include <xen/keyhandler.h>
#include <xen/event.h>
@@ -1421,12 +1420,7 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
if ( !is_iommu_enabled(d) )
return 0;
- /* Prevent device assign if mem paging or mem sharing have been
- * enabled for this domain */
- if ( d != dom_io &&
- unlikely(mem_sharing_enabled(d) ||
- vm_event_check_ring(d->vm_event_paging) ||
- p2m_get_hostp2m(d)->global_logdirty) )
+ if ( !arch_iommu_use_permitted(d) )
return -EXDEV;
/* device_assigned() should already have cleared the device for assignment */
diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index f17b1820f4..cea1032b3d 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -18,6 +18,7 @@
#include <xen/guest_access.h>
#include <xen/event.h>
#include <xen/softirq.h>
+#include <xen/vm_event.h>
#include <xsm/xsm.h>
#include <asm/hvm/io.h>
@@ -308,6 +309,18 @@ struct page_info *iommu_alloc_pgtable(struct domain *d)
return pg;
}
+bool arch_iommu_use_permitted(const struct domain *d)
+{
+ /*
+ * Prevent device assign if mem paging, mem sharing or log-dirty
+ * have been enabled for this domain.
+ */
+ return d == dom_io ||
+ (likely(!mem_sharing_enabled(d)) &&
+ likely(!vm_event_check_ring(d->vm_event_paging)) &&
+ likely(!p2m_get_hostp2m(d)->global_logdirty));
+}
+
/*
* Local variables:
* mode: C
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index 69af5baf92..f0295fd6c3 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -378,6 +378,8 @@ DECLARE_PER_CPU(bool_t, iommu_dont_flush_iotlb);
extern struct spinlock iommu_pt_cleanup_lock;
extern struct page_list_head iommu_pt_cleanup_list;
+bool arch_iommu_use_permitted(const struct domain *d);
+
#endif /* _IOMMU_H_ */
/*