aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeir Fraser <keir@xen.org>2010-11-10 14:16:45 +0000
committerKeir Fraser <keir@xen.org>2010-11-10 14:16:45 +0000
commitf3ecb8449c186e2e9407961ecb3a7716f8d0ad17 (patch)
tree623cbfa31f19a4896dc5e758319db2e0fd318857
parent923ecbaa8faa1523edec2c6d585c683fc58748a8 (diff)
downloadxen-f3ecb8449c186e2e9407961ecb3a7716f8d0ad17.tar.gz
xen-f3ecb8449c186e2e9407961ecb3a7716f8d0ad17.tar.bz2
xen-f3ecb8449c186e2e9407961ecb3a7716f8d0ad17.zip
hvmloader: fix off-by-one-bit error when initialising PCI devices
hvmloader is responsible for - amoungst other things - initialising the PCI device BARs prior to loading the guest BIOS. The previous code only probed for devfn up to 128. The lower 3 bits are function IDs so this meant that only devices in slots 0-15 were actually being initialized. Signed-off-by: Alex Zeffertt <alex.zeffertt@eu.citrix.com> Acked-by: Gianni Tedesco <gianni.tedesco@citrix.com> xen-unstable changeset: 22383:cba667fb80cf xen-unstable date: Wed Nov 10 13:58:16 2010 +0000 hvmloader: Fix 22383:cba667fb80cf iterating over defns 0..255 We need to declare devfn as wider than 8 bits for a loop 0<devfn<256 to terminate. Signed-off-by: Keir Fraser <keir@xen.org> xen-unstable changeset: 22384:c19e3371f31b xen-unstable date: Wed Nov 10 14:15:23 2010 +0000
-rw-r--r--tools/firmware/hvmloader/hvmloader.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c
index be0c3ffb98..97555dd6fd 100644
--- a/tools/firmware/hvmloader/hvmloader.c
+++ b/tools/firmware/hvmloader/hvmloader.c
@@ -196,7 +196,7 @@ static void pci_setup(void)
outb(0x4d1, (uint8_t)(PCI_ISA_IRQ_MASK >> 8));
/* Scan the PCI bus and map resources. */
- for ( devfn = 0; devfn < 128; devfn++ )
+ for ( devfn = 0; devfn < 256; devfn++ )
{
class = pci_readw(devfn, PCI_CLASS_DEVICE);
vendor_id = pci_readw(devfn, PCI_VENDOR_ID);
@@ -466,11 +466,10 @@ static int scan_option_rom(
*/
static int scan_etherboot_nic(uint32_t copy_rom_dest)
{
- uint8_t devfn;
- uint16_t class, vendor_id, device_id;
+ uint16_t class, vendor_id, device_id, devfn;
int rom_size = 0;
- for ( devfn = 0; (devfn < 128) && !rom_size; devfn++ )
+ for ( devfn = 0; (devfn < 256) && !rom_size; devfn++ )
{
class = pci_readw(devfn, PCI_CLASS_DEVICE);
vendor_id = pci_readw(devfn, PCI_VENDOR_ID);
@@ -494,10 +493,9 @@ static int scan_etherboot_nic(uint32_t copy_rom_dest)
static int pci_load_option_roms(uint32_t rom_base_addr)
{
uint32_t option_rom_addr, rom_phys_addr = rom_base_addr;
- uint16_t vendor_id, device_id;
- uint8_t devfn, class;
+ uint16_t vendor_id, device_id, devfn, class;
- for ( devfn = 0; devfn < 128; devfn++ )
+ for ( devfn = 0; devfn < 256; devfn++ )
{
class = pci_readb(devfn, PCI_CLASS_DEVICE + 1);
vendor_id = pci_readw(devfn, PCI_VENDOR_ID);