VirtualBox

Changeset 18534 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Mar 30, 2009 12:03:12 PM (16 years ago)
Author:
vboxsync
Message:

PDMDevHlp: Added deadlock detection to the Phys APIs (disabled unless you're me).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMDevHlp.cpp

    r18143 r18534  
    4242#include <iprt/string.h>
    4343#include <iprt/thread.h>
     44
     45
     46/*******************************************************************************
     47*   Defined Constants And Macros                                               *
     48*******************************************************************************/
     49/** @def PDM_DEVHLP_DEADLOCK_DETECTION
     50 * Define this to enable the deadlock detection when accessing physical memory.
     51 */
     52#if defined(DEBUG_bird) || defined(DOXYGEN_RUNNING)
     53# define PDM_DEVHLP_DEADLOCK_DETECTION
     54#endif
    4455
    4556
     
    20282039             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, pvBuf, cbRead));
    20292040
     2041#ifdef VBOX_WITH_NEW_PHYS_CODE
     2042#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     2043    if (!VM_IS_EMT(pVM)) /** @todo not true for SMP. oh joy! */
     2044    {
     2045        char szNames[128];
     2046        uint32_t cLocks = PDMR3CritSectCountOwned(pVM, szNames, sizeof(szNames));
     2047        AssertMsg(cLocks == 0, ("cLocks=%u %s\n", cLocks, szNames));
     2048    }
     2049#endif
     2050
    20302051    int rc;
    2031 #ifdef VBOX_WITH_NEW_PHYS_CODE
    20322052    if (VM_IS_EMT(pVM))
    20332053        rc = PGMPhysRead(pVM, GCPhys, pvBuf, cbRead);
     
    20362056#else
    20372057    PGMPhysRead(pVM, GCPhys, pvBuf, cbRead);
    2038     rc = VINF_SUCCESS;
     2058    int rc = VINF_SUCCESS;
    20392059#endif
    20402060    Log(("pdmR3DevHlp_PhysRead: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
     
    20512071             pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, GCPhys, pvBuf, cbWrite));
    20522072
     2073#ifdef VBOX_WITH_NEW_PHYS_CODE
     2074#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     2075    if (!VM_IS_EMT(pVM)) /** @todo not true for SMP. oh joy! */
     2076    {
     2077        char szNames[128];
     2078        uint32_t cLocks = PDMR3CritSectCountOwned(pVM, szNames, sizeof(szNames));
     2079        AssertMsg(cLocks == 0, ("cLocks=%u %s\n", cLocks, szNames));
     2080    }
     2081#endif
     2082
    20532083    int rc;
    2054 #ifdef VBOX_WITH_NEW_PHYS_CODE
    20552084    if (VM_IS_EMT(pVM))
    20562085        rc = PGMPhysWrite(pVM, GCPhys, pvBuf, cbWrite);
     
    20592088#else
    20602089    PGMPhysWrite(pVM, GCPhys, pvBuf, cbWrite);
    2061     rc = VINF_SUCCESS;
     2090    int rc = VINF_SUCCESS;
    20622091#endif
    20632092    Log(("pdmR3DevHlp_PhysWrite: caller='%s'/%d: returns %Rrc\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc));
     
    20752104    AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
    20762105
     2106#ifdef VBOX_WITH_NEW_PHYS_CODE
     2107#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     2108    if (!VM_IS_EMT(pVM)) /** @todo not true for SMP. oh joy! */
     2109    {
     2110        char szNames[128];
     2111        uint32_t cLocks = PDMR3CritSectCountOwned(pVM, szNames, sizeof(szNames));
     2112        AssertMsg(cLocks == 0, ("cLocks=%u %s\n", cLocks, szNames));
     2113    }
     2114#endif
     2115#endif
     2116
    20772117    int rc = PGMR3PhysGCPhys2CCPtrExternal(pVM, GCPhys, ppv, pLock);
    20782118
     
    20912131    AssertReturn(!fFlags, VERR_INVALID_PARAMETER);
    20922132
     2133#ifdef VBOX_WITH_NEW_PHYS_CODE
     2134#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     2135    if (!VM_IS_EMT(pVM)) /** @todo not true for SMP. oh joy! */
     2136    {
     2137        char szNames[128];
     2138        uint32_t cLocks = PDMR3CritSectCountOwned(pVM, szNames, sizeof(szNames));
     2139        AssertMsg(cLocks == 0, ("cLocks=%u %s\n", cLocks, szNames));
     2140    }
     2141#endif
     2142#endif
     2143
    20932144    int rc = PGMR3PhysGCPhys2CCPtrReadOnlyExternal(pVM, GCPhys, ppv, pLock);
    20942145
     
    21232174    if (!VM_IS_EMT(pVM))
    21242175        return VERR_ACCESS_DENIED;
     2176#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     2177    /** @todo SMP. */
     2178#endif
    21252179
    21262180    int rc = PGMPhysSimpleReadGCPtr(pVM, pvDst, GCVirtSrc, cb);
     
    21432197    if (!VM_IS_EMT(pVM))
    21442198        return VERR_ACCESS_DENIED;
     2199#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     2200    /** @todo SMP. */
     2201#endif
    21452202
    21462203    int rc = PGMPhysSimpleWriteGCPtr(pVM, GCVirtDst, pvSrc, cb);
     
    21632220    if (!VM_IS_EMT(pVM))
    21642221        return VERR_ACCESS_DENIED;
     2222#if defined(VBOX_STRICT) && defined(PDM_DEVHLP_DEADLOCK_DETECTION)
     2223    /** @todo SMP. */
     2224#endif
    21652225
    21662226    int rc = PGMPhysGCPtr2GCPhys(pVM, GCPtr, pGCPhys);
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