From 95f16fceadba22a7730c2a9c94cfd4028ef04a02 Mon Sep 17 00:00:00 2001 From: Swapnil Ingle Date: Fri, 14 May 2021 22:32:59 +0200 Subject: Fix dma read write count (#497) * spec: Fixed DMA_READ/WRITE data count DMA region size is maxed to uint64_t. Updated DMA_READ/WRITE data count to be defined as uint64_t. * Fix vfu_dma_read/write() as per spec changes Signed-off-by: Swapnil Ingle Reviewed-by: John Levon --- docs/vfio-user.rst | 4 ++-- include/vfio-user.h | 2 +- lib/libvfio-user.c | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/vfio-user.rst b/docs/vfio-user.rst index f956893..104a31d 100644 --- a/docs/vfio-user.rst +++ b/docs/vfio-user.rst @@ -1533,9 +1533,9 @@ DMA Read/Write Data +=========+========+==========+ | Address | 16 | 8 | +---------+--------+----------+ -| Count | 24 | 4 | +| Count | 24 | 8 | +---------+--------+----------+ -| Data | 28 | variable | +| Data | 32 | variable | +---------+--------+----------+ * *Address* is the area of client memory being accessed. This address must have diff --git a/include/vfio-user.h b/include/vfio-user.h index 053ead2..9d820c9 100644 --- a/include/vfio-user.h +++ b/include/vfio-user.h @@ -125,7 +125,7 @@ struct vfio_user_region_access { struct vfio_user_dma_region_access { uint64_t addr; - uint32_t count; + uint64_t count; uint8_t data[]; } __attribute__((packed)); diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index 9c32c73..4a03995 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -1502,7 +1502,7 @@ vfu_dma_read(vfu_ctx_t *vfu_ctx, dma_sg_t *sg, void *data) { struct vfio_user_dma_region_access *dma_recv; struct vfio_user_dma_region_access dma_send; - int recv_size; + uint64_t recv_size; int msg_id = 1, ret; assert(vfu_ctx != NULL); @@ -1543,7 +1543,7 @@ int vfu_dma_write(vfu_ctx_t *vfu_ctx, dma_sg_t *sg, void *data) { struct vfio_user_dma_region_access *dma_send, dma_recv; - int send_size = sizeof(*dma_send) + sg->length; + uint64_t send_size = sizeof(*dma_send) + sg->length; int msg_id = 1, ret; assert(vfu_ctx != NULL); -- cgit v1.1