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.

[PATCH] Fix PCI BAR size interpretation on 64-bit arches

On 64-bit machines, PCI_BASE_ADDRESS_MEM_MASK and other mask constants
passed to pci_size() are 64-bit (for example ~0x0fUL). However, pci_size
does comparisons between the u32 arguments and the mask, which will fail
even though any result from pci_size is still just 32-bit.

Changing the mask argument to u32 seems the obvious thing to do, since all
arithmetic in the function is 32-bit and having a larger mask makes no
sense.

This triggered on a PPC64 system here where an adapter (VGA, as it
happened) had a memory region base of 0xfe000000 and a sz of the same,
matching the if (max == maxbase ...) test at the bottom of pci_size but
failing the mask comparison. Quite a corner case which I guess explains
why we haven't seen it until now.

Signed-off-by: Olof Johansson <olof@lixom.net>
Acked-by: Greg KH <greg@kroah.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

Olof Johansson and committed by
Linus Torvalds
f797f9cc a3c77c67

+1 -1
+1 -1
drivers/pci/probe.c
··· 125 125 /* 126 126 * Find the extent of a PCI decode.. 127 127 */ 128 - static u32 pci_size(u32 base, u32 maxbase, unsigned long mask) 128 + static u32 pci_size(u32 base, u32 maxbase, u32 mask) 129 129 { 130 130 u32 size = mask & maxbase; /* Find the significant bits */ 131 131 if (!size)