All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] dma-helpers: Fix iovec alignment
@ 2024-04-12  8:06 Stefan Fritsch
  2024-04-12  9:51 ` Philippe Mathieu-Daudé
  2024-04-12 15:25 ` Eric Blake
  0 siblings, 2 replies; 9+ messages in thread
From: Stefan Fritsch @ 2024-04-12  8:06 UTC (permalink / raw)
  To: qemu-devel
  Cc: Paolo Bonzini, Peter Xu, David Hildenbrand,
	Philippe Mathieu-Daudé, Stefan Fritsch

Commit 99868af3d0 changed the hardcoded constant BDRV_SECTOR_SIZE to a
dynamic field 'align' but introduced a bug. qemu_iovec_discard_back()
is now passed the wanted iov length instead of the actually required
amount that should be removed from the end of the iov.

The bug can likely only be hit in uncommon configurations, e.g. with
icount enabled or when reading from disk directly to device memory.

Fixes: 99868af3d0a75cf6 ("dma-helpers: explicitly pass alignment into DMA helpers")
Signed-off-by: Stefan Fritsch <sf@sfritsch.de>
---
 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 9b221cf94e..c9677fd39b 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.43.0



^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2024-12-23 17:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-12  8:06 [PATCH] dma-helpers: Fix iovec alignment Stefan Fritsch
2024-04-12  9:51 ` Philippe Mathieu-Daudé
2024-04-12 15:25 ` Eric Blake
2024-04-16 11:36   ` Stefan Fritsch
2024-08-12 18:27     ` John Snow
2024-08-13 16:26       ` Stefan Fritsch
2024-08-11 17:47   ` Michael Tokarev
2024-12-20 21:07     ` Michael Tokarev
2024-12-23 17:42       ` Peter Xu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.