Patchwork pcie: Fix bug in pcie_ext_cap_set_next

login
register
mail settings
Submitter Knut Omang
Date Dec. 18, 2012, 9:36 p.m.
Message ID <1355866589.8438.6.camel@ori.omang.mine.nu>
Download mbox | patch
Permalink /patch/207230/
State New
Headers show

Comments

Knut Omang - Dec. 18, 2012, 9:36 p.m.
Upper 16 bits of the PCIe Extended Capability Header was truncated during update,
also breaking pcie_add_capability.

Signed-off-by: Knut Omang <knut.omang@oracle.com>
---
 hw/pcie.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Michael S. Tsirkin - Dec. 25, 2012, 12:18 p.m.
On Tue, Dec 18, 2012 at 10:36:29PM +0100, Knut Omang wrote:
> Upper 16 bits of the PCIe Extended Capability Header was truncated during update,
> also breaking pcie_add_capability.
> 
> Signed-off-by: Knut Omang <knut.omang@oracle.com>

Applied, thanks.

> ---
>  hw/pcie.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/pcie.c b/hw/pcie.c
> index 7c92f19..fa260af 100644
> --- a/hw/pcie.c
> +++ b/hw/pcie.c
> @@ -494,7 +494,7 @@ uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id)
>  
>  static void pcie_ext_cap_set_next(PCIDevice *dev, uint16_t pos, uint16_t next)
>  {
> -    uint16_t header = pci_get_long(dev->config + pos);
> +    uint32_t header = pci_get_long(dev->config + pos);
>      assert(!(next & (PCI_EXT_CAP_ALIGN - 1)));
>      header = (header & ~PCI_EXT_CAP_NEXT_MASK) |
>          ((next << PCI_EXT_CAP_NEXT_SHIFT) & PCI_EXT_CAP_NEXT_MASK);
> -- 
> 1.7.11.7
>

Patch

diff --git a/hw/pcie.c b/hw/pcie.c
index 7c92f19..fa260af 100644
--- a/hw/pcie.c
+++ b/hw/pcie.c
@@ -494,7 +494,7 @@  uint16_t pcie_find_capability(PCIDevice *dev, uint16_t cap_id)
 
 static void pcie_ext_cap_set_next(PCIDevice *dev, uint16_t pos, uint16_t next)
 {
-    uint16_t header = pci_get_long(dev->config + pos);
+    uint32_t header = pci_get_long(dev->config + pos);
     assert(!(next & (PCI_EXT_CAP_ALIGN - 1)));
     header = (header & ~PCI_EXT_CAP_NEXT_MASK) |
         ((next << PCI_EXT_CAP_NEXT_SHIFT) & PCI_EXT_CAP_NEXT_MASK);