From: Eric Auger <eric.auger@redhat.com>
To: eric.auger.pro@gmail.com, eric.auger@redhat.com,
qemu-devel@nongnu.org, qemu-arm@nongnu.org,
peter.maydell@linaro.org, pbonzini@redhat.com,
alex.williamson@redhat.com, peterx@redhat.com
Cc: mst@redhat.com
Subject: [Qemu-devel] [PATCH v2 2/5] vfio/common: Handle memory_region_register_iommu_notifier() failure
Date: Thu, 19 Sep 2019 14:18:42 +0200 [thread overview]
Message-ID: <20190919121845.29520-3-eric.auger@redhat.com> (raw)
In-Reply-To: <20190919121845.29520-1-eric.auger@redhat.com>
Now memory_region_register_iommu_notifier() is allowed to fail,
let's handle the returned value in vfio_listener_region_add().
This will allow to remove the error handling (exit) in the
IOMMUs that implement a notify_flag_changed() that sometimes
cannot accept the MAP flag.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
hw/vfio/common.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 3e03c495d8..d57d72cfb9 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -630,9 +630,13 @@ static void vfio_listener_region_add(MemoryListener *listener,
section->offset_within_region,
int128_get64(llend),
iommu_idx);
- QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
- memory_region_register_iommu_notifier(section->mr, &giommu->n);
+ ret = memory_region_register_iommu_notifier(section->mr, &giommu->n);
+ if (ret) {
+ g_free(giommu);
+ goto fail;
+ }
+ QLIST_INSERT_HEAD(&container->giommu_list, giommu, giommu_next);
memory_region_iommu_replay(giommu->iommu, &giommu->n);
return;
--
2.20.1
next prev parent reply other threads:[~2019-09-19 12:24 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-19 12:18 [Qemu-devel] [PATCH v2 0/5] Allow memory_region_register_iommu_notifier() to fail Eric Auger
2019-09-19 12:18 ` [Qemu-devel] [PATCH v2 1/5] memory: allow " Eric Auger
2019-09-19 12:18 ` Eric Auger [this message]
2019-09-19 12:18 ` [Qemu-devel] [PATCH v2 3/5] exec: assert on memory_region_register_iommu_notifier() failure Eric Auger
2019-09-19 12:18 ` [Qemu-devel] [PATCH v2 4/5] vhost: " Eric Auger
2019-09-19 12:18 ` [Qemu-devel] [PATCH v2 5/5] amd_iommu: Let amdvi_iommu_notify_flag_changed() fail Eric Auger
2019-09-20 6:16 ` [PATCH v2 0/5] Allow memory_region_register_iommu_notifier() to fail Peter Xu
2019-09-20 7:05 ` Auger Eric
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190919121845.29520-3-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).