mirror of
https://github.com/utmapp/qemu.git
synced 2026-12-01 22:23:23 -10:00
backends/iommufd: Introduce iommufd_backend_alloc_viommu
Add a helper to allocate a viommu object. Also introduce a struct IOMMUFDViommu that can be used later by vendor IOMMU implementations. Signed-off-by: Nicolin Chen <[email protected]> Reviewed-by: Eric Auger <[email protected]> Reviewed-by: Jonathan Cameron <[email protected]> Signed-off-by: Shameer Kolothum <[email protected]> Tested-by: Zhangfei Gao <[email protected]> Tested-by: Eric Auger <[email protected]> Signed-off-by: Shameer Kolothum <[email protected]> Reviewed-by: Yi Liu <[email protected]> Message-id: [email protected] Signed-off-by: Peter Maydell <[email protected]>
This commit is contained in:
1 parent
65fb9de488
commit
f2d31df0d9
3 files changed
+41
No files matched your search
@@ -447,6 +447,32 @@ bool iommufd_backend_invalidate_cache(IOMMUFDBackend *be, uint32_t id,
|
||||
return !ret;
|
||||
}
|
||||
|
||||
bool iommufd_backend_alloc_viommu(IOMMUFDBackend *be, uint32_t dev_id,
|
||||
uint32_t viommu_type, uint32_t hwpt_id,
|
||||
uint32_t *out_viommu_id, Error **errp)
|
||||
{
|
||||
int ret;
|
||||
struct iommu_viommu_alloc alloc_viommu = {
|
||||
.size = sizeof(alloc_viommu),
|
||||
.type = viommu_type,
|
||||
.dev_id = dev_id,
|
||||
.hwpt_id = hwpt_id,
|
||||
};
|
||||
|
||||
ret = ioctl(be->fd, IOMMU_VIOMMU_ALLOC, &alloc_viommu);
|
||||
|
||||
trace_iommufd_backend_alloc_viommu(be->fd, dev_id, viommu_type, hwpt_id,
|
||||
alloc_viommu.out_viommu_id, ret);
|
||||
if (ret) {
|
||||
error_setg_errno(errp, errno, "IOMMU_VIOMMU_ALLOC failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
g_assert(out_viommu_id);
|
||||
*out_viommu_id = alloc_viommu.out_viommu_id;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool host_iommu_device_iommufd_attach_hwpt(HostIOMMUDeviceIOMMUFD *idev,
|
||||
uint32_t hwpt_id, Error **errp)
|
||||
{
|
||||
|
||||
@@ -21,3 +21,4 @@ iommufd_backend_free_id(int iommufd, uint32_t id, int ret) " iommufd=%d id=%d (%
|
||||
iommufd_backend_set_dirty(int iommufd, uint32_t hwpt_id, bool start, int ret) " iommufd=%d hwpt=%u enable=%d (%d)"
|
||||
iommufd_backend_get_dirty_bitmap(int iommufd, uint32_t hwpt_id, uint64_t iova, uint64_t size, uint64_t flags, uint64_t page_size, int ret) " iommufd=%d hwpt=%u iova=0x%"PRIx64" size=0x%"PRIx64" flags=0x%"PRIx64" page_size=0x%"PRIx64" (%d)"
|
||||
iommufd_backend_invalidate_cache(int iommufd, uint32_t id, uint32_t data_type, uint32_t entry_len, uint32_t entry_num, uint32_t done_num, uint64_t data_ptr, int ret) " iommufd=%d id=%u data_type=%u entry_len=%u entry_num=%u done_num=%u data_ptr=0x%"PRIx64" (%d)"
|
||||
iommufd_backend_alloc_viommu(int iommufd, uint32_t dev_id, uint32_t type, uint32_t hwpt_id, uint32_t viommu_id, int ret) " iommufd=%d type=%u dev_id=%u hwpt_id=%u viommu_id=%u (%d)"
|
||||
@@ -38,6 +38,16 @@ struct IOMMUFDBackend {
|
||||
/*< public >*/
|
||||
};
|
||||
|
||||
/*
|
||||
* Virtual IOMMU object that represents physical IOMMU's virtualization
|
||||
* support
|
||||
*/
|
||||
typedef struct IOMMUFDViommu {
|
||||
IOMMUFDBackend *iommufd;
|
||||
uint32_t s2_hwpt_id; /* ID of stage 2 HWPT */
|
||||
uint32_t viommu_id; /* virtual IOMMU ID of allocated object */
|
||||
} IOMMUFDViommu;
|
||||
|
||||
bool iommufd_backend_connect(IOMMUFDBackend *be, Error **errp);
|
||||
void iommufd_backend_disconnect(IOMMUFDBackend *be);
|
||||
|
||||
@@ -59,6 +69,10 @@ bool iommufd_backend_alloc_hwpt(IOMMUFDBackend *be, uint32_t dev_id,
|
||||
uint32_t data_type, uint32_t data_len,
|
||||
void *data_ptr, uint32_t *out_hwpt,
|
||||
Error **errp);
|
||||
bool iommufd_backend_alloc_viommu(IOMMUFDBackend *be, uint32_t dev_id,
|
||||
uint32_t viommu_type, uint32_t hwpt_id,
|
||||
uint32_t *out_hwpt, Error **errp);
|
||||
|
||||
bool iommufd_backend_set_dirty_tracking(IOMMUFDBackend *be, uint32_t hwpt_id,
|
||||
bool start, Error **errp);
|
||||
bool iommufd_backend_get_dirty_bitmap(IOMMUFDBackend *be, uint32_t hwpt_id,
|
||||
|
||||
Reference in new issue
Block a user