VirtualBox

Changeset 90436 in vbox for trunk/src


Ignore:
Timestamp:
Jul 30, 2021 4:03:48 PM (4 years ago)
Author:
vboxsync
Message:

VMM,Dev*: Handle PDMCritSectEnter failures in relation to the PDM critsect. bugref:6695

Location:
trunk/src/VBox
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Bus/DevIommuAmd.cpp

    r90421 r90436  
    197197    } while (0)
    198198
    199 /** Acquires the PDM lock (shouldn't really fail). */
     199/** Acquires the PDM lock (can fail under extraordinary circumstance in in ring-0). */
    200200#ifdef IN_RING3
    201201# define IOMMU_LOCK(a_pDevIns, a_pThisCC)           (a_pThisCC)->CTX_SUFF(pIommuHlp)->pfnLock((a_pDevIns), VERR_IGNORED)
     
    204204    do { \
    205205        int const rcLock = (a_pThisCC)->CTX_SUFF(pIommuHlp)->pfnLock((a_pDevIns), VINF_SUCCESS); \
    206         AssertRC(rcLock); \
     206        PDM_CRITSECT_RELEASE_ASSERT_RC_DEV((a_pDevIns), NULL, rcLock); \
    207207    } while (0)
    208208#endif
  • trunk/src/VBox/Devices/Bus/DevIommuIntel.cpp

    r90429 r90436  
    6666    } while (0)
    6767
    68 /** Acquires the DMAR lock (not expected to fail). */
     68/** Acquires the DMAR lock (can fail under extraordinary circumstance in in ring-0). */
    6969#ifdef IN_RING3
    7070# define DMAR_LOCK(a_pDevIns, a_pThisCC)            (a_pThisCC)->CTX_SUFF(pIommuHlp)->pfnLock((a_pDevIns), VERR_IGNORED)
     
    7373    do { \
    7474        int const rcLock = (a_pThisCC)->CTX_SUFF(pIommuHlp)->pfnLock((a_pDevIns), VINF_SUCCESS); \
    75         AssertRC(rcLock); \
     75        PDM_CRITSECT_RELEASE_ASSERT_RC_DEV((a_pDevIns), NULL, rcLock); \
    7676    } while (0)
    7777#endif
  • trunk/src/VBox/Devices/Bus/DevPCI.cpp

    r87789 r90436  
    819819    {
    820820        PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);
    821         PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_WRITE);
     821        PCI_LOCK_RET(pDevIns, VINF_IOM_R3_IOPORT_WRITE);
    822822        pThis->uConfigReg = u32 & ~3; /* Bits 0-1 are reserved and we silently clear them */
    823823        PCI_UNLOCK(pDevIns);
     
    839839    {
    840840        PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);
    841         PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_READ);
     841        PCI_LOCK_RET(pDevIns, VINF_IOM_R3_IOPORT_READ);
    842842        *pu32 = pThis->uConfigReg;
    843843        PCI_UNLOCK(pDevIns);
     
    863863    if (!(offPort % cb))
    864864    {
    865         PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_WRITE);
     865        PCI_LOCK_RET(pDevIns, VINF_IOM_R3_IOPORT_WRITE);
    866866        rcStrict = pci_data_write(pDevIns, PDMINS_2_DATA(pDevIns, PDEVPCIROOT), offPort, u32, cb);
    867867        PCI_UNLOCK(pDevIns);
     
    882882    if (!(offPort % cb))
    883883    {
    884         PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_READ);
     884        PCI_LOCK_RET(pDevIns, VINF_IOM_R3_IOPORT_READ);
    885885        VBOXSTRICTRC rcStrict = pci_data_read(PDMINS_2_DATA(pDevIns, PDEVPCIROOT), offPort, cb, pu32);
    886886        PCI_UNLOCK(pDevIns);
  • trunk/src/VBox/Devices/Bus/DevPciIch9.cpp

    r85912 r90436  
    282282        u32 &= ~3;
    283283
    284         PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_WRITE);
     284        PCI_LOCK_RET(pDevIns, VINF_IOM_R3_IOPORT_WRITE);
    285285        pThis->uConfigReg = u32;
    286286        PCI_UNLOCK(pDevIns);
     
    306306        PDEVPCIROOT pThis = PDMINS_2_DATA(pDevIns, PDEVPCIROOT);
    307307
    308         PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_READ);
     308        PCI_LOCK_RET(pDevIns, VINF_IOM_R3_IOPORT_READ);
    309309        *pu32 = pThis->uConfigReg;
    310310        PCI_UNLOCK(pDevIns);
     
    388388    if (!(offPort % cb))
    389389    {
    390         PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_WRITE);
     390        PCI_LOCK_RET(pDevIns, VINF_IOM_R3_IOPORT_WRITE);
    391391
    392392        if (pThis->uConfigReg & (1 << 31))
     
    486486        *pu32 = 0xffffffff;
    487487
    488         PCI_LOCK(pDevIns, VINF_IOM_R3_IOPORT_READ);
     488        PCI_LOCK_RET(pDevIns, VINF_IOM_R3_IOPORT_READ);
    489489
    490490        /* Configuration space mapping enabled? */
     
    678678
    679679    /* Perform configuration space write */
    680     PCI_LOCK(pDevIns, VINF_IOM_R3_MMIO_WRITE);
     680    PCI_LOCK_RET(pDevIns, VINF_IOM_R3_MMIO_WRITE);
    681681    VBOXSTRICTRC rcStrict = ich9pciConfigWrite(pDevIns, pPciRoot, &aDest, u32, cb, VINF_IOM_R3_MMIO_WRITE);
    682682    PCI_UNLOCK(pDevIns);
     
    702702    /* Perform configuration space read */
    703703    uint32_t     u32Value = 0;
    704     PCI_LOCK(pDevIns, VINF_IOM_R3_MMIO_READ);
     704    PCI_LOCK_RET(pDevIns, VINF_IOM_R3_MMIO_READ);
    705705    VBOXSTRICTRC rcStrict = ich9pciConfigRead(pPciRoot, &aDest, cb, &u32Value, VINF_IOM_R3_MMIO_READ);
    706706    PCI_UNLOCK(pDevIns);
  • trunk/src/VBox/Devices/Bus/DevPciInternal.h

    r82968 r90436  
    187187#define DEVPCIBUS_2_DEVPCIROOT(pPciBus) RT_FROM_MEMBER(pPciBus, DEVPCIROOT, PciBus)
    188188
    189 /** @def PCI_LOCK
     189
     190/** @def PCI_LOCK_RET
    190191 * Acquires the PDM lock. This is a NOP if locking is disabled. */
     192#define PCI_LOCK_RET(pDevIns, rcBusy) \
     193    do { \
     194        int const rcLock = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC)->CTX_SUFF(pPciHlp)->pfnLock((pDevIns), rcBusy); \
     195        if (rcLock == VINF_SUCCESS) \
     196        { /* likely */ } \
     197        else \
     198            return rcLock; \
     199    } while (0)
    191200/** @def PCI_UNLOCK
    192201 * Releases the PDM lock. This is a NOP if locking is disabled. */
    193 #define PCI_LOCK(pDevIns, rc) \
    194     do { \
    195         int rc2 = PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC)->CTX_SUFF(pPciHlp)->pfnLock((pDevIns), rc); \
    196         if (rc2 != VINF_SUCCESS) \
    197             return rc2; \
    198     } while (0)
    199202#define PCI_UNLOCK(pDevIns) \
    200203    PDMINS_2_DATA_CC(pDevIns, PDEVPCIBUSCC)->CTX_SUFF(pPciHlp)->pfnUnlock(pDevIns)
  • trunk/src/VBox/Devices/PC/DevIoApic.cpp

    r90363 r90436  
    874874    bool fRemoteIrrCleared = false;
    875875    int rc = IOAPIC_LOCK(pDevIns, pThis, pThisCC, VINF_SUCCESS);
    876     AssertRC(rc);
     876    PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, NULL, rc);
    877877
    878878    for (uint8_t idxRte = 0; idxRte < RT_ELEMENTS(pThis->au64RedirTable); idxRte++)
     
    937937    {
    938938        int rc = IOAPIC_LOCK(pDevIns, pThis, pThisCC, VINF_SUCCESS);
    939         AssertRC(rc);
     939        PDM_CRITSECT_RELEASE_ASSERT_RC_DEV(pDevIns, NULL, rc);
    940940
    941941        uint8_t  const idxRte        = iIrq;
  • trunk/src/VBox/Devices/PC/DevPIC.cpp

    r84334 r90436  
    5858*   Defined Constants And Macros                                                                                                 *
    5959*********************************************************************************************************************************/
    60 /** @def PIC_LOCK
     60/** @def PIC_LOCK_RET
    6161 * Acquires the PDM lock. This is a NOP if locking is disabled. */
     62#define PIC_LOCK_RET(a_pDevIns, a_pThisCC, rcBusy) \
     63    do { \
     64        int const rcLock = (a_pThisCC)->pPicHlp->pfnLock((a_pDevIns), rcBusy); \
     65        if (rcLock == VINF_SUCCESS) \
     66        { /* likely */ } \
     67        else \
     68            return rcLock; \
     69    } while (0)
    6270/** @def PIC_UNLOCK
    6371 * Releases the PDM lock. This is a NOP if locking is disabled. */
    64 #define PIC_LOCK(a_pDevIns, a_pThisCC, rc) \
    65     do { \
    66         int rc2 = (a_pThisCC)->pPicHlp->pfnLock((a_pDevIns), rc); \
    67         if (rc2 != VINF_SUCCESS) \
    68             return rc2; \
    69     } while (0)
    7072#define PIC_UNLOCK(a_pDevIns, a_pThisCC) \
    7173    (a_pThisCC)->pPicHlp->pfnUnlock((a_pDevIns))
     
    681683    {
    682684        int rc;
    683         PIC_LOCK(pDevIns, pThisCC, VINF_IOM_R3_IOPORT_READ);
     685        PIC_LOCK_RET(pDevIns, pThisCC, VINF_IOM_R3_IOPORT_READ);
    684686        *pu32 = pic_ioport_read(pDevIns, pThis, pThisCC, &RT_SAFE_SUBSCRIPT(pThis->aPics, iPic), offPort, &rc);
    685687        PIC_UNLOCK(pDevIns, pThisCC);
     
    704706    {
    705707        VBOXSTRICTRC rc;
    706         PIC_LOCK(pDevIns, pThisCC, VINF_IOM_R3_IOPORT_WRITE);
     708        PIC_LOCK_RET(pDevIns, pThisCC, VINF_IOM_R3_IOPORT_WRITE);
    707709        rc = pic_ioport_write(pDevIns, pThis, pThisCC, &RT_SAFE_SUBSCRIPT(pThis->aPics, iPic), offPort, u32);
    708710        PIC_UNLOCK(pDevIns, pThisCC);
     
    722724        PDEVPICCC   pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PDEVPICCC);
    723725        PPICSTATE   pPic    = (PPICSTATE)pvUser;
    724         PIC_LOCK(pDevIns, pThisCC, VINF_IOM_R3_IOPORT_READ);
     726        PIC_LOCK_RET(pDevIns, pThisCC, VINF_IOM_R3_IOPORT_READ);
    725727        *pu32 = pPic->elcr;
    726728        PIC_UNLOCK(pDevIns, pThisCC);
     
    741743        PDEVPICCC   pThisCC = PDMDEVINS_2_DATA_CC(pDevIns, PDEVPICCC);
    742744        PPICSTATE   pPic    = (PPICSTATE)pvUser;
    743         PIC_LOCK(pDevIns, pThisCC, VINF_IOM_R3_IOPORT_WRITE);
     745        PIC_LOCK_RET(pDevIns, pThisCC, VINF_IOM_R3_IOPORT_WRITE);
    744746        pPic->elcr = u32 & pPic->elcr_mask;
    745747        PIC_UNLOCK(pDevIns, pThisCC);
  • trunk/src/VBox/VMM/VMMAll/PDMAll.cpp

    r90346 r90436  
    300300/**
    301301 * Locks PDM.
    302  * This might call back to Ring-3 in order to deal with lock contention in GC and R3.
     302 *
     303 * This might call back to Ring-3 in order to deal with lock contention in RC
     304 * and R0.
    303305 *
    304306 * @param   pVM     The cross context VM structure.
     
    308310#ifdef IN_RING3
    309311    int rc = PDMCritSectEnter(pVM, &pVM->pdm.s.CritSect, VERR_IGNORED);
     312    AssertRC(rc);
    310313#else
    311314    int rc = PDMCritSectEnter(pVM, &pVM->pdm.s.CritSect, VERR_GENERAL_FAILURE);
    312     if (rc == VERR_GENERAL_FAILURE)
    313         rc = VMMRZCallRing3NoCpu(pVM, VMMCALLRING3_PDM_LOCK, 0);
     315    if (RT_SUCCESS(rc))
     316    { /* likely */ }
     317    else
     318    {
     319        if (rc == VERR_GENERAL_FAILURE)
     320            rc = VMMRZCallRing3NoCpu(pVM, VMMCALLRING3_PDM_LOCK, 0);
     321        PDM_CRITSECT_RELEASE_ASSERT_RC(pVM, &pVM->pdm.s.CritSect, rc);
     322    }
    314323#endif
    315     AssertRC(rc);
    316324}
    317325
     
    323331 * @returns rc if we're in GC or R0 and can't get the lock.
    324332 * @param   pVM     The cross context VM structure.
    325  * @param   rc      The RC to return in GC or R0 when we can't get the lock.
    326  */
    327 int pdmLockEx(PVMCC pVM, int rc)
    328 {
    329     return PDMCritSectEnter(pVM, &pVM->pdm.s.CritSect, rc);
     333 * @param   rcBusy  The RC to return in GC or R0 when we can't get the lock.
     334 */
     335int pdmLockEx(PVMCC pVM, int rcBusy)
     336{
     337    return PDMCritSectEnter(pVM, &pVM->pdm.s.CritSect, rcBusy);
    330338}
    331339
  • trunk/src/VBox/VMM/include/PDMInternal.h

    r90420 r90436  
    16941694
    16951695void        pdmLock(PVMCC pVM);
    1696 int         pdmLockEx(PVMCC pVM, int rc);
     1696int         pdmLockEx(PVMCC pVM, int rcBusy);
    16971697void        pdmUnlock(PVMCC pVM);
    16981698bool        pdmLockIsOwner(PVMCC pVM);
Note: See TracChangeset for help on using the changeset viewer.

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