[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 02/17] vfio/common: Fix wrong %m usages
From: |
Alex Williamson |
Subject: |
[PULL 02/17] vfio/common: Fix wrong %m usages |
Date: |
Tue, 07 Mar 2023 11:52:28 -0700 |
User-agent: |
StGit/1.5.dev2+g9ce680a52bd9 |
From: Avihai Horon <avihaih@nvidia.com>
There are several places where the %m conversion is used if one of
vfio_dma_map(), vfio_dma_unmap() or vfio_get_dirty_bitmap() fail.
The %m usage in these places is wrong since %m relies on errno value while
the above functions don't report errors via errno.
Fix it by using strerror() with the returned value instead.
Signed-off-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Link: 20230307125450.62409-3-joao.m.martins@oracle.com">https://lore.kernel.org/r/20230307125450.62409-3-joao.m.martins@oracle.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
hw/vfio/common.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 9fc305448fa2..4d26e9cccf91 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -703,17 +703,17 @@ static void vfio_iommu_map_notify(IOMMUNotifier *n,
IOMMUTLBEntry *iotlb)
read_only);
if (ret) {
error_report("vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx", %p) = %d (%m)",
+ "0x%"HWADDR_PRIx", %p) = %d (%s)",
container, iova,
- iotlb->addr_mask + 1, vaddr, ret);
+ iotlb->addr_mask + 1, vaddr, ret, strerror(-ret));
}
} else {
ret = vfio_dma_unmap(container, iova, iotlb->addr_mask + 1, iotlb);
if (ret) {
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx") = %d (%m)",
+ "0x%"HWADDR_PRIx") = %d (%s)",
container, iova,
- iotlb->addr_mask + 1, ret);
+ iotlb->addr_mask + 1, ret, strerror(-ret));
}
}
out:
@@ -1095,8 +1095,9 @@ static void vfio_listener_region_add(MemoryListener
*listener,
vaddr, section->readonly);
if (ret) {
error_setg(&err, "vfio_dma_map(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx", %p) = %d (%m)",
- container, iova, int128_get64(llsize), vaddr, ret);
+ "0x%"HWADDR_PRIx", %p) = %d (%s)",
+ container, iova, int128_get64(llsize), vaddr, ret,
+ strerror(-ret));
if (memory_region_is_ram_device(section->mr)) {
/* Allow unexpected mappings not to be fatal for RAM devices */
error_report_err(err);
@@ -1228,16 +1229,18 @@ static void vfio_listener_region_del(MemoryListener
*listener,
ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
if (ret) {
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx") = %d (%m)",
- container, iova, int128_get64(llsize), ret);
+ "0x%"HWADDR_PRIx") = %d (%s)",
+ container, iova, int128_get64(llsize), ret,
+ strerror(-ret));
}
iova += int128_get64(llsize);
}
ret = vfio_dma_unmap(container, iova, int128_get64(llsize), NULL);
if (ret) {
error_report("vfio_dma_unmap(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx") = %d (%m)",
- container, iova, int128_get64(llsize), ret);
+ "0x%"HWADDR_PRIx") = %d (%s)",
+ container, iova, int128_get64(llsize), ret,
+ strerror(-ret));
}
}
@@ -1384,9 +1387,9 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n,
IOMMUTLBEntry *iotlb)
translated_addr);
if (ret) {
error_report("vfio_iommu_map_dirty_notify(%p, 0x%"HWADDR_PRIx", "
- "0x%"HWADDR_PRIx") = %d (%m)",
- container, iova,
- iotlb->addr_mask + 1, ret);
+ "0x%"HWADDR_PRIx") = %d (%s)",
+ container, iova, iotlb->addr_mask + 1, ret,
+ strerror(-ret));
}
}
rcu_read_unlock();
- [PULL 00/17] VFIO updates for 8.0, Alex Williamson, 2023/03/07
- [PULL 01/17] vfio/common: Fix error reporting in vfio_get_dirty_bitmap(), Alex Williamson, 2023/03/07
- [PULL 02/17] vfio/common: Fix wrong %m usages,
Alex Williamson <=
- [PULL 03/17] vfio/common: Abort migration if dirty log start/stop/sync fails, Alex Williamson, 2023/03/07
- [PULL 04/17] vfio/common: Add VFIOBitmap and alloc function, Alex Williamson, 2023/03/07
- [PULL 05/17] vfio/common: Add helper to validate iova/end against hostwin, Alex Williamson, 2023/03/07
- [PULL 06/17] vfio/common: Use a single tracepoint for skipped sections, Alex Williamson, 2023/03/07
- [PULL 07/17] vfio/common: Consolidate skip/invalid section into helper, Alex Williamson, 2023/03/07
- [PULL 08/17] vfio/common: Add helper to consolidate iova/end calculation, Alex Williamson, 2023/03/07
- [PULL 09/17] vfio/common: Record DMA mapped IOVA ranges, Alex Williamson, 2023/03/07
- [PULL 10/17] vfio/common: Add device dirty page tracking start/stop, Alex Williamson, 2023/03/07
- [PULL 11/17] vfio/common: Extract code from vfio_get_dirty_bitmap() to new function, Alex Williamson, 2023/03/07
- [PULL 12/17] vfio/common: Add device dirty page bitmap sync, Alex Williamson, 2023/03/07