svn commit: r363533 - in head/sys: dev/iommu x86/iommu

Ruslan Bukin br at FreeBSD.org
Sat Jul 25 19:07:14 UTC 2020


Author: br
Date: Sat Jul 25 19:07:12 2020
New Revision: 363533
URL: https://svnweb.freebsd.org/changeset/base/363533

Log:
  o Move iommu gas prototypes, DMAR flags to iommu.h;
  o Move hw.dmar sysctl node to iommu_gas.c.
  
  Reviewed by:	kib
  Sponsored by:	DARPA/AFRL
  Differential Revision:	https://reviews.freebsd.org/D25802

Modified:
  head/sys/dev/iommu/iommu.h
  head/sys/dev/iommu/iommu_gas.c
  head/sys/x86/iommu/intel_dmar.h
  head/sys/x86/iommu/intel_drv.c
  head/sys/x86/iommu/intel_utils.c

Modified: head/sys/dev/iommu/iommu.h
==============================================================================
--- head/sys/dev/iommu/iommu.h	Sat Jul 25 18:29:10 2020	(r363532)
+++ head/sys/dev/iommu/iommu.h	Sat Jul 25 19:07:12 2020	(r363533)
@@ -133,6 +133,24 @@ struct iommu_ctx {
 					   ephemeral reference is kept
 					   to prevent context destruction */
 
+#define	DMAR_DOMAIN_GAS_INITED		0x0001
+#define	DMAR_DOMAIN_PGTBL_INITED	0x0002
+#define	DMAR_DOMAIN_IDMAP		0x0010	/* Domain uses identity
+						   page table */
+#define	DMAR_DOMAIN_RMRR		0x0020	/* Domain contains RMRR entry,
+						   cannot be turned off */
+
+/* Map flags */
+#define	IOMMU_MF_CANWAIT	0x0001
+#define	IOMMU_MF_CANSPLIT	0x0002
+#define	IOMMU_MF_RMRR		0x0004
+
+#define	DMAR_PGF_WAITOK		0x0001
+#define	DMAR_PGF_ZERO		0x0002
+#define	DMAR_PGF_ALLOC		0x0004
+#define	DMAR_PGF_NOALLOC	0x0008
+#define	DMAR_PGF_OBJL		0x0010
+
 #define	IOMMU_LOCK(unit)		mtx_lock(&(unit)->lock)
 #define	IOMMU_UNLOCK(unit)		mtx_unlock(&(unit)->lock)
 #define	IOMMU_ASSERT_LOCKED(unit)	mtx_assert(&(unit)->lock, MA_OWNED)
@@ -173,5 +191,23 @@ int iommu_map(struct iommu_domain *iodom,
     u_int eflags, u_int flags, vm_page_t *ma, struct iommu_map_entry **res);
 int iommu_map_region(struct iommu_domain *domain,
     struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma);
+
+void iommu_gas_init_domain(struct iommu_domain *domain);
+void iommu_gas_fini_domain(struct iommu_domain *domain);
+struct iommu_map_entry *iommu_gas_alloc_entry(struct iommu_domain *domain,
+    u_int flags);
+void iommu_gas_free_entry(struct iommu_domain *domain,
+    struct iommu_map_entry *entry);
+void iommu_gas_free_space(struct iommu_domain *domain,
+    struct iommu_map_entry *entry);
+int iommu_gas_map(struct iommu_domain *domain,
+    const struct bus_dma_tag_common *common, iommu_gaddr_t size, int offset,
+    u_int eflags, u_int flags, vm_page_t *ma, struct iommu_map_entry **res);
+void iommu_gas_free_region(struct iommu_domain *domain,
+    struct iommu_map_entry *entry);
+int iommu_gas_map_region(struct iommu_domain *domain,
+    struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma);
+int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start,
+    iommu_gaddr_t end);
 
 #endif /* !_SYS_IOMMU_H_ */

Modified: head/sys/dev/iommu/iommu_gas.c
==============================================================================
--- head/sys/dev/iommu/iommu_gas.c	Sat Jul 25 18:29:10 2020	(r363532)
+++ head/sys/dev/iommu/iommu_gas.c	Sat Jul 25 19:07:12 2020	(r363533)
@@ -79,6 +79,10 @@ __FBSDID("$FreeBSD$");
 
 static uma_zone_t iommu_map_entry_zone;
 
