VirtualBox

Changeset 45301 in vbox


Ignore:
Timestamp:
Apr 3, 2013 9:51:13 AM (11 years ago)
Author:
vboxsync
Message:

IOM: Preparing to use read/write critsect.

Location:
trunk
Files:
8 edited

Legend:

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

    r44626 r45301  
    288288VMMDECL(int)            IOMMMIOMapMMIOHCPage(PVM pVM, PVMCPU pVCpu, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint64_t fPageFlags);
    289289VMMDECL(int)            IOMMMIOResetRegion(PVM pVM, RTGCPHYS GCPhys);
    290 VMMDECL(bool)           IOMIsLockOwner(PVM pVM);
     290VMMDECL(bool)           IOMIsLockWriteOwner(PVM pVM);
    291291
    292292#ifdef IN_RC
  • trunk/include/VBox/vmm/vm.h

    r45276 r45301  
    990990        struct IOM s;
    991991#endif
    992         uint8_t     padding[832];       /* multiple of 64 */
     992        uint8_t     padding[896];       /* multiple of 64 */
    993993    } iom;
    994994
     
    10871087
    10881088    /** Padding for aligning the cpu array on a page boundary. */
    1089     uint8_t         abAlignment2[542];
     1089    uint8_t         abAlignment2[478];
    10901090
    10911091    /* ---- end small stuff ---- */
  • trunk/src/VBox/VMM/VMMAll/EMAll.cpp

    r45276 r45301  
    251251
    252252    Assert(!PGMIsLockOwner(pVM));
    253     Assert(!IOMIsLockOwner(pVM));
     253    Assert(!IOMIsLockWriteOwner(pVM));
    254254    int rc = PDMCritSectEnter(&pVM->em.s.CritSectREM, VERR_SEM_BUSY);
    255255    AssertRCSuccess(rc);
  • trunk/src/VBox/VMM/VMMAll/IOMAll.cpp

    r44528 r45301  
    4141
    4242/**
    43  * Check if this VCPU currently owns the IOM lock.
     43 * Check if this VCPU currently owns the IOM lock exclusively.
    4444 *
    4545 * @returns bool owner/not owner
    4646 * @param   pVM         Pointer to the VM.
    4747 */
    48 VMMDECL(bool) IOMIsLockOwner(PVM pVM)
     48VMMDECL(bool) IOMIsLockWriteOwner(PVM pVM)
    4949{
     50#ifdef IOM_WITH_CRIT_SECT_RW
     51    return PDMCritSectRwIsWriteOwner(&pVM->iom.s.CritSect);
     52#else
    5053    return PDMCritSectIsOwner(&pVM->iom.s.CritSect);
     54#endif
    5155}
    5256
  • trunk/src/VBox/VMM/VMMR3/EM.cpp

    r45276 r45301  
    16941694            if (    pVM->cCpus == 1
    16951695                ||  (   !PGMIsLockOwner(pVM)
    1696                      && !IOMIsLockOwner(pVM))
     1696                     && !IOMIsLockWriteOwner(pVM))
    16971697               )
    16981698            {
  • trunk/src/VBox/VMM/VMMR3/IOM.cpp

    r44850 r45301  
    166166     * Initialize the REM critical section.
    167167     */
     168#ifdef IOM_WITH_CRIT_SECT_RW
     169    int rc = PDMR3CritSectRwInit(pVM, &pVM->iom.s.CritSect, RT_SRC_POS, "IOM Lock");
     170#else
    168171    int rc = PDMR3CritSectInit(pVM, &pVM->iom.s.CritSect, RT_SRC_POS, "IOM Lock");
     172#endif
    169173    AssertRCReturn(rc, rc);
    170174
     
    406410PIOMIOPORTSTATS iomR3IOPortStatsCreate(PVM pVM, RTIOPORT Port, const char *pszDesc)
    407411{
    408     Assert(IOMIsLockOwner(pVM));
     412    Assert(IOM_IS_EXCL_LOCK_OWNER(pVM));
     413
    409414    /* check if it already exists. */
    410415    PIOMIOPORTSTATS pPort = (PIOMIOPORTSTATS)RTAvloIOPortGet(&pVM->iom.s.pTreesR3->IOPortStatTree, Port);
     
    459464PIOMMMIOSTATS iomR3MMIOStatsCreate(PVM pVM, RTGCPHYS GCPhys, const char *pszDesc)
    460465{
    461     Assert(IOMIsLockOwner(pVM));
     466    Assert(IOM_IS_EXCL_LOCK_OWNER(pVM));
    462467#ifdef DEBUG_sandervl
    463468    AssertGCPhys32(GCPhys);
    464469#endif
     470
    465471    /* check if it already exists. */
    466472    PIOMMMIOSTATS pStats = (PIOMMMIOSTATS)RTAvloGCPhysGet(&pVM->iom.s.pTreesR3->MmioStatTree, GCPhys);
  • trunk/src/VBox/VMM/include/IOMInline.h

    r44528 r45301  
    3535DECLINLINE(CTX_SUFF(PIOMIOPORTRANGE)) iomIOPortGetRange(PVM pVM, RTIOPORT Port)
    3636{
    37     Assert(PDMCritSectIsOwner(&pVM->iom.s.CritSect));
     37    Assert(IOM_IS_SHARED_LOCK_OWNER(pVM));
    3838    return (CTX_SUFF(PIOMIOPORTRANGE))RTAvlroIOPortRangeGet(&pVM->iom.s.CTX_SUFF(pTrees)->CTX_SUFF(IOPortTree), Port);
    3939}
     
    5151DECLINLINE(PIOMIOPORTRANGER3) iomIOPortGetRangeR3(PVM pVM, RTIOPORT Port)
    5252{
    53     Assert(PDMCritSectIsOwner(&pVM->iom.s.CritSect));
     53    Assert(IOM_IS_SHARED_LOCK_OWNER(pVM));
    5454    return (PIOMIOPORTRANGER3)RTAvlroIOPortRangeGet(&pVM->iom.s.CTX_SUFF(pTrees)->IOPortTreeR3, Port);
    5555}
     
    6767DECLINLINE(PIOMMMIORANGE) iomMmioGetRange(PVM pVM, RTGCPHYS GCPhys)
    6868{
    69     Assert(PDMCritSectIsOwner(&pVM->iom.s.CritSect));
     69    Assert(IOM_IS_SHARED_LOCK_OWNER(pVM));
    7070    PIOMMMIORANGE pRange = pVM->iom.s.CTX_SUFF(pMMIORangeLast);
    7171    if (    !pRange
     
    102102DECLINLINE(PIOMMMIORANGE) iomMmioGetRangeWithRef(PVM pVM, RTGCPHYS GCPhys)
    103103{
    104     int rc = PDMCritSectEnter(&pVM->iom.s.CritSect, VINF_SUCCESS);
     104    int rc = IOM_LOCK_SHARED_EX(pVM, VINF_SUCCESS);
    105105    AssertRCReturn(rc, NULL);
    106106
     
    113113        iomMmioRetainRange(pRange);
    114114
    115     PDMCritSectLeave(&pVM->iom.s.CritSect);
     115    IOM_UNLOCK_SHARED(pVM);
    116116    return pRange;
    117117}
     
    170170DECLINLINE(PIOMMMIOSTATS) iomMmioGetStats(PVM pVM, RTGCPHYS GCPhys, PIOMMMIORANGE pRange)
    171171{
    172     PDMCritSectEnter(&pVM->iom.s.CritSect, VINF_SUCCESS);
     172    IOM_LOCK_SHARED_EX(pVM, VINF_SUCCESS);
    173173
    174174    /* For large ranges, we'll put everything on the first byte. */
     
    187187    }
    188188
    189     PDMCritSectLeave(&pVM->iom.s.CritSect);
     189    IOM_UNLOCK_SHARED(pVM);
    190190    return pStats;
    191191}
  • trunk/src/VBox/VMM/include/IOMInternal.h

    r44528 r45301  
    55
    66/*
    7  * Copyright (C) 2006-2012 Oracle Corporation
     7 * Copyright (C) 2006-2013 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    1919#define ___IOMInternal_h
    2020
     21//#define IOM_WITH_CRIT_SECT_RW
     22
    2123#include <VBox/cdefs.h>
    2224#include <VBox/types.h>
     
    2527#include <VBox/vmm/pgm.h>
    2628#include <VBox/vmm/pdmcritsect.h>
     29#ifdef IOM_WITH_CRIT_SECT_RW
     30# include <VBox/vmm/pdmcritsectrw.h>
     31#endif
    2732#include <VBox/param.h>
    2833#include <iprt/assert.h>
     
    324329
    325330    /** Lock serializing EMT access to IOM. */
     331#ifdef IOM_WITH_CRIT_SECT_RW
     332    PDMCRITSECTRW                   CritSect;
     333#else
    326334    PDMCRITSECT                     CritSect;
     335#endif
    327336
    328337    /** @name Caching of I/O Port and MMIO ranges and statistics.
     
    426435
    427436/* IOM locking helpers. */
    428 #define IOM_LOCK(a_pVM)     PDMCritSectEnter(&(a_pVM)->iom.s.CritSect, VERR_SEM_BUSY)
    429 #define IOM_UNLOCK(a_pVM)   do { PDMCritSectLeave(&(a_pVM)->iom.s.CritSect); } while (0)
     437#ifdef IOM_WITH_CRIT_SECT_RW
     438# define IOM_LOCK(a_pVM)                        PDMCritSectRwEnterExcl(&(a_pVM)->iom.s.CritSect, VERR_SEM_BUSY)
     439# define IOM_UNLOCK(a_pVM)                      do { PDMCritSectRwLeaveExcl(&(a_pVM)->iom.s.CritSect); } while (0)
     440# if 1 /* for the time being (the lookup caches needs to be in VMCPU) */
     441# define IOM_LOCK_SHARED_EX(a_pVM, a_rcBusy)    PDMCritSectRwEnterExcl(&(a_pVM)->iom.s.CritSect, (a_rcBusy))
     442# define IOM_UNLOCK_SHARED(a_pVM)               do { PDMCritSectRwLeaveExcl(&(a_pVM)->iom.s.CritSect); } while (0)
     443# define IOM_IS_SHARED_LOCK_OWNER(a_pVM)        PDMCritSectRwIsWriteOwner(&(a_pVM)->iom.s.CritSect)
     444# else
     445# define IOM_LOCK_SHARED_EX(a_pVM, a_rcBusy)    PDMCritSectRwEnterShared(&(a_pVM)->iom.s.CritSect, (a_rcBusy))
     446# define IOM_UNLOCK_SHARED(a_pVM)               do { PDMCritSectRwLeaveShared(&(a_pVM)->iom.s.CritSect); } while (0)
     447# define IOM_IS_SHARED_LOCK_OWNER(a_pVM)        PDMCritSectRwIsReadOwner(&(a_pVM)->iom.s.CritSect, true)
     448# endif
     449# define IOM_IS_EXCL_LOCK_OWNER(a_pVM)          PDMCritSectRwIsWriteOwner(&(a_pVM)->iom.s.CritSect)
     450#else
     451# define IOM_LOCK(a_pVM)                        PDMCritSectEnter(&(a_pVM)->iom.s.CritSect, VERR_SEM_BUSY)
     452# define IOM_UNLOCK(a_pVM)                      do { PDMCritSectLeave(&(a_pVM)->iom.s.CritSect); } while (0)
     453# define IOM_LOCK_SHARED_EX(a_pVM, a_rcBusy)    PDMCritSectEnter(&(a_pVM)->iom.s.CritSect, (a_rcBusy))
     454# define IOM_UNLOCK_SHARED(a_pVM)               do { PDMCritSectLeave(&(a_pVM)->iom.s.CritSect); } while (0)
     455# define IOM_IS_SHARED_LOCK_OWNER(a_pVM)        PDMCritSectIsOwner(&(a_pVM)->iom.s.CritSect)
     456# define IOM_IS_EXCL_LOCK_OWNER(a_pVM)          PDMCritSectIsOwner(&(a_pVM)->iom.s.CritSect)
     457#endif
     458#define IOM_LOCK_SHARED(a_pVM)                  IOM_LOCK_SHARED_EX(a_pVM, VERR_SEM_BUSY)
    430459
    431460
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