From: David Hildenbrand <david@redhat.com>
To: Steve Sistare <steven.sistare@oracle.com>, qemu-devel@nongnu.org
Cc: Marc-Andre Lureau <marcandre.lureau@redhat.com>,
Thanos Makatos <thanos.makatos@nutanix.com>,
"Daniel P. Berrange" <berrange@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>, Peter Xu <peterx@redhat.com>,
Cedric Le Goater <clg@redhat.com>,
Stefano Garzarella <sgarzare@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
Alex Williamson <alex.williamson@redhat.com>,
Philippe Mathieu-Daude <philmd@linaro.org>,
John Levon <john.levon@nutanix.com>
Subject: Re: [PATCH V4] vfio: return mr from vfio_get_xlat_addr
Date: Fri, 16 May 2025 20:58:34 +0200 [thread overview]
Message-ID: <e6b1e5ee-f8d3-40b5-a608-67469a8b599b@redhat.com> (raw)
In-Reply-To: <1747415599-131553-1-git-send-email-steven.sistare@oracle.com>
On 16.05.25 19:13, Steve Sistare wrote:
> Modify memory_get_xlat_addr and vfio_get_xlat_addr to return the memory
> region that the translated address is found in. This will be needed by
> CPR in a subsequent patch to map blocks using IOMMU_IOAS_MAP_FILE.
>
> Also return the xlat offset, so we can simplify the interface by removing
> the out parameters that can be trivially derived from mr and xlat.
>
> Lastly, rename the functions to to memory_translate_iotlb() and
> vfio_translate_iotlb().
>
> Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
> ---
> hw/vfio/listener.c | 33 ++++++++++++++++++++++-----------
> hw/virtio/vhost-vdpa.c | 9 +++++++--
> include/system/memory.h | 19 +++++++++----------
> system/memory.c | 32 +++++++-------------------------
> 4 files changed, 45 insertions(+), 48 deletions(-)
>
> diff --git a/hw/vfio/listener.c b/hw/vfio/listener.c
> index bfacb3d..a4931f1 100644
> --- a/hw/vfio/listener.c
> +++ b/hw/vfio/listener.c
> @@ -90,16 +90,17 @@ static bool vfio_listener_skipped_section(MemoryRegionSection *section)
> section->offset_within_address_space & (1ULL << 63);
> }
>
> -/* Called with rcu_read_lock held. */
> -static bool vfio_get_xlat_addr(IOMMUTLBEntry *iotlb, void **vaddr,
> - ram_addr_t *ram_addr, bool *read_only,
> - Error **errp)
> +/*
> + * Called with rcu_read_lock held.
> + * The returned MemoryRegion must not be accessed after calling rcu_read_unlock.
> + */
> +static MemoryRegion *vfio_translate_iotlb(IOMMUTLBEntry *iotlb, hwaddr *xlat_p,
> + Error **errp)
> {
> - bool ret, mr_has_discard_manager;
> + MemoryRegion *mr;
>
> - ret = memory_get_xlat_addr(iotlb, vaddr, ram_addr, read_only,
> - &mr_has_discard_manager, errp);
> - if (ret && mr_has_discard_manager) {
> + mr = memory_translate_iotlb(iotlb, xlat_p, errp);
> + if (!mr && memory_region_has_ram_discard_manager(mr)) {
Pretty sue this should be if (mr && ...)
otherwise we'd be dereferencing NULL :)
Apart from that, LGTM.
Thanks!
Acked-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2025-05-16 18:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 17:13 [PATCH V4] vfio: return mr from vfio_get_xlat_addr Steve Sistare
2025-05-16 18:58 ` David Hildenbrand [this message]
2025-05-16 19:26 ` Steven Sistare
2025-05-16 20:50 ` David Hildenbrand
2025-05-17 13:55 ` Steven Sistare
2025-05-19 8:28 ` David Hildenbrand
2025-05-19 13:21 ` Steven Sistare
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=e6b1e5ee-f8d3-40b5-a608-67469a8b599b@redhat.com \
--to=david@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=berrange@redhat.com \
--cc=clg@redhat.com \
--cc=john.levon@nutanix.com \
--cc=marcandre.lureau@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=sgarzare@redhat.com \
--cc=steven.sistare@oracle.com \
--cc=thanos.makatos@nutanix.com \
/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).