+#ifdef INVARIANTS
+static int iommu_check_free;
+#endif
+
 static void
 intel_gas_init(void)
 {
@@ -727,3 +731,11 @@ iommu_map_region(struct iommu_domain *domain, struct i
 
 	return (error);
 }
+
+#ifdef INVARIANTS
+static SYSCTL_NODE(_hw, OID_AUTO, iommu, CTLFLAG_RD | CTLFLAG_MPSAFE, NULL,
+    "");
+SYSCTL_INT(_hw_iommu, OID_AUTO, check_free, CTLFLAG_RWTUN,
+    &iommu_check_free, 0,
+    "Check the GPA RBtree for free_down and free_after validity");
+#endif

Modified: head/sys/x86/iommu/intel_dmar.h
==============================================================================
--- head/sys/x86/iommu/intel_dmar.h	Sat Jul 25 18:29:10 2020	(r363532)
+++ head/sys/x86/iommu/intel_dmar.h	Sat Jul 25 19:07:12 2020	(r363533)
@@ -81,13 +81,6 @@ struct dmar_ctx {
 	u_int refs;			/* (u) References from tags */
 };
 
-#define	DMAR_DOMAIN_GAS_INITED		0x0001
-#define	DMAR_DOMAIN_PGTBL_INITED	0x0002
-#define	DMAR_DOMAIN_IDMAP		0x0010	/* Domain uses identity
-						   page table */
-#define	DMAR_DOMAIN_RMRR		0x0020	/* Domain contains RMRR entry,
-						   cannot be turned off */
-
 #define	DMAR_DOMAIN_PGLOCK(dom)		VM_OBJECT_WLOCK((dom)->pgtbl_obj)
 #define	DMAR_DOMAIN_PGTRYLOCK(dom)	VM_OBJECT_TRYWLOCK((dom)->pgtbl_obj)
 #define	DMAR_DOMAIN_PGUNLOCK(dom)	VM_OBJECT_WUNLOCK((dom)->pgtbl_obj)
@@ -286,24 +279,6 @@ void dmar_domain_unload(struct dmar_domain *domain,
     struct iommu_map_entries_tailq *entries, bool cansleep);
 void dmar_domain_free_entry(struct iommu_map_entry *entry, bool free);
 
-void iommu_gas_init_domain(struct iommu_domain *domain);
-void iommu_gas_fini_domain(struct iommu_domain *domain);
-struct iommu_map_entry *iommu_gas_alloc_entry(struct iommu_domain *domain,
-    u_int flags);
-void iommu_gas_free_entry(struct iommu_domain *domain,
-    struct iommu_map_entry *entry);
-void iommu_gas_free_space(struct iommu_domain *domain,
-    struct iommu_map_entry *entry);
-int iommu_gas_map(struct iommu_domain *domain,
-    const struct bus_dma_tag_common *common, iommu_gaddr_t size, int offset,
-    u_int eflags, u_int flags, vm_page_t *ma, struct iommu_map_entry **res);
-void iommu_gas_free_region(struct iommu_domain *domain,
-    struct iommu_map_entry *entry);
-int iommu_gas_map_region(struct iommu_domain *domain,
-    struct iommu_map_entry *entry, u_int eflags, u_int flags, vm_page_t *ma);
-int iommu_gas_reserve_region(struct iommu_domain *domain, iommu_gaddr_t start,
-    iommu_gaddr_t end);
-
 void dmar_dev_parse_rmrr(struct dmar_domain *domain, int dev_domain,
     int dev_busno, const void *dev_path, int dev_path_len,
     struct iommu_map_entries_tailq *rmrr_entries);
@@ -318,22 +293,10 @@ void dmar_fini_irt(struct dmar_unit *unit);
 void dmar_set_buswide_ctx(struct iommu_unit *unit, u_int busno);
 bool dmar_is_buswide_ctx(struct dmar_unit *unit, u_int busno);
 
-/* Map flags */
-#define	IOMMU_MF_CANWAIT	0x0001
-#define	IOMMU_MF_CANSPLIT	0x0002
-#define	IOMMU_MF_RMRR		0x0004
-
-#define	DMAR_PGF_WAITOK	0x0001
-#define	DMAR_PGF_ZERO	0x0002
-#define	DMAR_PGF_ALLOC	0x0004
-#define	DMAR_PGF_NOALLOC 0x0008
-#define	DMAR_PGF_OBJL	0x0010
-
 extern iommu_haddr_t dmar_high;
 extern int haw;
 extern int dmar_tbl_pagecnt;
 extern int dmar_batch_coalesce;
-extern int iommu_check_free;
 
 static inline uint32_t
 dmar_read4(const struct dmar_unit *unit, int reg)

Modified: head/sys/x86/iommu/intel_drv.c
==============================================================================
--- head/sys/x86/iommu/intel_drv.c	Sat Jul 25 18:29:10 2020	(r363532)
+++ head/sys/x86/iommu/intel_drv.c	Sat Jul 25 19:07:12 2020	(r363533)
@@ -175,9 +175,6 @@ dmar_identify(driver_t *driver, device_t parent)
 	TUNABLE_INT_FETCH("hw.dmar.enable", &dmar_enable);
 	if (!dmar_enable)
 		return;
-#ifdef INVARIANTS
-	TUNABLE_INT_FETCH("hw.iommu.check_free", &iommu_check_free);
-#endif
 	status = AcpiGetTable(ACPI_SIG_DMAR, 1, (ACPI_TABLE_HEADER **)&dmartbl);
 	if (ACPI_FAILURE(status))
 		return;

Modified: head/sys/x86/iommu/intel_utils.c
==============================================================================
--- head/sys/x86/iommu/intel_utils.c	Sat Jul 25 18:29:10 2020	(r363532)
+++ head/sys/x86/iommu/intel_utils.c	Sat Jul 25 19:07:12 2020	(r363533)
@@ -667,10 +667,3 @@ SYSCTL_PROC(_hw_dmar, OID_AUTO, timeout,
     CTLTYPE_U64 | CTLFLAG_RW | CTLFLAG_MPSAFE, 0, 0,
     dmar_timeout_sysctl, "QU",
     "Timeout for command wait, in nanoseconds");
-#ifdef INVARIANTS
-int iommu_check_free;
-SYSCTL_INT(_hw_dmar, OID_AUTO, check_free, CTLFLAG_RWTUN,
-    &iommu_check_free, 0,
-    "Check the GPA RBtree for free_down and free_after validity");
-#endif
-


More information about the svn-src-head mailing list