From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DCFC443B48C; Tue, 21 Jul 2026 21:49:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670557; cv=none; b=TxLsW3Mcry8bFfrGDg9UfTaI0WPUlVVTh3BkYLoyts/fjipUb2te0VPveM8pwanhtDs5IE0RpJI3kQgn1VI36XWhYNsqC20OkjQupPJWqZcEGxwhAmyzfZGKgK+wnbjToxCGEJxUWhIy4PPp811YjRRpHq2DEaN/ACQ6T+SudM8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784670557; c=relaxed/simple; bh=ttaNS0Ji27DCoLZqBNw9cLoDTpIR1P+qtsvFDHXTW90=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Chdj4RbLPc9I1iCYs9P4jy3thJpA9GHT8ijBYMCW8Y+zgrwox6SUT2aaezCFC/FtbKe4i6R8N0+JIN+wKj+9TFfZTB5hVFraGciCLo0bNnw6BHJRkbLek9zIdflpyXloGTrWEByNGt7RdV3cV+q8HmmhfyoqtJ8VMNTsmKJTNqk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=1a1Ay8Cc; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="1a1Ay8Cc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14BF71F00A3D; Tue, 21 Jul 2026 21:49:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784670555; bh=dhs+yi2B7Jy/Ea+GxaL4gAVXYOzyC1cg7ZJGK6JixHg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=1a1Ay8CcF5myjMkwNBzWdtDY331ZYvkkfJD3yfX2RlmECjJv8GWMcR0935WhhXVxP i4AVc1rNxrsc7Qd8dv9W5tebTVoL2D/OLCCdYqg/zaltu94tF8T+Y6dA3MwL1Ls6E3 R7WHqj0x6RL2WeFuFlfR5wOlqqnt5FV9VyRb8T/g= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Marco Nenciarini , Bjorn Helgaas , Sasha Levin Subject: [PATCH 6.1 0975/1067] PCI: Skip Resizable BAR restore on read error Date: Tue, 21 Jul 2026 17:26:16 +0200 Message-ID: <20260721152446.358747619@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marco Nenciarini [ Upstream commit ee7471fe968d210939be9046089a924cd23c8c3b ] pci_restore_rebar_state() uses the Resizable BAR Control register to decide how many BARs to restore (nbars) and which BAR each iteration addresses (bar_idx). When a device does not respond, config reads typically return PCI_ERROR_RESPONSE (~0). Both fields are 3 bits wide, so nbars and bar_idx both evaluate to 7, past the spec's valid ranges for both fields. pci_resource_n() then returns an unrelated resource slot, whose size is used to derive a nonsensical value written back to the Resizable BAR Control register. Bail out if any Resizable BAR Control read returns PCI_ERROR_RESPONSE. No further BARs are touched, which is safe because a config read that returns PCI_ERROR_RESPONSE indicates the device is unreachable and restoration is pointless. Fixes: d3252ace0bc6 ("PCI: Restore resized BAR state on resume") Signed-off-by: Marco Nenciarini Signed-off-by: Bjorn Helgaas Cc: stable@vger.kernel.org Link: https://patch.msgid.link/666cac19b5daa0ab0e0ab64454e76b4d24465dbd.1776429882.git.mnencia@kcore.it Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/pci/rebar.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/pci/rebar.c +++ b/drivers/pci/rebar.c @@ -131,6 +131,9 @@ void pci_restore_rebar_state(struct pci_ return; pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl); + if (PCI_POSSIBLE_ERROR(ctrl)) + return; + nbars = FIELD_GET(PCI_REBAR_CTRL_NBAR_MASK, ctrl); for (i = 0; i < nbars; i++, pos += 8) { @@ -138,6 +141,9 @@ void pci_restore_rebar_state(struct pci_ int bar_idx, size; pci_read_config_dword(pdev, pos + PCI_REBAR_CTRL, &ctrl); + if (PCI_POSSIBLE_ERROR(ctrl)) + return; + bar_idx = ctrl & PCI_REBAR_CTRL_BAR_IDX; res = pci_resource_n(pdev, bar_idx); size = pci_rebar_bytes_to_size(resource_size(res));