diff options
| author | Steve Sistare <steven.sistare@oracle.com> | 2025-07-02 14:58:43 -0700 |
|---|---|---|
| committer | Cédric Le Goater <clg@redhat.com> | 2025-07-03 13:42:28 +0200 |
| commit | ab48cedc648a60a3e51db73acf12148d90f19c4c (patch) | |
| tree | 9ac9bfb246e795e2d5e7f2bb935b3e5922291748 /backends | |
| parent | e563dc88c21915e111ecef0756cc291e9e473c35 (diff) | |
| download | focaccia-qemu-ab48cedc648a60a3e51db73acf12148d90f19c4c.tar.gz focaccia-qemu-ab48cedc648a60a3e51db73acf12148d90f19c4c.zip | |
backends/iommufd: change process ioctl
Define the change process ioctl Signed-off-by: Steve Sistare <steven.sistare@oracle.com> Reviewed-by: Cédric Le Goater <clg@redhat.com> Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com> Link: https://lore.kernel.org/qemu-devel/1751493538-202042-7-git-send-email-steven.sistare@oracle.com Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'backends')
| -rw-r--r-- | backends/iommufd.c | 24 | ||||
| -rw-r--r-- | backends/trace-events | 1 |
2 files changed, 25 insertions, 0 deletions
diff --git a/backends/iommufd.c b/backends/iommufd.c index 3a2ecc7f5b..87f81a05f6 100644 --- a/backends/iommufd.c +++ b/backends/iommufd.c @@ -73,6 +73,30 @@ static void iommufd_backend_class_init(ObjectClass *oc, const void *data) object_class_property_add_str(oc, "fd", NULL, iommufd_backend_set_fd); } +bool iommufd_change_process_capable(IOMMUFDBackend *be) +{ + struct iommu_ioas_change_process args = {.size = sizeof(args)}; + + /* + * Call IOMMU_IOAS_CHANGE_PROCESS to verify it is a recognized ioctl. + * This is a no-op if the process has not changed since DMA was mapped. + */ + return !ioctl(be->fd, IOMMU_IOAS_CHANGE_PROCESS, &args); +} + +bool iommufd_change_process(IOMMUFDBackend *be, Error **errp) +{ + struct iommu_ioas_change_process args = {.size = sizeof(args)}; + bool ret = !ioctl(be->fd, IOMMU_IOAS_CHANGE_PROCESS, &args); + + if (!ret) { + error_setg_errno(errp, errno, "IOMMU_IOAS_CHANGE_PROCESS fd %d failed", + be->fd); + } + trace_iommufd_change_process(be->fd, ret); + return ret; +} + bool iommufd_backend_connect(IOMMUFDBackend *be, Error **errp) { int fd; diff --git a/backends/trace-events b/backends/trace-events index e5f3e70cd1..56132d3fd2 100644 --- a/backends/trace-events +++ b/backends/trace-events @@ -7,6 +7,7 @@ dbus_vmstate_loading(const char *id) "id: %s" dbus_vmstate_saving(const char *id) "id: %s" # iommufd.c +iommufd_change_process(int fd, bool ret) "fd=%d (%d)" iommufd_backend_connect(int fd, bool owned, uint32_t users) "fd=%d owned=%d users=%d" iommufd_backend_disconnect(int fd, uint32_t users) "fd=%d users=%d" iommu_backend_set_fd(int fd) "pre-opened /dev/iommu fd=%d" |