VirtualBox

Changeset 81035 in vbox


Ignore:
Timestamp:
Sep 26, 2019 8:22:35 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
133638
Message:

DevPci: Allow access to config space above 256 bytes with ICH9. bugref:9218

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/pdmpcidevint.h

    r81031 r81035  
    194194
    195195    /** Pointer to bus specific data. (R3 ptr) */
    196     R3PTRTYPE(const void *)         pPciBusPtrR3;
     196    R3PTRTYPE(const void *)         pvPciBusPtrR3;
    197197    /** I/O regions. */
    198198    PCIIOREGION                     aIORegions[VBOX_PCI_NUM_REGIONS];
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r81034 r81035  
    151151    int                 iIrqPinBridge  = ((pPciDev->uDevFn >> 3) + iIrq) & 3;
    152152    uint64_t            bmSeen[256/64] = { 0, 0, 0, 0 };
    153     ASMBitSet(bmSeen, RT_MIN(pPciDevBus->Int.s.idxPdmBus, 255));
     153    ASMBitSet(bmSeen, pPciDevBus->Int.s.idxPdmBus); AssertCompile(sizeof(pPciDevBus->Int.s.idxPdmBus) == 1);
    154154
    155155    /* Walk the chain until we reach the host bus. */
     
    24582458{
    24592459    uint32_t uValue;
    2460     if (uAddress + cb <= 256)
     2460    if (uAddress + cb <= RT_MIN(pPciDev->cbConfig, sizeof(pPciDev->abConfig)))
    24612461    {
    24622462        switch (cb)
     
    24912491    else
    24922492    {
    2493         if (uAddress + cb < _4K)
    2494             LogRel(("PCI: %8s/%u: Read from extended register %d fallen back to generic code\n",
    2495                     pPciDev->pszNameR3, pPciDev->Int.s.CTX_SUFF(pDevIns)->iInstance, uAddress));
    2496         else
    2497             AssertFailed();
     2493        AssertMsgFailed(("Read after end of PCI config space: %#x LB %u\n", uAddress, cb));
    24982494        uValue = 0;
    24992495    }
     
    28242820    VBOXSTRICTRC rcStrict = VINF_SUCCESS;
    28252821
    2826     if (uAddress + cb <= 256)
     2822    if (uAddress + cb <= RT_MIN(pPciDev->cbConfig, sizeof(pPciDev->abConfig)))
    28272823    {
    28282824        /*
     
    29052901                            break;
    29062902                        }
    2907                         else if (uAddress < VBOX_PCI_BASE_ADDRESS_2 || uAddress > VBOX_PCI_BASE_ADDRESS_5+3)
     2903                        if (uAddress < VBOX_PCI_BASE_ADDRESS_2 || uAddress > VBOX_PCI_BASE_ADDRESS_5+3)
    29082904                        {
    29092905                            /* PCI bridges have only BAR0, BAR1 and ROM */
     
    29132909                            break;
    29142910                        }
    2915                         else if (   uAddress == VBOX_PCI_IO_BASE
    2916                                  || uAddress == VBOX_PCI_IO_LIMIT
    2917                                  || uAddress == VBOX_PCI_MEMORY_BASE
    2918                                  || uAddress == VBOX_PCI_MEMORY_LIMIT
    2919                                  || uAddress == VBOX_PCI_PREF_MEMORY_BASE
    2920                                  || uAddress == VBOX_PCI_PREF_MEMORY_LIMIT)
     2911                        if (   uAddress == VBOX_PCI_IO_BASE
     2912                            || uAddress == VBOX_PCI_IO_LIMIT
     2913                            || uAddress == VBOX_PCI_MEMORY_BASE
     2914                            || uAddress == VBOX_PCI_MEMORY_LIMIT
     2915                            || uAddress == VBOX_PCI_PREF_MEMORY_BASE
     2916                            || uAddress == VBOX_PCI_PREF_MEMORY_LIMIT)
    29212917                        {
    29222918                            /* All bridge address decoders have the low 4 bits
     
    29482944        }
    29492945    }
    2950     else if (uAddress + cb <= _4K)
    2951         LogRel(("PCI: %8s/%u: Write to extended register %d fallen back to generic code\n",
    2952                 pPciDev->pszNameR3, pPciDev->Int.s.CTX_SUFF(pDevIns)->iInstance, uAddress));
    29532946    else
    2954         AssertMsgFailed(("Write after end of PCI config space\n"));
     2947        AssertMsgFailed(("Write after end of PCI config space: %#x LB %u\n", uAddress, cb));
    29552948
    29562949    return rcStrict;
     
    36243617    pBus->fPureBridge = true;
    36253618    pBusCC->pDevInsR3 = pDevIns;
    3626     /** @todo r=klaus figure out how to extend this to allow PCIe config space
    3627      * extension, which increases the config space from 256 bytes to 4K.
    3628      * bird: What does this allocation have to do with PCIe config space?!?  */
    36293619    pBus->papBridgesR3 = (PPDMPCIDEV *)PDMDevHlpMMHeapAllocZ(pDevIns, sizeof(PPDMPCIDEV) * RT_ELEMENTS(pBus->apDevices));
    36303620    AssertLogRelReturn(pBus->papBridgesR3, VERR_NO_MEMORY);
  • trunk/src/VBox/Devices/Bus/MsixCommon.cpp

    r81031 r81035  
    120120PDMBOTHCBDECL(int) msixR3MMIORead(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void *pv, unsigned cb)
    121121{
    122     LogFlowFunc(("\n"));
    123 
    124     uint32_t off = (uint32_t)(GCPhysAddr & 0xffff);
    125122    PPDMPCIDEV pPciDev = (PPDMPCIDEV)pvUser;
     123    uint32_t   off     = (uint32_t)(GCPhysAddr & 0xffff);
     124    LogFlowFunc(("GCPhysAddr=%RGp cb=%d\n", GCPhysAddr, cb));
    126125
    127126    /// @todo qword accesses?
    128127    RT_NOREF(pDevIns);
    129     AssertMsgReturn(cb == 4,
    130                     ("MSI-X must be accessed with 4-byte reads"),
    131                     VERR_INTERNAL_ERROR);
    132     AssertMsgReturn(off + cb <= pPciDev->Int.s.cbMsixRegion,
    133                     ("Out of bounds access for the MSI-X region\n"),
    134                     VINF_IOM_MMIO_UNUSED_FF);
    135 
    136     *(uint32_t *)pv = *(uint32_t *)msixGetPageOffset(pPciDev, off);
     128    AssertMsgReturn(cb == 4, ("MSI-X must be accessed with 4-byte reads\n"), VERR_INTERNAL_ERROR);
     129    AssertMsgReturn(off + cb <= pPciDev->Int.s.cbMsixRegion, ("Out of bounds access for the MSI-X region\n"), VINF_IOM_MMIO_UNUSED_FF);
     130    *(uint32_t *)pv = *(uint32_t *)&pPciDev->abMsixState[off];
     131
    137132    return VINF_SUCCESS;
    138133}
     
    140135PDMBOTHCBDECL(int) msixR3MMIOWrite(PPDMDEVINS pDevIns, void *pvUser, RTGCPHYS GCPhysAddr, void const *pv, unsigned cb)
    141136{
    142     LogFlowFunc(("\n"));
    143 
    144137    PPDMPCIDEV pPciDev = (PPDMPCIDEV)pvUser;
    145     uint32_t off = (uint32_t)(GCPhysAddr & 0xffff);
     138    uint32_t   off     = (uint32_t)(GCPhysAddr & 0xffff);
     139    LogFlowFunc(("GCPhysAddr=%RGp cb=%d\n", GCPhysAddr, cb));
    146140
    147141    /// @todo qword accesses?
    148     AssertMsgReturn(cb == 4,
    149                     ("MSI-X must be accessed with 4-byte reads"),
    150                     VERR_INTERNAL_ERROR);
    151     AssertMsgReturn(off + cb <= pPciDev->Int.s.offMsixPba,
    152                     ("Trying to write to PBA\n"), VINF_SUCCESS);
    153 
    154     *(uint32_t *)msixGetPageOffset(pPciDev, off) = *(uint32_t *)pv;
    155 
    156     msixR3CheckPendingVector(pDevIns, (PCPDMPCIHLP)pPciDev->Int.s.pPciBusPtrR3, pPciDev, off / VBOX_MSIX_ENTRY_SIZE);
     142    AssertMsgReturn(cb == 4, ("MSI-X must be accessed with 4-byte reads\n"), VERR_INTERNAL_ERROR);
     143    AssertMsgReturn(off + cb <= pPciDev->Int.s.offMsixPba, ("Trying to write to PBA\n"), VINF_SUCCESS);
     144    *(uint32_t *)&pPciDev->abMsixState[off] = *(uint32_t *)pv;
     145
     146    /* (See MsixR3Init the setting up of pvPciBusPtrR3.) */
     147    msixR3CheckPendingVector(pDevIns, (PCPDMPCIHLP)pPciDev->Int.s.pvPciBusPtrR3, pPciDev, off / VBOX_MSIX_ENTRY_SIZE);
    157148    return VINF_SUCCESS;
    158149}
     
    167158    NOREF(iRegion); NOREF(enmType);
    168159
    169     int rc = PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, pPciDev,
    170                                    IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
    171                                    msixR3MMIOWrite, msixR3MMIORead, "MSI-X tables");
    172 
    173     if (RT_FAILURE(rc))
    174         return rc;
    175 
    176     return VINF_SUCCESS;
     160    return PDMDevHlpMMIORegister(pDevIns, GCPhysAddress, cb, pPciDev,
     161                                 IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU,
     162                                 msixR3MMIOWrite, msixR3MMIORead, "MSI-X tables");
    177163}
    178164
     
    228214
    229215    /* R3 PCI helper */
    230     pDev->Int.s.pPciBusPtrR3    = pPciHlp;
     216    pDev->Int.s.pvPciBusPtrR3   = pPciHlp;
    231217
    232218    PCIDevSetByte(pDev,  iCapOffset + 0, VBOX_PCI_CAP_ID_MSIX);
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette