From bb308a2e8ee9486a4c8b53d8d773f7c8faaeba08 Mon Sep 17 00:00:00 2001 From: Mattias Nissler <122288598+mnissler-rivos@users.noreply.github.com> Date: Mon, 3 Jul 2023 18:28:59 +0200 Subject: Fix address calculation for message-based DMA (#740) The correct DMA address is formed by adding base and offset - the latter was accidentally missing. Change the server example to read and write blocks at non-zero offsets, such that `test-client-server.sh` exercises offset handling. Signed-off-by: Mattias Nissler --- lib/libvfio-user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libvfio-user.c b/lib/libvfio-user.c index 94524a2..663d2cd 100644 --- a/lib/libvfio-user.c +++ b/lib/libvfio-user.c @@ -2198,7 +2198,7 @@ vfu_dma_transfer(vfu_ctx_t *vfu_ctx, enum vfio_user_command cmd, while (remaining > 0) { int ret; - dma_req->addr = (uintptr_t)sg->dma_addr + count; + dma_req->addr = (uintptr_t)sg->dma_addr + sg->offset + count; dma_req->count = MIN(remaining, vfu_ctx->client_max_data_xfer_size); if (cmd == VFIO_USER_DMA_WRITE) { -- cgit v1.1