• M
    PCI: add pci_pcie_cap2() check for PCIe feature capabilities >= v2 · c463b8cb
    Myron Stowe 提交于
    This patch resolves potential issues when accessing PCI Express
    Capability structures.  The makeup of the capability varies
    substantially between v1 and v2:
    
        Version 1 of the PCI Express Capability (defined by PCI Express
        1.0 and 1.1 base) neither requires the endpoint to implement the
        entire PCIe capability structure nor specifies default values of
        registers that are not implemented by the device.
    
        Version 2 of the PCI Express Capability (defined by PCIe 1.1
        Capability Structure Expansion ECN, PCIe 2.0, 2.1, and 3.0) added
        additional registers to the structure and requires all registers
        to be either implemented or hardwired to 0.
    
    Due to the differences in the capability structures, code dealing with
    capability features must be careful not to access the additional
    registers introduced with v2 unless the device is specifically known to
    be a v2 capable device.  Otherwise, attempts to access non-existant
    registers will occur.  This is a subtle issue that is hard to track down
    when it occurs (and it has - see commit 864d296c).
    
    To try and help mitigate such occurrences, this patch introduces
    pci_pcie_cap2() which is similar to pci_pcie_cap() but also checks
    that the PCIe capability version is >= 2.  pci_pcie_cap2() should be
    used for qualifying PCIe capability features introduced after v1.
    
    Suggested by Don Dutile.
    Acked-by: NDonald Dutile <ddutile@redhat.com>
    Signed-off-by: NMyron Stowe <myron.stowe@redhat.com>
    Signed-off-by: NBjorn Helgaas <bhelgaas@google.com>
    c463b8cb
pci_regs.h 36.7 KB