mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mohamad Raizudeen <raizudeen.kerneldev@gmail.com>
To: bhelgaas@google.com
Cc: skhan@linuxfoundation.org, jkoolstra@xs4all.nl,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	gregkh@linuxfoundation.org, yinghai@kernel.org,
	Mohamad Raizudeen <raizudeen.kerneldev@gmail.com>
Subject: [PATCH] PCI: probe: Fix 64-bit limit truncation in prefetchable window
Date: Fri, 14 Aug 2026 22:16:52 +0530	[thread overview]
Message-ID: <20260814164652.43501-1-raizudeen.kerneldev@gmail.com> (raw)

In pci_read_bridge_mmio_pref(), the code checks if the 64 bit base
address is truncated on 32 bit pci_bus_addr_t. However, it misses this
same check for the limit address.

If firmware sets a window that starts below 4GB but ends above 4GB, the
base check passes. But the 64 bit limit is silently cut down to 32 bits
and wraps around to zero. This makes the base larger than the limit,
causing the kernel to silently disable the memory window instead of
printing an error.

Fix this by checking if the limit was truncated, just like the base.
Also, update the error message to print both the base and limit
addresses to make debugging easier.

Fixes: 7fc986d8a9727 ("PCI: Support 64-bit bridge windows if we have 64-bit dma_addr_t")
Signed-off-by: Mohamad Raizudeen <raizudeen.kerneldev@gmail.com>
---
 drivers/pci/probe.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index dd0abbc63e18..0cf2d1d35146 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -479,9 +479,10 @@ static void pci_read_bridge_mmio_pref(struct pci_dev *dev, struct resource *res,
 	base = (pci_bus_addr_t) base64;
 	limit = (pci_bus_addr_t) limit64;
 
-	if (base != base64) {
-		pci_err(dev, "can't handle bridge window above 4GB (bus address %#010llx)\n",
-			(unsigned long long) base64);
+	if (base != base64 || limit != limit64) {
+		pci_err(dev, "can't handle bridge window above 4GB (bus address %#010llx-%#010llx)\n",
+			(unsigned long long) base64,
+			(unsigned long long) limit64);
 		return;
 	}
 
-- 
2.53.0


             reply	other threads:[~2026-08-14 16:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-14 16:46 Mohamad Raizudeen [this message]
2026-09-16  5:10 ` Mohamad Raizudeen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260814164652.43501-1-raizudeen.kerneldev@gmail.com \
    --to=raizudeen.kerneldev@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jkoolstra@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=yinghai@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®