From patchwork Wed May 24 11:19:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1785688 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm3 header.b=cWpees63; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=FUCjZgcZ; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QR7yw6Wtsz20Pb for ; Wed, 24 May 2023 21:20:40 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1mWT-00013l-2F; Wed, 24 May 2023 07:19:17 -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 1q1mWR-000133-8p; Wed, 24 May 2023 07:19:15 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1mWO-0005U0-UL; Wed, 24 May 2023 07:19:14 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.west.internal (Postfix) with ESMTP id 02C33320094B; Wed, 24 May 2023 07:19:10 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 24 May 2023 07:19:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1684927150; x= 1685013550; bh=3bvbGpFH5nB/9p9vzminXpFAEYUzSqm0I9KkDrSD2rw=; b=c Wpees63T8upCEsBMnI9TiqyZShqAgJ/LicN7y3vHjNUQV2a+f5xXt7hFgGrjjCUM +VDsjfEOEPVYJyuV/0x85mJMkZIQOzKIg4bX6dYpNnWhAableCZuWvoia/nZK/Hg tnK7EgQWnVLwf55OW7NpfIAEz7cD8CMh4nJs9GdZjDXkmf7cz8ztRKjqD2gaVNVS UzOGIh0sOfx0Jnoc2tUnSJK4VWCK+b8ckFoqbwHmMK0cDwE4TkWnbF9DcgZ+1ecv lPAQY1Znu6JZcJ6uVq02rg/ospiKEPSv+2FG6bGRAYlQEHgX0dudT1Vd43N4JxBT cwvyiIfWreq/dvdCUHGFA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1684927150; x= 1685013550; bh=3bvbGpFH5nB/9p9vzminXpFAEYUzSqm0I9KkDrSD2rw=; b=F UCjZgcZqyhJrNRYNYDTlYt3S/qtMJVxKSXIAN3N9ZyLAnOPDF5R4FR9Pnnv/RH4y 9C1jMRlM6aznw+rFfeMp+TUn1BtQTT+8laHU82YG7K3FzCaNJmMhpT/j21UBOaxT nGe2DVBTKuR+wUU31JY+Pskxg0cf6Lvn84JoMz71+ZdUFwR/bKhoZzm3Oa/wXBXE blKmAn9VvCZwPU+GNQf5lkvLMxsVj2aR3Lh3pK8WEygF4RyWYFdtFV9qRUYFcw7W syZOuxSaJzQw/8RAgoFxYYWU7xH/PZHLVM3s1X2nHlIoiIFo64ibTYNMI09a1tMa v+Kgm21LTdv4pP/QWhSLw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejhedgfeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepudehueeuueektedutddtvddvvdefheefkeelveetkeeffeeuieefveduudfh heetnecuffhomhgrihhnpehruhhhshdrthhonecuvehluhhsthgvrhfuihiivgeptdenuc frrghrrghmpehmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 24 May 2023 07:19:09 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Keith Busch , Jesper Devantier , Klaus Jensen Subject: [PATCH 1/4] hw/nvme: fix verification of number of ruhis Date: Wed, 24 May 2023 13:19:01 +0200 Message-Id: <20230524111904.91179-2-its@irrelevant.dk> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230524111904.91179-1-its@irrelevant.dk> References: <20230524111904.91179-1-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1684; i=k.jensen@samsung.com; h=from:subject; bh=ynMkYum9LI91n9UwJ7qIOfxthXLwXcu/Btdf/0Xz4Tg=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGRt8qhqc2W5WimuJybNSD77nQ3RuYtISuPjx xwtyAA6iBIzPYkBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJkbfKoAAoJEE3hrzFt Tw3pELcH/2PpynuzwtYHXeaSf8OxxeYqU0szpzw4Sjg5NnJyX+x0sVPvY9+i3putGerpwbbUJgK chBeteNskJ4JlZByMDUQAPkbniUZAX+aQYWtvn5HpPN3N/GGk7yYogS40YRvhazM7gnvKR6s5oG 8+lV01y2Q1XwEYl3+TEmJAFUVlUscAKeDs2D88gkM8DBZl+q+TUG7LJsKz2q4p4BOrkd9JMU/jn Ugh1QP6yYQpzAGxapdxwAlE0VAT7NQdfwA4oR0b5Xm6l4uf9Xoo5qUWzT5wQ05WaTBrKbxZzAqR SJxXN8scntlPW1OhVkSZPWbsAboUVBII7YTkzOhIkPihcyPRyUS+o6Ih X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=64.147.123.25; envelope-from=its@irrelevant.dk; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Klaus Jensen Fix a off-by-one error when verifying the number of reclaim unit handle identifiers specified in fdp.ruhs. To make the fix nicer, move the verification of the fdp.nruh parameter to an earlier point. Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation") Signed-off-by: Klaus Jensen --- hw/nvme/ns.c | 4 +--- hw/nvme/subsys.c | 6 ++++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 547c0b154312..050fdaf50fcd 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -438,9 +438,7 @@ static bool nvme_ns_init_fdp(NvmeNamespace *ns, Error **errp) /* parse the placement handle identifiers */ while ((token = qemu_strsep(&p, ";")) != NULL) { - ns->fdp.nphs += 1; - if (ns->fdp.nphs > NVME_FDP_MAXPIDS || - ns->fdp.nphs == endgrp->fdp.nruh) { + if (ns->fdp.nphs++ == endgrp->fdp.nruh) { error_setg(errp, "too many placement handles"); free(r); return false; diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index 24ddec860e45..d30bb8bfd5b4 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -158,8 +158,10 @@ static bool nvme_subsys_setup_fdp(NvmeSubsystem *subsys, Error **errp) endgrp->fdp.nrg = subsys->params.fdp.nrg; - if (!subsys->params.fdp.nruh) { - error_setg(errp, "fdp.nruh must be non-zero"); + if (!subsys->params.fdp.nruh || + subsys->params.fdp.nruh > NVME_FDP_MAXPIDS) { + error_setg(errp, "fdp.nruh must be non-zero and less than %u", + NVME_FDP_MAXPIDS); return false; } From patchwork Wed May 24 11:19:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1785685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm3 header.b=KUi2qBN/; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=cVovPdn9; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QR7yP5vH5z20Pb for ; Wed, 24 May 2023 21:20:12 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1mWU-00014h-L9; Wed, 24 May 2023 07:19:18 -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 1q1mWT-00013n-2y; Wed, 24 May 2023 07:19:17 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1mWR-0005Ud-JC; Wed, 24 May 2023 07:19:16 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.west.internal (Postfix) with ESMTP id 36EE33200CB3; Wed, 24 May 2023 07:19:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Wed, 24 May 2023 07:19:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1684927152; x= 1685013552; bh=MPxNR/d+Be05qsqUSN3DCTwFXaX/ZTGQ2ty+dh5pFmI=; b=K Ui2qBN/SjB9B+3auCdo88/yHXq8LPcyVQbDzpVUhkqlTjT8PJTapNVPPJvkBNRpr VFqV/2nyfjjwnFz0I0kQfnNDCXQn94vg359AP8mbu6xMX4ciGCXLZG/q08f74Zp3 6JyeDZ1f7EfcbgzT5ckJ9RoNuOVVwzd5rj5jpp4a48Wk60HQoEW+0j8ASuX4Fbgr lRnaTF1vXl8/7IMmIBqPHc3dChC0FJwB0ntAj1a1bibRctXbxvoZ0TeIKjMtEKx5 qq1OizHx2UXWyQKlmje6pAz9mBBsgbw/kp9aQ1diZEZ4f91BTy6DLV9HBBcO4EcG jx/vz7EunoIE8FycGl49A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1684927152; x= 1685013552; bh=MPxNR/d+Be05qsqUSN3DCTwFXaX/ZTGQ2ty+dh5pFmI=; b=c VovPdn93wJfO163k+u3tzMiXCgAsNvG1gCFM7LOeZxBtNk/RjCLpQIUE7DXtK5+a xMIEJWcKAM6u6s4ItBCHgn36t+DYNwQST/DWWZgQxG+j94+vb6Rydk76OadpsDnt CZeAeJMofZ0LYIHDaeekdcHEIkHEs2+ie4JHZlK6PZCGRf1ESK6Vv0A+f2ZnKbdM bhKTlfhd4O0VNlmrGn4dsjqF4ka5BTEU78Y717xLVnyOOGMMKjnKIsBS2LIWYhSV 1zlX4X0YzDzJi+MZYpIv+auvhKVej3ifOCl1vSGsOC8G+cJcAnxaOyKLN00fX4wj 5NIu5KfQF1H4Wt1ybYzpw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejhedgfeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepjefgieelgfeiveehkeeuveehheekfeevgeeigfehfefgjeejhefffeegudej udegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 24 May 2023 07:19:11 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Keith Busch , Jesper Devantier , Klaus Jensen Subject: [PATCH 2/4] hw/nvme: verify uniqueness of reclaim unit handle identifiers Date: Wed, 24 May 2023 13:19:02 +0200 Message-Id: <20230524111904.91179-3-its@irrelevant.dk> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230524111904.91179-1-its@irrelevant.dk> References: <20230524111904.91179-1-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1006; i=k.jensen@samsung.com; h=from:subject; bh=QWGUVmkW2V21EYR2tjvALqDu+O3R+BdYoLEGmbgoPL0=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGRt8qhhDGpoUoHt5+oqDFnzManrrwazyP9hi TL1WniFbsenC4kBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJkbfKoAAoJEE3hrzFt Tw3pRMIIAKuuDLnS1KJb5GY6wvL0fshBVAH/V/cTa3PhtHR06b7YgHBuxFqoN7HulGxaY/qnh52 xYLwNRvgQNHakUlcsXvbErkYSiFim9pHChLdNAcz26oE0TV0bPPj+MQsu5VTMt5HaN3WKMjpDeH fOAwHOFdrNb1A9hroto0JXrPT+UCd39/ieJpMFmvFlG40lINCROuaWN5UJp2ZKnQYUuVjn3CkV0 axuskkik6rg/wd75iuWBTaspLOW/X+LN2zs5N2f0mGMbVDPomatedYi8gPfEgZciczxIXU3Ivie aY1ytqBcHflQdja4z9KY5wneW/eDwni3Dj2wMPtO8Ut5tUE/DGcuRK9h X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=64.147.123.25; envelope-from=its@irrelevant.dk; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Klaus Jensen Verify that a reclaim unit handle identifier is only specified once in fdp.ruhs. Fixes: 73064edfb864 ("hw/nvme: flexible data placement emulation") Signed-off-by: Klaus Jensen --- hw/nvme/ns.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 050fdaf50fcd..c4ea2033bb1c 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -453,6 +453,17 @@ static bool nvme_ns_init_fdp(NvmeNamespace *ns, Error **errp) free(r); + /* verify that the ruhids are unique */ + for (unsigned int i = 0; i < ns->fdp.nphs; i++) { + for (unsigned int j = i + 1; j < ns->fdp.nphs; j++) { + if (ruhids[i] == ruhids[j]) { + error_setg(errp, "duplicate reclaim unit handle identifier: %u", + ruhids[i]); + return false; + } + } + } + ph = ns->fdp.phs = g_new(uint16_t, ns->fdp.nphs); ruhid = ruhids; From patchwork Wed May 24 11:19:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1785689 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm3 header.b=gpc3oaej; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=peSPqUYd; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QR7yy5tqsz20Pb for ; Wed, 24 May 2023 21:20:42 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1mWV-00015t-UP; Wed, 24 May 2023 07:19:19 -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 1q1mWU-00014y-Qd; Wed, 24 May 2023 07:19:18 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1mWT-0005VL-AW; Wed, 24 May 2023 07:19:18 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 76688320094B; Wed, 24 May 2023 07:19:15 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 24 May 2023 07:19:15 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1684927155; x= 1685013555; bh=YqGaCzeBP1QNn1kIDA1euHvhKAUTMMU7+EJjuPn+rU8=; b=g pc3oaejqMhhdaQTYueDBSe6N+JNvVuff5ieRZZFrRrGk/P6fL7gTv8Cf3wZxZoxb 8lqb3ThRUCwnUqvUE7TJlEwd9T54FKQYLAXC7QxfSvsg4fPEv+TdiJ9eJePncfdJ NONUHsaD7GakjhB7JGmZhwcXuVA9ZQkB9km6OuEgLxN05juiDMmiIpptFQgyO/0+ WZIeTrmQxY7ipYclQRX9hjPu3Pl/VKBXBJH2SJRYpkZy4L221hUGZsEkz6l+IJue FuRrrfr3KxLUYOjiUMuzZFzcQ7EosaOEkq14ZwPu9Rapgi2vmmX2McVxrRmp4/5t HlS/XdIGY42tLT+MUxlrQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1684927155; x= 1685013555; bh=YqGaCzeBP1QNn1kIDA1euHvhKAUTMMU7+EJjuPn+rU8=; b=p eSPqUYdt7VSzbYpcT3PWpFpBDrrj0eHf5QlvUUr2o/zma3D6aGexdMfYZprSrtaz dFfjJOwQhHG1yWfBgYgiTmG1NCbho76XVodykHXYZW9J5h3s5ojrftTi32gDwsug A++yw2+AdVBzDY/CxkjuZ+ULMdvnTdOkXVb9ASuSOPOXN4nUqU+Y58/ZV8F36iAy 5Ti2dN8yd3PddApS/audiukcfiZ4Gmkz56wgUL4uy0tq5Q46yOEl2nsi0t+XF/P4 Ok+9Al2OGELhIcLqW8+NDy8U/bFUOHreCh5LOwv+3LCMg1JoDibmyRWsyIgG3Ofw yLSfddqv/X2PgV9kFt66g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejhedgfeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepjefgieelgfeiveehkeeuveehheekfeevgeeigfehfefgjeejhefffeegudej udegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 24 May 2023 07:19:13 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Keith Busch , Jesper Devantier , Klaus Jensen Subject: [PATCH 3/4] hw/nvme: add placement handle list ranges Date: Wed, 24 May 2023 13:19:03 +0200 Message-Id: <20230524111904.91179-4-its@irrelevant.dk> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230524111904.91179-1-its@irrelevant.dk> References: <20230524111904.91179-1-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2334; i=k.jensen@samsung.com; h=from:subject; bh=vS8E2scsOJE6wr9X0UOl/Oqkk1vJ57D54CyeDYB3j2Y=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGRt8qjorDoJSCHIewT4lH3hP6bsrZr3hI3gg iAx1Lae8BCuTokBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJkbfKoAAoJEE3hrzFt Tw3px+cIALU2ktFdUJfAbf9Apw6wO+MGOX+eTrN3x30ZEXhmZ4HJtNiJO/uudENotdYgVALP2aX nHb6SApeyrxz4jS0r6MNeaz9FPg6Tb9erae9wC//hL0vu88DWTBtAo9YQ3YYWRQpscmEEGT7y+w gaZBpGBy44W9jpENjH0pcqBiru/QWosfWugNU5b+Sp28spWaMX8ior1O+maH+V5O0/GUZw6R7et VIrIJDl0LK4uVIrzOgO7HBtrW8S1oXlHuAYC9WrBBPEn0bVDOQOxoRkHYHYGEbfzenmhyzI36lD 5iQ/KdDRoGExtIkVRWshDThGvo9Bljl8jzvXkr8RvQxvmEEYA1CDGaoG X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=64.147.123.25; envelope-from=its@irrelevant.dk; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Klaus Jensen Allow the placement handles to be specified as ranges, i.e. `fdp.ruhs=1:3-5` will attempt to assign ruh 1, 3, 4 and 5 to the namespace. Signed-off-by: Klaus Jensen --- hw/nvme/ns.c | 42 +++++++++++++++++++++++++++++++++--------- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index c4ea2033bb1c..44aba8f4d9cf 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -400,8 +400,9 @@ static bool nvme_ns_init_fdp(NvmeNamespace *ns, Error **errp) NvmeRuHandle *ruh; uint8_t lbafi = NVME_ID_NS_FLBAS_INDEX(ns->id_ns.flbas); g_autofree unsigned int *ruhids = NULL; - unsigned int *ruhid; - char *r, *p, *token; + unsigned int n, m, *ruhid; + const char *endptr, *token; + char *r, *p; uint16_t *ph; if (!ns->params.fdp.ruhs) { @@ -438,17 +439,40 @@ static bool nvme_ns_init_fdp(NvmeNamespace *ns, Error **errp) /* parse the placement handle identifiers */ while ((token = qemu_strsep(&p, ";")) != NULL) { - if (ns->fdp.nphs++ == endgrp->fdp.nruh) { - error_setg(errp, "too many placement handles"); - free(r); - return false; - } - - if (qemu_strtoui(token, NULL, 0, ruhid++) < 0) { + if (qemu_strtoui(token, &endptr, 0, &n) < 0) { error_setg(errp, "cannot parse reclaim unit handle identifier"); free(r); return false; } + + m = n; + + /* parse range */ + if (*endptr == '-') { + token = endptr + 1; + + if (qemu_strtoui(token, NULL, 0, &m) < 0) { + error_setg(errp, "cannot parse reclaim unit handle identifier"); + free(r); + return false; + } + + if (m < n) { + error_setg(errp, "invalid reclaim unit handle identifier range"); + free(r); + return false; + } + } + + for (; n <= m; n++) { + if (ns->fdp.nphs++ == endgrp->fdp.nruh) { + error_setg(errp, "too many placement handles"); + free(r); + return false; + } + + *ruhid++ = n; + } } free(r); From patchwork Wed May 24 11:19:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Klaus Jensen X-Patchwork-Id: 1785686 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=irrelevant.dk header.i=@irrelevant.dk header.a=rsa-sha256 header.s=fm3 header.b=ZEi+suiG; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm1 header.b=x4skSto7; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QR7yZ4rQLz20Pb for ; Wed, 24 May 2023 21:20:22 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q1mWZ-0001Bp-Lu; Wed, 24 May 2023 07:19:23 -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 1q1mWX-00016Q-6E; Wed, 24 May 2023 07:19:21 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q1mWV-0005Vy-KD; Wed, 24 May 2023 07:19:20 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id B36AA3200CAF; Wed, 24 May 2023 07:19:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 24 May 2023 07:19:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=cc:cc:content-transfer-encoding:content-type:date:date:from :from:in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1684927157; x= 1685013557; bh=Grh6DrHEmcAnFn1Qk0dmK9BQaoWAbv7gLcA+ZNpjdiQ=; b=Z Ei+suiG5diXS45Pc/9CPN/nvehraRpTBaEzz7u3cVmNEBhFnGWWvNEaMiKJcMalO eZNlltMia10Bi8HCE0laUK66l619MlzBdsJcTx7vRvNBp/bxy6oeY1SdTuetar1F 27kTQ10SHLU462C3rDBDWAewnnN7E5wJCNcOhTxNpiKwA2o8qFckSprr+ypzEef3 3tkf4Wc4KDbIqasRD01u4X+P3injy+X+WP2W6etyqWPJKi1XuXcwCcqTPxa8Vxme PR1Pg5AWWt3/zW07pkt9zv3BQvw0MA/+ruqDSKAEC1vB4Q4Bb7ivzLGAeybn1efR qOC++jvoNFSsJP29obXrA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1684927157; x= 1685013557; bh=Grh6DrHEmcAnFn1Qk0dmK9BQaoWAbv7gLcA+ZNpjdiQ=; b=x 4skSto7qPmsv7zC2TQAHuDWMNxGgyU91hFbnfLYwTAVTnEh03HgpUoOQckBHILaE SMzqAurMkFqj/ky3pxgIRY/9G87cMUq/2w2xC6/cVoVTsTioF9qxRUWB9J2+IF9M H5P3HM/WrJzPmyVhOql6C27XceH8xcnfT7gi4uYuIbCvre2HP4UQhk8Pby6rTeLW HPzP1h78pYH2BzkPsyduHFdmVJqHQEl5x+fvEOSU8mhlajrMLhU8mwfu5L23/7MH qMrgD47nPzwSsCrnElMf+JjMpXE3PUpODZ7DqIpYLsx6RAW8Kq8iDnYNFThPL8es Epr1OZDXRThU0SZrWkHjQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeejhedgfeejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepjefgieelgfeiveehkeeuveehheekfeevgeeigfehfefgjeejhefffeegudej udegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 24 May 2023 07:19:16 -0400 (EDT) From: Klaus Jensen To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, Klaus Jensen , Keith Busch , Jesper Devantier , Klaus Jensen Subject: [PATCH 4/4] docs: update hw/nvme documentation for TP4146 Date: Wed, 24 May 2023 13:19:04 +0200 Message-Id: <20230524111904.91179-5-its@irrelevant.dk> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230524111904.91179-1-its@irrelevant.dk> References: <20230524111904.91179-1-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2263; i=k.jensen@samsung.com; h=from:subject; bh=TJrB+rTXW0/5/nfN8WmCGPKxSketd2L0e0mYGODsu48=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGRt8qidaynVoM7JkWbVCgT3GK/7MsuuGfpSo XPqMRdhn7ciTokBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJkbfKoAAoJEE3hrzFt Tw3pQzAH/jWVyAyW9A/zHR1e8l2nOytsm/ozfnff+WZQtXyLW4zCCZCkAQeMumtCvRQezyj5+xw yn+DTxcV6h7ciSnHz5OSKWS8V02Gxv9NdfF8eB/lABH5DP+FB49Dv2jDi13R5EjJoo71M2wwQ5X GYnWhI0xchM25DBMWJGlQVHXB04xIALr1+FADiaBP75zMymquYkYoylU1it7Akn2kgBbg3wjmeU zxI5K7OWPWEVkQWzZ0KP5EfOf5BCAaTLT8StDsfzq8/5r2c/Npy7mUvDs6oMeGQbDEDhxN390vN 1yRJGtIZVRS06Rmuj1zd+HAeLGxRQyHROtjq9jejS9bc7ERGozUU76Qx X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 Received-SPF: pass client-ip=64.147.123.25; envelope-from=its@irrelevant.dk; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Klaus Jensen Update documentation for TP4146 ("Flexible Data Placement") emulation. Signed-off-by: Klaus Jensen --- docs/system/devices/nvme.rst | 37 +++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/docs/system/devices/nvme.rst b/docs/system/devices/nvme.rst index 30f841ef6222..a8bb8d729cd2 100644 --- a/docs/system/devices/nvme.rst +++ b/docs/system/devices/nvme.rst @@ -212,6 +212,41 @@ The namespace may be configured with additional parameters the minimum memory page size (CAP.MPSMIN). The default value (``0``) has this property inherit the ``mdts`` value. +Flexible Data Placement +----------------------- + +The device may be configured to support TP4146 ("Flexible Data Placement") by +configuring it (``fdp=on``) on the subsystem:: + + -device nvme-subsys,id=nvme-subsys-0,nqn=subsys0,fdp=on,fdp.nruh=16 + +The subsystem emulates a single Endurance Group, on which Flexible Data +Placement will be supported. Also note that the device emulation deviates +slightly from the specification, by always enabling the "FDP Mode" feature on +the controller if the subsystems is configured for Flexible Data Placement. + +Enabling Flexible Data Placement on the subsyste enables the following +parameters: + +``fdp.nrg`` (default: ``1``) + Set the number of Reclaim Groups. + +``fdp.nruh`` (default: ``0``) + Set the number of Reclaim Unit Handles. This is a mandatory paramater and + must be non-zero. + +``fdp.runs`` (default: ``96M``) + Set the Reclaim Unit Nominal Size. Defaults to 96 MiB. + +Namespaces within this subsystem may requests Reclaim Unit Handles:: + + -device nvme-ns,drive=nvm-1,fdp.ruhs=RUHLIST + +The ``RUHLIST`` is a semicolon separated list (i.e. ``0;1;2;3``) and may +include ranges (i.e. ``0;8-15``). If no reclaim unit handle list is specified, +the controller will assign the controller-specified reclaim unit handle to +placement handle identifier 0. + Metadata -------- @@ -320,4 +355,4 @@ controller are: .. code-block:: console - echo 0000:01:00.1 > /sys/bus/pci/drivers/nvme/bind \ No newline at end of file + echo 0000:01:00.1 > /sys/bus/pci/drivers/nvme/bind