mirror of
https://github.com/qemu/qemu.git
synced 2026-07-08 17:56:38 +00: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 <nicolinc@nvidia.com> Reviewed-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com> Tested-by: Zhangfei Gao <zhangfei.gao@linaro.org> Tested-by: Eric Auger <eric.auger@redhat.com> Signed-off-by: Shameer Kolothum <skolothumtho@nvidia.com> Reviewed-by: Yi Liu <yi.l.liu@intel.com> Message-id: 20260126104342.253965-2-skolothumtho@nvidia.com Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
committed by
Peter Maydell
parent
65fb9de488
commit
f2d31df0d9
@@ -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