Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PCI: Use resource_set_range() that correctly sets ->end

__pci_read_base() sets resource start and end addresses when resource
is larger than 4G but pci_bus_addr_t or resource_size_t are not capable
of representing 64-bit PCI addresses. This creates a problematic
resource that has non-zero flags but the start and end addresses do not
yield to resource size of 0 but 1.

Replace custom resource addresses setup with resource_set_range()
that correctly sets end address as -1 which results in resource_size()
returning 0.

For consistency, also use resource_set_range() in the other branch that
does size based resource setup.

Fixes: 23b13bc76f35 ("PCI: Fail safely if we can't handle BARs larger than 4GB")
Link: https://lore.kernel.org/all/20251207215359.28895-1-ansuelsmth@gmail.com/T/#m990492684913c5a158ff0e5fc90697d8ad95351b
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Cc: stable@vger.kernel.org
Cc: Christian Marangi <ansuelsmth@gmail.com>
Link: https://patch.msgid.link/20251208145654.5294-1-ilpo.jarvinen@linux.intel.com

authored by

Ilpo Järvinen and committed by
Bjorn Helgaas
11721c45 8f0b4cce

+2 -4
+2 -4
drivers/pci/probe.c
··· 287 287 if ((sizeof(pci_bus_addr_t) < 8 || sizeof(resource_size_t) < 8) 288 288 && sz64 > 0x100000000ULL) { 289 289 res->flags |= IORESOURCE_UNSET | IORESOURCE_DISABLED; 290 - res->start = 0; 291 - res->end = 0; 290 + resource_set_range(res, 0, 0); 292 291 pci_err(dev, "%s: can't handle BAR larger than 4GB (size %#010llx)\n", 293 292 res_name, (unsigned long long)sz64); 294 293 goto out; ··· 296 297 if ((sizeof(pci_bus_addr_t) < 8) && l) { 297 298 /* Above 32-bit boundary; try to reallocate */ 298 299 res->flags |= IORESOURCE_UNSET; 299 - res->start = 0; 300 - res->end = sz64 - 1; 300 + resource_set_range(res, 0, sz64); 301 301 pci_info(dev, "%s: can't handle BAR above 4GB (bus address %#010llx)\n", 302 302 res_name, (unsigned long long)l64); 303 303 goto out;