From nobody Sun May 5 22:03:05 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529260511239536.9076577944178; Sun, 17 Jun 2018 11:35:11 -0700 (PDT) Received: from localhost ([::1]:56052 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUcW1-0003dh-1L for importer@patchew.org; Sun, 17 Jun 2018 14:35:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33985) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fUcUV-0002ob-Lw for qemu-devel@nongnu.org; Sun, 17 Jun 2018 14:33:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fUcUU-00075S-Pq for qemu-devel@nongnu.org; Sun, 17 Jun 2018 14:33:31 -0400 Received: from mail-pl0-x243.google.com ([2607:f8b0:400e:c01::243]:39078) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fUcUU-000757-JS; Sun, 17 Jun 2018 14:33:30 -0400 Received: by mail-pl0-x243.google.com with SMTP id f1-v6so7802248plt.6; Sun, 17 Jun 2018 11:33:30 -0700 (PDT) Received: from localhost.localdomain ([103.81.93.105]) by smtp.gmail.com with ESMTPSA id r188-v6sm21502232pgr.78.2018.06.17.11.33.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Jun 2018 11:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=kpGJmn9hv2hqGt6ysxL2Tr/SEA1w4vs+ACLz3uwjVDE=; b=nLSruFA9NtNeHXlX4aHmaxwZbtXlb3AuH5RM8qXD9wv1E4aSuMBqyE8K8QDXIKQuAE wrOub62EXic6fV7XhFmqImPqkxtr6Fp4Eq4Rs7qGOcxadM8Pr6Ciwr1kJdqrPHYNmoYv gz8uffmQ60k7ClNuuxAh6g6I0bJpWOueyPMbu49Yvz2sLWhBQnUK/PjVts9F88sYv30g HGIgW1UyAC8w75ZnefQ6rNvTCMVJLdVm6DRlWtTOMEteCaOHGgXG5Ay3UCwG/1rLlVux b5FFK23xlzz9hOhdCJ5S6B0tFuQ9RrvaLOYkEq+3ZJ3PVJHchyZBHGXv9lt2PP6l61Ku CmmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=kpGJmn9hv2hqGt6ysxL2Tr/SEA1w4vs+ACLz3uwjVDE=; b=dLIR0MoWkyrxRxi/6rR96giWC37y+xQ3a5tQbdWhAhJrCVsN7fGUCn1v0Yikc8iOCR iyrdWRbi391EtxzENso3WrB3rYoBtYjbgw5PigXK3NTz0sbLXdgv87kRD7xnWZYFVPow UyTOXmsaKc0PusFCjXHm0ItltYw+xFBGY5tfMCgSysMmS6T5mzJMX2wBqqdgcV8xhad6 LNkjtzb6YBRJLtFyLobvTXQn7oFC6pM8QNHMqOaZLJKS/sR6Oqt279sYuirwPRAzQnho TCRuYGXJ19sFdDBkE628MRq6J777+gKm8GFeH0vQZvbVuAYGCN1F3aOIgQEV140JoJVF byzw== X-Gm-Message-State: APt69E2oS5jRlDCMvX1WghrszHH/y3ddsQhXQu9wM/+g9qFHL9buyTai ovlNKCwcO3Qz387+GbPKQ1UzyknSZzQ= X-Google-Smtp-Source: ADUXVKJ7dy3eakCOR0H55N9DEJ964Ua6VGQE0iU6S26sx6EzPmKhd6zhWnv1K/qa3EQyGvHT/ceXZw== X-Received: by 2002:a17:902:9a4b:: with SMTP id x11-v6mr10821924plv.176.1529260409503; Sun, 17 Jun 2018 11:33:29 -0700 (PDT) From: Amol Surati To: qemu-devel@nongnu.org Date: Mon, 18 Jun 2018 00:05:15 +0530 Message-Id: <20180617183515.3982-2-suratiamol@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180617183515.3982-1-suratiamol@gmail.com> References: <20180617183515.3982-1-suratiamol@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::243 Subject: [Qemu-devel] [RFC 1/1] ide: bug #1777315: io_buffer_size and sg.size can represent partial sector sizes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amol Surati , John Snow , "open list:IDE" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This patch fixes the assumption that io_buffer_size is always a perfect multiple of the sector size. The assumption is the cause of the firing of 'assert(n * 512 =3D=3D s->sg.size);'. Signed-off-by: Amol Surati --- hw/ide/core.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hw/ide/core.c b/hw/ide/core.c index 2c62efc536..53a7c68196 100644 --- a/hw/ide/core.c +++ b/hw/ide/core.c @@ -835,7 +835,7 @@ int ide_handle_rw_error(IDEState *s, int error, int op) static void ide_dma_cb(void *opaque, int ret) { IDEState *s =3D opaque; - int n; + int m, n; int64_t sector_num; uint64_t offset; bool stay_active =3D false; @@ -858,6 +858,10 @@ static void ide_dma_cb(void *opaque, int ret) } =20 n =3D s->io_buffer_size >> 9; + if (s->io_buffer_size & (~BDRV_SECTOR_MASK)) { + n++; + } + if (n > s->nsector) { /* The PRDs were longer than needed for this request. Shorten them= so * we don't get a negative remainder. The Active bit must remain s= et @@ -868,7 +872,11 @@ static void ide_dma_cb(void *opaque, int ret) =20 sector_num =3D ide_get_sector(s); if (n > 0) { - assert(n * 512 =3D=3D s->sg.size); + m =3D s->sg.size >> 9; + if (s->sg.size & (~BDRV_SECTOR_MASK)) { + m++; + } + assert(n =3D=3D m); dma_buf_commit(s, s->sg.size); sector_num +=3D n; ide_set_sector(s, sector_num); --=20 2.17.1