From c11cfcfaffc79be5686c666f881c4c08f69e1b86 Mon Sep 17 00:00:00 2001 From: Adam Jackson Date: Thu, 18 May 2006 23:48:57 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20#6377:=20Ignore=20disabled=20BARs,=20and?= =?UTF-8?q?=20allow=20matching=20BARs=20aligned=20to=20less=20=20=20=20=20?= =?UTF-8?q?than=2016=20bytes.=20(Felix=20K=C3=BChling,=20ATI)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ChangeLog | 6 ++++++ hw/xfree86/os-support/linux/lnx_pci.c | 26 +++++++++++++++----------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2972a0a1..b865ec109 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-05-18 Adam Jackson + + * hw/xfree86/os-support/linux/lnx_pci.c: + Bug #6377: Ignore disabled BARs, and allow matching BARs + aligned to less than 16 bytes. (Felix Kühling, ATI) + 2006-05-18 Adam Jackson * hw/xfree86/os-support/linux/lnx_acpi.c: diff --git a/hw/xfree86/os-support/linux/lnx_pci.c b/hw/xfree86/os-support/linux/lnx_pci.c index cec9226c8..3505887bc 100644 --- a/hw/xfree86/os-support/linux/lnx_pci.c +++ b/hw/xfree86/os-support/linux/lnx_pci.c @@ -202,22 +202,26 @@ xf86GetOSOffsetFromPCI(PCITAG tag, int space, unsigned long base) if (tag == pciTag(bus,dev,fn)) { /* ok now look through all the BAR values of this device */ for (ndx=0; ndx<7; ndx++) { - unsigned long savePtr; - /* - * remember to lop of the last 4bits of the BAR values as they are - * memory attributes - */ + unsigned long savePtr, flagMask; if (ndx == 6) - savePtr = (0xFFFFFFF0) & - pciReadLong(tag, PCI_CMD_BIOS_REG); + savePtr = pciReadLong(tag, PCI_CMD_BIOS_REG); else /* this the ROM bar */ - savePtr = (0xFFFFFFF0) & - pciReadLong(tag, PCI_CMD_BASE_REG + (0x4 * ndx)); + savePtr = pciReadLong(tag, PCI_CMD_BASE_REG + (0x4 * ndx)); + /* Ignore unset base addresses. The kernel may + * have reported non-zero size and address even + * if they are disabled (e.g. disabled ROM BAR). + */ + if (savePtr == 0) + continue; + /* Remove memory attribute bits, different for IO + * and memory ranges. */ + flagMask = (savePtr & 0x1) ? ~0x3UL : ~0xFUL; + savePtr &= flagMask; /* find the index of the incoming base */ - if (base >= savePtr && base <= (savePtr + size[ndx])) { + if (base >= savePtr && base < (savePtr + size[ndx])) { fclose(file); - return (offset[ndx] & ~(0xFUL)) + (base - savePtr); + return (offset[ndx] & flagMask) + (base - savePtr); } } }