From: "Cédric Le Goater" <clg@redhat.com>
To: Eric Auger <eric.auger@redhat.com>,
eric.auger.pro@gmail.com, qemu-devel@nongnu.org,
qemu-arm@nongnu.org, mst@redhat.com, jean-philippe@linaro.org,
peter.maydell@linaro.org, yanghliu@redhat.com,
zhenzhong.duan@intel.com
Cc: alex.williamson@redhat.com, jasowang@redhat.com,
pbonzini@redhat.com, berrange@redhat.com
Subject: Re: [PATCH v4 3/8] HostIOMMUDevice: Introduce get_iova_ranges callback
Date: Mon, 17 Jun 2024 15:23:54 +0200 [thread overview]
Message-ID: <8b8ac158-ffc4-4d2e-aaf5-2893f1b680f7@redhat.com> (raw)
In-Reply-To: <20240614095402.904691-4-eric.auger@redhat.com>
On 6/14/24 11:52 AM, Eric Auger wrote:
> Introduce a new HostIOMMUDevice callback that allows to
> retrieve the usable IOVA ranges.
>
> Implement this callback in the legacy VFIO and IOMMUFD VFIO
> host iommu devices. This relies on the VFIODevice agent's
> base container iova_ranges resource.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>
> ---
>
> v2 -> v3:
> - add g_assert(vdev)
> ---
> include/sysemu/host_iommu_device.h | 8 ++++++++
> hw/vfio/container.c | 16 ++++++++++++++++
> hw/vfio/iommufd.c | 16 ++++++++++++++++
> 3 files changed, 40 insertions(+)
>
> diff --git a/include/sysemu/host_iommu_device.h b/include/sysemu/host_iommu_device.h
> index 3e5f058e7b..40e0fa13ef 100644
> --- a/include/sysemu/host_iommu_device.h
> +++ b/include/sysemu/host_iommu_device.h
> @@ -80,6 +80,14 @@ struct HostIOMMUDeviceClass {
> * i.e., HOST_IOMMU_DEVICE_CAP_AW_BITS.
> */
> int (*get_cap)(HostIOMMUDevice *hiod, int cap, Error **errp);
> + /**
> + * @get_iova_ranges: Return the list of usable iova_ranges along with
> + * @hiod Host IOMMU device
> + *
> + * @hiod: handle to the host IOMMU device
> + * @errp: error handle
> + */
> + GList* (*get_iova_ranges)(HostIOMMUDevice *hiod, Error **errp);
> };
>
> /*
> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
> index b728b978a2..c48749c089 100644
> --- a/hw/vfio/container.c
> +++ b/hw/vfio/container.c
> @@ -1164,12 +1164,28 @@ static int hiod_legacy_vfio_get_cap(HostIOMMUDevice *hiod, int cap,
> }
> }
>
> +static GList *
> +hiod_legacy_vfio_get_iova_ranges(HostIOMMUDevice *hiod, Error **errp)
> +{
> + VFIODevice *vdev = hiod->agent;
> + GList *l = NULL;
> +
> + g_assert(vdev);
> +
> + if (vdev->bcontainer) {
> + l = g_list_copy(vdev->bcontainer->iova_ranges);
> + }
> +
> + return l;
> +}
> +
> static void hiod_legacy_vfio_class_init(ObjectClass *oc, void *data)
> {
> HostIOMMUDeviceClass *hioc = HOST_IOMMU_DEVICE_CLASS(oc);
>
> hioc->realize = hiod_legacy_vfio_realize;
> hioc->get_cap = hiod_legacy_vfio_get_cap;
> + hioc->get_iova_ranges = hiod_legacy_vfio_get_iova_ranges;
> };
>
> static const TypeInfo types[] = {
> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
> index dbdae1adbb..e502081c2a 100644
> --- a/hw/vfio/iommufd.c
> +++ b/hw/vfio/iommufd.c
> @@ -645,11 +645,27 @@ static bool hiod_iommufd_vfio_realize(HostIOMMUDevice *hiod, void *opaque,
> return true;
> }
>
> +static GList *
> +hiod_iommufd_vfio_get_iova_ranges(HostIOMMUDevice *hiod, Error **errp)
> +{
> + VFIODevice *vdev = hiod->agent;
> + GList *l = NULL;
> +
> + g_assert(vdev);
> +
> + if (vdev->bcontainer) {
> + l = g_list_copy(vdev->bcontainer->iova_ranges);
> + }
> +
> + return l;
> +}
May be introduce a common vfio_container_get_iova_ranges() to be called from
the get_iova_ranges() handlers ?
Thanks,
C.
> static void hiod_iommufd_vfio_class_init(ObjectClass *oc, void *data)
> {
> HostIOMMUDeviceClass *hiodc = HOST_IOMMU_DEVICE_CLASS(oc);
>
> hiodc->realize = hiod_iommufd_vfio_realize;
> + hiodc->get_iova_ranges = hiod_iommufd_vfio_get_iova_ranges;
> };
>
> static const TypeInfo types[] = {
next prev parent reply other threads:[~2024-06-17 13:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-14 9:52 [PATCH v4 0/8] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices Eric Auger
2024-06-14 9:52 ` [PATCH v4 1/8] HostIOMMUDevice: Store the VFIO/VDPA agent Eric Auger
2024-06-14 9:52 ` [PATCH v4 2/8] virtio-iommu: Implement set|unset]_iommu_device() callbacks Eric Auger
2024-06-14 9:52 ` [PATCH v4 3/8] HostIOMMUDevice: Introduce get_iova_ranges callback Eric Auger
2024-06-17 13:23 ` Cédric Le Goater [this message]
2024-06-14 9:52 ` [PATCH v4 4/8] HostIOMMUDevice: Store the aliased bus and devfn Eric Auger
2024-06-14 9:52 ` [PATCH v4 5/8] virtio-iommu: Compute host reserved regions Eric Auger
2024-06-14 9:52 ` [PATCH v4 6/8] virtio-iommu: Remove the implementation of iommu_set_iova_range Eric Auger
2024-06-14 9:52 ` [PATCH v4 7/8] hw/vfio: Remove memory_region_iommu_set_iova_ranges() call Eric Auger
2024-06-14 9:52 ` [PATCH v4 8/8] memory: Remove IOMMU MR iommu_set_iova_range API Eric Auger
2024-06-17 10:28 ` [PATCH v4 0/8] VIRTIO-IOMMU/VFIO: Fix host iommu geometry handling for hotplugged devices Duan, Zhenzhong
2024-06-24 10:29 ` Michael S. Tsirkin
2024-06-24 21:17 ` Cédric Le Goater
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=8b8ac158-ffc4-4d2e-aaf5-2893f1b680f7@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=berrange@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=eric.auger@redhat.com \
--cc=jasowang@redhat.com \
--cc=jean-philippe@linaro.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=yanghliu@redhat.com \
--cc=zhenzhong.duan@intel.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).