From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796214425; b=2zs7Dedsu6HKeyoTXxZqDP+S7Dhksc6VuXn2CBa6bUQiPVYF+ig2/90FfB4rw00UtVQ3 1tKmg2E12L4dUpaNQuLcoDtISKT1tVrdgIx973lz4hRNAbHsqj565o+7ayFrb+P++QjtT jYmLWowPybyiU3X553IuHFfAMMAgD7eKW5OpiJDangl99huF8Ao4L3aqcKXQn2zeU2W79 7ex8rI6IBnYG1EraKsVOvCuAztr4Dn7Z7xBzG0AgHyLat3+SDI/FIiKPmqIBt4MqKHIq0 GLXRXX8dY/O7CEEWhyd9T2DFfRCRc1ngMaW00Wpai6GJPUOubn/VkNIT0soRkTlRL6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796214425; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=MYvepJJc5zOsfBn3oaycCoKhRmmu8RoOBvOdLBjBols=; b=HbcxN4/Atojwh5vWCR5pwrKh+Gi8aIL8ZWFhS7i08tMcDoF2gZ2rEss4LjZK3L4XGwkK 7B33uIf4vTedF/lsNjKM+Nmy64+uGXsGwaGVV19fWELTasdLtTp9fkTxDFI26mI1rywfZ hnagk+fpqlFtGaa76WXPAYweAq+B9PncBjfWxLcwmjeUtSf/G2+QnKZZJy4iW31PNNCAV ToJetp1f7TI8hxEviYlQs4zUd96afNPywFPWgl5Eq5bxstbRzsaj3czIsIPJBHYAGitZz 4TZWRbhQ1/7V6vzjXZEy0CqV08cgO5z2ZfK6+YyTlo2kW0YQ7715nXuoJT5Bcw108Wg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TSpioEHm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7D77A606A31A for ; Wed, 2 Dec 2026 12:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TSpioEHm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21DD31F000C1; Wed, 2 Dec 2026 12:27:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796214425; bh=MYvepJJc5zOsfBn3oaycCoKhRmmu8RoOBvOdLBjBols=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=TSpioEHmivdj2/AVpV/37LzzMZNVtjaQ4dfRofDFbm28QAhfBzWSixTtkIu90Y9ZF 9bgZiZjN1NCnZwNPGunBN7UlKTwUza6lQX/xATlRFVgGlZnEXdEUIAdyzjKMHrazjp C0FEu3a8t120rf275IlQmHD73+oO/E2HbUl5aaRcDpzH8qyTjp0T3vKS3Xoej7NO2S VttRmbtbIo5pSBpmkEX2YajJNGQJ74XoM+TfFqKJ2sm0oWnxtydim/LRcAvUgN5htT t0rqwl3/hr9bhp7Y8dI8XGaqA36vzLYCpwH08NlCi1omXCiiuPJb6Uujj8fZIhm+Tx /YzPzJOZEfeUw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2] PCI: Don't move a window's start when it holds a non-power-of-2 resource Reply-To: sashiko-reviews@lists.linux.dev To: "Greg Lamberson" Cc: linux-pci@vger.kernel.org In-Reply-To: <179621321433.1105012.12699444202985653339@lamco.io> References: <179621321433.1105012.12699444202985653339@lamco.io> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 12:27:04 +0000 X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] PCI: pbus_window_holds_npot() ignores non-power-of-2 child bridge window size -- commit eb9639b607c547d4e76987d498e27e3b03a3d942 Author: Greg Lamberson PCI: Don't move a window's start when it holds a non-power-of-2 resource This commit keeps the aligned start address in pci_align_resource() for a bridge window that holds a resource with a non-power-of-2 size directly or behind child bridges. > diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c > index 376f09630a4ab..5c86a680db89f 100644 > --- a/drivers/pci/setup-res.c > +++ b/drivers/pci/setup-res.c > @@ -260,10 +260,60 @@ resource_size_t pci_resource_alignment(const struct= pci_dev *dev, > return resource_alignment(res); > } > =20 > +/* > + * Whether @win of @bus->self holds, directly or behind child bridges, a > + * resource whose size isn't a power of 2. An IOV resource is the VF BAR= size > + * times TotalVFs, so it's a power of 2 only when TotalVFs is. > + */ > +static bool pbus_window_holds_npot(struct pci_bus *bus, > + const struct resource *win) > +{ > + struct pci_dev *dev; > + > + list_for_each_entry(dev, &bus->devices, bus_list) { > + struct resource *r; > + int i; > + > + pci_dev_for_each_resource(dev, r, i) { > + resource_size_t size; > + > + if (!r->flags || (r->flags & IORESOURCE_DISABLED)) > + continue; > + if (pbus_select_window(bus, r) !=3D win) > + continue; > + /* > + * A child window that holds only optional resources, > + * such as SR-IOV BARs, has size 0 until its own bus is > + * assigned, so look behind it whatever its size. > + */ > + if (pci_resource_is_bridge_win(i)) { > + if (dev->subordinate && > + pbus_window_holds_npot(dev->subordinate, r)) > + return true; > + continue; > + } > + /* > + * is_power_of_2() takes an unsigned long, which would > + * truncate a 64-bit resource_size_t on 32-bit kernels. > + */ > + size =3D resource_size(r); > + if (size & (size - 1)) > + return true; > + } > + } [Severity: Medium] Does skipping the size & (size - 1) check on a child bridge window r when pci_resource_is_bridge_win(i) is true leave the parent window susceptible to the same splitting failure? A child bridge window is allocated as a single contiguous resource inside the parent window, and its total size need not be a power of 2 even when every leaf BAR behind it is (for example, two 16 GiB BARs and an 8 GiB BAR give a 40 GiB child window aligned to 8 GiB). Because r_size > align for that child window, pbus_size_mem() excludes it from aligns[]: drivers/pci/setup-bus.c:pbus_size_mem() { ... if (r_size <=3D align) aligns[order] +=3D align; ... } If the parent bus also has a 32 GiB sibling BAR, the parent window is sized to 72 GiB aligned to 32 GiB. When pbus_window_holds_npot() returns false for the parent window, pci_align_resource() shifts the parent start down by 8 GiB, and placing the 32 GiB sibling BAR at the first 32 GiB boundary splits the parent window into 8 GiB head and 32 GiB tail segments, neither of which can fit the 40 GiB child bridge window. Note that checking size & (size - 1) on child bridge windows inside pbus_window_holds_npot() only constrains parent windows containing a child bridge window; a leaf bridge window is not a child of itself, so relocating a leaf window that holds multiple power-of-2 BARs remains unaffected. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/179621321433.110501= 2.12699444202985653339@lamco.io?part=3D1