From nobody Mon Feb 9 19:53:27 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=philmd@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599136135; cv=none; d=zohomail.com; s=zohoarc; b=iQsJdqO70ZhQAODIFr2nbln7CWZlxJxAKFHPpquOxRAdIwYqcOXWxBBT3a3iH35fppwVpEU+CF/dANj/ElnONEJqE9ST59Yhw44HIqt8aOA5vboccPHEPiAaIcl5LWE8DBpfCs+Ww6ZYt+G4j/pLOG6TNcIjaUrIbE3mX6+TSoc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599136135; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=BCC5Fw+MiUlqW0HMIIfQxzi+31vZOBfq2qQvazw+mlU=; b=kxJeHYS431huI1wkA0au9xDV5hlUVshJixFvL1AzYhVkAMLT8IwClCgGTSHifv9Bp2PPARAA4G19/ATU8nODEzEcJPf2Wg8rSw937chZAsWZyhTdbTKa3AO4V6eOyAJNptO5E9MgVK9eza9QYfp/eF1fbhAqp+xiMT0BQfhitXU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 159913613500299.84834237209054; Thu, 3 Sep 2020 05:28:55 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-Pj6TAq46PW-i6n6wGTFOtQ-1; Thu, 03 Sep 2020 08:28:50 -0400 Received: by mail-wr1-f72.google.com with SMTP id s8so1013589wrb.15 for ; Thu, 03 Sep 2020 05:28:50 -0700 (PDT) Return-Path: Return-Path: Received: from localhost.localdomain (50.red-83-52-54.dynamicip.rima-tde.net. [83.52.54.50]) by smtp.gmail.com with ESMTPSA id q186sm4451819wma.45.2020.09.03.05.28.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2020 05:28:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599136134; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=BCC5Fw+MiUlqW0HMIIfQxzi+31vZOBfq2qQvazw+mlU=; b=WErzbKIpiRpnU+RDz/PmXYMBJiZNhPruj6uvjWT67mD6IyW6tJIR5vC+7ftRIIYcj33xxv gt86EG/Og/SndbcjTfJ21YNvgHK+v2OzH3y6uqJ6Iy9OE2/Mwu/hGDlWtZrdaewJ68YYTj MVaItuiD9JAQO4y7tO57wFqgL0ddO5U= X-MC-Unique: Pj6TAq46PW-i6n6wGTFOtQ-1 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:mime-version:content-transfer-encoding; bh=BCC5Fw+MiUlqW0HMIIfQxzi+31vZOBfq2qQvazw+mlU=; b=OcwMmfMtORC5cbL0v+NytDwDKF9EPnSkDcbXxTVv75KnHNuCa62oqTOzqjGr8fdzAm /h9ONbHneIVYph71J6a8zPq2l0RbexXJozMXRPXnF30WrYm4duC6u7DmktICa0XaYIol pUYi0VLBZ6SpVJlu3opIz4+DFa/tCddboecBK7rral5j+ztX7k7lkwfhvufqyPEs0/fb byRrDZ1irXzV6kNBUEOrHu/60cmjOFys9lZ0FE+7IUA2jqF9/6CGvaYjRFsOEgeGRMyk wAolZUjwWFBiiXSs3UBacEiz4IljO5L3i2QBRyPq5WCIsNAGEpxu3B1QtdaWNt2zuCAe Kx6Q== X-Gm-Message-State: AOAM530PMzJXs0fK3TYNNlxMqqXKj1KAkIpz4OEuTckfOWlnolpMdmGp wbLRdhWotRmqWe33yH8S+9MZtRkWpI2XdYK/XokUtxCwiy0d8CX/2B1a5FcNVELwM4HMkVcPrie RI0GYlaiYwHA7iQ== X-Received: by 2002:adf:f984:: with SMTP id f4mr2244784wrr.102.1599136129567; Thu, 03 Sep 2020 05:28:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSQ+MU+mHMCK0Ymds2uyXemBfkA9hatSDOQRDvUt5dpj6d430q2JtIhNwlBnkXhCDWfzcZxQ== X-Received: by 2002:adf:f984:: with SMTP id f4mr2244772wrr.102.1599136129408; Thu, 03 Sep 2020 05:28:49 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Fam Zheng , Max Reitz , Keith Busch , Kevin Wolf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Stefan Hajnoczi , Stefano Garzarella Subject: [PATCH v7 09/15] block/nvme: Replace qemu_try_blockalign0 by qemu_try_blockalign/memset Date: Thu, 3 Sep 2020 14:27:57 +0200 Message-Id: <20200903122803.405265-10-philmd@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200903122803.405265-1-philmd@redhat.com> References: <20200903122803.405265-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8"; text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) In the next commit we'll get rid of qemu_try_blockalign(). To ease review, first replace qemu_try_blockalign0() by explicit calls to qemu_try_blockalign() and memset(). Reviewed-by: Stefan Hajnoczi Reviewed-by: Stefano Garzarella Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- block/nvme.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/block/nvme.c b/block/nvme.c index b0d55ecfb25..60e39b69a23 100644 --- a/block/nvme.c +++ b/block/nvme.c @@ -174,12 +174,12 @@ static void nvme_init_queue(BlockDriverState *bs, NVM= eQueue *q, =20 bytes =3D ROUND_UP(nentries * entry_bytes, s->page_size); q->head =3D q->tail =3D 0; - q->queue =3D qemu_try_blockalign0(bs, bytes); - + q->queue =3D qemu_try_blockalign(bs, bytes); if (!q->queue) { error_setg(errp, "Cannot allocate queue"); return; } + memset(q->queue, 0, bytes); r =3D qemu_vfio_dma_map(s->vfio, q->queue, bytes, false, &q->iova); if (r) { error_setg(errp, "Cannot map queue"); @@ -223,11 +223,12 @@ static NVMeQueuePair *nvme_create_queue_pair(BlockDri= verState *bs, if (!q) { return NULL; } - q->prp_list_pages =3D qemu_try_blockalign0(bs, + q->prp_list_pages =3D qemu_try_blockalign(bs, s->page_size * NVME_NUM_REQS); if (!q->prp_list_pages) { goto fail; } + memset(q->prp_list_pages, 0, s->page_size * NVME_NUM_REQS); qemu_mutex_init(&q->lock); q->s =3D s; q->index =3D idx; @@ -521,7 +522,7 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) .cdw10 =3D cpu_to_le32(0x1), }; =20 - id =3D qemu_try_blockalign0(bs, sizeof(*id)); + id =3D qemu_try_blockalign(bs, sizeof(*id)); if (!id) { error_setg(errp, "Cannot allocate buffer for identify response"); goto out; @@ -531,8 +532,9 @@ static void nvme_identify(BlockDriverState *bs, int nam= espace, Error **errp) error_setg(errp, "Cannot map buffer for DMA"); goto out; } - cmd.dptr.prp1 =3D cpu_to_le64(iova); =20 + memset(id, 0, sizeof(*id)); + cmd.dptr.prp1 =3D cpu_to_le64(iova); if (nvme_cmd_sync(bs, s->queues[INDEX_ADMIN], &cmd)) { error_setg(errp, "Failed to identify controller"); goto out; @@ -1283,11 +1285,11 @@ static int coroutine_fn nvme_co_pdiscard(BlockDrive= rState *bs, =20 assert(s->nr_queues > 1); =20 - buf =3D qemu_try_blockalign0(bs, s->page_size); + buf =3D qemu_try_blockalign(bs, s->page_size); if (!buf) { return -ENOMEM; } - + memset(buf, 0, s->page_size); buf->nlb =3D cpu_to_le32(bytes >> s->blkshift); buf->slba =3D cpu_to_le64(offset >> s->blkshift); buf->cattr =3D 0; --=20 2.26.2