From nobody Mon Feb 9 17:23:46 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1597258590; cv=none; d=zohomail.com; s=zohoarc; b=nS0Wu5P9RSd2wECydHmswpHaam9nKGCHaafoZ+wiefN3IR7s7EJoetlVnsVhPsnjlq3iaxRZbz6rYMn95V5lEIxE9bS7qjr+oilx24rsC44W1wo1Uia5rZds0medIu4qWROzk490EmnD051ohUTfNm7nOIpXcYBnJTwafIH9naM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1597258590; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ly+tZyoT9mB5aIGDZr/lfe6I60y34yWPMg7owP1UeRk=; b=VPyOLnB1To96KbCDOsGx8al+0EzYLuiFv06xgBBtxGsSe/zqp3py6FZXVrFIQIiJAtUqz1QZhp3HTY1wy2hdJ0j15Rx4BuVOE8CQBia3gHtQolRq1QNbGDy4eRXfxop/CSEbeerlVd/zWwsRDO/hvGXvWctuYKKuSFNflBQi74g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1597258590238958.5506495400651; Wed, 12 Aug 2020 11:56:30 -0700 (PDT) Received: from localhost ([::1]:47038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k5vvJ-0002AK-0T for importer@patchew.org; Wed, 12 Aug 2020 14:56:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51122) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k5vq8-0000pm-T3 for qemu-devel@nongnu.org; Wed, 12 Aug 2020 14:51:08 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:49023 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k5vq7-0004hL-2j for qemu-devel@nongnu.org; Wed, 12 Aug 2020 14:51:08 -0400 Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-RERYtswqNCeiZHWDIZsQjQ-1; Wed, 12 Aug 2020 14:51:04 -0400 Received: by mail-wr1-f71.google.com with SMTP id e14so1212572wrr.7 for ; Wed, 12 Aug 2020 11:51:04 -0700 (PDT) Received: from x1w.redhat.com (121.red-81-40-121.staticip.rima-tde.net. [81.40.121.121]) by smtp.gmail.com with ESMTPSA id e4sm5755579wru.55.2020.08.12.11.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Aug 2020 11:51:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597258266; 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=ly+tZyoT9mB5aIGDZr/lfe6I60y34yWPMg7owP1UeRk=; b=St6YFNGrR9+KQXAtlqR0hWU4uS4UjdVqj39TLEX94vl/9pmOX0eaO4+WXg0oIUKQySp2zN jlj6efHUPHLJbLrX1ZEndVrPJp+dXFHIRESfzbModd5Y+7Gv+vtw65D1YocYpyWU7GZJub hJyAGWCmRq0oF6ZVnBVcKGmHd26VtXY= X-MC-Unique: RERYtswqNCeiZHWDIZsQjQ-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=ly+tZyoT9mB5aIGDZr/lfe6I60y34yWPMg7owP1UeRk=; b=KzBhauqYzoM80RcRJ5rQWvQwsiQTncgKXzQB6XwUma3gcFLtuW6Qa6/JTvO5R9P3Kt VO9A5VRMOsAN+T5jhOGNoccbO6G7TikDfWd/CFlaHjAsWa2htMeNBhFsrWtkJrbR2kk8 aMqz/IiaK549mRjP8NyEMwB7BF02pwOohJQzSlktI5gPnBwwf6XOMGcXVOZkfMN87BnB RE/XSyw6FcXJsU7GR4cVroSabGrrRVDCWiAoTQfgjAttTxSQd7nsjENMzIzuMDcIBwlw EEfk51BBZE6vZQVXm87P5CginCa75rwqixxSw2FNbobissnLfATcsTaXndHSzfhuPew7 tHTg== X-Gm-Message-State: AOAM532Kc4TiPzlCDkAagyIm9zfDO5nb/6xASZGo9wzkGJjv3QpM2L7R H8OblhkFp4JbxI7y6BddLc0RMftDeDH77slt+iHbkeGuNFou/GbMGQvp6QzE7w7QBYPPRvf4COP 8F46GMdMYUfop+Z4= X-Received: by 2002:a5d:5704:: with SMTP id a4mr518332wrv.318.1597258263343; Wed, 12 Aug 2020 11:51:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyow9EA+U38+VfAK5Hq0eCQ4nEegdzcIXo+cAk3xZpBp9cOFCXWPdPeJLrAKvCHN15Zc8pF2g== X-Received: by 2002:a5d:5704:: with SMTP id a4mr518316wrv.318.1597258263180; Wed, 12 Aug 2020 11:51:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v4 09/14] block/nvme: Replace qemu_try_blockalign0 by qemu_try_blockalign/memset Date: Wed, 12 Aug 2020 20:50:09 +0200 Message-Id: <20200812185014.18267-10-philmd@redhat.com> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200812185014.18267-1-philmd@redhat.com> References: <20200812185014.18267-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 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/12 03:52:04 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -40 X-Spam_score: -4.1 X-Spam_bar: ---- X-Spam_report: (-4.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Kevin Wolf , qemu-block@nongnu.org, Max Reitz , Stefan Hajnoczi , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) 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 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 2bd1935f95..ac6bb52043 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_QUEUE_SIZE); if (!q->prp_list_pages) { goto fail; } + memset(q->prp_list_pages, 0, s->page_size * NVME_QUEUE_SIZE); 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.prp1 =3D cpu_to_le64(iova); =20 + memset(id, 0, sizeof(*id)); + cmd.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.21.3