From 2a60525710ea8a615f6a98c6a3f7d47c861b0a17 Mon Sep 17 00:00:00 2001 From: jhb Date: Thu, 3 Mar 2011 20:13:44 +0000 Subject: [PATCH] MFC 218968: Properly handle BARs bigger than 4G. The '1' was treated as an int causing the size calculation to be truncated to the size of an int (32-bits on all current architectures). git-svn-id: svn://svn.freebsd.org/base/stable/8@219250 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f --- sys/dev/pci/pci.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c index ae3d3c556..b94ef4427 100644 --- a/sys/dev/pci/pci.c +++ b/sys/dev/pci/pci.c @@ -2499,13 +2499,13 @@ pci_add_map(device_t bus, device_t dev, int reg, struct resource_list *rl, return (barlen); } - count = 1 << mapsize; + count = (pci_addr_t)1 << mapsize; if (basezero || base == pci_mapbase(testval)) { start = 0; /* Let the parent decide. */ end = ~0ULL; } else { start = base; - end = base + (1 << mapsize) - 1; + end = base + count - 1; } resource_list_add(rl, type, reg, start, end, count); @@ -3680,7 +3680,7 @@ pci_alloc_map(device_t dev, device_t child, int type, int *rid, * another driver, which won't work. */ mapsize = pci_mapsize(testval); - count = 1UL << mapsize; + count = (pci_addr_t)1 << mapsize; if (RF_ALIGNMENT(flags) < mapsize) flags = (flags & ~RF_ALIGNMENT_MASK) | RF_ALIGNMENT_LOG2(mapsize); if (PCI_BAR_MEM(testval) && (testval & PCIM_BAR_MEM_PREFETCH)) -- 2.45.0