From nobody Tue Nov 26 05:50: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