include/linux/iommufd.h

Source file repositories/reference/linux-study-clean/include/linux/iommufd.h

File Facts

System
Linux kernel
Corpus path
include/linux/iommufd.h
Extension
.h
Size
14854 bytes
Lines
401
Domain
Core OS
Bucket
Core Kernel Interface
Inferred role
Core OS: implementation source
Status
source implementation candidate

Why This File Exists

Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.

Dependency Surface

Detected Declarations

Annotated Snippet

struct iommufd_object {
	/*
	 * Destroy will sleep and wait for wait_cnt to go to zero. This allows
	 * concurrent users of the ID to reliably avoid causing a spurious
	 * destroy failure. Incrementing this count should either be short
	 * lived or be revoked and blocked during pre_destroy().
	 */
	refcount_t wait_cnt;
	refcount_t users;
	enum iommufd_object_type type;
	unsigned int id;
};

struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx,
					   struct device *dev, u32 *id);
void iommufd_device_unbind(struct iommufd_device *idev);

int iommufd_device_attach(struct iommufd_device *idev, ioasid_t pasid,
			  u32 *pt_id);
int iommufd_device_replace(struct iommufd_device *idev, ioasid_t pasid,
			   u32 *pt_id);
void iommufd_device_detach(struct iommufd_device *idev, ioasid_t pasid);

struct iommufd_ctx *iommufd_device_to_ictx(struct iommufd_device *idev);
u32 iommufd_device_to_id(struct iommufd_device *idev);

struct iommufd_access_ops {
	u8 needs_pin_pages : 1;
	void (*unmap)(void *data, unsigned long iova, unsigned long length);
};

enum {
	IOMMUFD_ACCESS_RW_READ = 0,
	IOMMUFD_ACCESS_RW_WRITE = 1 << 0,
	/* Set if the caller is in a kthread then rw will use kthread_use_mm() */
	IOMMUFD_ACCESS_RW_KTHREAD = 1 << 1,

	/* Only for use by selftest */
	__IOMMUFD_ACCESS_RW_SLOW_PATH = 1 << 2,
};

struct iommufd_access *
iommufd_access_create(struct iommufd_ctx *ictx,
		      const struct iommufd_access_ops *ops, void *data, u32 *id);
void iommufd_access_destroy(struct iommufd_access *access);
int iommufd_access_attach(struct iommufd_access *access, u32 ioas_id);
int iommufd_access_replace(struct iommufd_access *access, u32 ioas_id);
void iommufd_access_detach(struct iommufd_access *access);

void iommufd_ctx_get(struct iommufd_ctx *ictx);

struct iommufd_viommu {
	struct iommufd_object obj;
	struct iommufd_ctx *ictx;
	struct iommu_device *iommu_dev;
	struct iommufd_hwpt_paging *hwpt;

	const struct iommufd_viommu_ops *ops;

	struct xarray vdevs;
	struct list_head veventqs;
	struct rw_semaphore veventqs_rwsem;

	enum iommu_viommu_type type;
};

struct iommufd_vdevice {
	struct iommufd_object obj;
	struct iommufd_viommu *viommu;
	struct iommufd_device *idev;

	/*
	 * Virtual device ID per vIOMMU, e.g. vSID of ARM SMMUv3, vDeviceID of
	 * AMD IOMMU, and vRID of Intel VT-d
	 */
	u64 virt_id;

	/* Clean up all driver-specific parts of an iommufd_vdevice */
	void (*destroy)(struct iommufd_vdevice *vdev);
};

struct iommufd_hw_queue {
	struct iommufd_object obj;
	struct iommufd_viommu *viommu;
	struct iommufd_access *access;

	u64 base_addr; /* in guest physical address space */
	size_t length;

	enum iommu_hw_queue_type type;

Annotation

Implementation Notes