Commit d9f92cd3 authored by Seth Howell's avatar Seth Howell Committed by Darek Stojaczyk
Browse files

memory: add way of checking iommu usage



Since the fuzz tester will be submitting random commands with random
memory addresses and such to the NVMe drives, we want to be especially
sure that we are using the IOMMU while running this test to prevent
memory corruption in the event that an errant command triggers a bad
DMA.
This function exposes to the application whether or not we are using the
IOMMU.

Change-Id: Ie4d26c706967a520967bfc81f72f7b581b792437
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/446568


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 961cd6ab
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -573,6 +573,13 @@ size_t spdk_ring_enqueue(struct spdk_ring *ring, void **objs, size_t count);
 */
size_t spdk_ring_dequeue(struct spdk_ring *ring, void **objs, size_t count);

/**
 * Reports whether the SPDK application is using the IOMMU for DMA
 *
 * \return True if we are using the IOMMU, false otherwise.
 */
bool spdk_iommu_is_enabled(void);

#define SPDK_VTOPHYS_ERROR	(0xFFFFFFFFFFFFFFFFULL)

/**
+10 −0
Original line number Diff line number Diff line
@@ -779,6 +779,16 @@ spdk_mem_map_init(void)
	return 0;
}

bool
spdk_iommu_is_enabled(void)
{
#if SPDK_VFIO_ENABLED
	return g_vfio.enabled && !g_vfio.noiommu_enabled;
#else
	return false;
#endif
}

struct spdk_vtophys_pci_device {
	struct rte_pci_device *pci_device;
	TAILQ_ENTRY(spdk_vtophys_pci_device) tailq;