Add a new ioctl for user space to do a vIOMMU allocation. It must be based on a nesting parent HWPT, so take its refcount. IOMMU driver wanting to support vIOMMUs must define its IOMMU_VIOMMU_TYPE_ in the uAPI header and implement a viommu_alloc op in its iommu_ops.
Showing the changes to include/uapi (1 of 5 files). Show all
Unified · Split
| @@ -52,6 +52,7 @@ enum { · 51 unmodified lines | ||
| 52 | 52 | IOMMUFD_CMD_HWPT_INVALIDATE = 0x8d, |
| 53 | 53 | IOMMUFD_CMD_FAULT_QUEUE_ALLOC = 0x8e, |
| 54 | 54 | IOMMUFD_CMD_IOAS_MAP_FILE = 0x8f, |
| 55 | + IOMMUFD_CMD_VIOMMU_ALLOC = 0x90, | |
| 55 | 56 | }; |
| 56 | 57 | |
| 57 | 58 | /** |
| @@ -822,4 +823,43 @@ struct iommu_fault_alloc { · 764 unmodified lines | ||
| 822 | 823 | __u32 out_fault_fd; |
| 823 | 824 | }; |
| 824 | 825 | #define IOMMU_FAULT_QUEUE_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_FAULT_QUEUE_ALLOC) |
| 826 | + | |
| 827 | +/** | |
| 828 | + * enum iommu_viommu_type - Virtual IOMMU Type | |
| 829 | + * @IOMMU_VIOMMU_TYPE_DEFAULT: Reserved for future use | |
| 830 | + */ | |
| 831 | +enum iommu_viommu_type { | |
| 832 | + IOMMU_VIOMMU_TYPE_DEFAULT = 0, | |
| 833 | +}; | |
| 834 | + | |
| 835 | +/** | |
| 836 | + * struct iommu_viommu_alloc - ioctl(IOMMU_VIOMMU_ALLOC) | |
| 837 | + * @size: sizeof(struct iommu_viommu_alloc) | |
| 838 | + * @flags: Must be 0 | |
| 839 | + * @type: Type of the virtual IOMMU. Must be defined in enum iommu_viommu_type | |
| 840 | + * @dev_id: The device's physical IOMMU will be used to back the virtual IOMMU | |
| 841 | + * @hwpt_id: ID of a nesting parent HWPT to associate to | |
| 842 | + * @out_viommu_id: Output virtual IOMMU ID for the allocated object | |
| 843 | + * | |
| 844 | + * Allocate a virtual IOMMU object, representing the underlying physical IOMMU's | |
| 845 | + * virtualization support that is a security-isolated slice of the real IOMMU HW | |
| 846 | + * that is unique to a specific VM. Operations global to the IOMMU are connected | |
| 847 | + * to the vIOMMU, such as: | |
| 848 | + * - Security namespace for guest owned ID, e.g. guest-controlled cache tags | |
| 849 | + * - Non-device-affiliated event reporting, e.g. invalidation queue errors | |
| 850 | + * - Access to a sharable nesting parent pagetable across physical IOMMUs | |
| 851 | + * - Virtualization of various platforms IDs, e.g. RIDs and others | |
| 852 | + * - Delivery of paravirtualized invalidation | |
| 853 | + * - Direct assigned invalidation queues | |
| 854 | + * - Direct assigned interrupts | |
| 855 | + */ | |
| 856 | +struct iommu_viommu_alloc { | |
| 857 | + __u32 size; | |
| 858 | + __u32 flags; | |
| 859 | + __u32 type; | |
| 860 | + __u32 dev_id; | |
| 861 | + __u32 hwpt_id; | |
| 862 | + __u32 out_viommu_id; | |
| 863 | +}; | |
| 864 | +#define IOMMU_VIOMMU_ALLOC _IO(IOMMUFD_TYPE, IOMMUFD_CMD_VIOMMU_ALLOC) | |
| 825 | 865 | #endif |