From nobody Sat May 18 19:24:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637309783074247.63643886351258; Fri, 19 Nov 2021 00:16:23 -0800 (PST) Received: from localhost ([::1]:56104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnz4H-0001ta-TL for importer@patchew.org; Fri, 19 Nov 2021 03:16:22 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnyyG-0006wC-1u; Fri, 19 Nov 2021 03:10:08 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:34417) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnyyB-00058c-CY; Fri, 19 Nov 2021 03:10:07 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 4B77E5C0102; Fri, 19 Nov 2021 03:10:01 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 19 Nov 2021 03:10:01 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 19 Nov 2021 03:09:59 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=pA6j83PMhYFTs /LxiS8Ys/jrEzDtiicAn9hwxxAn3Ck=; b=kZSRsx32IiVTrJMFL8OtS8DIZkxKL ogtW0c0+m0A/Cw/cg09vZF4n9XrphLKGCVI/mayLMbpjRNEVKaGT66SgXrVIpB+v /inB1C2WmhIBiDJPXkbszCdjeHu1riOAPv8HvUShV8FsrfNfI6/pa79vQlUjhLYB Mf0jSHXaYB+8284S0HGFztJds53RRLaInDOWMJsunPiXVREHoFTPUmLQpPWBDIQf GeFPTjqE/tr/UhlNAAur7e7bUUzRNqYs0eZGbu6Ufph0t5LlisvzJ/XVfOjerPiO Inflzku7McqaP40TMvaTUAkoDIF/Iw2fT9D8J6nkEdVVzp25ipb+NdRuQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=pA6j83PMhYFTs/LxiS8Ys/jrEzDtiicAn9hwxxAn3Ck=; b=LcJeZg8C XC5Q48VdrZ3U9WjtIarQMyyjsQ3VICaqGJIgjdCJnA5eYFuFprh/BlNPbxTz7rsR 8RnnS8dVtUIS9EBwnkliY/hL8CzpCV9nZVjXRgUudGZdQ3Xb2tMX27ftOS/ncDUY RqlZiLppU3h5pfChhX3CAzBe4hw+Cl8f4tJ92cdkq8qwNezDPzBS0LFHyAZuhgQl BkpCTRr7UxiEJTt0bAtZEMmZ4tYlOM/vcG4TePzxzlgeUqA7XbWRSXp0guo6cH8a LZ8GqRxmzuFCdkuVS/tXTJXwfmf8NFSUtAnD9/03SqDz4VzOLpKD2TTr/JIrd60H oSBZC+htQhndTA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeejgdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL for-6.2 1/3] hw/nvme: reattach subsystem namespaces on hotplug Date: Fri, 19 Nov 2021 09:09:52 +0100 Message-Id: <20211119080954.211927-2-its@irrelevant.dk> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211119080954.211927-1-its@irrelevant.dk> References: <20211119080954.211927-1-its@irrelevant.dk> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.28; envelope-from=its@irrelevant.dk; helo=out4-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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , qemu-block@nongnu.org, Klaus Jensen , Klaus Jensen , Hannes Reinecke , Keith Busch , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1637309785252100001 Content-Type: text/plain; charset="utf-8" From: Hannes Reinecke With commit 5ffbaeed16 ("hw/nvme: fix controller hot unplugging") namespaces get moved from the controller to the subsystem if one is specified. That keeps the namespaces alive after a controller hot-unplug, but after a controller hotplug we have to reconnect the namespaces from the subsystem to the controller. Fixes: 5ffbaeed16 ("hw/nvme: fix controller hot unplugging") Cc: Klaus Jensen Reviewed-by: Keith Busch Signed-off-by: Hannes Reinecke [k.jensen: only attach to shared and non-detached namespaces] Signed-off-by: Klaus Jensen --- hw/nvme/subsys.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/nvme/subsys.c b/hw/nvme/subsys.c index 495dcff5ebb8..fb58d639504e 100644 --- a/hw/nvme/subsys.c +++ b/hw/nvme/subsys.c @@ -14,7 +14,7 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) { NvmeSubsystem *subsys =3D n->subsys; - int cntlid; + int cntlid, nsid; =20 for (cntlid =3D 0; cntlid < ARRAY_SIZE(subsys->ctrls); cntlid++) { if (!subsys->ctrls[cntlid]) { @@ -29,12 +29,20 @@ int nvme_subsys_register_ctrl(NvmeCtrl *n, Error **errp) =20 subsys->ctrls[cntlid] =3D n; =20 + for (nsid =3D 1; nsid < ARRAY_SIZE(subsys->namespaces); nsid++) { + NvmeNamespace *ns =3D subsys->namespaces[nsid]; + if (ns && ns->params.shared && !ns->params.detached) { + nvme_attach_ns(n, ns); + } + } + return cntlid; } =20 void nvme_subsys_unregister_ctrl(NvmeSubsystem *subsys, NvmeCtrl *n) { subsys->ctrls[n->cntlid] =3D NULL; + n->cntlid =3D -1; } =20 static void nvme_subsys_setup(NvmeSubsystem *subsys) --=20 2.34.0 From nobody Sat May 18 19:24:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16373097098891019.3610483853299; Fri, 19 Nov 2021 00:15:09 -0800 (PST) Received: from localhost ([::1]:55606 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnz35-0001Z1-Tr for importer@patchew.org; Fri, 19 Nov 2021 03:15:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnyyE-0006ul-Ss; Fri, 19 Nov 2021 03:10:06 -0500 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:48079) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnyyB-00058m-Ue; Fri, 19 Nov 2021 03:10:06 -0500 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 2E6C35C0183; Fri, 19 Nov 2021 03:10:03 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Fri, 19 Nov 2021 03:10:03 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 19 Nov 2021 03:10:01 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm1; bh=qztWwZIo8ByiX ttN9x1f7gYwn3kBpcJV2veNOz8+HPw=; b=MkGHIB2gByYc0ReRBejCsUkmYh3C7 LftNVgpiEzY64CG1Krv9hfODC5cDjV+iun2LHu9FS05QqngQtLmOa6+ewY0ToHZE 4mfMH5p3+192wXHWOW4delkESzeRka+BpxH/FanVE9F5tn04hz0Z/mTtEr29abC2 JMYg7hl203ylyqn1qSo1Hk21yFZXOetisnZ04L8Xvau9Wi5gddwy8MI3TXZfUBbu 2blHmuRmCCIURZhp37gE7kvvvhrb3NHlCisRC6EF/D20wAyKLte2jLidlj3IsbcY mHFGuHg33CLJ3YPLk6qpuaxiA/LrrMb7Xkt5RleXBuaTWNF5XllcLw1Fg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=qztWwZIo8ByiXttN9x1f7gYwn3kBpcJV2veNOz8+HPw=; b=mm+1yb9J Fo55BsBemi1qrWru1VK+dflqtR2AHrQwbuYLV9fye2q64PTFyAPGQBSCOSmL7D80 Foz4GxJpH8BF/0Qj/LLWUEapPlhbToQ15uGknno3EPcWMETCiOXoVn9z1jWluLD4 aIzG6mJqSUT9hTxozEzzESbVvSr+FJPcsh4UPcxSorF3S5l7EJ1I49l5kRe4MJlS ts1KpJd7orSzVIjv9QfMpy1yjoGkTgTn5SVAjRaw9lW1aq8qWch6Cc1GXuMgojhU yL6h5n0a9bhhh5wKTvXhQKG8cC8xzpZfcroVTUZqIPIKgZiyjMTPH12P1HBdos5+ QWpKVU0vRjzkEg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeejgdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefmlhgruhhs ucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrghtth gvrhhnpeeuleetgeeiuefhgfekfefgveejiefgteekiedtgfdtieefhfdthfefueffvefg keenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehith hssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL for-6.2 2/3] hw/nvme: change nvme-ns 'shared' default Date: Fri, 19 Nov 2021 09:09:53 +0100 Message-Id: <20211119080954.211927-3-its@irrelevant.dk> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211119080954.211927-1-its@irrelevant.dk> References: <20211119080954.211927-1-its@irrelevant.dk> 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+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.28; envelope-from=its@irrelevant.dk; helo=out4-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_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , qemu-block@nongnu.org, Klaus Jensen , Klaus Jensen , Keith Busch , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1637309710934100001 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen Change namespaces to be shared namespaces by default (parameter shared=3Don). Keep shared=3Doff for older machine types. Reviewed-by: Keith Busch Signed-off-by: Klaus Jensen --- docs/system/devices/nvme.rst | 24 ++++++++++++++---------- hw/core/machine.c | 1 + hw/nvme/ns.c | 8 +------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/docs/system/devices/nvme.rst b/docs/system/devices/nvme.rst index bff72d1c24d0..a1c0db01f6d5 100644 --- a/docs/system/devices/nvme.rst +++ b/docs/system/devices/nvme.rst @@ -110,28 +110,32 @@ multipath I/O. This will create an NVM subsystem with two controllers. Having controllers linked to an ``nvme-subsys`` device allows additional ``nvme-ns`` paramete= rs: =20 -``shared`` (default: ``off``) +``shared`` (default: ``on`` since 6.2) Specifies that the namespace will be attached to all controllers in the - subsystem. If set to ``off`` (the default), the namespace will remain a - private namespace and may only be attached to a single controller at a t= ime. + subsystem. If set to ``off``, the namespace will remain a private namesp= ace + and may only be attached to a single controller at a time. Shared namesp= aces + are always automatically attached to all controllers (also when controll= ers + are hotplugged). =20 ``detached`` (default: ``off``) If set to ``on``, the namespace will be be available in the subsystem, b= ut - not attached to any controllers initially. + not attached to any controllers initially. A shared namespace with this = set + to ``on`` will never be automatically attached to controllers. =20 Thus, adding =20 .. code-block:: console =20 -drive file=3Dnvm-1.img,if=3Dnone,id=3Dnvm-1 - -device nvme-ns,drive=3Dnvm-1,nsid=3D1,shared=3Don + -device nvme-ns,drive=3Dnvm-1,nsid=3D1 -drive file=3Dnvm-2.img,if=3Dnone,id=3Dnvm-2 - -device nvme-ns,drive=3Dnvm-2,nsid=3D3,detached=3Don + -device nvme-ns,drive=3Dnvm-2,nsid=3D3,shared=3Doff,detached=3Don =20 -will cause NSID 1 will be a shared namespace (due to ``shared=3Don``) that= is -initially attached to both controllers. NSID 3 will be a private namespace -(i.e. only attachable to a single controller at a time) and will not be -attached to any controller initially (due to ``detached=3Don``). +will cause NSID 1 will be a shared namespace that is initially attached to= both +controllers. NSID 3 will be a private namespace due to ``shared=3Doff`` an= d only +attachable to a single controller at a time. Additionally it will not be +attached to any controller initially (due to ``detached=3Don``) or to hotp= lugged +controllers. =20 Optional Features =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/hw/core/machine.c b/hw/core/machine.c index 26ec54e7261c..53a99abc5605 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -39,6 +39,7 @@ =20 GlobalProperty hw_compat_6_1[] =3D { { "vhost-user-vsock-device", "seqpacket", "off" }, + { "nvme-ns", "shared", "off" }, }; const size_t hw_compat_6_1_len =3D G_N_ELEMENTS(hw_compat_6_1); =20 diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index b7cf1494e75b..8b5f98c76180 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -465,12 +465,6 @@ static void nvme_ns_realize(DeviceState *dev, Error **= errp) "linked to an nvme-subsys device"); return; } - - if (ns->params.shared) { - error_setg(errp, "shared requires that the nvme device is " - "linked to an nvme-subsys device"); - return; - } } else { /* * If this namespace belongs to a subsystem (through a link on the @@ -532,7 +526,7 @@ static void nvme_ns_realize(DeviceState *dev, Error **e= rrp) static Property nvme_ns_props[] =3D { DEFINE_BLOCK_PROPERTIES(NvmeNamespace, blkconf), DEFINE_PROP_BOOL("detached", NvmeNamespace, params.detached, false), - DEFINE_PROP_BOOL("shared", NvmeNamespace, params.shared, false), + DEFINE_PROP_BOOL("shared", NvmeNamespace, params.shared, true), DEFINE_PROP_UINT32("nsid", NvmeNamespace, params.nsid, 0), DEFINE_PROP_UUID("uuid", NvmeNamespace, params.uuid), DEFINE_PROP_UINT64("eui64", NvmeNamespace, params.eui64, 0), --=20 2.34.0 From nobody Sat May 18 19:24:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1637310171945961.097746729619; Fri, 19 Nov 2021 00:22:51 -0800 (PST) Received: from localhost ([::1]:36706 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mnzAY-0008GO-I0 for importer@patchew.org; Fri, 19 Nov 2021 03:22:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45240) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnyyL-0006yy-EM; Fri, 19 Nov 2021 03:10:14 -0500 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:50345) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mnyyG-00059l-7p; Fri, 19 Nov 2021 03:10:13 -0500 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 0DCE758084F; Fri, 19 Nov 2021 03:10:05 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Fri, 19 Nov 2021 03:10:05 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 19 Nov 2021 03:10:03 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm1; bh= TwOfWohAdwfzhbzIUDcE5yVVFa/bT0grKQNbK8jSv34=; b=GGkEQkh/wbYmjfaM pYh2z70Jmd5s4wfFyKzAKc85D0udV1ThbRSRS2iswfVy/NPzxMVLPRiGPSlinzq1 bpcTIfVAxP0b7h3eqhFBASnguC1gv4gsOjk4rLlQu/l1uI4fAtR1zuSUT8HEtiBN sp8SCKSWAfPTq06fe6I3APUxXkG8Qh8xecpLx5cClajAf9ecFFkEgvx7e/tw+zfa FmrXGQEdxOZ/v9KoR7NnG9dUlgy+y2VKHYFBAq+zuBXv+AJlSCFW2dMg/VUqXqDP b+cPikc9Zj1VgDUN93ZRwH9OEtecXGOz1AdgWCbYC2N9yA7CsVwS0UomdXveAQVV l/xryA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; bh=TwOfWohAdwfzhbzIUDcE5yVVFa/bT0grKQNbK8jSv 34=; b=gB/ThoayvMkuqinBUiBAHAd00HsKgrsOPScG4plAX8jAlKFHeuBbaME33 xaJVacYL6EeDBow6a8utpcn27UZT5VjPVHGUORreAU95LXiqbWCWzDXVDigPw4ZE fCoYxaEFJgxvuQOeDjZp2n3hJUkCBjFveZVngJ2LxKMwWwsE5OV6ntzyYW02Ba9h SHE0R0qkiWS9CjiR4XLSW1xsJeA4fJAbvNaOvfYEK8ZgNfNHGA5V5Frc93lN55E4 NhMjGP+imEpDvk1VFe+kQL2y0crQfZa0EZNv0OpZfA2asAc5ePFP0AyyHVIB7YC+ b6X7O7+UTgXJkblQcZnW4UooFfcHw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfeejgdduudehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvufffkffojghfgggtgfesthekredtredtjeenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepteevuedugeevieehgeeileeufeetvddtkeetfeelgeehudfhjeeuledvhfff tdegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Subject: [PULL for-6.2 3/3] hw/nvme: fix buffer overrun in nvme_changed_nslist (CVE-2021-3947) Date: Fri, 19 Nov 2021 09:09:54 +0100 Message-Id: <20211119080954.211927-4-its@irrelevant.dk> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20211119080954.211927-1-its@irrelevant.dk> References: <20211119080954.211927-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Type: 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=66.111.4.229; envelope-from=its@irrelevant.dk; helo=new3-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, SPF_HELO_PASS=-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.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , qemu-block@nongnu.org, Klaus Jensen , qemu-stable@nongnu.org, Qiuhao Li , Klaus Jensen , Keith Busch , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1637310173768100001 From: Klaus Jensen Fix missing offset verification. Cc: qemu-stable@nongnu.org Cc: Philippe Mathieu-Daud=C3=A9 Reported-by: Qiuhao Li Fixes: f432fdfa121 ("support changed namespace asynchronous event") Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 6a571d18cfae..5f573c417b3d 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -4168,6 +4168,11 @@ static uint16_t nvme_changed_nslist(NvmeCtrl *n, uin= t8_t rae, uint32_t buf_len, int i =3D 0; uint32_t nsid; =20 + if (off >=3D sizeof(nslist)) { + trace_pci_nvme_err_invalid_log_page_offset(off, sizeof(nslist)); + return NVME_INVALID_FIELD | NVME_DNR; + } + memset(nslist, 0x0, sizeof(nslist)); trans_len =3D MIN(sizeof(nslist) - off, buf_len); =20 --=20 2.34.0