diff mbox

[2/2] pci: correct pci config size default for cap version 2 endpoints

Message ID 20110720234940.5002.26262.stgit@dddsys0.bos.redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Donald Dutile July 20, 2011, 11:51 p.m. UTC
Corrected default size of PCIe Cap Structure from 0x3c to 0x34.
0x34 is min size for version 2 Cap Structure for an endpoint.

0x3c value failed on a real device that aligned this
structure at 0xcc, exceeding the size of the config_map[]
by 8 bytes.

Signed-off-by: Donald Dutile <ddutile@redhat.com>
cc: Alex Williamson <alex.williamson@redhat.com>
cc: Michael S. Tsirkin <mst@redhat.com>
---

 hw/device-assignment.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Alex Williamson July 21, 2011, 2:43 a.m. UTC | #1
On Wed, 2011-07-20 at 19:51 -0400, Donald Dutile wrote:
> Corrected default size of PCIe Cap Structure from 0x3c to 0x34.
> 0x34 is min size for version 2 Cap Structure for an endpoint.
> 
> 0x3c value failed on a real device that aligned this
> structure at 0xcc, exceeding the size of the config_map[]
> by 8 bytes.
> 
> Signed-off-by: Donald Dutile <ddutile@redhat.com>
> cc: Alex Williamson <alex.williamson@redhat.com>
> cc: Michael S. Tsirkin <mst@redhat.com>
> ---
> 
>  hw/device-assignment.c |    4 +++-
>  1 files changed, 3 insertions(+), 1 deletions(-)
> 
> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
> index 36ad6b0..1d2ee5d 100644
> --- a/hw/device-assignment.c
> +++ b/hw/device-assignment.c
> @@ -1422,12 +1422,14 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>          uint8_t version;
>          uint16_t type, devctl, lnkcap, lnksta;
>          uint32_t devcap;
> -        int size = 0x3c; /* version 2 size */
>  
>          version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS);
>          version &= PCI_EXP_FLAGS_VERS;
>          if (version == 1) {
>              size = 0x14;
> +	} else if (version == 2) {
> +	    /* don't include slot cap/stat/ctrl 2 regs; only support endpoints */
> +	    size = 0x34;
>          } else if (version > 2) {
>              fprintf(stderr, "Unsupported PCI express capability version %d\n",
>                      version);
> 

Does this compile?  Where is size defined now?  Also whitespace issues
with tabs.

Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Donald Dutile July 21, 2011, 3:52 p.m. UTC | #2
On 07/20/2011 10:43 PM, Alex Williamson wrote:
> On Wed, 2011-07-20 at 19:51 -0400, Donald Dutile wrote:
>> Corrected default size of PCIe Cap Structure from 0x3c to 0x34.
>> 0x34 is min size for version 2 Cap Structure for an endpoint.
>>
>> 0x3c value failed on a real device that aligned this
>> structure at 0xcc, exceeding the size of the config_map[]
>> by 8 bytes.
>>
>> Signed-off-by: Donald Dutile<ddutile@redhat.com>
>> cc: Alex Williamson<alex.williamson@redhat.com>
>> cc: Michael S. Tsirkin<mst@redhat.com>
>> ---
>>
>>   hw/device-assignment.c |    4 +++-
>>   1 files changed, 3 insertions(+), 1 deletions(-)
>>
>> diff --git a/hw/device-assignment.c b/hw/device-assignment.c
>> index 36ad6b0..1d2ee5d 100644
>> --- a/hw/device-assignment.c
>> +++ b/hw/device-assignment.c
>> @@ -1422,12 +1422,14 @@ static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
>>           uint8_t version;
>>           uint16_t type, devctl, lnkcap, lnksta;
>>           uint32_t devcap;
>> -        int size = 0x3c; /* version 2 size */
>>
>>           version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS);
>>           version&= PCI_EXP_FLAGS_VERS;
>>           if (version == 1) {
>>               size = 0x14;
>> +	} else if (version == 2) {
>> +	    /* don't include slot cap/stat/ctrl 2 regs; only support endpoints */
>> +	    size = 0x34;
>>           } else if (version>  2) {
>>               fprintf(stderr, "Unsupported PCI express capability version %d\n",
>>                       version);
>>
>
> Does this compile?  Where is size defined now?  Also whitespace issues
> with tabs.
>
> Alex
>
doh! during recent workstation upgrade, i forgot to install pciutils-devel;
I didn't look at the configure output closely, and now see this file wasn't compiled!
thanks for catch.  will repost shortly.

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index 36ad6b0..1d2ee5d 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -1422,12 +1422,14 @@  static int assigned_device_pci_cap_init(PCIDevice *pci_dev)
         uint8_t version;
         uint16_t type, devctl, lnkcap, lnksta;
         uint32_t devcap;
-        int size = 0x3c; /* version 2 size */
 
         version = pci_get_byte(pci_dev->config + pos + PCI_EXP_FLAGS);
         version &= PCI_EXP_FLAGS_VERS;
         if (version == 1) {
             size = 0x14;
+	} else if (version == 2) {
+	    /* don't include slot cap/stat/ctrl 2 regs; only support endpoints */
+	    size = 0x34;
         } else if (version > 2) {
             fprintf(stderr, "Unsupported PCI express capability version %d\n",
                     version);