From: Daniel Gomez <[email protected]>

Commit 99868af3d0 ("dma-helpers: explicitly pass alignment into DMA
helpers") replaced the sub-sector remainder with the aligned size as the
amount passed to qemu_iovec_discard_back(), effectively discarding the
wrong chunk. Go back to discarding the tail bytes of unaligned IO.

Fixes: 99868af3d0 ("dma-helpers: explicitly pass alignment into DMA helpers")
Acked-by: Jesper Wendel Devantier <[email protected]>
Reviewed-by: Keith Busch <[email protected]>
Signed-off-by: Daniel Gomez <[email protected]>
---
 system/dma-helpers.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/system/dma-helpers.c b/system/dma-helpers.c
index 0d592f64680..8ee83ce9e75 100644
--- a/system/dma-helpers.c
+++ b/system/dma-helpers.c
@@ -174,8 +174,7 @@ static void dma_blk_cb(void *opaque, int ret)
     }
 
     if (!QEMU_IS_ALIGNED(dbs->iov.size, dbs->align)) {
-        qemu_iovec_discard_back(&dbs->iov,
-                                QEMU_ALIGN_DOWN(dbs->iov.size, dbs->align));
+        qemu_iovec_discard_back(&dbs->iov, dbs->iov.size % dbs->align);
     }
 
     dbs->acb = dbs->io_func(dbs->offset, &dbs->iov,

-- 
2.55.0


Reply via email to