From nobody Tue Nov 26 03:38:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1710184359; cv=none; d=zohomail.com; s=zohoarc; b=UPWUrr5RAXYeSIVoKehYTjuz6JtRQu1pZYcV6IaIO3fQ47zU/OASLG7k80s+T8hgihe3Pzwo4OmR7eRTuJi6/jvAYjm3UCnbXbdFtIUvkt4KoA1P6QZdHmcDXBBar4ESbZcL88t4+C/xGHCNUAv1HoLwtatUHi5biqvs5zcPs9E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710184359; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=l7VA1kmIdj5go01fibCCpJkzwEtHzwcL+nZbGerYsTM=; b=MhsayyHBzkQurlzz61OImNmqJC5UdXolTkDhm9ZYm6WNsg6eHxW/0TDuJYTEADKQBZoPYET8DVGjR+StujRImEdCcLLAYYDNpKk7R/o+H+YsVWQGooxe18WV8Z1OzNjBLKaqrrBjwyxe/QV8IhpA9JcvjJoMdZuPSkje1+BkKKo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1710184359511933.1826552821193; Mon, 11 Mar 2024 12:12:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjl3V-0001mX-Dx; Mon, 11 Mar 2024 15:11:25 -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 1rjl3S-0001kb-Vi; Mon, 11 Mar 2024 15:11:23 -0400 Received: from wfhigh7-smtp.messagingengine.com ([64.147.123.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjl3R-0000CQ-7t; Mon, 11 Mar 2024 15:11:22 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.west.internal (Postfix) with ESMTP id D36E318000CF; Mon, 11 Mar 2024 15:11:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 11 Mar 2024 15:11:19 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Mar 2024 15:11:14 -0400 (EDT) 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:subject:subject:to:to; s=fm3; t=1710184277; x= 1710270677; bh=l7VA1kmIdj5go01fibCCpJkzwEtHzwcL+nZbGerYsTM=; b=F 0qgqDc/1dbyTxDraVxmRbM8oB3KXN5U2rXHvLiMsryXFo9HOVAFMwCWx+XmpFii4 xtEGM2NnQbVA3fHMc07LSlf0ZjMciXJhqMmuL0wkutTBlNL4UOQQozfJgcK39rS0 gdYilo3HviDSG0F72lPuIxxAwgyKDT0nYtE1337OXu2SjV8VzvgONi0rIcN458FB qa33dzDsXDwLQX8Zo2DJk8ZIC6Gcf4robs1zWMBVy0/ebsRi5C2pLPC77hNsoymp yTXDi619Pyu1cVoEkNF2sy0jS7/uOkibrUKj/xqpV9gvdeUMJb+POgirb8Ec7rTU BY59GAeXOLsIXQnqwtj+A== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1710184277; x= 1710270677; bh=l7VA1kmIdj5go01fibCCpJkzwEtHzwcL+nZbGerYsTM=; b=W VLYRFQJvlwXk5mdAlhPv3dr0/PCpqYB03s6F8FsW7Opchk5C1rtj7oXEivr1nns1 MLAT/IGjVUDWwhrsl3/C7+2gbUuupRMpun5ruS/d2AYqli2fDo2eqt2UaYmoOQnM b49O/f3EW5Vo3KMX1/NjwIwTqC8Djq9N1pOdYgXSvdlSqxAaK5HSBVkgD1u4cPz9 dSdhSlSP3V/inbgDfty6WNhliCHqC/U6iZYVdOfVFmZXNdAyIkmk+DnGGfH+YJRK 3j1VREkPE2iYJEwmwlN7nl5RInLloG8pFAu4R2QmyPhNN93RH8Y7hvWZH6jrs+Dg JPM2zkCkCzvU/RnCPWTRw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedugdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepjefgieelgfeiveehkeeuveehheekfeevgeeigfehfefgjeejhefffeegudej udegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Klaus Jensen , Jesper Devantier , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Keith Busch , Minwoo Im , qemu-stable@nongnu.org, Klaus Jensen Subject: [PULL 1/6] hw/nvme: separate 'serial' property for VFs Date: Mon, 11 Mar 2024 20:11:07 +0100 Message-ID: <20240311191105.35224-9-its@irrelevant.dk> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311191105.35224-8-its@irrelevant.dk> References: <20240311191105.35224-8-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1724; i=k.jensen@samsung.com; h=from:subject; bh=XddK9fgznLnaxCGQz8aWhKGnoFKoCfbUCAuoljS2hIM=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGXvV0oZj5olpC72zzipnjwY6NMt1OnU4pj+p RI2dDcXbu+bZokBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJl71dKAAoJEE3hrzFt Tw3peDkH/jW4o08oZ/CXnRPync5YzdBE4EqeDL7PMB0O/G2U64s+QjhrVx8jaeKyIl6zZAbckgm vGjL9Yx6aEy8wQM5z+y9fne/dBUcRE85sAk1WqgWlICnbE27Mk6+67IsMWI21kgcRj0AzbpeQ+M orRGNGoNTNePo/Qzqb2g6EcRqOP7E1rCGtrQ3bvo0cYGf1IJaOyMju7C41MZhLSRvNTJ8k0xJI4 80USYzjOdXp/mO9lLhQ1OVuSzS+FsT6qska6sTorlUG3JHbMRwAMU+pbnGQjf7ciJRO2zbAAHXV mo4nD3Wp+UqYFiOr4LS2Z2Zc+qlTMd9ypMzD/qcvNKgHPNTqkm60Pqkf X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 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=64.147.123.158; envelope-from=its@irrelevant.dk; helo=wfhigh7-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_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @irrelevant.dk) X-ZM-MESSAGEID: 1710184361166100003 Content-Type: text/plain; charset="utf-8" From: Minwoo Im Currently, when a VF is created, it uses the 'params' object of the PF as it is. In other words, the 'params.serial' string memory area is also shared. In this situation, if the VF is removed from the system, the PF's 'params.serial' object is released with object_finalize() followed by object_property_del_all() which release the memory for 'serial' property. If that happens, the next VF created will inherit a serial from a corrupted memory area. If this happens, an error will occur when comparing subsys->serial and n->params.serial in the nvme_subsys_register_ctrl() function. Cc: qemu-stable@nongnu.org Fixes: 44c2c09488db ("hw/nvme: Add support for SR-IOV") Signed-off-by: Minwoo Im Reviewed-by: Klaus Jensen Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 76fe0397045b..94ef63945725 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8309,9 +8309,15 @@ static void nvme_realize(PCIDevice *pci_dev, Error *= *errp) if (pci_is_vf(pci_dev)) { /* * VFs derive settings from the parent. PF's lifespan exceeds - * that of VF's, so it's safe to share params.serial. + * that of VF's. */ memcpy(&n->params, &pn->params, sizeof(NvmeParams)); + + /* + * Set PF's serial value to a new string memory to prevent 'serial' + * property object release of PF when a VF is removed from the sys= tem. + */ + n->params.serial =3D g_strdup(pn->params.serial); n->subsys =3D pn->subsys; } =20 --=20 2.44.0 From nobody Tue Nov 26 03:38:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1710184362; cv=none; d=zohomail.com; s=zohoarc; b=cPJyLX4MA8upsPzgW9sBbo8IKbVAbF3u4RgQOrUL8waPwdD7UELk9i3AB2KFjbL+/o3iQPNXIsQXIy9jS0WXppYqRkjU2DXdQaLPtLO1Q3LFg+y3kPhogKPb7OVk5abF8bEn+NMfK/G4kp46r0LXfEC9ZTLbgy6idG7HW86q8rY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710184362; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=13jK2IFXNV4aTtLcfKWBEUfG4qVN5gepwxltR43I56A=; b=G6j+XuXNA6Mw2xbl1kVgxeksrQOM8itsEhbQjSBIVEKURvs5jkq8ZguCQfHatl6B/qJL09JvQxySzo/t53o9CNR5bO9/l5js//Y8awehkjgdhxGl/WRYpG2ILzj8GMBqsiOrbNz+eIhqro5ema7DSf7CNdjauyARek3fjCl4Zdo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1710184362906187.1355903831451; Mon, 11 Mar 2024 12:12:42 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjl3a-0001nr-Aq; Mon, 11 Mar 2024 15:11:30 -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 1rjl3Y-0001mm-1c; Mon, 11 Mar 2024 15:11:28 -0400 Received: from wfhigh7-smtp.messagingengine.com ([64.147.123.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjl3W-0000EV-Es; Mon, 11 Mar 2024 15:11:27 -0400 Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.west.internal (Postfix) with ESMTP id F1B43180008B; Mon, 11 Mar 2024 15:11:22 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Mon, 11 Mar 2024 15:11:24 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Mar 2024 15:11:19 -0400 (EDT) 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:subject:subject:to:to; s=fm3; t=1710184282; x= 1710270682; bh=13jK2IFXNV4aTtLcfKWBEUfG4qVN5gepwxltR43I56A=; b=N eBw+O9Q0OO+wPdLZyok5rqRDdjGDC24TTdXE2AxTirW78wYXiA1uN0SoLZgug+4r oC9xJtSY2doEDFTHiIVejtP3+imPmWarXIHfEJ+lviloS7+nRnTOpqz5omq3OUob Tm6WKiHpypw1Mj6yLSFoEhaJAog4wfoV4utVVqcH/RtHbevRNKGFLRlXkgiYAMTE bngMOPkFTNWYOom7L+E4aVH46DKVfmIvj42vo0yEYqJAhB8HJazI91CUjM9Tm1o7 pTaacmwQMiLIHIlMHQgbvblnks6uJc8FeKrc4PjmoXBujgSOPifa0utgbVx7Hnxq tHvhfIqkwSkLOjP6yu92Q== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1710184282; x= 1710270682; bh=13jK2IFXNV4aTtLcfKWBEUfG4qVN5gepwxltR43I56A=; b=e TJ7UKXP0se+Th7OJBMKN6YvkCA4woZ1fQmOtUH6VIb8FX/XiUZe4P5Z6g+IePpa+ qHcuouuzDYXZPycHdno+/qEj8kZFb3Y32Nqn6Pt+qm0AwSC/jMlx77FDxtSLSiFb AarUpcOxYvkfEI3ZPQLsBH/1zgSV025M7tKKuWJjo+6BrZeKvHEkKpWz2xEC15qq BuKGkn/US6G3or5LuSCXKJeBOE5KTJMwNux4/kggdpDIV1xJAIa9ngqcIUbOyLGU 3KfgJwK0sxm2qtuVKa06J3mWjmR/zqlJWzMP88mkWkgDW+rGx7vYL1V2nPxqhCHZ OLa2UMrEUuuFM1BGm+80w== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedugdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepjefgieelgfeiveehkeeuveehheekfeevgeeigfehfefgjeejhefffeegudej udegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Klaus Jensen , Jesper Devantier , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Keith Busch , Klaus Jensen , qemu-stable@nongnu.org, Minwoo Im Subject: [PULL 2/6] hw/nvme: fix invalid check on mcl Date: Mon, 11 Mar 2024 20:11:08 +0100 Message-ID: <20240311191105.35224-10-its@irrelevant.dk> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311191105.35224-8-its@irrelevant.dk> References: <20240311191105.35224-8-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=29IW2qUZendh/4uF6O1NNuOeOuNodGl0+hczTMx8y10=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGXvV0q3MM2YL4haIMM0TcnKl5nI/enGn4KRx 98LSvMfPETdkYkBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJl71dKAAoJEE3hrzFt Tw3plLMH/2niDmHuQ5okyCT6X2puLO9AZqkInlgSowAZUmwSbesqfkl7Ks2wdXBAevYa9ZrgNhZ afUIT6rLOHLfeMkFHlob+LREbukx8Upy2l242Nc7uqc3/uVA+EigKlCkhL9Dkh1Q2yHbyO+5BgL SsiUCGhVj4BjkdINvEWsku9mon3rvewwqYRrVhLbijEjn2aDDtJh8BxVtm4B45/KqhhjrV/DR5j 0m9nXWrmTcou/yMjfSLp2LiAgFcbgUEU55ymcCmZpPJg5dE5St4lFynb4TXnmk1Xa2no1TfuJjl XD8M5Lcuc2iaCgFRaFfjWd6q9Ir/85hcX0FZk9MfOnPlkiHORZMW5akP X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 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=64.147.123.158; envelope-from=its@irrelevant.dk; helo=wfhigh7-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_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @irrelevant.dk) X-ZM-MESSAGEID: 1710184364527100001 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen The number of logical blocks within a source range is converted into a 1s based number at the time of parsing. However, when verifying the copy length we add one again, causing the check against MCL to fail in error. Cc: qemu-stable@nongnu.org Fixes: 381ab99d8587 ("hw/nvme: check maximum copy length (MCL) for COPY") Reviewed-by: Minwoo Im Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 94ef63945725..abc0387f2ca8 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -2855,7 +2855,7 @@ static inline uint16_t nvme_check_copy_mcl(NvmeNamesp= ace *ns, uint32_t nlb; nvme_copy_source_range_parse(iocb->ranges, idx, iocb->format, NULL, &nlb, NULL, NULL, NULL); - copy_len +=3D nlb + 1; + copy_len +=3D nlb; } =20 if (copy_len > ns->id_ns.mcl) { --=20 2.44.0 From nobody Tue Nov 26 03:38:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1710184395; cv=none; d=zohomail.com; s=zohoarc; b=iF5h1UfTdx7HQF1EJyPtKC2DFWJJVWyLDCfdNhE00qCAZoGCVzBQ0SN7yGjzLfTGrJVUM3C4Dog+/ZjWXRe0uuLWzu6HTcnu04vLHrbjTovTOKE0jAvgjWHViNNCMuuW5xypLilsktgCXkB0OkeBEzeQHjjW/3k8vqXRDttYIZM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710184395; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=yzwycJF1YoesaBUmclU+Ge6urJCZcxStE+/F83YbfiM=; b=e8K4lThxir21SY7pJByOeaRBsLDvqQDcx8fTNvylqewSDVkEAO106EyawIvJa0nydN0zDFUxIKp2eMJch9I1eatirEEhJnOvFKyxtiEdv5L8ysU15YryhyZJ5y7LflXawR6h71rta8IBFNAqR1F20ptekQ9MkpUltuqaHGWXOaA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1710184395251473.51435963168046; Mon, 11 Mar 2024 12:13:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjl3e-0001ol-1O; Mon, 11 Mar 2024 15:11:34 -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 1rjl3b-0001nx-Ro; Mon, 11 Mar 2024 15:11:31 -0400 Received: from wfhigh7-smtp.messagingengine.com ([64.147.123.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjl3a-0000F3-9S; Mon, 11 Mar 2024 15:11:31 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.west.internal (Postfix) with ESMTP id 7A45F180009E; Mon, 11 Mar 2024 15:11:27 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Mon, 11 Mar 2024 15:11:28 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Mar 2024 15:11:24 -0400 (EDT) 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:subject:subject:to:to; s=fm3; t=1710184287; x= 1710270687; bh=yzwycJF1YoesaBUmclU+Ge6urJCZcxStE+/F83YbfiM=; b=k KUr6P1D0psBQwHvdkrVfB/MusGaEbsWCSAd9UmADdE8GVh4XAZGDI2C+3CobGpxT Dufz7XAmGkvs6i48g+zEt/NdVBYhWrd5ZLVYP5CXWNp6wqMlBLKXT2alJBz+zIRe lTkDIu959j7ok4MzgxlxVQe4LFzbZ5kUNb6wjnb8roQMN0ZGJf4zE4Pwvthv2Plu MadhrpLfPdOVBFbeMF9EM0UvmqTIieHAm8mOXp79/N1nKG/LaYvoSgxk3UBVAhYe rZYZP1TZrcA/Iayt02t6P36s7W+FCV0vOK2nnoZMs2j7OqOh33J5xvu9mbQHQrcL qyd2D3qHyjIHbmSaveMxQ== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1710184287; x= 1710270687; bh=yzwycJF1YoesaBUmclU+Ge6urJCZcxStE+/F83YbfiM=; b=X 34rP4Qm2pAM5T+o6ZVXS4RJsdZUDyZyZT64rq1XdYm3i0xTV1rKsMo/0z40X8bqM kPa/PyuOJjP8OwTjb2YWSBfiqnox8jdtZ2QTWk2H5KOis+tzohRzPlXDOyGQuIuK Ziuetp6W0jVa9KVJYjmOFM2E9rLXFaQnLpXdWqFe1aVGgfzToX80pzUVGt35+ApF 6G7T0896YqWJm2qw4YAdudMWoBQe7Bkdvj5DBaPE7/OejZsQ0ai08D1FhH5TnC9k xl4S3j+sLvWLIm4nH30NFAjq6dp7fyciu6/NNVvJ9zxEh/mKbHCKQA0xe45kuyFT RpMO5xhcBj6A1g0RBxhlw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedugdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepjefgieelgfeiveehkeeuveehheekfeevgeeigfehfefgjeejhefffeegudej udegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Klaus Jensen , Jesper Devantier , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Keith Busch , Klaus Jensen Subject: [PULL 3/6] MAINTAINERS: add Jesper as reviewer on hw/nvme Date: Mon, 11 Mar 2024 20:11:09 +0100 Message-ID: <20240311191105.35224-11-its@irrelevant.dk> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311191105.35224-8-its@irrelevant.dk> References: <20240311191105.35224-8-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=709; i=k.jensen@samsung.com; h=from:subject; bh=KwZk2OfOX/c12vcnmuOOH6UBK2IEVxYGtINXXuDLU/s=; b=owJ4nJvAy8zAxej7cL1hrj/vS8bTakkMqe/DvZTtuv9uu/VqwrO3shV7fu9TWx6iXbZ/p57HJ t05B2qjdV93MhqzMDByMciKKbIEaRivKn1059ki97QDMINYmUCmMHBxCsBEslw4GBoz5P3e6y7e Oo+BY/9vbt1N5X+POe11PqP7ttVTR2Ta7p3PfXjrX5t1e1tJh27p6Lk8pyI+20W3IuQkN5Pphss zi8LWMHg2WOw5tpPnxAEhlanhkXbvb25+mBQk4pJ0MfhiofR1boPeEy+jxb4vsNON+REnEfEhse 5Skpjn4bg1R4xU1P9yyq1u+67oXWmSvv2AZviHhudZt0zb6/LKw6ov5sQtf18g/WyFvd++E0bXr dapFvhXb1y9fqtpw125Zl6D/TGiChmCvlHW2+el3j5caKo+kTmq9Mj7FcsmnPfotIqb8OT9Oktf bnE185r69V4B3fNe1cRZtjouLm3vulrOwWFvMWNT+QRn7R8AR26i4A== X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 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=64.147.123.158; envelope-from=its@irrelevant.dk; helo=wfhigh7-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_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @irrelevant.dk) X-ZM-MESSAGEID: 1710184396684100001 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen My colleague, Jesper, will be assiting with hw/nvme related reviews. Add him with R: so he gets automatically bugged going forward. Cc: Jesper Devantier Acked-by: Jesper Devantier Signed-off-by: Klaus Jensen --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 4d96f855de5c..e21e18e93c63 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2407,6 +2407,7 @@ F: docs/system/devices/virtio-snd.rst nvme M: Keith Busch M: Klaus Jensen +R: Jesper Devantier L: qemu-block@nongnu.org S: Supported F: hw/nvme/* --=20 2.44.0 From nobody Tue Nov 26 03:38:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1710184359; cv=none; d=zohomail.com; s=zohoarc; b=bjpJrO+ZoePdELCaxCB+EAjR7o5qltkiMoDx0+VBI7CpS9TmG0MwLs42b71E4wyPPFGDGkeevgFlKghIt6CXkmTllGy/tiTO2KOaqdIYG5O0En+PSfMj0Mv/2NihCtjilaEnf8x99F5dOlrETZuLU7invpRxD5XSq7crMg7QC4I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710184359; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CL070b4BGR4o23FsAxR9eeclFDLoEOJMatO1Gas4ulo=; b=KoHZe7jS6v9xW/GBHggV2RtHiOK6BXy5Iz5chEiaffy4tb4H+vm4tr169w68JEK7ktAvi3w0yuWde976NlezGphHC/9tCvduSoD4zk5s3qxo2n9dXIxY6Rt3nHO30mCarRmvSomHxSqJOaWsuXaCLgVtUkmVx1wJ0V5hB3jkOiA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 17101843597341000.7209569941645; Mon, 11 Mar 2024 12:12:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjl3k-0001pR-Dv; Mon, 11 Mar 2024 15:11:40 -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 1rjl3i-0001p7-G6; Mon, 11 Mar 2024 15:11:38 -0400 Received: from wfout6-smtp.messagingengine.com ([64.147.123.149]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjl3g-0000FH-3Q; Mon, 11 Mar 2024 15:11:38 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailfout.west.internal (Postfix) with ESMTP id 2DA641C000BB; Mon, 11 Mar 2024 15:11:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 11 Mar 2024 15:11:34 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Mar 2024 15:11:29 -0400 (EDT) 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:subject:subject:to:to; s=fm3; t=1710184292; x= 1710270692; bh=CL070b4BGR4o23FsAxR9eeclFDLoEOJMatO1Gas4ulo=; b=L rOYtRDgATYoryK87GewGCbJxyPb0zjQmJmYUrIMMv7RmD/rsZlC6c95NeJz67nqH VjDhURglxY43E5jRiOijKBWTN1tpMp57UpG8F3aZJJsbeCRqUktu+dqLk4DW+uqU xk5I5BG4iGzDpHAzBAc7M5yYWHloR8M6K1ouMQVel4UsqL3ReMACqF16YK2psiIk 1eNtb4yakBabDOQ6j/sInIQ4lRlaHlAG1L8cD7YZzXX1mou3WFPqbLdbeDpWRtZw xgWenr0/vxiNseROKX2FzyO3AQ4cDudfaSy+WunV7HVr9ETKKyUmk1NyF4VxfLVe Oon3pd9JQqBBMVKnyfYJw== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1710184292; x= 1710270692; bh=CL070b4BGR4o23FsAxR9eeclFDLoEOJMatO1Gas4ulo=; b=I T8K3i7cBCLxylVS03mqOmUbFtZdn8LcY5iesm5MbRgCCmA2Bg0ZV2tO5+z6ymFMI dZA2DjhI8alm7aeINRuv//l6vK2G4mzg6a0XE8eHOSGTrOEdEdJXuHMwvv3ro8H2 iVvghrkDhOKWHR/XkLEtrU222NfWX6VQzZ7bH0iVJt7uC+6UWhcVKQlochWFn0ia FN2xTsmQK/iJjUKJ5aZ2GiJWxlyq+8eZxACBD3dbjruC83tX1/GTuFnVZHcWKYG4 DTI+7HPkFADETlwBtrAhnhtth9S97omnkRGrXgl1WCUaXYhhsxryBiJx94G1D4l8 gUst9V+2y0XWQMNLmZxXQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedugdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepteeffeffieelheeuvedtieejfeduleejheeigfegtdefhedtuedvgfffgeej jeeknecuffhomhgrihhnpehnghhuihgurdgurghtrgenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Klaus Jensen , Jesper Devantier , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Keith Busch , Roque Arcudia Hernandez , Nabih Estefan , Klaus Jensen Subject: [PULL 4/6] hw/nvme: Add NVMe NGUID property Date: Mon, 11 Mar 2024 20:11:10 +0100 Message-ID: <20240311191105.35224-12-its@irrelevant.dk> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311191105.35224-8-its@irrelevant.dk> References: <20240311191105.35224-8-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=11228; i=k.jensen@samsung.com; h=from:subject; bh=if9pvYLcwRx1YNXtDGaMFbOULNcR5Y8rsNcfNn8aV94=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGXvV0oP5IoqhCHIv52aJdfZsMKfcA7xShrcc Q3tAN/V597n5okBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJl71dKAAoJEE3hrzFt Tw3pOJsH/3zL6s0vtNEUQPpeNHhYfYN6i+fxMzbzs3mdQEvpAeGUh5X1A/ei6h1g+gNpij5QY+S cRi4Lq/hXqmILtJun8gZ/Rw/xeUETLFyGqEXjhfBTy9eCcbmbB28x4/bFfMAPOj4F9X1rPC0yHN kO2daR0UUAjwV9JbJnlzKZbl2cOgDBIS7esIQ71YhFmN8LFso4gV3ugVzh2lZ76CiI/9FRiSAlY iFZL0QMaxHtfPJfn7lNeW8YybH72BM6qevvdZ0GwkRGfsO/N+iNZOa6CBTYA3uCUfVd/dW2RWj4 oi6cnnqhRwbxzbhea0V63McTQ0eM2Va/avfVtUbkng9+qmjFhNecVa3P X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 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=64.147.123.149; envelope-from=its@irrelevant.dk; helo=wfout6-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_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @irrelevant.dk) X-ZM-MESSAGEID: 1710184361189100005 Content-Type: text/plain; charset="utf-8" From: Roque Arcudia Hernandez This patch adds a way to specify an NGUID for a given NVMe Namespace using a string of hexadecimal digits with an optional '-' separator to group bytes.= For instance: -device nvme-ns,nguid=3D"e9accd3b83904e13167cf0593437f57d" If provided, the NGUID will be part of the Namespace Identification Descrip= tor list and the Identify Namespace data. Signed-off-by: Roque Arcudia Hernandez Signed-off-by: Nabih Estefan Reviewed-by: Klaus Jensen Signed-off-by: Klaus Jensen --- docs/system/devices/nvme.rst | 7 ++ hw/nvme/ctrl.c | 12 +++ hw/nvme/meson.build | 2 +- hw/nvme/nguid.c | 187 +++++++++++++++++++++++++++++++++++ hw/nvme/ns.c | 2 + hw/nvme/nvme.h | 26 +++-- 6 files changed, 229 insertions(+), 7 deletions(-) create mode 100644 hw/nvme/nguid.c diff --git a/docs/system/devices/nvme.rst b/docs/system/devices/nvme.rst index 4ea957baed10..d2b1ca96455f 100644 --- a/docs/system/devices/nvme.rst +++ b/docs/system/devices/nvme.rst @@ -81,6 +81,13 @@ There are a number of parameters available: Set the UUID of the namespace. This will be reported as a "Namespace UUI= D" descriptor in the Namespace Identification Descriptor List. =20 +``nguid`` + Set the NGUID of the namespace. This will be reported as a "Namespace Gl= obally + Unique Identifier" descriptor in the Namespace Identification Descriptor= List. + It is specified as a string of hexadecimal digits containing exactly 16 = bytes + or "auto" for a random value. An optional '-' separator could be used to= group + bytes. If not specified the NGUID will remain all zeros. + ``eui64`` Set the EUI-64 of the namespace. This will be reported as a "IEEE Extend= ed Unique Identifier" descriptor in the Namespace Identification Descriptor= List. diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index abc0387f2ca8..6c5a2b875da8 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -5640,6 +5640,10 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl= *n, NvmeRequest *req) NvmeIdNsDescr hdr; uint8_t v[NVME_NIDL_UUID]; } QEMU_PACKED uuid =3D {}; + struct { + NvmeIdNsDescr hdr; + uint8_t v[NVME_NIDL_NGUID]; + } QEMU_PACKED nguid =3D {}; struct { NvmeIdNsDescr hdr; uint64_t v; @@ -5668,6 +5672,14 @@ static uint16_t nvme_identify_ns_descr_list(NvmeCtrl= *n, NvmeRequest *req) pos +=3D sizeof(uuid); } =20 + if (!nvme_nguid_is_null(&ns->params.nguid)) { + nguid.hdr.nidt =3D NVME_NIDT_NGUID; + nguid.hdr.nidl =3D NVME_NIDL_NGUID; + memcpy(nguid.v, ns->params.nguid.data, NVME_NIDL_NGUID); + memcpy(pos, &nguid, sizeof(nguid)); + pos +=3D sizeof(nguid); + } + if (ns->params.eui64) { eui64.hdr.nidt =3D NVME_NIDT_EUI64; eui64.hdr.nidl =3D NVME_NIDL_EUI64; diff --git a/hw/nvme/meson.build b/hw/nvme/meson.build index 1a6a2ca2f307..7d5caa53c280 100644 --- a/hw/nvme/meson.build +++ b/hw/nvme/meson.build @@ -1 +1 @@ -system_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('ctrl.c', 'dif.c', '= ns.c', 'subsys.c')) +system_ss.add(when: 'CONFIG_NVME_PCI', if_true: files('ctrl.c', 'dif.c', '= ns.c', 'subsys.c', 'nguid.c')) \ No newline at end of file diff --git a/hw/nvme/nguid.c b/hw/nvme/nguid.c new file mode 100644 index 000000000000..829832bd9f41 --- /dev/null +++ b/hw/nvme/nguid.c @@ -0,0 +1,187 @@ +/* + * QEMU NVMe NGUID functions + * + * Copyright 2024 Google LLC + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but WIT= HOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "qemu/osdep.h" +#include "qapi/visitor.h" +#include "qemu/ctype.h" +#include "nvme.h" + +#define NGUID_SEPARATOR '-' + +#define NGUID_VALUE_AUTO "auto" + +#define NGUID_FMT \ + "%02hhx%02hhx%02hhx%02hhx" \ + "%02hhx%02hhx%02hhx%02hhx" \ + "%02hhx%02hhx%02hhx%02hhx" \ + "%02hhx%02hhx%02hhx%02hhx" + +#define NGUID_STR_LEN (2 * NGUID_LEN + 1) + +bool nvme_nguid_is_null(const NvmeNGUID *nguid) +{ + static NvmeNGUID null_nguid; + return memcmp(nguid, &null_nguid, sizeof(NvmeNGUID)) =3D=3D 0; +} + +static void nvme_nguid_generate(NvmeNGUID *out) +{ + int i; + uint32_t x; + + QEMU_BUILD_BUG_ON((NGUID_LEN % sizeof(x)) !=3D 0); + + for (i =3D 0; i < NGUID_LEN; i +=3D sizeof(x)) { + x =3D g_random_int(); + memcpy(&out->data[i], &x, sizeof(x)); + } +} + +/* + * The Linux Kernel typically prints the NGUID of an NVMe namespace using = the + * same format as the UUID. For instance: + * + * $ cat /sys/class/block/nvme0n1/nguid + * e9accd3b-8390-4e13-167c-f0593437f57d + * + * When there is no UUID but there is NGUID the Kernel will print the NGUI= D as + * wwid and it won't use the UUID format: + * + * $ cat /sys/class/block/nvme0n1/wwid + * eui.e9accd3b83904e13167cf0593437f57d + * + * The NGUID has different fields compared to the UUID, so the grouping us= ed in + * the UUID format has no relation with the 3 fields of the NGUID. + * + * This implementation won't expect a strict format as the UUID one and in= stead + * it will admit any string of hexadecimal digits. Byte groups could be cr= eated + * using the '-' separator. The number of bytes needs to be exactly 16 and= the + * separator '-' has to be exactly in a byte boundary. The following are + * examples of accepted formats for the NGUID string: + * + * nguid=3D"e9accd3b-8390-4e13-167c-f0593437f57d" + * nguid=3D"e9accd3b83904e13167cf0593437f57d" + * nguid=3D"FEDCBA9876543210-ABCDEF-0123456789" + */ +static bool nvme_nguid_is_valid(const char *str) +{ + int i; + int digit_count =3D 0; + + for (i =3D 0; i < strlen(str); i++) { + const char c =3D str[i]; + if (qemu_isxdigit(c)) { + digit_count++; + continue; + } + if (c =3D=3D NGUID_SEPARATOR) { + /* + * We need to make sure the separator is in a byte boundary, t= he + * string does not start with the separator and they are not b= ack to + * back "--". + */ + if ((i > 0) && (str[i - 1] !=3D NGUID_SEPARATOR) && + (digit_count % 2) =3D=3D 0) { + continue; + } + } + return false; + } + /* + * The string should have the correct byte length and not finish with = the + * separator + */ + return (digit_count =3D=3D (2 * NGUID_LEN)) && (str[i - 1] !=3D NGUID_= SEPARATOR); +} + +static int nvme_nguid_parse(const char *str, NvmeNGUID *nguid) +{ + uint8_t *id =3D &nguid->data[0]; + int ret =3D 0; + int i; + const char *ptr =3D str; + + if (!nvme_nguid_is_valid(str)) { + return -1; + } + + for (i =3D 0; i < NGUID_LEN; i++) { + ret =3D sscanf(ptr, "%02hhx", &id[i]); + if (ret !=3D 1) { + return -1; + } + ptr +=3D 2; + if (*ptr =3D=3D NGUID_SEPARATOR) { + ptr++; + } + } + + return 0; +} + +/* + * When converted back to string this implementation will use a raw hex nu= mber + * with no separators, for instance: + * + * "e9accd3b83904e13167cf0593437f57d" + */ +static void nvme_nguid_stringify(const NvmeNGUID *nguid, char *out) +{ + const uint8_t *id =3D &nguid->data[0]; + snprintf(out, NGUID_STR_LEN, NGUID_FMT, + id[0], id[1], id[2], id[3], id[4], id[5], id[6], id[7], + id[8], id[9], id[10], id[11], id[12], id[13], id[14], id[15]); +} + +static void get_nguid(Object *obj, Visitor *v, const char *name, void *opa= que, + Error **errp) +{ + Property *prop =3D opaque; + NvmeNGUID *nguid =3D object_field_prop_ptr(obj, prop); + char buffer[NGUID_STR_LEN]; + char *p =3D buffer; + + nvme_nguid_stringify(nguid, buffer); + + visit_type_str(v, name, &p, errp); +} + +static void set_nguid(Object *obj, Visitor *v, const char *name, void *opa= que, + Error **errp) +{ + Property *prop =3D opaque; + NvmeNGUID *nguid =3D object_field_prop_ptr(obj, prop); + char *str; + + if (!visit_type_str(v, name, &str, errp)) { + return; + } + + if (!strcmp(str, NGUID_VALUE_AUTO)) { + nvme_nguid_generate(nguid); + } else if (nvme_nguid_parse(str, nguid) < 0) { + error_set_from_qdev_prop_error(errp, EINVAL, obj, name, str); + } + g_free(str); +} + +const PropertyInfo qdev_prop_nguid =3D { + .name =3D "str", + .description =3D + "NGUID or \"" NGUID_VALUE_AUTO "\" for random value", + .get =3D get_nguid, + .set =3D set_nguid, +}; diff --git a/hw/nvme/ns.c b/hw/nvme/ns.c index 0eabcf5cf500..ea8db175dbd1 100644 --- a/hw/nvme/ns.c +++ b/hw/nvme/ns.c @@ -89,6 +89,7 @@ static int nvme_ns_init(NvmeNamespace *ns, Error **errp) id_ns->mcl =3D cpu_to_le32(ns->params.mcl); id_ns->msrc =3D ns->params.msrc; id_ns->eui64 =3D cpu_to_be64(ns->params.eui64); + memcpy(&id_ns->nguid, &ns->params.nguid.data, sizeof(id_ns->nguid)); =20 ds =3D 31 - clz32(ns->blkconf.logical_block_size); ms =3D ns->params.ms; @@ -797,6 +798,7 @@ static Property nvme_ns_props[] =3D { DEFINE_PROP_BOOL("shared", NvmeNamespace, params.shared, true), DEFINE_PROP_UINT32("nsid", NvmeNamespace, params.nsid, 0), DEFINE_PROP_UUID_NODEFAULT("uuid", NvmeNamespace, params.uuid), + DEFINE_PROP_NGUID_NODEFAULT("nguid", NvmeNamespace, params.nguid), DEFINE_PROP_UINT64("eui64", NvmeNamespace, params.eui64, 0), DEFINE_PROP_UINT16("ms", NvmeNamespace, params.ms, 0), DEFINE_PROP_UINT8("mset", NvmeNamespace, params.mset, 0), diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 5f2ae7b28b9c..392c02942682 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -171,13 +171,27 @@ static const uint8_t nvme_fdp_evf_shifts[FDP_EVT_MAX]= =3D { [FDP_EVT_RUH_IMPLICIT_RU_CHANGE] =3D 33, }; =20 +#define NGUID_LEN 16 + +typedef struct { + uint8_t data[NGUID_LEN]; +} NvmeNGUID; + +bool nvme_nguid_is_null(const NvmeNGUID *nguid); + +extern const PropertyInfo qdev_prop_nguid; + +#define DEFINE_PROP_NGUID_NODEFAULT(_name, _state, _field) \ + DEFINE_PROP(_name, _state, _field, qdev_prop_nguid, NvmeNGUID) + typedef struct NvmeNamespaceParams { - bool detached; - bool shared; - uint32_t nsid; - QemuUUID uuid; - uint64_t eui64; - bool eui64_default; + bool detached; + bool shared; + uint32_t nsid; + QemuUUID uuid; + NvmeNGUID nguid; + uint64_t eui64; + bool eui64_default; =20 uint16_t ms; uint8_t mset; --=20 2.44.0 From nobody Tue Nov 26 03:38:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1710184470; cv=none; d=zohomail.com; s=zohoarc; b=l2jOHN6do3uyWMyg2u3VHYC4uO4ISWPna3QBxmHEiigJkXMilSIR1gG4Oi7rg3k22DM0AdszPgOkcHNfwvBG3vbcBqcaDzYb/r15e80l2Y1oKBzqDSDIResdshD7kDS9cx+4XC4Plul4fFbetwxESSnlhv3B6A7t7SnPGyQODDg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710184470; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=36zri1GcmnYjWuiUbS/DYfGvFGJWspbBOoOk5UfdR7E=; b=hCH/o5YpSGxCVZa18GnBw/wMIVyNf8oKN928m1zlPycJfloN1hZA8u7eo4GtVCuwUGy5/5/n3DUi5vOVFkLqLnnPh+RIkXUAbpr0QuNkbBc2LsdCym2IpGBWN3z3C4aJHrCpZPP6Axm/lDPVFFe4q8XMXF+kxV4R5UmDQihidcc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1710184470006581.9203445454467; Mon, 11 Mar 2024 12:14:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjl3z-00021u-81; Mon, 11 Mar 2024 15:11:55 -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 1rjl3x-00020y-Gn; Mon, 11 Mar 2024 15:11:53 -0400 Received: from wfout6-smtp.messagingengine.com ([64.147.123.149]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjl3o-0000FZ-SN; Mon, 11 Mar 2024 15:11:53 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfout.west.internal (Postfix) with ESMTP id C1BE21C000C1; Mon, 11 Mar 2024 15:11:39 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 11 Mar 2024 15:11:40 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Mar 2024 15:11:34 -0400 (EDT) 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:subject:subject:to:to; s=fm3; t=1710184299; x= 1710270699; bh=36zri1GcmnYjWuiUbS/DYfGvFGJWspbBOoOk5UfdR7E=; b=s e842zXAkQwXLEME93dnaXMiaK8uWYAtr0NlTc8HsN4mASkE7ASqnZrX0pDHWsZKt h+f1pQMBPuVKV7szLczdFvj/6cqey9U2grRfq+JlraxyYmmAwTvgVbCEjAoRYIzA LDQUyNQhTLYhwta9vQTIpR4ffQS4FQCKOvaN3RslMvPvWNy68TUfDIGwGZE7dgLZ Gr81exfaObAIqqW9NCcY2ncM9w1N1W00XVGVACPC/82dHt6uU5ma8q7xUQCQqoPC HgOSdZPfeDf8thJU5Ickd2C8Edf5UNbkb7B6tnOHQTuY5w4H8gmx3muYYmDpcyd8 42q+tU1RA2GtIjLkYWsNw== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1710184299; x= 1710270699; bh=36zri1GcmnYjWuiUbS/DYfGvFGJWspbBOoOk5UfdR7E=; b=A bNfGGPEMdkWje1tib+Ms5vi4XCejX2Ghv1rqLjB4P2GHSv0PMWLMFepHevf2dS8E E6NNGoqlLEjzdc9Oh3RXM/Kul7G6PtIk2t3E5KyLFC7ULqqsAMdW3eYhV+oZje+b hEPtuiktgDjMmp1ldzOc2om/29fwEgz5RanznZjOOwO27EtHcPYR4yt+KQNQS5Fv b+739RbXcXJ9hrw9pUDuhULd1aAqXAqGnrxa0P52uR+cQzh6DcKp/o1c7KT6P7BO CVcelaD+mP8ptFR2QTNnzaRRmaqGDKuWmy4yTZ86OEMAOt2rU+7W2O3xcjSIxCfC vhkwjtk+QZHWp5wmowBow== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedugdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepjefgieelgfeiveehkeeuveehheekfeevgeeigfehfefgjeejhefffeegudej udegnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomhepih htshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Klaus Jensen , Jesper Devantier , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Keith Busch , Klaus Jensen , qemu-stable@nongnu.org Subject: [PULL 5/6] hw/nvme: generalize the mbar size helper Date: Mon, 11 Mar 2024 20:11:11 +0100 Message-ID: <20240311191105.35224-13-its@irrelevant.dk> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311191105.35224-8-its@irrelevant.dk> References: <20240311191105.35224-8-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3040; i=k.jensen@samsung.com; h=from:subject; bh=Iu1VY7eu1syRxpCgT+eHNq1QL+mThEly36cgVUNqMKI=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGXvV0qSCft48nMy3ACHXN/+RxYPNlwhF548q DRQl9v8WhXVoYkBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJl71dKAAoJEE3hrzFt Tw3pbuoH/3Eydkwv8kCZaQ2el3T6HPvbGawBnQr+DpIMA94jzhd8bN/pBdUExLm1mhjVIOVvuGi GyUbDvjv32cmGgSef/UD5tGXs8fK3LH86/gOZwWItVz6R3ocDeX89t3IKePxApi1LFKx1t5vgln vl1lGWH6xOCiiLQwzsnNbUChix8xfPXG+DFtcEEDaKYou5KoxdvuXGqqiMrWPRR8UOBH5D3cxHJ aGOCg2ff/d6K9C7n4/lrLMMQChO36UTHqelp44SJkz1APUCeJRwjXzrHTYjqWRG7ZMZcm8Nirv8 Z47njuy87YQjchm0eq0tw0N8ZveJt3okDHa2J2fW6FWB9V0bGgu0iKfW X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 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=64.147.123.149; envelope-from=its@irrelevant.dk; helo=wfout6-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_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @irrelevant.dk) X-ZM-MESSAGEID: 1710184470711100001 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen Generalize the mbar size helper such that it can handle cases where the MSI-X table and PBA are expected to be in an exclusive bar. Cc: qemu-stable@nongnu.org Reviewed-by: Jesper Wendel Devantier Signed-off-by: Klaus Jensen --- hw/nvme/ctrl.c | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 6c5a2b875da8..5ee8deda22a4 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -8015,13 +8015,18 @@ static void nvme_init_pmr(NvmeCtrl *n, PCIDevice *p= ci_dev) memory_region_set_enabled(&n->pmr.dev->mr, false); } =20 -static uint64_t nvme_bar_size(unsigned total_queues, unsigned total_irqs, - unsigned *msix_table_offset, - unsigned *msix_pba_offset) +static uint64_t nvme_mbar_size(unsigned total_queues, unsigned total_irqs, + unsigned *msix_table_offset, + unsigned *msix_pba_offset) { - uint64_t bar_size, msix_table_size, msix_pba_size; + uint64_t bar_size, msix_table_size; =20 bar_size =3D sizeof(NvmeBar) + 2 * total_queues * NVME_DB_SIZE; + + if (total_irqs =3D=3D 0) { + goto out; + } + bar_size =3D QEMU_ALIGN_UP(bar_size, 4 * KiB); =20 if (msix_table_offset) { @@ -8036,11 +8041,10 @@ static uint64_t nvme_bar_size(unsigned total_queues= , unsigned total_irqs, *msix_pba_offset =3D bar_size; } =20 - msix_pba_size =3D QEMU_ALIGN_UP(total_irqs, 64) / 8; - bar_size +=3D msix_pba_size; + bar_size +=3D QEMU_ALIGN_UP(total_irqs, 64) / 8; =20 - bar_size =3D pow2ceil(bar_size); - return bar_size; +out: + return pow2ceil(bar_size); } =20 static void nvme_init_sriov(NvmeCtrl *n, PCIDevice *pci_dev, uint16_t offs= et) @@ -8048,7 +8052,7 @@ static void nvme_init_sriov(NvmeCtrl *n, PCIDevice *p= ci_dev, uint16_t offset) uint16_t vf_dev_id =3D n->params.use_intel_id ? PCI_DEVICE_ID_INTEL_NVME : PCI_DEVICE_ID_REDHAT_N= VME; NvmePriCtrlCap *cap =3D &n->pri_ctrl_cap; - uint64_t bar_size =3D nvme_bar_size(le16_to_cpu(cap->vqfrsm), + uint64_t bar_size =3D nvme_mbar_size(le16_to_cpu(cap->vqfrsm), le16_to_cpu(cap->vifrsm), NULL, NULL); =20 @@ -8110,8 +8114,8 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *pci= _dev, Error **errp) } =20 /* add one to max_ioqpairs to account for the admin queue pair */ - bar_size =3D nvme_bar_size(n->params.max_ioqpairs + 1, n->params.msix_= qsize, - &msix_table_offset, &msix_pba_offset); + bar_size =3D nvme_mbar_size(n->params.max_ioqpairs + 1, n->params.msix= _qsize, + &msix_table_offset, &msix_pba_offset); =20 memory_region_init(&n->bar0, OBJECT(n), "nvme-bar0", bar_size); memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, "nvme", --=20 2.44.0 From nobody Tue Nov 26 03:38:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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 ARC-Seal: i=1; a=rsa-sha256; t=1710184777; cv=none; d=zohomail.com; s=zohoarc; b=P9/0cvE6qdMtyG84WsI5BOMlMxsQf4CMwdO0ElEtBiAaozPCWvekgckazEduI+ggcxhozlov4O5cyVnNrxVpaxs8VK/DUVuwNiGZKk9JlLyBBgUC5PdJvhINU1iHEdOT4tJmuYaE32B2/k6cQS7x1ThBXq79yciLm8gQ/PUZenI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1710184777; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=xeaA3B6nNY/auJAWVa8Kj/VA+ZcJ5c0DXgBvsxcQDFI=; b=kU5/4cGk2SQ/ciGCAwADfiiLKSk1Nq3f1gxnMAewywj9+yt49quFToQn1inUHKBpqGivxSm2MZ9elnDe6o/o3rFTPr6PldlU1ABZrMpB/HFDHAY33jTBD0qHQdfl3O5hf53oS+XhEWwsUInB8zyuhtBrZXyaK+49mDA+qX34Sks= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1710184777467338.53041326853304; Mon, 11 Mar 2024 12:19:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rjl3v-0001ym-8E; Mon, 11 Mar 2024 15:11:51 -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 1rjl3u-0001xC-93; Mon, 11 Mar 2024 15:11:50 -0400 Received: from wfhigh7-smtp.messagingengine.com ([64.147.123.158]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rjl3s-0000HJ-Cg; Mon, 11 Mar 2024 15:11:49 -0400 Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.west.internal (Postfix) with ESMTP id 8483418000C7; Mon, 11 Mar 2024 15:11:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Mon, 11 Mar 2024 15:11:46 -0400 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Mon, 11 Mar 2024 15:11:41 -0400 (EDT) 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:subject:subject:to:to; s=fm3; t=1710184305; x= 1710270705; bh=xeaA3B6nNY/auJAWVa8Kj/VA+ZcJ5c0DXgBvsxcQDFI=; b=C vjEt6JBG/iXmr/j6d7WgoSOJqo0qfJZJo2u+c3ReJI52cE8q7xKKQ/DtjZ+Hoh3d oL9DCQSJ+pP0TB01WkipVhjRHfBkXVDyGTo7v2J49My/xQ+bB3Y90ugVN9IjBG9Q jM4rBd2z50iuC7wau80DItFwjkLta00CerDGwFb4qtQ5nd3HyyrymzC2JvQ2/MV7 IXkaMGRKuq4r68ewZC83qa9CQBuijSZ2g/YlTAwMgy0catsMjjGvYivyprGIyq+C IvZpRH4EFUVNbEi90EBTP3mQioZQDdK9Umac9Tc84oA9/VGaViWcb24B0gW1PG47 6wkdoqqmpDJKqZsaUPYYg== 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:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1710184305; x= 1710270705; bh=xeaA3B6nNY/auJAWVa8Kj/VA+ZcJ5c0DXgBvsxcQDFI=; b=N uPp4nFgAuFjAaiUx6MDiDeiXFlyoVBltkZryDS0magcgPxfeU/+ddpYvc8scpFe5 2azn93tzr5Yv5MyRyLChbsENAu2w+IBiYc99qMbHG9GHKFr1W9EEaN3tLXiEdfqj DcNOQKZ3TKPEcugk63YU1p5nGlGR2lQTg64sVbo45dPjomnhf9dlmOlhEh/SZVZ8 uOS0NpSH27jSyz5uu5P3oDqC4jlbDnk/X4fONaJqIfRT3GeV4qlZELMTeahYmQD9 IzbNWGENMYJZiaig24uXBkeDllhB59aWu3gZsxbupS45Y/1YjKHCwCWYtjlpyV5i Hzp5qEhdfD3qb/4Oqom4A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrjedugdduvddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepfeehteeghefffeegkefghfegieejkeevfffhjeevfeekudeiieevheetledu jedunecuffhomhgrihhnpehgihhtlhgrsgdrtghomhenucevlhhushhtvghrufhiiigvpe dtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehithhssehirhhrvghlvghvrghnthdrughk X-ME-Proxy: Feedback-ID: idc91472f:Fastmail From: Klaus Jensen To: Peter Maydell , qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-block@nongnu.org, Klaus Jensen , Jesper Devantier , Yanan Wang , Marcel Apfelbaum , Eduardo Habkost , Keith Busch , Klaus Jensen , qemu-stable@nongnu.org Subject: [PULL 6/6] hw/nvme: add machine compatibility parameter to enable msix exclusive bar Date: Mon, 11 Mar 2024 20:11:12 +0100 Message-ID: <20240311191105.35224-14-its@irrelevant.dk> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240311191105.35224-8-its@irrelevant.dk> References: <20240311191105.35224-8-its@irrelevant.dk> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=5456; i=k.jensen@samsung.com; h=from:subject; bh=VqY3EtATqGmHEXsM4cSzQzUsetHUMxEPWtYmWwRlFv0=; b=owJ4nAFtAZL+kA0DAAoBTeGvMW1PDekByyZiAGXvV0t6sqi1p7GZ31HnHJuxtH6FO3kVtfuEN hG0K8k+0rBV64kBMwQAAQoAHRYhBFIoM6p14tzmokdmwE3hrzFtTw3pBQJl71dLAAoJEE3hrzFt Tw3p2joIAKMI14iaH11KGkUQsYXpXugMbyq/IjUbm6DH15yDLkQfpOKEKC+pl+VI/uP2poUawiT qz6l+ZLQq6HWmwQzTC5wqCUGQemCQl+kFl6aV56GETKw4EiEEiWq0/XADPVb/XkC0ekneK80opL XAlS71gE9HgGxAZGCwOa+23hvnwxAPE+l0d8JjM1fDpGq+F8FF+CqcFbBGCM75qfefMykxKlqIq cZnNhLwkD4XZbSyjL9HGW+tEGot+qI7PwmlISmeyDxElZEtS6VMypzoy3DqXYyttLYt+nykgGQa FifLb6updP5Rwixyk8El1PwhTRVRx8KDe/fO0hqAU0pUFYrIwtgNjagz X-Developer-Key: i=k.jensen@samsung.com; a=openpgp; fpr=DDCA4D9C9EF931CC3468427263D56FC5E55DA838 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=64.147.123.158; envelope-from=its@irrelevant.dk; helo=wfhigh7-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_NONE=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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @irrelevant.dk) X-ZM-MESSAGEID: 1710184777849100001 Content-Type: text/plain; charset="utf-8" From: Klaus Jensen Commit 1901b4967c3f ("hw/block/nvme: move msix table and pba to BAR 0") moved the MSI-X table and PBA to BAR 0 to make room for enabling CMR and PMR at the same time. As reported by Julien Grall in #2184, this breaks migration through system hibernation. Add a machine compatibility parameter and set it on machines pre 6.0 to enable the old behavior automatically, restoring the hibernation migration support. Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2184 Fixes: 1901b4967c3f ("hw/block/nvme: move msix table and pba to BAR 0") Reported-by: Julien Grall julien@xen.org Tested-by: Julien Grall julien@xen.org Reviewed-by: Jesper Wendel Devantier Signed-off-by: Klaus Jensen --- hw/core/machine.c | 1 + hw/nvme/ctrl.c | 51 ++++++++++++++++++++++++++++++++--------------- hw/nvme/nvme.h | 1 + 3 files changed, 37 insertions(+), 16 deletions(-) diff --git a/hw/core/machine.c b/hw/core/machine.c index 9ac5d5389a6c..f3012bca1370 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -100,6 +100,7 @@ GlobalProperty hw_compat_5_2[] =3D { { "PIIX4_PM", "smm-compat", "on"}, { "virtio-blk-device", "report-discard-granularity", "off" }, { "virtio-net-pci-base", "vectors", "3"}, + { "nvme", "msix-exclusive-bar", "on"}, }; const size_t hw_compat_5_2_len =3D G_N_ELEMENTS(hw_compat_5_2); =20 diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c index 5ee8deda22a4..6210b7098845 100644 --- a/hw/nvme/ctrl.c +++ b/hw/nvme/ctrl.c @@ -7810,6 +7810,11 @@ static bool nvme_check_params(NvmeCtrl *n, Error **e= rrp) } =20 if (n->pmr.dev) { + if (params->msix_exclusive_bar) { + error_setg(errp, "not enough BARs available to enable PMR"); + return false; + } + if (host_memory_backend_is_mapped(n->pmr.dev)) { error_setg(errp, "can't use already busy memdev: %s", object_get_canonical_path_component(OBJECT(n->pmr.d= ev))); @@ -8113,24 +8118,36 @@ static bool nvme_init_pci(NvmeCtrl *n, PCIDevice *p= ci_dev, Error **errp) pcie_ari_init(pci_dev, 0x100); } =20 - /* add one to max_ioqpairs to account for the admin queue pair */ - bar_size =3D nvme_mbar_size(n->params.max_ioqpairs + 1, n->params.msix= _qsize, - &msix_table_offset, &msix_pba_offset); - - memory_region_init(&n->bar0, OBJECT(n), "nvme-bar0", bar_size); - memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, "nvme", - msix_table_offset); - memory_region_add_subregion(&n->bar0, 0, &n->iomem); - - if (pci_is_vf(pci_dev)) { - pcie_sriov_vf_register_bar(pci_dev, 0, &n->bar0); - } else { + if (n->params.msix_exclusive_bar && !pci_is_vf(pci_dev)) { + bar_size =3D nvme_mbar_size(n->params.max_ioqpairs + 1, 0, NULL, N= ULL); + memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, "nv= me", + bar_size); pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | - PCI_BASE_ADDRESS_MEM_TYPE_64, &n->bar0); + PCI_BASE_ADDRESS_MEM_TYPE_64, &n->iomem); + ret =3D msix_init_exclusive_bar(pci_dev, n->params.msix_qsize, 4, = errp); + } else { + /* add one to max_ioqpairs to account for the admin queue pair */ + bar_size =3D nvme_mbar_size(n->params.max_ioqpairs + 1, + n->params.msix_qsize, &msix_table_offset, + &msix_pba_offset); + + memory_region_init(&n->bar0, OBJECT(n), "nvme-bar0", bar_size); + memory_region_init_io(&n->iomem, OBJECT(n), &nvme_mmio_ops, n, "nv= me", + msix_table_offset); + memory_region_add_subregion(&n->bar0, 0, &n->iomem); + + if (pci_is_vf(pci_dev)) { + pcie_sriov_vf_register_bar(pci_dev, 0, &n->bar0); + } else { + pci_register_bar(pci_dev, 0, PCI_BASE_ADDRESS_SPACE_MEMORY | + PCI_BASE_ADDRESS_MEM_TYPE_64, &n->bar0); + } + + ret =3D msix_init(pci_dev, n->params.msix_qsize, + &n->bar0, 0, msix_table_offset, + &n->bar0, 0, msix_pba_offset, 0, errp); } - ret =3D msix_init(pci_dev, n->params.msix_qsize, - &n->bar0, 0, msix_table_offset, - &n->bar0, 0, msix_pba_offset, 0, errp); + if (ret =3D=3D -ENOTSUP) { /* report that msix is not supported, but do not error out */ warn_report_err(*errp); @@ -8434,6 +8451,8 @@ static Property nvme_props[] =3D { params.sriov_max_vi_per_vf, 0), DEFINE_PROP_UINT8("sriov_max_vq_per_vf", NvmeCtrl, params.sriov_max_vq_per_vf, 0), + DEFINE_PROP_BOOL("msix-exclusive-bar", NvmeCtrl, params.msix_exclusive= _bar, + false), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/nvme/nvme.h b/hw/nvme/nvme.h index 392c02942682..bed8191bd5fd 100644 --- a/hw/nvme/nvme.h +++ b/hw/nvme/nvme.h @@ -536,6 +536,7 @@ typedef struct NvmeParams { uint16_t sriov_vi_flexible; uint8_t sriov_max_vq_per_vf; uint8_t sriov_max_vi_per_vf; + bool msix_exclusive_bar; } NvmeParams; =20 typedef struct NvmeCtrl { --=20 2.44.0