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,
alex.williamson@redhat.com, clg@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, zhenzhong.duan@intel.com, yi.l.liu@intel.com,
yanghliu@redhat.com
Subject: [PATCH v4 02/12] memory: Introduce memory_region_iommu_set_iova_ranges
Date: Thu, 19 Oct 2023 15:45:08 +0200 [thread overview]
Message-ID: <20231019134651.842175-3-eric.auger@redhat.com> (raw)
In-Reply-To: <20231019134651.842175-1-eric.auger@redhat.com>
This helper will allow to convey information about valid
IOVA ranges to virtual IOMMUS.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Acked-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
---
v2 -> v3:
- Pass a Glist instead
- Added a comment on memory_region_iommu_set_iova_ranges
- Removed R-b due to that change
---
include/exec/memory.h | 30 ++++++++++++++++++++++++++++++
system/memory.c | 13 +++++++++++++
2 files changed, 43 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index a089ab4555..1b2791145e 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -527,6 +527,24 @@ struct IOMMUMemoryRegionClass {
int (*iommu_set_page_size_mask)(IOMMUMemoryRegion *iommu,
uint64_t page_size_mask,
Error **errp);
+ /**
+ * @iommu_set_iova_ranges:
+ *
+ * Propagate information about the usable IOVA ranges for a given IOMMU
+ * memory region. Used for example to propagate host physical device
+ * reserved memory region constraints to the virtual IOMMU.
+ *
+ * Optional method: if this method is not provided, then the default IOVA
+ * aperture is used.
+ *
+ * @iova_ranges: list of ordered IOVA ranges (at least one range)
+ *
+ * Returns 0 on success, or a negative error. In case of failure, the error
+ * object must be created.
+ */
+ int (*iommu_set_iova_ranges)(IOMMUMemoryRegion *iommu,
+ GList *iova_ranges,
+ Error **errp);
};
typedef struct RamDiscardListener RamDiscardListener;
@@ -1856,6 +1874,18 @@ int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr,
uint64_t page_size_mask,
Error **errp);
+/**
+ * memory_region_iommu_set_iova_ranges - Set the usable IOVA ranges
+ * for a given IOMMU MR region
+ *
+ * @iommu_mr: IOMMU memory region
+ * @iova_ranges: list of ordered IOVA ranges (at least one range)
+ * @errp: pointer to Error*, to store an error if it happens.
+ */
+int memory_region_iommu_set_iova_ranges(IOMMUMemoryRegion *iommu,
+ GList *iova_ranges,
+ Error **errp);
+
/**
* memory_region_name: get a memory region's name
*
diff --git a/system/memory.c b/system/memory.c
index a800fbc9e5..1034f136f0 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1916,6 +1916,19 @@ int memory_region_iommu_set_page_size_mask(IOMMUMemoryRegion *iommu_mr,
return ret;
}
+int memory_region_iommu_set_iova_ranges(IOMMUMemoryRegion *iommu_mr,
+ GList *iova_ranges,
+ Error **errp)
+{
+ IOMMUMemoryRegionClass *imrc = IOMMU_MEMORY_REGION_GET_CLASS(iommu_mr);
+ int ret = 0;
+
+ if (imrc->iommu_set_iova_ranges) {
+ ret = imrc->iommu_set_iova_ranges(iommu_mr, iova_ranges, errp);
+ }
+ return ret;
+}
+
int memory_region_register_iommu_notifier(MemoryRegion *mr,
IOMMUNotifier *n, Error **errp)
{
--
2.41.0
next prev parent reply other threads:[~2023-10-19 13:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-19 13:45 [PATCH v4 00/12] VIRTIO-IOMMU/VFIO: Don't assume 64b IOVA space Eric Auger
2023-10-19 13:45 ` [PATCH v4 01/12] memory: Let ReservedRegion use Range Eric Auger
2023-10-19 13:45 ` Eric Auger [this message]
2023-10-19 13:45 ` [PATCH v4 03/12] vfio: Collect container iova range info Eric Auger
2023-10-19 13:45 ` [PATCH v4 04/12] virtio-iommu: Rename reserved_regions into prop_resv_regions Eric Auger
2023-10-19 13:45 ` [PATCH v4 05/12] range: Make range_compare() public Eric Auger
2023-10-19 13:45 ` [PATCH v4 06/12] util/reserved-region: Add new ReservedRegion helpers Eric Auger
2023-10-19 13:45 ` [PATCH v4 07/12] virtio-iommu: Introduce per IOMMUDevice reserved regions Eric Auger
2023-10-19 13:45 ` [PATCH v4 08/12] range: Introduce range_inverse_array() Eric Auger
2023-10-19 13:45 ` [PATCH v4 09/12] virtio-iommu: Record whether a probe request has been issued Eric Auger
2023-10-19 13:45 ` [PATCH v4 10/12] virtio-iommu: Implement set_iova_ranges() callback Eric Auger
2023-10-19 13:45 ` [PATCH v4 11/12] virtio-iommu: Consolidate host reserved regions and property set ones Eric Auger
2023-10-19 13:45 ` [PATCH v4 12/12] test: Add some tests for range and resv-mem helpers Eric Auger
2023-10-20 12:17 ` [PATCH v4 00/12] VIRTIO-IOMMU/VFIO: Don't assume 64b IOVA space 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=20231019134651.842175-3-eric.auger@redhat.com \
--to=eric.auger@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=clg@redhat.com \
--cc=david@redhat.com \
--cc=eric.auger.pro@gmail.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 \
--cc=yanghliu@redhat.com \
--cc=yi.l.liu@intel.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).