From: "Cédric Le Goater" <clg@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Alex Williamson" <alex.williamson@redhat.com>,
"Eric Auger" <eric.auger@redhat.com>,
"Peter Xu" <peterx@redhat.com>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Cédric Le Goater" <clg@redhat.com>
Subject: [PULL 02/22] memory: Introduce memory_region_iommu_set_iova_ranges
Date: Mon, 6 Nov 2023 15:36:33 +0100 [thread overview]
Message-ID: <20231106143653.302391-3-clg@redhat.com> (raw)
In-Reply-To: <20231106143653.302391-1-clg@redhat.com>
From: Eric Auger <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>
[ clg: fixes in memory_region_iommu_set_iova_ranges() and
iommu_set_iova_ranges() documentation ]
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
include/exec/memory.h | 32 ++++++++++++++++++++++++++++++++
system/memory.c | 13 +++++++++++++
2 files changed, 45 insertions(+)
diff --git a/include/exec/memory.h b/include/exec/memory.h
index d94314d6fc3b3de6ef1fa7c4f70837728a8309fb..831f7c996d9da49cdf9884fdeffa32959865cb07 100644
--- a/include/exec/memory.h
+++ b/include/exec/memory.h
@@ -527,6 +527,26 @@ 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.
+ *
+ * @iommu: the IOMMUMemoryRegion
+ *
+ * @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 +1876,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: 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 4928f2525de12afbc55231d3b230f239dedbbf07..304fa843ea1206c9f4946ec707dc87df4fa65626 100644
--- a/system/memory.c
+++ b/system/memory.c
@@ -1921,6 +1921,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-11-06 14:39 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-06 14:36 [PULL 00/22] vfio queue Cédric Le Goater
2023-11-06 14:36 ` [PULL 01/22] memory: Let ReservedRegion use Range Cédric Le Goater
2023-11-06 14:36 ` Cédric Le Goater [this message]
2023-11-06 14:36 ` [PULL 03/22] vfio: Collect container iova range info Cédric Le Goater
2023-11-06 14:36 ` [PULL 04/22] virtio-iommu: Rename reserved_regions into prop_resv_regions Cédric Le Goater
2023-11-06 14:36 ` [PULL 05/22] range: Make range_compare() public Cédric Le Goater
2023-11-06 14:36 ` [PULL 06/22] util/reserved-region: Add new ReservedRegion helpers Cédric Le Goater
2023-11-06 14:36 ` [PULL 07/22] virtio-iommu: Introduce per IOMMUDevice reserved regions Cédric Le Goater
2023-11-06 14:36 ` [PULL 08/22] range: Introduce range_inverse_array() Cédric Le Goater
2023-11-06 14:36 ` [PULL 09/22] virtio-iommu: Record whether a probe request has been issued Cédric Le Goater
2023-11-09 15:08 ` Peter Maydell
2023-11-09 16:56 ` Eric Auger
2023-11-06 14:36 ` [PULL 10/22] virtio-iommu: Implement set_iova_ranges() callback Cédric Le Goater
2023-11-06 14:36 ` [PULL 11/22] virtio-iommu: Consolidate host reserved regions and property set ones Cédric Le Goater
2023-11-06 14:36 ` [PULL 12/22] test: Add some tests for range and resv-mem helpers Cédric Le Goater
2023-11-06 14:36 ` [PULL 13/22] hw/pci: modify pci_setup_iommu() to set PCIIOMMUOps Cédric Le Goater
2023-11-06 14:36 ` [PULL 14/22] util/uuid: Add UUID_STR_LEN definition Cédric Le Goater
2023-11-06 14:36 ` [PULL 15/22] vfio/pci: Fix buffer overrun when writing the VF token Cédric Le Goater
2023-11-06 14:36 ` [PULL 16/22] util/uuid: Remove UUID_FMT_LEN Cédric Le Goater
2023-11-06 14:36 ` [PULL 17/22] util/uuid: Define UUID_STR_LEN from UUID_NONE string Cédric Le Goater
2023-11-06 14:36 ` [PULL 18/22] vfio/container: Move IBM EEH related functions into spapr_pci_vfio.c Cédric Le Goater
2023-11-06 14:36 ` [PULL 19/22] vfio/container: Move vfio_container_add/del_section_window into spapr.c Cédric Le Goater
2023-11-06 14:36 ` [PULL 20/22] vfio/container: Move spapr specific init/deinit " Cédric Le Goater
2023-11-06 14:36 ` [PULL 21/22] vfio/spapr: Make vfio_spapr_create/remove_window static Cédric Le Goater
2023-11-06 14:36 ` [PULL 22/22] vfio/common: Move vfio_host_win_add/del into spapr.c Cédric Le Goater
2023-11-07 3:02 ` [PULL 00/22] vfio queue Stefan Hajnoczi
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=20231106143653.302391-3-clg@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=eric.auger@redhat.com \
--cc=mst@redhat.com \
--cc=peterx@redhat.com \
--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).