Patchwork pci: Fix function pci_default_write_config

login
register
mail settings
Submitter Stefan Weil
Date Nov. 13, 2009, 10:26 p.m.
Message ID <1258151187-10003-1-git-send-email-weil@mail.berlios.de>
Download mbox | patch
Permalink /patch/38394/
State New
Headers show

Comments

Stefan Weil - Nov. 13, 2009, 10:26 p.m.
Change 260c0cd3d985e51b15870ff47e17b7b930efbda1
(pci: use range helper functions) introduced a
bug which made pci cirrus vga on mips malta
(and maybe other pci devices) fail.

Don't change addr - its original value is needed
by ranges_overlap() and range_covers().

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
---
 hw/pci.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Ryan Harper - Nov. 13, 2009, 10:58 p.m.
* Stefan Weil <weil@mail.berlios.de> [2009-11-13 16:29]:
> Change 260c0cd3d985e51b15870ff47e17b7b930efbda1
> (pci: use range helper functions) introduced a
> bug which made pci cirrus vga on mips malta
> (and maybe other pci devices) fail.
> 
> Don't change addr - its original value is needed
> by ranges_overlap() and range_covers().
> 
> Signed-off-by: Stefan Weil <weil@mail.berlios.de>

This fixes the fedora 9 boot from dvd issue I've seen.

Acked-by: Ryan Harper <ryanh@us.ibm.com>

> ---
>  hw/pci.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index a326930..6864339 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -856,9 +856,9 @@ void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
>      int i;
>      uint32_t config_size = pci_config_size(d);
> 
> -    for(i = 0; i < l && addr < config_size; val >>= 8, ++i, ++addr) {
> -        uint8_t wmask = d->wmask[addr];
> -        d->config[addr] = (d->config[addr] & ~wmask) | (val & wmask);
> +    for (i = 0; i < l && addr + i < config_size; val >>= 8, ++i) {
> +        uint8_t wmask = d->wmask[addr + i];
> +        d->config[addr + i] = (d->config[addr + i] & ~wmask) | (val & wmask);
>      }
>      if (ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) ||
>          ranges_overlap(addr, l, PCI_ROM_ADDRESS, 4) ||
> -- 
> 1.5.6.5
> 
>

Patch

diff --git a/hw/pci.c b/hw/pci.c
index a326930..6864339 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -856,9 +856,9 @@  void pci_default_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int l)
     int i;
     uint32_t config_size = pci_config_size(d);
 
-    for(i = 0; i < l && addr < config_size; val >>= 8, ++i, ++addr) {
-        uint8_t wmask = d->wmask[addr];
-        d->config[addr] = (d->config[addr] & ~wmask) | (val & wmask);
+    for (i = 0; i < l && addr + i < config_size; val >>= 8, ++i) {
+        uint8_t wmask = d->wmask[addr + i];
+        d->config[addr + i] = (d->config[addr + i] & ~wmask) | (val & wmask);
     }
     if (ranges_overlap(addr, l, PCI_BASE_ADDRESS_0, 24) ||
         ranges_overlap(addr, l, PCI_ROM_ADDRESS, 4) ||