[PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map

Philippe Mathieu-Daudé posted 3 patches 1 month, 2 weeks ago
Maintainers: Yi Liu <yi.l.liu@intel.com>, Eric Auger <eric.auger@redhat.com>, Zhenzhong Duan <zhenzhong.duan@intel.com>, John Levon <john.levon@nutanix.com>, Thanos Makatos <thanos.makatos@nutanix.com>, "Cédric Le Goater" <clg@redhat.com>, Alex Williamson <alex.williamson@redhat.com>
There is a newer version of this series
[PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
The 'ram_addr_t' type is described as:

  a QEMU internal address space that maps guest RAM physical
  addresses into an intermediate address space that can map
  to host virtual address spaces.

This doesn't represent well an IOVA mapping size. Simply use
the uint64_t type.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 include/hw/vfio/vfio-container.h | 10 +++++-----
 hw/vfio-user/container.c         |  4 ++--
 hw/vfio/container-legacy.c       |  8 ++++----
 hw/vfio/container.c              |  5 ++---
 hw/vfio/iommufd.c                |  6 +++---
 5 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/include/hw/vfio/vfio-container.h b/include/hw/vfio/vfio-container.h
index 093c360f0ee..c4b58d664b7 100644
--- a/include/hw/vfio/vfio-container.h
+++ b/include/hw/vfio/vfio-container.h
@@ -81,10 +81,10 @@ void vfio_address_space_insert(VFIOAddressSpace *space,
                                VFIOContainer *bcontainer);
 
 int vfio_container_dma_map(VFIOContainer *bcontainer,
-                           hwaddr iova, ram_addr_t size,
+                           hwaddr iova, uint64_t size,
                            void *vaddr, bool readonly, MemoryRegion *mr);
 int vfio_container_dma_unmap(VFIOContainer *bcontainer,
-                             hwaddr iova, ram_addr_t size,
+                             hwaddr iova, uint64_t size,
                              IOMMUTLBEntry *iotlb, bool unmap_all);
 bool vfio_container_add_section_window(VFIOContainer *bcontainer,
                                        MemoryRegionSection *section,
@@ -167,7 +167,7 @@ struct VFIOIOMMUClass {
      * Returns 0 to indicate success and -errno otherwise.
      */
     int (*dma_map)(const VFIOContainer *bcontainer,
-                   hwaddr iova, ram_addr_t size,
+                   hwaddr iova, uint64_t size,
                    void *vaddr, bool readonly, MemoryRegion *mr);
     /**
      * @dma_map_file
@@ -182,7 +182,7 @@ struct VFIOIOMMUClass {
      * @readonly: map read only if true
      */
     int (*dma_map_file)(const VFIOContainer *bcontainer,
-                        hwaddr iova, ram_addr_t size,
+                        hwaddr iova, uint64_t size,
                         int fd, unsigned long start, bool readonly);
     /**
      * @dma_unmap
@@ -198,7 +198,7 @@ struct VFIOIOMMUClass {
      * Returns 0 to indicate success and -errno otherwise.
      */
     int (*dma_unmap)(const VFIOContainer *bcontainer,
-                     hwaddr iova, ram_addr_t size,
+                     hwaddr iova, uint64_t size,
                      IOMMUTLBEntry *iotlb, bool unmap_all);
 
 
diff --git a/hw/vfio-user/container.c b/hw/vfio-user/container.c
index 411eb7b28b7..e45192fef65 100644
--- a/hw/vfio-user/container.c
+++ b/hw/vfio-user/container.c
@@ -39,7 +39,7 @@ static void vfio_user_listener_commit(VFIOContainer *bcontainer)
 }
 
 static int vfio_user_dma_unmap(const VFIOContainer *bcontainer,
-                               hwaddr iova, ram_addr_t size,
+                               hwaddr iova, uint64_t size,
                                IOMMUTLBEntry *iotlb, bool unmap_all)
 {
     VFIOUserContainer *container = VFIO_IOMMU_USER(bcontainer);
@@ -81,7 +81,7 @@ static int vfio_user_dma_unmap(const VFIOContainer *bcontainer,
 }
 
 static int vfio_user_dma_map(const VFIOContainer *bcontainer, hwaddr iova,
-                             ram_addr_t size, void *vaddr, bool readonly,
+                             uint64_t size, void *vaddr, bool readonly,
                              MemoryRegion *mrp)
 {
     VFIOUserContainer *container = VFIO_IOMMU_USER(bcontainer);
diff --git a/hw/vfio/container-legacy.c b/hw/vfio/container-legacy.c
index c0f87f774a0..3a710d8265c 100644
--- a/hw/vfio/container-legacy.c
+++ b/hw/vfio/container-legacy.c
@@ -69,7 +69,7 @@ static int vfio_ram_block_discard_disable(VFIOLegacyContainer *container,
 }
 
 static int vfio_dma_unmap_bitmap(const VFIOLegacyContainer *container,
-                                 hwaddr iova, ram_addr_t size,
+                                 hwaddr iova, uint64_t size,
                                  IOMMUTLBEntry *iotlb)
 {
     const VFIOContainer *bcontainer = VFIO_IOMMU(container);
@@ -122,7 +122,7 @@ unmap_exit:
 }
 
 static int vfio_legacy_dma_unmap_one(const VFIOContainer *bcontainer,
-                                     hwaddr iova, ram_addr_t size,
+                                     hwaddr iova, uint64_t size,
                                      IOMMUTLBEntry *iotlb)
 {
     const VFIOLegacyContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
@@ -185,7 +185,7 @@ static int vfio_legacy_dma_unmap_one(const VFIOContainer *bcontainer,
  * DMA - Mapping and unmapping for the "type1" IOMMU interface used on x86
  */
 static int vfio_legacy_dma_unmap(const VFIOContainer *bcontainer,
-                                 hwaddr iova, ram_addr_t size,
+                                 hwaddr iova, uint64_t size,
                                  IOMMUTLBEntry *iotlb, bool unmap_all)
 {
     int ret;
@@ -210,7 +210,7 @@ static int vfio_legacy_dma_unmap(const VFIOContainer *bcontainer,
 }
 
 static int vfio_legacy_dma_map(const VFIOContainer *bcontainer, hwaddr iova,
-                               ram_addr_t size, void *vaddr, bool readonly,
+                               uint64_t size, void *vaddr, bool readonly,
                                MemoryRegion *mr)
 {
     const VFIOLegacyContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index 9d694393714..b5af3ac174c 100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -15,7 +15,6 @@
 
 #include "qemu/osdep.h"
 #include "system/tcg.h"
-#include "system/ram_addr.h"
 #include "qapi/error.h"
 #include "qemu/error-report.h"
 #include "hw/vfio/vfio-container.h"
@@ -74,7 +73,7 @@ void vfio_address_space_insert(VFIOAddressSpace *space,
 }
 
 int vfio_container_dma_map(VFIOContainer *bcontainer,
-                           hwaddr iova, ram_addr_t size,
+                           hwaddr iova, uint64_t size,
                            void *vaddr, bool readonly, MemoryRegion *mr)
 {
     VFIOIOMMUClass *vioc = VFIO_IOMMU_GET_CLASS(bcontainer);
@@ -93,7 +92,7 @@ int vfio_container_dma_map(VFIOContainer *bcontainer,
 }
 
 int vfio_container_dma_unmap(VFIOContainer *bcontainer,
-                             hwaddr iova, ram_addr_t size,
+                             hwaddr iova, uint64_t size,
                              IOMMUTLBEntry *iotlb, bool unmap_all)
 {
     VFIOIOMMUClass *vioc = VFIO_IOMMU_GET_CLASS(bcontainer);
diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
index f0ffe235919..68470d552ec 100644
--- a/hw/vfio/iommufd.c
+++ b/hw/vfio/iommufd.c
@@ -35,7 +35,7 @@
             TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio"
 
 static int iommufd_cdev_map(const VFIOContainer *bcontainer, hwaddr iova,
-                            ram_addr_t size, void *vaddr, bool readonly,
+                            uint64_t size, void *vaddr, bool readonly,
                             MemoryRegion *mr)
 {
     const VFIOIOMMUFDContainer *container = VFIO_IOMMU_IOMMUFD(bcontainer);
@@ -46,7 +46,7 @@ static int iommufd_cdev_map(const VFIOContainer *bcontainer, hwaddr iova,
 }
 
 static int iommufd_cdev_map_file(const VFIOContainer *bcontainer,
-                                 hwaddr iova, ram_addr_t size,
+                                 hwaddr iova, uint64_t size,
                                  int fd, unsigned long start, bool readonly)
 {
     const VFIOIOMMUFDContainer *container = VFIO_IOMMU_IOMMUFD(bcontainer);
@@ -57,7 +57,7 @@ static int iommufd_cdev_map_file(const VFIOContainer *bcontainer,
 }
 
 static int iommufd_cdev_unmap(const VFIOContainer *bcontainer,
-                              hwaddr iova, ram_addr_t size,
+                              hwaddr iova, uint64_t size,
                               IOMMUTLBEntry *iotlb, bool unmap_all)
 {
     const VFIOIOMMUFDContainer *container = VFIO_IOMMU_IOMMUFD(bcontainer);
-- 
2.51.0


Re: [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
Posted by Cédric Le Goater 1 month, 2 weeks ago
On 9/29/25 18:08, Philippe Mathieu-Daudé wrote:
> The 'ram_addr_t' type is described as:
> 
>    a QEMU internal address space that maps guest RAM physical
>    addresses into an intermediate address space that can map
>    to host virtual address spaces.
> 
> This doesn't represent well an IOVA mapping size. Simply use
> the uint64_t type.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/vfio/vfio-container.h | 10 +++++-----
>   hw/vfio-user/container.c         |  4 ++--
>   hw/vfio/container-legacy.c       |  8 ++++----
>   hw/vfio/container.c              |  5 ++---
>   hw/vfio/iommufd.c                |  6 +++---
>   5 files changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/include/hw/vfio/vfio-container.h b/include/hw/vfio/vfio-container.h
> index 093c360f0ee..c4b58d664b7 100644
> --- a/include/hw/vfio/vfio-container.h
> +++ b/include/hw/vfio/vfio-container.h
> @@ -81,10 +81,10 @@ void vfio_address_space_insert(VFIOAddressSpace *space,
>                                  VFIOContainer *bcontainer);
>   
>   int vfio_container_dma_map(VFIOContainer *bcontainer,
> -                           hwaddr iova, ram_addr_t size,
> +                           hwaddr iova, uint64_t size,
>                              void *vaddr, bool readonly, MemoryRegion *mr);
>   int vfio_container_dma_unmap(VFIOContainer *bcontainer,
> -                             hwaddr iova, ram_addr_t size,
> +                             hwaddr iova, uint64_t size,
>                                IOMMUTLBEntry *iotlb, bool unmap_all);
>   bool vfio_container_add_section_window(VFIOContainer *bcontainer,
>                                          MemoryRegionSection *section,
> @@ -167,7 +167,7 @@ struct VFIOIOMMUClass {
>        * Returns 0 to indicate success and -errno otherwise.
>        */
>       int (*dma_map)(const VFIOContainer *bcontainer,
> -                   hwaddr iova, ram_addr_t size,
> +                   hwaddr iova, uint64_t size,
>                      void *vaddr, bool readonly, MemoryRegion *mr);
>       /**
>        * @dma_map_file
> @@ -182,7 +182,7 @@ struct VFIOIOMMUClass {
>        * @readonly: map read only if true
>        */
>       int (*dma_map_file)(const VFIOContainer *bcontainer,
> -                        hwaddr iova, ram_addr_t size,
> +                        hwaddr iova, uint64_t size,
>                           int fd, unsigned long start, bool readonly);


Don't forget to change :

typedef int (*dma_map_fn)(const struct VFIOContainer *bcontainer,
                           hwaddr iova, ram_addr_t size, void *vaddr,
                           bool readonly, MemoryRegion *mr);

in /include/hw/vfio/vfio-cpr.h.


Thanks,

C.


Re: [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
On 30/9/25 10:53, Cédric Le Goater wrote:
> On 9/29/25 18:08, Philippe Mathieu-Daudé wrote:
>> The 'ram_addr_t' type is described as:
>>
>>    a QEMU internal address space that maps guest RAM physical
>>    addresses into an intermediate address space that can map
>>    to host virtual address spaces.
>>
>> This doesn't represent well an IOVA mapping size. Simply use
>> the uint64_t type.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   include/hw/vfio/vfio-container.h | 10 +++++-----
>>   hw/vfio-user/container.c         |  4 ++--
>>   hw/vfio/container-legacy.c       |  8 ++++----
>>   hw/vfio/container.c              |  5 ++---
>>   hw/vfio/iommufd.c                |  6 +++---
>>   5 files changed, 16 insertions(+), 17 deletions(-)
>>
>> diff --git a/include/hw/vfio/vfio-container.h b/include/hw/vfio/vfio- 
>> container.h
>> index 093c360f0ee..c4b58d664b7 100644
>> --- a/include/hw/vfio/vfio-container.h
>> +++ b/include/hw/vfio/vfio-container.h
>> @@ -81,10 +81,10 @@ void vfio_address_space_insert(VFIOAddressSpace 
>> *space,
>>                                  VFIOContainer *bcontainer);
>>   int vfio_container_dma_map(VFIOContainer *bcontainer,
>> -                           hwaddr iova, ram_addr_t size,
>> +                           hwaddr iova, uint64_t size,
>>                              void *vaddr, bool readonly, MemoryRegion 
>> *mr);
>>   int vfio_container_dma_unmap(VFIOContainer *bcontainer,
>> -                             hwaddr iova, ram_addr_t size,
>> +                             hwaddr iova, uint64_t size,
>>                                IOMMUTLBEntry *iotlb, bool unmap_all);
>>   bool vfio_container_add_section_window(VFIOContainer *bcontainer,
>>                                          MemoryRegionSection *section,
>> @@ -167,7 +167,7 @@ struct VFIOIOMMUClass {
>>        * Returns 0 to indicate success and -errno otherwise.
>>        */
>>       int (*dma_map)(const VFIOContainer *bcontainer,
>> -                   hwaddr iova, ram_addr_t size,
>> +                   hwaddr iova, uint64_t size,
>>                      void *vaddr, bool readonly, MemoryRegion *mr);
>>       /**
>>        * @dma_map_file
>> @@ -182,7 +182,7 @@ struct VFIOIOMMUClass {
>>        * @readonly: map read only if true
>>        */
>>       int (*dma_map_file)(const VFIOContainer *bcontainer,
>> -                        hwaddr iova, ram_addr_t size,
>> +                        hwaddr iova, uint64_t size,
>>                           int fd, unsigned long start, bool readonly);
> 
> 
> Don't forget to change :
> 
> typedef int (*dma_map_fn)(const struct VFIOContainer *bcontainer,
>                            hwaddr iova, ram_addr_t size, void *vaddr,
>                            bool readonly, MemoryRegion *mr);
> 
> in /include/hw/vfio/vfio-cpr.h.

Odd place to declare a typedef aiming to match a prototype of
another header. No common vfio header between vfio-cpr.h and
vfio-container.h?

Re: [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
Posted by Cédric Le Goater 1 month, 2 weeks ago
On 9/29/25 18:08, Philippe Mathieu-Daudé wrote:
> The 'ram_addr_t' type is described as:
> 
>    a QEMU internal address space that maps guest RAM physical
>    addresses into an intermediate address space that can map
>    to host virtual address spaces.
> 
> This doesn't represent well an IOVA mapping size. Simply use
> the uint64_t type.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/vfio/vfio-container.h | 10 +++++-----
>   hw/vfio-user/container.c         |  4 ++--
>   hw/vfio/container-legacy.c       |  8 ++++----
>   hw/vfio/container.c              |  5 ++---
>   hw/vfio/iommufd.c                |  6 +++---
>   5 files changed, 16 insertions(+), 17 deletions(-)
> 
> diff --git a/include/hw/vfio/vfio-container.h b/include/hw/vfio/vfio-container.h
> index 093c360f0ee..c4b58d664b7 100644
> --- a/include/hw/vfio/vfio-container.h
> +++ b/include/hw/vfio/vfio-container.h
> @@ -81,10 +81,10 @@ void vfio_address_space_insert(VFIOAddressSpace *space,
>                                  VFIOContainer *bcontainer);
>   
>   int vfio_container_dma_map(VFIOContainer *bcontainer,
> -                           hwaddr iova, ram_addr_t size,
> +                           hwaddr iova, uint64_t size,
>                              void *vaddr, bool readonly, MemoryRegion *mr);
>   int vfio_container_dma_unmap(VFIOContainer *bcontainer,
> -                             hwaddr iova, ram_addr_t size,
> +                             hwaddr iova, uint64_t size,
>                                IOMMUTLBEntry *iotlb, bool unmap_all);
>   bool vfio_container_add_section_window(VFIOContainer *bcontainer,
>                                          MemoryRegionSection *section,
> @@ -167,7 +167,7 @@ struct VFIOIOMMUClass {
>        * Returns 0 to indicate success and -errno otherwise.
>        */
>       int (*dma_map)(const VFIOContainer *bcontainer,
> -                   hwaddr iova, ram_addr_t size,
> +                   hwaddr iova, uint64_t size,
>                      void *vaddr, bool readonly, MemoryRegion *mr);
>       /**
>        * @dma_map_file
> @@ -182,7 +182,7 @@ struct VFIOIOMMUClass {
>        * @readonly: map read only if true
>        */
>       int (*dma_map_file)(const VFIOContainer *bcontainer,
> -                        hwaddr iova, ram_addr_t size,
> +                        hwaddr iova, uint64_t size,
>                           int fd, unsigned long start, bool readonly);
>       /**
>        * @dma_unmap
> @@ -198,7 +198,7 @@ struct VFIOIOMMUClass {
>        * Returns 0 to indicate success and -errno otherwise.
>        */
>       int (*dma_unmap)(const VFIOContainer *bcontainer,
> -                     hwaddr iova, ram_addr_t size,
> +                     hwaddr iova, uint64_t size,
>                        IOMMUTLBEntry *iotlb, bool unmap_all);
>   
>   
> diff --git a/hw/vfio-user/container.c b/hw/vfio-user/container.c
> index 411eb7b28b7..e45192fef65 100644
> --- a/hw/vfio-user/container.c
> +++ b/hw/vfio-user/container.c
> @@ -39,7 +39,7 @@ static void vfio_user_listener_commit(VFIOContainer *bcontainer)
>   }
>   
>   static int vfio_user_dma_unmap(const VFIOContainer *bcontainer,
> -                               hwaddr iova, ram_addr_t size,
> +                               hwaddr iova, uint64_t size,
>                                  IOMMUTLBEntry *iotlb, bool unmap_all)
>   {
>       VFIOUserContainer *container = VFIO_IOMMU_USER(bcontainer);
> @@ -81,7 +81,7 @@ static int vfio_user_dma_unmap(const VFIOContainer *bcontainer,
>   }
>   
>   static int vfio_user_dma_map(const VFIOContainer *bcontainer, hwaddr iova,
> -                             ram_addr_t size, void *vaddr, bool readonly,
> +                             uint64_t size, void *vaddr, bool readonly,
>                                MemoryRegion *mrp)
>   {
>       VFIOUserContainer *container = VFIO_IOMMU_USER(bcontainer);
> diff --git a/hw/vfio/container-legacy.c b/hw/vfio/container-legacy.c
> index c0f87f774a0..3a710d8265c 100644
> --- a/hw/vfio/container-legacy.c
> +++ b/hw/vfio/container-legacy.c
> @@ -69,7 +69,7 @@ static int vfio_ram_block_discard_disable(VFIOLegacyContainer *container,
>   }
>   
>   static int vfio_dma_unmap_bitmap(const VFIOLegacyContainer *container,
> -                                 hwaddr iova, ram_addr_t size,
> +                                 hwaddr iova, uint64_t size,
>                                    IOMMUTLBEntry *iotlb)
>   {
>       const VFIOContainer *bcontainer = VFIO_IOMMU(container);
> @@ -122,7 +122,7 @@ unmap_exit:
>   }
>   
>   static int vfio_legacy_dma_unmap_one(const VFIOContainer *bcontainer,
> -                                     hwaddr iova, ram_addr_t size,
> +                                     hwaddr iova, uint64_t size,
>                                        IOMMUTLBEntry *iotlb)
>   {
>       const VFIOLegacyContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
> @@ -185,7 +185,7 @@ static int vfio_legacy_dma_unmap_one(const VFIOContainer *bcontainer,
>    * DMA - Mapping and unmapping for the "type1" IOMMU interface used on x86
>    */
>   static int vfio_legacy_dma_unmap(const VFIOContainer *bcontainer,
> -                                 hwaddr iova, ram_addr_t size,
> +                                 hwaddr iova, uint64_t size,
>                                    IOMMUTLBEntry *iotlb, bool unmap_all)
>   {
>       int ret;
> @@ -210,7 +210,7 @@ static int vfio_legacy_dma_unmap(const VFIOContainer *bcontainer,
>   }
>   
>   static int vfio_legacy_dma_map(const VFIOContainer *bcontainer, hwaddr iova,
> -                               ram_addr_t size, void *vaddr, bool readonly,
> +                               uint64_t size, void *vaddr, bool readonly,
>                                  MemoryRegion *mr)
>   {
>       const VFIOLegacyContainer *container = VFIO_IOMMU_LEGACY(bcontainer);
> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
> index 9d694393714..b5af3ac174c 100644
> --- a/hw/vfio/container.c
> +++ b/hw/vfio/container.c
> @@ -15,7 +15,6 @@
>   
>   #include "qemu/osdep.h"
>   #include "system/tcg.h"
> -#include "system/ram_addr.h"

This is required for cpu_physical_memory_set_dirty_range()

C.



>   #include "qapi/error.h"
>   #include "qemu/error-report.h"
>   #include "hw/vfio/vfio-container.h"
> @@ -74,7 +73,7 @@ void vfio_address_space_insert(VFIOAddressSpace *space,
>   }
>   
>   int vfio_container_dma_map(VFIOContainer *bcontainer,
> -                           hwaddr iova, ram_addr_t size,
> +                           hwaddr iova, uint64_t size,
>                              void *vaddr, bool readonly, MemoryRegion *mr)
>   {
>       VFIOIOMMUClass *vioc = VFIO_IOMMU_GET_CLASS(bcontainer);
> @@ -93,7 +92,7 @@ int vfio_container_dma_map(VFIOContainer *bcontainer,
>   }
>   
>   int vfio_container_dma_unmap(VFIOContainer *bcontainer,
> -                             hwaddr iova, ram_addr_t size,
> +                             hwaddr iova, uint64_t size,
>                                IOMMUTLBEntry *iotlb, bool unmap_all)
>   {
>       VFIOIOMMUClass *vioc = VFIO_IOMMU_GET_CLASS(bcontainer);
> diff --git a/hw/vfio/iommufd.c b/hw/vfio/iommufd.c
> index f0ffe235919..68470d552ec 100644
> --- a/hw/vfio/iommufd.c
> +++ b/hw/vfio/iommufd.c
> @@ -35,7 +35,7 @@
>               TYPE_HOST_IOMMU_DEVICE_IOMMUFD "-vfio"
>   
>   static int iommufd_cdev_map(const VFIOContainer *bcontainer, hwaddr iova,
> -                            ram_addr_t size, void *vaddr, bool readonly,
> +                            uint64_t size, void *vaddr, bool readonly,
>                               MemoryRegion *mr)
>   {
>       const VFIOIOMMUFDContainer *container = VFIO_IOMMU_IOMMUFD(bcontainer);
> @@ -46,7 +46,7 @@ static int iommufd_cdev_map(const VFIOContainer *bcontainer, hwaddr iova,
>   }
>   
>   static int iommufd_cdev_map_file(const VFIOContainer *bcontainer,
> -                                 hwaddr iova, ram_addr_t size,
> +                                 hwaddr iova, uint64_t size,
>                                    int fd, unsigned long start, bool readonly)
>   {
>       const VFIOIOMMUFDContainer *container = VFIO_IOMMU_IOMMUFD(bcontainer);
> @@ -57,7 +57,7 @@ static int iommufd_cdev_map_file(const VFIOContainer *bcontainer,
>   }
>   
>   static int iommufd_cdev_unmap(const VFIOContainer *bcontainer,
> -                              hwaddr iova, ram_addr_t size,
> +                              hwaddr iova, uint64_t size,
>                                 IOMMUTLBEntry *iotlb, bool unmap_all)
>   {
>       const VFIOIOMMUFDContainer *container = VFIO_IOMMU_IOMMUFD(bcontainer);


Re: [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
Posted by Philippe Mathieu-Daudé 1 month, 2 weeks ago
On 29/9/25 18:08, Philippe Mathieu-Daudé wrote:
> The 'ram_addr_t' type is described as:
> 
>    a QEMU internal address space that maps guest RAM physical
>    addresses into an intermediate address space that can map
>    to host virtual address spaces.
> 
> This doesn't represent well an IOVA mapping size. Simply use
> the uint64_t type.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   include/hw/vfio/vfio-container.h | 10 +++++-----
>   hw/vfio-user/container.c         |  4 ++--
>   hw/vfio/container-legacy.c       |  8 ++++----
>   hw/vfio/container.c              |  5 ++---
>   hw/vfio/iommufd.c                |  6 +++---
>   5 files changed, 16 insertions(+), 17 deletions(-)


> diff --git a/hw/vfio/container.c b/hw/vfio/container.c
> index 9d694393714..b5af3ac174c 100644
> --- a/hw/vfio/container.c
> +++ b/hw/vfio/container.c
> @@ -15,7 +15,6 @@
>   
>   #include "qemu/osdep.h"
>   #include "system/tcg.h"
> -#include "system/ram_addr.h"

This header must not be removed (yet).

>   #include "qapi/error.h"
>   #include "qemu/error-report.h"
>   #include "hw/vfio/vfio-container.h"