* [PATCH 0/3] hw/vfio: Remove invalid uses of ram_addr_t type
@ 2025-09-29 16:08 Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 1/3] system/iommufd: Use uint64_t type for IOVA mapping size Philippe Mathieu-Daudé
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-29 16:08 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Cédric Le Goater, Thanos Makatos, John Levon,
Alex Williamson, Eric Auger, Zhenzhong Duan,
Philippe Mathieu-Daudé
Replace ram_addr_t by either hwaddr or uint64_t types.
Philippe Mathieu-Daudé (3):
system/iommufd: Use uint64_t type for IOVA mapping size
hw/vfio: Avoid ram_addr_t in vfio_container_query_dirty_bitmap()
hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
include/hw/vfio/vfio-container.h | 13 +++++++------
include/system/iommufd.h | 6 +++---
backends/iommufd.c | 6 +++---
hw/vfio-user/container.c | 4 ++--
hw/vfio/container-legacy.c | 8 ++++----
hw/vfio/container.c | 16 ++++++++--------
hw/vfio/iommufd.c | 6 +++---
7 files changed, 30 insertions(+), 29 deletions(-)
--
2.51.0
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] system/iommufd: Use uint64_t type for IOVA mapping size
2025-09-29 16:08 [PATCH 0/3] hw/vfio: Remove invalid uses of ram_addr_t type Philippe Mathieu-Daudé
@ 2025-09-29 16:08 ` Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 2/3] hw/vfio: Avoid ram_addr_t in vfio_container_query_dirty_bitmap() Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map Philippe Mathieu-Daudé
2 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-29 16:08 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Cédric Le Goater, Thanos Makatos, John Levon,
Alex Williamson, Eric Auger, Zhenzhong Duan,
Philippe Mathieu-Daudé
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/system/iommufd.h | 6 +++---
backends/iommufd.c | 6 +++---
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/include/system/iommufd.h b/include/system/iommufd.h
index c9c72ffc450..a659f36a20f 100644
--- a/include/system/iommufd.h
+++ b/include/system/iommufd.h
@@ -45,12 +45,12 @@ bool iommufd_backend_alloc_ioas(IOMMUFDBackend *be, uint32_t *ioas_id,
Error **errp);
void iommufd_backend_free_id(IOMMUFDBackend *be, uint32_t id);
int iommufd_backend_map_file_dma(IOMMUFDBackend *be, uint32_t ioas_id,
- hwaddr iova, ram_addr_t size, int fd,
+ hwaddr iova, uint64_t size, int fd,
unsigned long start, bool readonly);
int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova,
- ram_addr_t size, void *vaddr, bool readonly);
+ uint64_t size, void *vaddr, bool readonly);
int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id,
- hwaddr iova, ram_addr_t size);
+ hwaddr iova, uint64_t size);
bool iommufd_backend_get_device_info(IOMMUFDBackend *be, uint32_t devid,
uint32_t *type, void *data, uint32_t len,
uint64_t *caps, Error **errp);
diff --git a/backends/iommufd.c b/backends/iommufd.c
index 2a33c7ab0bc..fdfb7c9d671 100644
--- a/backends/iommufd.c
+++ b/backends/iommufd.c
@@ -197,7 +197,7 @@ void iommufd_backend_free_id(IOMMUFDBackend *be, uint32_t id)
}
int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova,
- ram_addr_t size, void *vaddr, bool readonly)
+ uint64_t size, void *vaddr, bool readonly)
{
int ret, fd = be->fd;
struct iommu_ioas_map map = {
@@ -230,7 +230,7 @@ int iommufd_backend_map_dma(IOMMUFDBackend *be, uint32_t ioas_id, hwaddr iova,
}
int iommufd_backend_map_file_dma(IOMMUFDBackend *be, uint32_t ioas_id,
- hwaddr iova, ram_addr_t size,
+ hwaddr iova, uint64_t size,
int mfd, unsigned long start, bool readonly)
{
int ret, fd = be->fd;
@@ -268,7 +268,7 @@ int iommufd_backend_map_file_dma(IOMMUFDBackend *be, uint32_t ioas_id,
}
int iommufd_backend_unmap_dma(IOMMUFDBackend *be, uint32_t ioas_id,
- hwaddr iova, ram_addr_t size)
+ hwaddr iova, uint64_t size)
{
int ret, fd = be->fd;
struct iommu_ioas_unmap unmap = {
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] hw/vfio: Avoid ram_addr_t in vfio_container_query_dirty_bitmap()
2025-09-29 16:08 [PATCH 0/3] hw/vfio: Remove invalid uses of ram_addr_t type Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 1/3] system/iommufd: Use uint64_t type for IOVA mapping size Philippe Mathieu-Daudé
@ 2025-09-29 16:08 ` Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map Philippe Mathieu-Daudé
2 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-29 16:08 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Cédric Le Goater, Thanos Makatos, John Levon,
Alex Williamson, Eric Auger, Zhenzhong Duan,
Philippe Mathieu-Daudé
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.
vfio_container_query_dirty_bitmap() doesn't expect such QEMU
intermediate address, but a guest physical addresses. Use the
appropriate 'hwaddr' type, rename as @translated_addr for
clarity.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
include/hw/vfio/vfio-container.h | 3 ++-
hw/vfio/container.c | 11 ++++++-----
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/include/hw/vfio/vfio-container.h b/include/hw/vfio/vfio-container.h
index b8fb2b8b5d7..093c360f0ee 100644
--- a/include/hw/vfio/vfio-container.h
+++ b/include/hw/vfio/vfio-container.h
@@ -98,7 +98,8 @@ bool vfio_container_dirty_tracking_is_started(
bool vfio_container_devices_dirty_tracking_is_supported(
const VFIOContainer *bcontainer);
int vfio_container_query_dirty_bitmap(const VFIOContainer *bcontainer,
- uint64_t iova, uint64_t size, ram_addr_t ram_addr, Error **errp);
+ uint64_t iova, uint64_t size,
+ hwaddr translated_addr, Error **errp);
GList *vfio_container_get_iova_ranges(const VFIOContainer *bcontainer);
diff --git a/hw/vfio/container.c b/hw/vfio/container.c
index 250b20f4245..9d694393714 100644
--- a/hw/vfio/container.c
+++ b/hw/vfio/container.c
@@ -246,7 +246,7 @@ static int vfio_container_devices_query_dirty_bitmap(
int vfio_container_query_dirty_bitmap(const VFIOContainer *bcontainer,
uint64_t iova, uint64_t size,
- ram_addr_t ram_addr, Error **errp)
+ hwaddr translated_addr, Error **errp)
{
bool all_device_dirty_tracking =
vfio_container_devices_dirty_tracking_is_supported(bcontainer);
@@ -255,7 +255,7 @@ int vfio_container_query_dirty_bitmap(const VFIOContainer *bcontainer,
int ret;
if (!bcontainer->dirty_pages_supported && !all_device_dirty_tracking) {
- cpu_physical_memory_set_dirty_range(ram_addr, size,
+ cpu_physical_memory_set_dirty_range(translated_addr, size,
tcg_enabled() ? DIRTY_CLIENTS_ALL :
DIRTY_CLIENTS_NOCODE);
return 0;
@@ -280,11 +280,12 @@ int vfio_container_query_dirty_bitmap(const VFIOContainer *bcontainer,
goto out;
}
- dirty_pages = cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap, ram_addr,
+ dirty_pages = cpu_physical_memory_set_dirty_lebitmap(vbmap.bitmap,
+ translated_addr,
vbmap.pages);
- trace_vfio_container_query_dirty_bitmap(iova, size, vbmap.size, ram_addr,
- dirty_pages);
+ trace_vfio_container_query_dirty_bitmap(iova, size, vbmap.size,
+ translated_addr, dirty_pages);
out:
g_free(vbmap.bitmap);
--
2.51.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
2025-09-29 16:08 [PATCH 0/3] hw/vfio: Remove invalid uses of ram_addr_t type Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 1/3] system/iommufd: Use uint64_t type for IOVA mapping size Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 2/3] hw/vfio: Avoid ram_addr_t in vfio_container_query_dirty_bitmap() Philippe Mathieu-Daudé
@ 2025-09-29 16:08 ` Philippe Mathieu-Daudé
2025-09-30 8:46 ` Philippe Mathieu-Daudé
` (2 more replies)
2 siblings, 3 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-29 16:08 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Cédric Le Goater, Thanos Makatos, John Levon,
Alex Williamson, Eric Auger, Zhenzhong Duan,
Philippe Mathieu-Daudé
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
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
2025-09-29 16:08 ` [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map Philippe Mathieu-Daudé
@ 2025-09-30 8:46 ` Philippe Mathieu-Daudé
2025-09-30 8:48 ` Cédric Le Goater
2025-09-30 8:53 ` Cédric Le Goater
2 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30 8:46 UTC (permalink / raw)
To: qemu-devel
Cc: Yi Liu, Cédric Le Goater, Thanos Makatos, John Levon,
Alex Williamson, Eric Auger, Zhenzhong Duan
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"
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
2025-09-29 16:08 ` [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map Philippe Mathieu-Daudé
2025-09-30 8:46 ` Philippe Mathieu-Daudé
@ 2025-09-30 8:48 ` Cédric Le Goater
2025-09-30 8:53 ` Cédric Le Goater
2 siblings, 0 replies; 8+ messages in thread
From: Cédric Le Goater @ 2025-09-30 8:48 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Thanos Makatos, John Levon, Alex Williamson, Eric Auger,
Zhenzhong Duan
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);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
2025-09-29 16:08 ` [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map Philippe Mathieu-Daudé
2025-09-30 8:46 ` Philippe Mathieu-Daudé
2025-09-30 8:48 ` Cédric Le Goater
@ 2025-09-30 8:53 ` Cédric Le Goater
2025-09-30 9:08 ` Philippe Mathieu-Daudé
2 siblings, 1 reply; 8+ messages in thread
From: Cédric Le Goater @ 2025-09-30 8:53 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Yi Liu, Thanos Makatos, John Levon, Alex Williamson, Eric Auger,
Zhenzhong Duan
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.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map
2025-09-30 8:53 ` Cédric Le Goater
@ 2025-09-30 9:08 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 8+ messages in thread
From: Philippe Mathieu-Daudé @ 2025-09-30 9:08 UTC (permalink / raw)
To: Cédric Le Goater, qemu-devel
Cc: Yi Liu, Thanos Makatos, John Levon, Alex Williamson, Eric Auger,
Zhenzhong Duan
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?
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-09-30 9:09 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-29 16:08 [PATCH 0/3] hw/vfio: Remove invalid uses of ram_addr_t type Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 1/3] system/iommufd: Use uint64_t type for IOVA mapping size Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 2/3] hw/vfio: Avoid ram_addr_t in vfio_container_query_dirty_bitmap() Philippe Mathieu-Daudé
2025-09-29 16:08 ` [PATCH 3/3] hw/vfio: Use uint64_t for IOVA mapping size in vfio_container_dma_*map Philippe Mathieu-Daudé
2025-09-30 8:46 ` Philippe Mathieu-Daudé
2025-09-30 8:48 ` Cédric Le Goater
2025-09-30 8:53 ` Cédric Le Goater
2025-09-30 9:08 ` Philippe Mathieu-Daudé
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).