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, alex.williamson@redhat.com,
jean-philippe@linaro.org, mst@redhat.com, pbonzini@redhat.com
Cc: peter.maydell@linaro.org, peterx@redhat.com, david@redhat.com,
philmd@linaro.org
Subject: Re: [PATCH v2 04/12] virtio-iommu: Rename reserved_regions into prop_resv_regions
Date: Wed, 13 Sep 2023 15:01:48 +0200 [thread overview]
Message-ID: <b5ad656f-9b8e-ab39-7ee1-d844f464911b@redhat.com> (raw)
In-Reply-To: <20230913080423.523953-5-eric.auger@redhat.com>
On 9/13/23 10:01, Eric Auger wrote:
> Rename VirtIOIOMMU (nb_)reserved_regions fields with the "prop_" prefix
> to highlight those fields are set through a property, at machine level.
> They are IOMMU wide.
>
> A subsequent patch will introduce per IOMMUDevice reserved regions
> that will include both those IOMMU wide property reserved
> regions plus, sometimes, host reserved regions, if the device is
> backed by a host device protected by a physical IOMMU. Also change
> nb_ prefix by nr_.
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>
> ---
> include/hw/virtio/virtio-iommu.h | 4 ++--
> hw/virtio/virtio-iommu-pci.c | 8 ++++----
> hw/virtio/virtio-iommu.c | 15 ++++++++-------
> 3 files changed, 14 insertions(+), 13 deletions(-)
>
> diff --git a/include/hw/virtio/virtio-iommu.h b/include/hw/virtio/virtio-iommu.h
> index a93fc5383e..eea4564782 100644
> --- a/include/hw/virtio/virtio-iommu.h
> +++ b/include/hw/virtio/virtio-iommu.h
> @@ -55,8 +55,8 @@ struct VirtIOIOMMU {
> GHashTable *as_by_busptr;
> IOMMUPciBus *iommu_pcibus_by_bus_num[PCI_BUS_MAX];
> PCIBus *primary_bus;
> - ReservedRegion *reserved_regions;
> - uint32_t nb_reserved_regions;
> + ReservedRegion *prop_resv_regions;
> + uint32_t nr_prop_resv_regions;
> GTree *domains;
> QemuRecMutex mutex;
> GTree *endpoints;
> diff --git a/hw/virtio/virtio-iommu-pci.c b/hw/virtio/virtio-iommu-pci.c
> index 7ef2f9dcdb..9459fbf6ed 100644
> --- a/hw/virtio/virtio-iommu-pci.c
> +++ b/hw/virtio/virtio-iommu-pci.c
> @@ -37,7 +37,7 @@ struct VirtIOIOMMUPCI {
> static Property virtio_iommu_pci_properties[] = {
> DEFINE_PROP_UINT32("class", VirtIOPCIProxy, class_code, 0),
> DEFINE_PROP_ARRAY("reserved-regions", VirtIOIOMMUPCI,
> - vdev.nb_reserved_regions, vdev.reserved_regions,
> + vdev.nr_prop_resv_regions, vdev.prop_resv_regions,
> qdev_prop_reserved_region, ReservedRegion),
> DEFINE_PROP_END_OF_LIST(),
> };
> @@ -54,9 +54,9 @@ static void virtio_iommu_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp)
> "for the virtio-iommu-pci device");
> return;
> }
> - for (int i = 0; i < s->nb_reserved_regions; i++) {
> - if (s->reserved_regions[i].type != VIRTIO_IOMMU_RESV_MEM_T_RESERVED &&
> - s->reserved_regions[i].type != VIRTIO_IOMMU_RESV_MEM_T_MSI) {
> + for (int i = 0; i < s->nr_prop_resv_regions; i++) {
> + if (s->prop_resv_regions[i].type != VIRTIO_IOMMU_RESV_MEM_T_RESERVED &&
> + s->prop_resv_regions[i].type != VIRTIO_IOMMU_RESV_MEM_T_MSI) {
> error_setg(errp, "reserved region %d has an invalid type", i);
> error_append_hint(errp, "Valid values are 0 and 1\n");
> return;
> diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
> index e5e46e1b55..979cdb5648 100644
> --- a/hw/virtio/virtio-iommu.c
> +++ b/hw/virtio/virtio-iommu.c
> @@ -631,22 +631,23 @@ static ssize_t virtio_iommu_fill_resv_mem_prop(VirtIOIOMMU *s, uint32_t ep,
> size_t size = sizeof(prop), length = size - sizeof(prop.head), total;
> int i;
>
> - total = size * s->nb_reserved_regions;
> + total = size * s->nr_prop_resv_regions;
>
> if (total > free) {
> return -ENOSPC;
> }
>
> - for (i = 0; i < s->nb_reserved_regions; i++) {
> - unsigned subtype = s->reserved_regions[i].type;
> + for (i = 0; i < s->nr_prop_resv_regions; i++) {
> + unsigned subtype = s->prop_resv_regions[i].type;
> + Range *range = &s->prop_resv_regions[i].range;
>
> assert(subtype == VIRTIO_IOMMU_RESV_MEM_T_RESERVED ||
> subtype == VIRTIO_IOMMU_RESV_MEM_T_MSI);
> prop.head.type = cpu_to_le16(VIRTIO_IOMMU_PROBE_T_RESV_MEM);
> prop.head.length = cpu_to_le16(length);
> prop.subtype = subtype;
> - prop.start = cpu_to_le64(range_lob(&s->reserved_regions[i].range));
> - prop.end = cpu_to_le64(range_upb(&s->reserved_regions[i].range));
> + prop.start = cpu_to_le64(range_lob(range));
> + prop.end = cpu_to_le64(range_upb(range));
>
> memcpy(buf, &prop, size);
>
> @@ -894,8 +895,8 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
> goto unlock;
> }
>
> - for (i = 0; i < s->nb_reserved_regions; i++) {
> - ReservedRegion *reg = &s->reserved_regions[i];
> + for (i = 0; i < s->nr_prop_resv_regions; i++) {
> + ReservedRegion *reg = &s->prop_resv_regions[i];
>
> if (range_contains(®->range, addr)) {
> switch (reg->type) {
next prev parent reply other threads:[~2023-09-13 13:02 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-13 8:01 [PATCH v2 00/12] VIRTIO-IOMMU/VFIO: Don't assume 64b IOVA space Eric Auger
2023-09-13 8:01 ` [PATCH v2 01/12] memory: Let ReservedRegion use Range Eric Auger
2023-09-13 12:43 ` Cédric Le Goater
2023-09-13 8:01 ` [PATCH v2 02/12] memory: Introduce memory_region_iommu_set_iova_ranges Eric Auger
2023-09-13 12:43 ` Cédric Le Goater
2023-09-20 7:40 ` Eric Auger
2023-09-13 8:01 ` [PATCH v2 03/12] vfio: Collect container iova range info Eric Auger
2023-09-13 12:55 ` Cédric Le Goater
2023-09-20 7:38 ` Eric Auger
2023-09-19 15:44 ` Alex Williamson
2023-09-20 7:15 ` Eric Auger
2023-09-20 7:39 ` Eric Auger
2023-09-13 8:01 ` [PATCH v2 04/12] virtio-iommu: Rename reserved_regions into prop_resv_regions Eric Auger
2023-09-13 13:01 ` Cédric Le Goater [this message]
2023-09-13 8:01 ` [PATCH v2 05/12] virtio-iommu: Introduce per IOMMUDevice reserved regions Eric Auger
2023-09-29 15:52 ` Jean-Philippe Brucker
2023-10-03 15:48 ` Eric Auger
2023-09-13 8:01 ` [PATCH v2 06/12] range: Introduce range_inverse_array() Eric Auger
2023-09-19 16:29 ` Alex Williamson
2023-09-20 7:24 ` Eric Auger
2023-09-13 8:01 ` [PATCH v2 07/12] virtio-iommu: Implement set_iova_ranges() callback Eric Auger
2023-09-29 16:15 ` Jean-Philippe Brucker
2023-10-10 14:36 ` Eric Auger
2023-09-13 8:01 ` [PATCH v2 08/12] range: Make range_compare() public Eric Auger
2023-09-13 8:01 ` [PATCH v2 09/12] util/reserved-region: Add new ReservedRegion helpers Eric Auger
2023-09-29 16:16 ` Jean-Philippe Brucker
2023-10-10 13:51 ` Eric Auger
2023-09-13 8:01 ` [PATCH v2 10/12] virtio-iommu: Consolidate host reserved regions and property set ones Eric Auger
2023-09-13 8:01 ` [PATCH v2 11/12] test: Add some tests for range and resv-mem helpers Eric Auger
2023-09-13 8:01 ` [PATCH v2 12/12] vfio: Remove 64-bit IOVA address space assumption Eric Auger
2023-09-19 17:22 ` Alex Williamson
2023-09-20 7:28 ` Eric Auger
2023-09-26 20:00 ` Eric Auger
2023-10-10 17:16 ` Eric Auger
2023-09-20 20:02 ` Alex Williamson
2023-10-11 17:32 ` Eric Auger
2023-09-26 8:06 ` [PATCH v2 00/12] VIRTIO-IOMMU/VFIO: Don't assume 64b IOVA space YangHang Liu
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=b5ad656f-9b8e-ab39-7ee1-d844f464911b@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=david@redhat.com \
--cc=eric.auger.pro@gmail.com \
--cc=eric.auger@redhat.com \
--cc=jean-philippe@linaro.org \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=philmd@linaro.org \
--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).