From 60d6142c73a47bb68d34f76a9c021d98255ac267 Mon Sep 17 00:00:00 2001 From: zhangpengrui Date: Wed, 18 Jun 2025 16:38:45 +0800 Subject: [PATCH] QEMU update to version 8.2.0-35: - Revert "backends/iommufd: Make iommufd_backend_*() return bool" - qapi/misc-target: Add Virtcca capability struct and query command. Signed-off-by: Pengrui Zhang --- Fix-error-in-virtCCA-CoDA-scenario.patch | 28 ++++ ...iommufd-Make-iommufd_backend_-return.patch | 153 ++++++++++++++++++ qemu.spec | 8 +- 3 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 Fix-error-in-virtCCA-CoDA-scenario.patch create mode 100644 Revert-backends-iommufd-Make-iommufd_backend_-return.patch diff --git a/Fix-error-in-virtCCA-CoDA-scenario.patch b/Fix-error-in-virtCCA-CoDA-scenario.patch new file mode 100644 index 00000000..d9da628c --- /dev/null +++ b/Fix-error-in-virtCCA-CoDA-scenario.patch @@ -0,0 +1,28 @@ +From f80776f3dfd1d05ef3328d5be9fe42df095f4bc1 Mon Sep 17 00:00:00 2001 +From: yxk +Date: Mon, 21 Apr 2025 04:00:46 -0400 +Subject: [PATCH] Fix error in virtCCA CoDA scenario. + +Add 'iommu_type' VFIO_TYPE1v2_S_IOMMU in vfio_get_iommu_class +to avoid error happens in virtCCA CoDA scenario. + +Signed-off-by: yxk +--- + hw/vfio/container.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/hw/vfio/container.c b/hw/vfio/container.c +index 64eacfd912..539cf34b20 100644 +--- a/hw/vfio/container.c ++++ b/hw/vfio/container.c +@@ -439,6 +439,7 @@ static const VFIOIOMMUClass *vfio_get_iommu_class(int iommu_type, Error **errp) + switch (iommu_type) { + case VFIO_TYPE1v2_IOMMU: + case VFIO_TYPE1_IOMMU: ++ case VFIO_TYPE1v2_S_IOMMU: + klass = object_class_by_name(TYPE_VFIO_IOMMU_LEGACY); + break; + case VFIO_SPAPR_TCE_v2_IOMMU: +-- +2.33.0 + diff --git a/Revert-backends-iommufd-Make-iommufd_backend_-return.patch b/Revert-backends-iommufd-Make-iommufd_backend_-return.patch new file mode 100644 index 00000000..1d952d3a --- /dev/null +++ b/Revert-backends-iommufd-Make-iommufd_backend_-return.patch @@ -0,0 +1,153 @@ +From 25c0fad8f9a2ac10f184d346f87da03506314ed6 Mon Sep 17 00:00:00 2001 +From: Zhou Wang +Date: Fri, 13 Jun 2025 11:26:54 +0800 +Subject: [PATCH] Revert "backends/iommufd: Make iommufd_backend_*() return + bool" + +Revert "backends/iommufd: Make iommufd_backend_*() return bool" and +fix the way of vdpa codes use related iommufd APIs. + +Signed-off-by: Zhou Wang +Signed-off-by: Jian Cai +--- + backends/iommufd.c | 29 ++++++++++++++++------------- + backends/trace-events | 4 ++-- + hw/virtio/vdpa-dev-iommufd.c | 6 +++--- + include/sysemu/iommufd.h | 6 +++--- + 4 files changed, 24 insertions(+), 21 deletions(-) + +diff --git a/backends/iommufd.c b/backends/iommufd.c +index 62df6e41f0..4446efaa32 100644 +--- a/backends/iommufd.c ++++ b/backends/iommufd.c +@@ -74,21 +74,23 @@ static void iommufd_backend_class_init(ObjectClass *oc, void *data) + object_class_property_add_str(oc, "fd", NULL, iommufd_backend_set_fd); + } + +-bool iommufd_backend_connect(IOMMUFDBackend *be, Error **errp) ++int iommufd_backend_connect(IOMMUFDBackend *be, Error **errp) + { +- int fd; ++ int fd, ret = 0; + + if (be->owned && !be->users) { + fd = qemu_open("/dev/iommu", O_RDWR, errp); + if (fd < 0) { +- return false; ++ ret = fd; ++ goto out; + } + be->fd = fd; + } + be->users++; +- +- trace_iommufd_backend_connect(be->fd, be->owned, be->users); +- return true; ++out: ++ trace_iommufd_backend_connect(be->fd, be->owned, ++ be->users, ret); ++ return ret; + } + + void iommufd_backend_disconnect(IOMMUFDBackend *be) +@@ -105,24 +107,25 @@ out: + trace_iommufd_backend_disconnect(be->fd, be->users); + } + +-bool iommufd_backend_alloc_ioas(IOMMUFDBackend *be, uint32_t *ioas_id, +- Error **errp) ++int iommufd_backend_alloc_ioas(IOMMUFDBackend *be, uint32_t *ioas_id, ++ Error **errp) + { +- int fd = be->fd; ++ int ret, fd = be->fd; + struct iommu_ioas_alloc alloc_data = { + .size = sizeof(alloc_data), + .flags = 0, + }; + +- if (ioctl(fd, IOMMU_IOAS_ALLOC, &alloc_data)) { ++ ret = ioctl(fd, IOMMU_IOAS_ALLOC, &alloc_data); ++ if (ret) { + error_setg_errno(errp, errno, "Failed to allocate ioas"); +- return false; ++ return ret; + } + + *ioas_id = alloc_data.out_ioas_id; +- trace_iommufd_backend_alloc_ioas(fd, *ioas_id); ++ trace_iommufd_backend_alloc_ioas(fd, *ioas_id, ret); + +- return true; ++ return ret; + } + + void iommufd_backend_free_id(IOMMUFDBackend *be, uint32_t id) +diff --git a/backends/trace-events b/backends/trace-events +index 8fe77149b2..f8592a2711 100644 +--- a/backends/trace-events ++++ b/backends/trace-events +@@ -7,13 +7,13 @@ dbus_vmstate_loading(const char *id) "id: %s" + dbus_vmstate_saving(const char *id) "id: %s" + + # iommufd.c +-iommufd_backend_connect(int fd, bool owned, uint32_t users) "fd=%d owned=%d users=%d" ++iommufd_backend_connect(int fd, bool owned, uint32_t users, int ret) "fd=%d owned=%d users=%d (%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" + iommufd_backend_map_dma(int iommufd, uint32_t ioas, uint64_t iova, uint64_t size, void *vaddr, bool readonly, int ret) " iommufd=%d ioas=%d iova=0x%"PRIx64" size=0x%"PRIx64" addr=%p readonly=%d (%d)" + iommufd_backend_unmap_dma_non_exist(int iommufd, uint32_t ioas, uint64_t iova, uint64_t size, int ret) " Unmap nonexistent mapping: iommufd=%d ioas=%d iova=0x%"PRIx64" size=0x%"PRIx64" (%d)" + iommufd_backend_unmap_dma(int iommufd, uint32_t ioas, uint64_t iova, uint64_t size, int ret) " iommufd=%d ioas=%d iova=0x%"PRIx64" size=0x%"PRIx64" (%d)" +-iommufd_backend_alloc_ioas(int iommufd, uint32_t ioas) " iommufd=%d ioas=%d" ++iommufd_backend_alloc_ioas(int iommufd, uint32_t ioas, int ret) " iommufd=%d ioas=%d (%d)" + iommufd_backend_alloc_hwpt(int iommufd, uint32_t dev_id, uint32_t pt_id, uint32_t flags, uint32_t hwpt_type, uint32_t len, uint64_t data_ptr, uint32_t out_hwpt_id, int ret) " iommufd=%d dev_id=%u pt_id=%u flags=0x%x hwpt_type=%u len=%u data_ptr=0x%"PRIx64" out_hwpt=%u (%d)" + iommufd_backend_free_id(int iommufd, uint32_t id, int ret) " iommufd=%d id=%d (%d)" + iommufd_backend_set_dirty(int iommufd, uint32_t hwpt_id, bool start, int ret) " iommufd=%d hwpt=%u enable=%d (%d)" +diff --git a/hw/virtio/vdpa-dev-iommufd.c b/hw/virtio/vdpa-dev-iommufd.c +index 2b0498f9dc..f5718bae99 100644 +--- a/hw/virtio/vdpa-dev-iommufd.c ++++ b/hw/virtio/vdpa-dev-iommufd.c +@@ -186,12 +186,12 @@ static int vhost_vdpa_container_connect_iommufd(VDPAIOMMUFDContainer *container) + return -1; + } + +- if (!iommufd_backend_connect(iommufd, &err)) { ++ if (iommufd_backend_connect(iommufd, &err)) { + error_report_err(err); + return -1; + } + +- if (!iommufd_backend_alloc_ioas(iommufd, &ioas_id, &err)) { ++ if (iommufd_backend_alloc_ioas(iommufd, &ioas_id, &err)) { + error_report_err(err); + iommufd_backend_disconnect(iommufd); + return -1; +@@ -480,4 +480,4 @@ void vhost_vdpa_detach_container(VhostVdpaDevice *vdev) + vhost_vdpa_container_disconnect_iommufd(container); + + vhost_vdpa_destroy_container(container); +-} +\ No newline at end of file ++} +diff --git a/include/sysemu/iommufd.h b/include/sysemu/iommufd.h +index 0531a4ad98..908c94d811 100644 +--- a/include/sysemu/iommufd.h ++++ b/include/sysemu/iommufd.h +@@ -43,11 +43,11 @@ typedef struct IOMMUFDViommu { + uint32_t viommu_id; + } IOMMUFDViommu; + +-bool iommufd_backend_connect(IOMMUFDBackend *be, Error **errp); ++int iommufd_backend_connect(IOMMUFDBackend *be, Error **errp); + void iommufd_backend_disconnect(IOMMUFDBackend *be); + +-bool iommufd_backend_alloc_ioas(IOMMUFDBackend *be, uint32_t *ioas_id, +- Error **errp); ++int iommufd_backend_alloc_ioas(IOMMUFDBackend *be, uint32_t *ioas_id, ++ Error **errp); + void iommufd_backend_free_id(IOMMUFDBackend *be, uint32_t id); + int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova, + ram_addr_t size, void *vaddr, bool readonly); +-- +2.33.0 + diff --git a/qemu.spec b/qemu.spec index c438d4e6..22447f48 100644 --- a/qemu.spec +++ b/qemu.spec @@ -3,7 +3,7 @@ Name: qemu Version: 8.2.0 -Release: 34 +Release: 35 Epoch: 11 Summary: QEMU is a generic and open source machine emulator and virtualizer License: GPLv2 and BSD and MIT and CC-BY-SA-4.0 @@ -932,6 +932,8 @@ Patch0915: memory-Optimize-flatview-ioeventfd-processing.patch Patch0916: vdpa-iommufd-All-vdpa-devices-perform-only-one-log_s.patch Patch0917: Revert-target-arm-Change-arm_cpu_mp_affinity-when-en.patch Patch0918: target-arm-support-the-IPIV-feature.patch +Patch0919: Fix-error-in-virtCCA-CoDA-scenario.patch +Patch0920: Revert-backends-iommufd-Make-iommufd_backend_-return.patch BuildRequires: flex BuildRequires: gcc @@ -1530,6 +1532,10 @@ getent passwd qemu >/dev/null || \ %endif %changelog +* Wed Jun 18 2025 Pengrui Zhang - 11:8.2.0-35 +- Fix error in virtCCA CoDA scenario. +- Revert "backends/iommufd: Make iommufd_backend_*() return bool" + * Wed May 28 2025 Jiabo Feng - 11:8.2.0-34 - target/arm: support the IPIV feature - Revert "target/arm: Change arm_cpu_mp_affinity when enabled IPIV feature" -- Gitee