VirtualBox

Changeset 20071 in vbox


Ignore:
Timestamp:
May 27, 2009 12:07:38 PM (15 years ago)
Author:
vboxsync
Message:

Bit more REM locking

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/em.h

    r19693 r20071  
    183183
    184184VMMR3DECL(void)     EMR3ReleaseOwnedLocks(PVM pVM);
     185VMMR3DECL(void)     EMR3RemUnlock(PVM pVM);
     186VMMR3DECL(void)     EMR3RemLock(PVM pVM);
    185187
    186188/**
  • trunk/src/VBox/VMM/EM.cpp

    r20040 r20071  
    109109static int emR3SingleStepExecRem(PVM pVM, uint32_t cIterations);
    110110static EMSTATE emR3Reschedule(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
    111 static void emR3RemLock(PVM pVM);
    112 static void emR3RemUnlock(PVM pVM);
    113111
    114112/**
     
    872870 * @param   pVM         VM handle.
    873871 */
    874 static void emR3RemLock(PVM pVM)
     872VMMR3DECL(void) EMR3RemLock(PVM pVM)
    875873{
    876874    int rc = PDMCritSectEnter(&pVM->em.s.CritSectREM, VERR_SEM_BUSY);
     
    883881 * @param   pVM         VM handle.
    884882 */
    885 static void emR3RemUnlock(PVM pVM)
     883VMMR3DECL(void) EMR3RemUnlock(PVM pVM)
    886884{
    887885    PDMCritSectLeave(&pVM->em.s.CritSectREM);
     
    901899    LogFlow(("emR3RemStep: cs:eip=%04x:%08x\n", CPUMGetGuestCS(pVCpu),  CPUMGetGuestEIP(pVCpu)));
    902900
    903     emR3RemLock(pVM);
     901    EMR3RemLock(pVM);
    904902
    905903    /*
     
    912910        REMR3StateBack(pVM, pVCpu);
    913911    }
    914     emR3RemUnlock(pVM);
     912    EMR3RemUnlock(pVM);
    915913
    916914    LogFlow(("emR3RemStep: returns %Rrc cs:eip=%04x:%08x\n", rc, CPUMGetGuestCS(pVCpu),  CPUMGetGuestEIP(pVCpu)));
     
    954952
    955953    /* Big lock, but you are not supposed to own any lock when coming in here. */
    956     emR3RemLock(pVM);
     954    EMR3RemLock(pVM);
    957955
    958956    /*
     
    10771075        STAM_PROFILE_STOP(&pVCpu->em.s.StatREMSync, e);
    10781076    }
    1079     emR3RemUnlock(pVM);
     1077    EMR3RemUnlock(pVM);
    10801078
    10811079    STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatREMTotal, a);
     
    14821480    STAM_PROFILE_START(&pVCpu->em.s.StatREMEmu, a);
    14831481    Log(("EMINS: %04x:%RGv RSP=%RGv\n", pCtx->cs, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp));
    1484     emR3RemLock(pVM);
     1482    EMR3RemLock(pVM);
    14851483    /* Flush the recompiler TLB if the VCPU has changed. */
    14861484    if (pVM->em.s.idLastRemCpu != pVCpu->idCpu)
     
    14891487
    14901488    rc = REMR3EmulateInstruction(pVM, pVCpu);
    1491     emR3RemUnlock(pVM);
     1489    EMR3RemUnlock(pVM);
    14921490    STAM_PROFILE_STOP(&pVCpu->em.s.StatREMEmu, a);
    14931491
     
    24972495        case VERR_REM_FLUSHED_PAGES_OVERFLOW:
    24982496            Assert((pCtx->ss & X86_SEL_RPL) != 1);
    2499             emR3RemLock(pVM);
     2497            EMR3RemLock(pVM);
    25002498            REMR3ReplayInvalidatedPages(pVM, pVCpu);
    2501             emR3RemUnlock(pVM);
     2499            EMR3RemUnlock(pVM);
    25022500            rc = VINF_SUCCESS;
    25032501            break;
     
    34503448        if (VM_FF_IS_PENDING_EXCEPT(pVM, VM_FF_REM_HANDLER_NOTIFY, VM_FF_PGM_NO_MEMORY))
    34513449        {
    3452             emR3RemLock(pVM);
     3450            EMR3RemLock(pVM);
    34533451            REMR3ReplayHandlerNotifications(pVM);
    3454             emR3RemUnlock(pVM);
     3452            EMR3RemUnlock(pVM);
    34553453        }
    34563454
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r19861 r20071  
    18411841        }
    18421842        GMMR3FreePagesCleanup(pReq);
     1843        pgmUnlock(pVM);
    18431844    }
    18441845    else
     
    18461847        /* link in the ram range */
    18471848        pgmR3PhysLinkRamRange(pVM, &pCur->RamRange, pRamPrev);
     1849        pgmUnlock(pVM);
    18481850        REMR3NotifyPhysRamRegister(pVM, GCPhys, pCur->RamRange.cb, REM_NOTIFY_PHYS_RAM_FLAGS_MMIO2);
    18491851    }
    18501852
    1851     pgmUnlock(pVM);
    18521853
    18531854    return VINF_SUCCESS;
  • trunk/src/recompiler/VBoxREMWrapper.cpp

    r20002 r20071  
    11071107    { "DISInstr",                               (void *)(uintptr_t)&DISInstr,                       &g_aArgsDISInstr[0],                        RT_ELEMENTS(g_aArgsDISInstr),                          REMFNDESC_FLAGS_RET_INT,    sizeof(bool),       NULL },
    11081108    { "EMR3FatalError",                         (void *)(uintptr_t)&EMR3FatalError,                 &g_aArgsEMR3FatalError[0],                  RT_ELEMENTS(g_aArgsEMR3FatalError),                    REMFNDESC_FLAGS_RET_VOID,   0,                  NULL },
     1109    { "EMR3RemLock",                            (void *)(uintptr_t)&EMR3RemLock,                    &g_aArgsVM[0],                              RT_ELEMENTS(g_aArgsVM),                                REMFNDESC_FLAGS_RET_VOID,   0,                  NULL },
     1110    { "EMR3RemUnlock",                          (void *)(uintptr_t)&EMR3RemUnlock,                  &g_aArgsVM[0],                              RT_ELEMENTS(g_aArgsVM),                                REMFNDESC_FLAGS_RET_VOID,   0,                  NULL },
    11091111    { "HWACCMR3CanExecuteGuest",                (void *)(uintptr_t)&HWACCMR3CanExecuteGuest,        &g_aArgsHWACCMR3CanExecuteGuest[0],         RT_ELEMENTS(g_aArgsHWACCMR3CanExecuteGuest),           REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
    11101112    { "IOMIOPortRead",                          (void *)(uintptr_t)&IOMIOPortRead,                  &g_aArgsIOMIOPortRead[0],                   RT_ELEMENTS(g_aArgsIOMIOPortRead),                     REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
     
    11501152    { "PGMR3PhysWriteU64",                      (void *)(uintptr_t)&PGMR3PhysWriteU64,              &g_aArgsPGMR3PhysWriteU64[0],               RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32),                 REMFNDESC_FLAGS_RET_VOID,   0,                  NULL },
    11511153    { "PGMR3PhysTlbGCPhys2Ptr",                 (void *)(uintptr_t)&PGMR3PhysTlbGCPhys2Ptr,         &g_aArgsPGMR3PhysTlbGCPhys2Ptr[0],          RT_ELEMENTS(g_aArgsPGMR3PhysTlbGCPhys2Ptr),            REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
     1154    { "PGMIsLockOwner",                         (void *)(uintptr_t)&PGMIsLockOwner,                 &g_aArgsVM[0],                              RT_ELEMENTS(g_aArgsVM),                                REMFNDESC_FLAGS_RET_INT,    sizeof(bool),       NULL },
    11521155    { "SSMR3GetGCPtr",                          (void *)(uintptr_t)&SSMR3GetGCPtr,                  &g_aArgsSSMR3GetGCPtr[0],                   RT_ELEMENTS(g_aArgsSSMR3GetGCPtr),                     REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
    11531156    { "SSMR3GetMem",                            (void *)(uintptr_t)&SSMR3GetMem,                    &g_aArgsSSMR3GetMem[0],                     RT_ELEMENTS(g_aArgsSSMR3GetMem),                       REMFNDESC_FLAGS_RET_INT,    sizeof(int),        NULL },
  • trunk/src/recompiler/VBoxRecompiler.c

    r20002 r20071  
    28392839    Assert(RT_ALIGN_Z(cb, PAGE_SIZE) == cb);
    28402840    AssertMsg(fFlags == REM_NOTIFY_PHYS_RAM_FLAGS_RAM || fFlags == REM_NOTIFY_PHYS_RAM_FLAGS_MMIO2, ("#x\n", fFlags));
     2841    Assert(!PGMIsLockOwner(pVM));
     2842
     2843    EMR3RemLock(pVM);
    28412844
    28422845    /*
     
    28612864    Assert(pVM->rem.s.fIgnoreAll);
    28622865    pVM->rem.s.fIgnoreAll = false;
     2866    EMR3RemUnlock(pVM);
    28632867}
    28642868
     
    28862890    Assert(cb);
    28872891    Assert(RT_ALIGN_Z(cb, PAGE_SIZE) == cb);
    2888 
     2892    Assert(!PGMIsLockOwner(pVM));
     2893
     2894    EMR3RemLock(pVM);
    28892895    /*
    28902896     * Register the rom.
     
    28972903    Assert(pVM->rem.s.fIgnoreAll);
    28982904    pVM->rem.s.fIgnoreAll = false;
     2905    EMR3RemUnlock(pVM);
    28992906}
    29002907
     
    29182925    Assert(cb);
    29192926    Assert(RT_ALIGN_Z(cb, PAGE_SIZE) == cb);
     2927    Assert(!PGMIsLockOwner(pVM));
     2928
     2929    EMR3RemLock(pVM);
    29202930
    29212931    /*
     
    29292939    Assert(pVM->rem.s.fIgnoreAll);
    29302940    pVM->rem.s.fIgnoreAll = false;
     2941    EMR3RemUnlock(pVM);
    29312942}
    29322943
     
    29512962    Assert(RT_ALIGN_T(GCPhys, PAGE_SIZE, RTGCPHYS) == GCPhys);
    29522963    Assert(RT_ALIGN_T(cb, PAGE_SIZE, RTGCPHYS) == cb);
    2953 
     2964    Assert(!PGMIsLockOwner(pVM));
     2965
     2966    EMR3RemLock(pVM);
    29542967    if (pVM->rem.s.cHandlerNotifications)
    29552968        REMR3ReplayHandlerNotifications(pVM);
     
    29652978    Assert(pVM->rem.s.fIgnoreAll);
    29662979    pVM->rem.s.fIgnoreAll = false;
     2980    EMR3RemUnlock(pVM);
    29672981}
    29682982
     
    29832997          enmType, GCPhys, cb, fHasHCHandler, fRestoreAsRAM, MMR3PhysGetRamSize(pVM)));
    29842998    VM_ASSERT_EMT(pVM);
     2999    Assert(!PGMIsLockOwner(pVM));
     3000
     3001    EMR3RemLock(pVM);
    29853002
    29863003    if (pVM->rem.s.cHandlerNotifications)
     
    30103027    Assert(pVM->rem.s.fIgnoreAll);
    30113028    pVM->rem.s.fIgnoreAll = false;
     3029    EMR3RemUnlock(pVM);
    30123030}
    30133031
     
    30303048    VM_ASSERT_EMT(pVM);
    30313049    AssertReleaseMsg(enmType != PGMPHYSHANDLERTYPE_MMIO, ("enmType=%d\n", enmType));
     3050    Assert(!PGMIsLockOwner(pVM));
     3051
     3052    EMR3RemLock(pVM);
    30323053
    30333054    if (pVM->rem.s.cHandlerNotifications)
     
    30623083        pVM->rem.s.fIgnoreAll = false;
    30633084    }
     3085    EMR3RemUnlock(pVM);
    30643086}
    30653087
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