aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMattias Nissler <122288598+mnissler-rivos@users.noreply.github.com>2023-07-03 18:28:59 +0200
committerGitHub <noreply@github.com>2023-07-03 17:28:59 +0100
commitbb308a2e8ee9486a4c8b53d8d773f7c8faaeba08 (patch)
treea0e7d7eb4ef1823e11c3add311eae99c5cdabef9 /lib
parentbf8ce3fbe1b503324dfacba49cbdb18f637986d8 (diff)
downloadlibvfio-user-bb308a2e8ee9486a4c8b53d8d773f7c8faaeba08.zip
libvfio-user-bb308a2e8ee9486a4c8b53d8d773f7c8faaeba08.tar.gz
libvfio-user-bb308a2e8ee9486a4c8b53d8d773f7c8faaeba08.tar.bz2
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 <mnissler@rivosinc.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/libvfio-user.c2
1 files changed, 1 insertions, 1 deletions
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) {