[{"id":3686691,"web_url":"http://patchwork.ozlabs.org/comment/3686691/","msgid":"<20260505203651.6D631C2BCB4@smtp.kernel.org>","list_archive_url":null,"date":"2026-05-05T20:36:50","subject":"Re: [PATCH 2/3] PCI/IOV: Restore initial VF ReBAR sizes on SR-IOV\n disable/failure","submitter":{"id":93311,"url":"http://patchwork.ozlabs.org/api/people/93311/","name":null,"email":"sashiko-bot@kernel.org"},"content":"Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:\n- [High] Early error returns in sriov_enable() bypass the newly introduced sriov_restore_vf_rebar_initial_sizes() cleanup.\n--\n\ncommit 4da183a318507a36de3ca157ee8755ad1eec90ca\nAuthor: Marcin Bernatowicz <marcin.bernatowicz@linux.intel.com>\n\nPCI/IOV: Restore initial VF ReBAR sizes on SR-IOV disable/failure\n\nThis commit introduces a mechanism to restore the initial VF BAR sizes when\nSR-IOV is disabled or when enabling it fails. This prevents the PCI core\nfrom persisting inflated VF BAR sizes, which can lead to MMIO space exhaustion.\n\nCloses: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/5937\n\n> diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c\n> index 217e133a38c73..a05c1be388d2f 100644\n> --- a/drivers/pci/iov.c\n> +++ b/drivers/pci/iov.c\n\n[ ... ]\n\n> @@ -687,36 +721,42 @@ static int sriov_enable(struct pci_dev *dev, int nr_virtfn)\n>  \t}\n>  \tif (nres != iov->nres) {\n>  \t\tpci_err(dev, \"not enough MMIO resources for SR-IOV\\n\");\n> -\t\treturn -ENOMEM;\n> +\t\trc = -ENOMEM;\n> +\t\tgoto err_restore;\n>  \t}\n\nShould the earlier error returns in sriov_enable() also jump to err_restore?\n\nThere are early validation checks before this point that return directly:\n\ndrivers/pci/iov.c:sriov_enable() {\n    ...\n\tpci_read_config_word(dev, iov->pos + PCI_SRIOV_INITIAL_VF, &initial);\n\tif (initial > iov->total_VFs ||\n\t    (!(iov->cap & PCI_SRIOV_CAP_VFM) && (initial != iov->total_VFs)))\n\t\treturn -EIO;\n\n\tif (nr_virtfn < 0 || nr_virtfn > iov->total_VFs ||\n\t    (!(iov->cap & PCI_SRIOV_CAP_VFM) && (nr_virtfn > initial)))\n\t\treturn -EINVAL;\n    ...\n}\n\nIf an early exit occurs here, the hardware BAR remains inflated and\niov->num_VFs remains 0.\n\nBecause iov->num_VFs is 0, subsequent cleanup calls like pci_disable_sriov()\nduring driver teardown or system shutdown will bypass the restore logic due to\nthe early return in sriov_disable():\n\ndrivers/pci/iov.c:sriov_disable() {\n\tstruct pci_sriov *iov = dev->sriov;\n\n\tif (!iov->num_VFs)\n\t\treturn;\n    ...\n}\n\nWill this leave the hardware BAR permanently inflated across kexec or warm\nreboots, potentially leading to the MMIO space exhaustion this patch aims to\nfix?","headers":{"Return-Path":"\n <linux-pci+bounces-53790-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-pci@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=EpEp1D1H;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-pci+bounces-53790-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"EpEp1D1H\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g99Kh36n9z1yJV\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 06 May 2026 06:36:56 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 1B11E300BBAA\n\tfor <incoming@patchwork.ozlabs.org>; Tue,  5 May 2026 20:36:53 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 282593431F5;\n\tTue,  5 May 2026 20:36:52 +0000 (UTC)","from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 0520531717C\n\tfor <linux-pci@vger.kernel.org>; Tue,  5 May 2026 20:36:51 +0000 (UTC)","by smtp.kernel.org (Postfix) with ESMTPSA id 6D631C2BCB4;\n\tTue,  5 May 2026 20:36:51 +0000 (UTC)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1778013412; cv=none;\n b=ORuCqK63hNMHvNo1QmbNK1lKhGTcNVVgkQW3kgcGHtHItdzc3xuwTIo3upF1nnGwScXDRjGEadfx0Ocwe4WfJ+4lKevRzcCURi9HjQXskuyyIYRBYz1+l7h8SLSXBF9ND5bwKjFCKUCoYNQ6OK49Q1K/SnHL7kOxjxFOJpLSxiM=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1778013412; c=relaxed/simple;\n\tbh=Bl4EzR+RDEf6NeV287iKQmvj4GAWe1mSiV8FLmhGBDg=;\n\th=From:Subject:To:Cc:In-Reply-To:References:Content-Type:Date:\n\t Message-Id;\n b=Dbojww/S77gQpxKMtHc5PXKp6p1NFpA6sYRSpPSYaIfa2tqv6v72cmRNksk7q5i0GpbWCXmj9k9zwdye1Ge5xexdXSoUsmwarOKPW0mjCg4lKdRS23AyyUXUYAffNCQq7i27MuYStArSTWuMz2FOYCFRUc6c9Vyzgoey4vc2s1I=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=EpEp1D1H; arc=none smtp.client-ip=10.30.226.201","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1778013411;\n\tbh=Bl4EzR+RDEf6NeV287iKQmvj4GAWe1mSiV8FLmhGBDg=;\n\th=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date:From;\n\tb=EpEp1D1HcFD8wRoHKBk6j8nArhBEbM3N3Knz009aBSACj/8g9Wl5wHCzdPAlih14y\n\t SSMasXVzlZYTEY1Ue2MezWP/QxwIVYw//9ajs6JYQ3n8NvtZJvSsPx/uYhdvo4LvvS\n\t INtWE8rS1DFsrnE58cqjhEUeuPLfZOPEDcJ/2RQCIJ0zx72Fg37cASKLaToz9j/k7l\n\t KSeTXLY425q5eF/lwh6IJse59R4SH+M54FANgWCmtulyw2hJVOZ3ZFsryPy2ESZjzB\n\t 3UkidyYsTteVZl3IFiSQgA0UTBg7FmMsnSHULVGHWKsAxTgx4RrABve2R9YcsytKUy\n\t 9P3jxiA6SjpzA==","From":"sashiko-bot@kernel.org","Subject":"Re: [PATCH 2/3] PCI/IOV: Restore initial VF ReBAR sizes on SR-IOV\n disable/failure","Reply-To":"sashiko@lists.linux.dev","To":"\"Marcin Bernatowicz\" <marcin.bernatowicz@linux.intel.com>","Cc":"linux-pci@vger.kernel.org","In-Reply-To":"<20260505170010.3414074-3-marcin.bernatowicz@linux.intel.com>","References":"<20260505170010.3414074-3-marcin.bernatowicz@linux.intel.com>","Content-Type":"text/plain; charset=utf-8","Content-Transfer-Encoding":"quoted-printable","Date":"Tue, 05 May 2026 20:36:50 +0000","Message-Id":"<20260505203651.6D631C2BCB4@smtp.kernel.org>","Precedence":"bulk","X-Mailing-List":"linux-pci@vger.kernel.org","List-Id":"<linux-pci.vger.kernel.org>","List-Subscribe":"<mailto:linux-pci+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-pci+unsubscribe@vger.kernel.org>"}}]