- kvm-meson-configure-add-valgrind-option-en-dis-able-valg.patch [RHEL-88153] - kvm-distro-add-an-explicit-valgrind-devel-build-dep.patch [RHEL-88153] - kvm-hw-i386-Fix-machine-type-compatibility.patch [RHEL-91307] - kvm-vfio-helpers-Refactor-vfio_region_mmap-error-handlin.patch [RHEL-88533] - kvm-vfio-helpers-Align-mmaps.patch [RHEL-88533] - Resolves: RHEL-88153 ([s390x] valgrind not working with qemu-kvm for non-x86 builds) - Resolves: RHEL-91307 (Fix x86 M-type compats) - Resolves: RHEL-88533 (Improve VFIO mmapping performance with huge pfnmaps)
94 lines
3.1 KiB
Diff
94 lines
3.1 KiB
Diff
From f3af9e4476546c0bc814f78d5dd1047ec60768e8 Mon Sep 17 00:00:00 2001
|
|
From: Alex Williamson <alex.williamson@redhat.com>
|
|
Date: Tue, 22 Oct 2024 14:08:28 -0600
|
|
Subject: [PATCH 4/5] vfio/helpers: Refactor vfio_region_mmap() error handling
|
|
MIME-Version: 1.0
|
|
Content-Type: text/plain; charset=UTF-8
|
|
Content-Transfer-Encoding: 8bit
|
|
|
|
RH-Author: Donald Dutile <None>
|
|
RH-MergeRequest: 366: Improve VFIO mmapping performance with huge pfnmaps
|
|
RH-Jira: RHEL-88533
|
|
RH-Acked-by: Cédric Le Goater <clg@redhat.com>
|
|
RH-Acked-by: Alex Williamson <None>
|
|
RH-Commit: [1/2] b83c7dbc6a6037b465a141961ae810e5551fad30 (ddutile/qemu-kvm)
|
|
|
|
Move error handling code to the end of the function so that it can more
|
|
easily be shared by new mmap failure conditions. No functional change
|
|
intended.
|
|
|
|
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
|
|
Reviewed-by: Peter Xu <peterx@redhat.com>
|
|
Reviewed-by: Cédric Le Goater <clg@redhat.com>
|
|
(cherry picked from commit 49915c0d2c9868e6f25e52e4d839943611b69e98)
|
|
|
|
Jira: https://issues.redhat.com/browse/RHEL-88533
|
|
|
|
Signed-off-by: Donald Dutile <ddutile@redhat.com>
|
|
---
|
|
hw/vfio/helpers.c | 34 +++++++++++++++++-----------------
|
|
1 file changed, 17 insertions(+), 17 deletions(-)
|
|
|
|
diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c
|
|
index ea15c79db0..b9e606e364 100644
|
|
--- a/hw/vfio/helpers.c
|
|
+++ b/hw/vfio/helpers.c
|
|
@@ -395,7 +395,7 @@ static void vfio_subregion_unmap(VFIORegion *region, int index)
|
|
|
|
int vfio_region_mmap(VFIORegion *region)
|
|
{
|
|
- int i, prot = 0;
|
|
+ int i, ret, prot = 0;
|
|
char *name;
|
|
|
|
if (!region->mem) {
|
|
@@ -411,22 +411,8 @@ int vfio_region_mmap(VFIORegion *region)
|
|
region->fd_offset +
|
|
region->mmaps[i].offset);
|
|
if (region->mmaps[i].mmap == MAP_FAILED) {
|
|
- int ret = -errno;
|
|
-
|
|
- trace_vfio_region_mmap_fault(memory_region_name(region->mem), i,
|
|
- region->fd_offset +
|
|
- region->mmaps[i].offset,
|
|
- region->fd_offset +
|
|
- region->mmaps[i].offset +
|
|
- region->mmaps[i].size - 1, ret);
|
|
-
|
|
- region->mmaps[i].mmap = NULL;
|
|
-
|
|
- for (i--; i >= 0; i--) {
|
|
- vfio_subregion_unmap(region, i);
|
|
- }
|
|
-
|
|
- return ret;
|
|
+ ret = -errno;
|
|
+ goto no_mmap;
|
|
}
|
|
|
|
name = g_strdup_printf("%s mmaps[%d]",
|
|
@@ -446,6 +432,20 @@ int vfio_region_mmap(VFIORegion *region)
|
|
}
|
|
|
|
return 0;
|
|
+
|
|
+no_mmap:
|
|
+ trace_vfio_region_mmap_fault(memory_region_name(region->mem), i,
|
|
+ region->fd_offset + region->mmaps[i].offset,
|
|
+ region->fd_offset + region->mmaps[i].offset +
|
|
+ region->mmaps[i].size - 1, ret);
|
|
+
|
|
+ region->mmaps[i].mmap = NULL;
|
|
+
|
|
+ for (i--; i >= 0; i--) {
|
|
+ vfio_subregion_unmap(region, i);
|
|
+ }
|
|
+
|
|
+ return ret;
|
|
}
|
|
|
|
void vfio_region_unmap(VFIORegion *region)
|
|
--
|
|
2.48.1
|
|
|