On 21/5/25 22:55, John Levon wrote:
Pass through the MemoryRegion to DMA operation handlers of vfio
containers. The vfio-user container will need this later, to translate
the vaddr into an offset for the dma map vfio-user message; CPR will
also will need this.

"will ... will" typo.


Originally-by: John Johnson <[email protected]>
Signed-off-by: Jagannathan Raman <[email protected]>
Signed-off-by: Elena Ufimtseva <[email protected]>
Signed-off-by: John Levon <[email protected]>
---
  include/hw/vfio/vfio-container-base.h | 9 +++++----
  hw/vfio/container-base.c              | 4 ++--
  hw/vfio/container.c                   | 3 ++-
  hw/vfio/iommufd.c                     | 3 ++-
  hw/vfio/listener.c                    | 6 +++---
  5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/include/hw/vfio/vfio-container-base.h 
b/include/hw/vfio/vfio-container-base.h
index f9e561cb08..3feb773e5f 100644
--- a/include/hw/vfio/vfio-container-base.h
+++ b/include/hw/vfio/vfio-container-base.h
@@ -78,7 +78,7 @@ void vfio_address_space_insert(VFIOAddressSpace *space,
int vfio_container_dma_map(VFIOContainerBase *bcontainer,
                             hwaddr iova, ram_addr_t size,
-                           void *vaddr, bool readonly);
+                           void *vaddr, bool readonly, MemoryRegion *mr);
  int vfio_container_dma_unmap(VFIOContainerBase *bcontainer,
                               hwaddr iova, ram_addr_t size,
                               IOMMUTLBEntry *iotlb, bool unmap_all);
@@ -151,20 +151,21 @@ struct VFIOIOMMUClass {
      /**
       * @dma_map
       *
-     * Map an address range into the container.
+     * Map an address range into the container. Note that the memory region is
+     * referenced within an RCU read lock region across this call.
       *
       * @bcontainer: #VFIOContainerBase to use
       * @iova: start address to map
       * @size: size of the range to map
       * @vaddr: process virtual address of mapping
       * @readonly: true if mapping should be readonly
+     * @mr: the memory region for this mapping
       *
       * Returns 0 to indicate success and -errno otherwise.
       */
      int (*dma_map)(const VFIOContainerBase *bcontainer,
                     hwaddr iova, ram_addr_t size,
-                   void *vaddr, bool readonly);
-
+                   void *vaddr, bool readonly, MemoryRegion *mr);

Since the memory region shouldn't be altered, preferably
"const MemoryRegion *mr" (here and in vfio_container_dma_map).

Reviewed-by: Philippe Mathieu-Daudé <[email protected]>


Reply via email to