From nobody Thu Dec 26 13:30:53 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=sfritsch.de ARC-Seal: i=1; a=rsa-sha256; t=1712913627; cv=none; d=zohomail.com; s=zohoarc; b=lfE5HagbjHWeeL8oQWmNmbJBqS7HfbcA8E+fbwZ6WITPJOqF74IBclpVYUusvxfmsBe0s4XeYfS/8RuBK8yYzjp14iUITdLheNc1/pLRw894CgeiO4irAyqfc5a8mwDgWnP9bTLtDAvrhg6UYJfdD2cqaquc27/jd9nl3q2z600= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1712913627; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=IZhTvU1TRRoPdACQE+iV/SSJmbrlIalWzaEBCFoTG8M=; b=JptTC1U3xFwIDRNEg0pdAFp8Grk2GR7fjnQwJGIC7lODWkBVPxKwS9uW5Uqu57DXfaKR1bG+wVsEfNJq7KWoIgIU1xhXxnGhNFkUQ6IuQorWFTIDUVhYiRUEgKN2IZr6Q98GoymNR5BR8irRlK44EPM5+6x0tdSt8/huRdx8Ids= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1712913627744218.71824666842167; Fri, 12 Apr 2024 02:20:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rvD4d-00059S-Gr; Fri, 12 Apr 2024 05:19:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvBwD-0006Ah-PG for qemu-devel@nongnu.org; Fri, 12 Apr 2024 04:07:11 -0400 Received: from manul.sfritsch.de ([2a01:4f8:262:44c1:112::2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rvBwA-0004z3-P6 for qemu-devel@nongnu.org; Fri, 12 Apr 2024 04:07:08 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sfritsch.de ; s=rsa-1; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject: Cc:To:From:From:Reply-To:Subject:Content-Type:Content-ID:Content-Description: In-Reply-To:References:X-Debbugs-Cc; bh=IZhTvU1TRRoPdACQE+iV/SSJmbrlIalWzaEBCFoTG8M=; t=1712909224; x=1713773224; b=ubwIvAaloy6swlzOEWGPPHlyPaJo6dg7haQt11BTTb7NEmDSpydu9mSD+AjELBjpOjUnH4T59hc 3VEct5kz+PQBToGDA6OZX3mLBxXQuwdmF4F7qJw56BIYOSwwyYJhYMb/LIsJKNAz85pf198CjfQHl 9UBykH211ja2qaF1YOyNUfz8b+vP3SS0b0e1XQaIjmE9L8kv3FB4rFyw2cclA7rxlpXjg62Io9aCV IRvzhlNNtr1nTVSn0lDssv4z7r6qyGgmAQQBZlag0DB8r6wo+8NIilnZXE5b9u+ZSoKkuG0nuBGcf qdOqvBjgxJrskRy7pHRLabb6k2pOu6n5+Ebg==; From: Stefan Fritsch To: qemu-devel@nongnu.org Cc: Paolo Bonzini , Peter Xu , David Hildenbrand , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Fritsch Subject: [PATCH] dma-helpers: Fix iovec alignment Date: Fri, 12 Apr 2024 10:06:17 +0200 Message-Id: <20240412080617.1299883-1-sf@sfritsch.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a01:4f8:262:44c1:112::2; envelope-from=sf@sfritsch.de; helo=manul.sfritsch.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 12 Apr 2024 05:19:52 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @sfritsch.de) X-ZM-MESSAGEID: 1712913629816100003 Content-Type: text/plain; charset="utf-8" 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 h= elpers") Signed-off-by: Stefan Fritsch Reviewed-by: Eric Blake --- 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) } =20 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); } =20 dbs->acb =3D dbs->io_func(dbs->offset, &dbs->iov, --=20 2.43.0