- Timestamp:
- Apr 30, 2009 3:55:16 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/EM.cpp
r19241 r19278 109 109 static int emR3SingleStepExecRem(PVM pVM, uint32_t cIterations); 110 110 static EMSTATE emR3Reschedule(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx); 111 static void emR3RemLock(PVM pVM); 112 static void emR3RemUnlock(PVM pVM); 111 113 112 114 /** … … 138 140 pVM->fRawR0Enabled = true; 139 141 Log(("EMR3Init: fRawR3Enabled=%d fRawR0Enabled=%d\n", pVM->fRawR3Enabled, pVM->fRawR0Enabled)); 142 143 /* 144 * Initialize the REM critical section. 145 */ 146 rc = PDMR3CritSectInit(pVM, &pVM->em.s.CritSectREM, "EM-REM"); 147 AssertRCReturn(rc, rc); 140 148 141 149 /* … … 476 484 { 477 485 AssertMsg(pVM->em.s.offVM, ("bad init order!\n")); 486 487 PDMR3CritSectDelete(&pVM->em.s.CritSectREM); 478 488 return VINF_SUCCESS; 479 489 } … … 837 847 } 838 848 849 /** 850 * Locks REM execution to a single VCpu 851 * 852 * @param pVM VM handle. 853 */ 854 static void emR3RemLock(PVM pVM) 855 { 856 int rc = PDMCritSectEnter(&pVM->em.s.CritSectREM, VERR_SEM_BUSY); 857 AssertMsg(rc == VINF_SUCCESS, ("%Rrc\n", rc)); 858 } 859 860 /** 861 * Unlocks REM execution 862 * 863 * @param pVM VM handle. 864 */ 865 static void emR3RemUnlock(PVM pVM) 866 { 867 PDMCritSectLeave(&pVM->em.s.CritSectREM); 868 } 839 869 840 870 /** … … 851 881 LogFlow(("emR3RemStep: cs:eip=%04x:%08x\n", CPUMGetGuestCS(pVCpu), CPUMGetGuestEIP(pVCpu))); 852 882 883 emR3RemLock(pVM); 884 853 885 /* 854 886 * Switch to REM, step instruction, switch back. … … 860 892 REMR3StateBack(pVM, pVCpu); 861 893 } 894 emR3RemUnlock(pVM); 895 862 896 LogFlow(("emR3RemStep: returns %Rrc cs:eip=%04x:%08x\n", rc, CPUMGetGuestCS(pVCpu), CPUMGetGuestEIP(pVCpu))); 863 897 return rc; … … 899 933 #endif 900 934 935 /* Big lock, but you are not supposed to own any lock when coming in here. */ 936 emR3RemLock(pVM); 937 901 938 /* 902 939 * Spin till we get a forced action which returns anything but VINF_SUCCESS … … 906 943 bool fInREMState = false; 907 944 int rc = VINF_SUCCESS; 945 946 /* Flush the recompiler TLB if the VCPU has changed. */ 947 if (pVM->em.s.idLastRemCpu != pVCpu->idCpu) 948 REMFlushTBs(pVM); 949 pVM->em.s.idLastRemCpu = pVCpu->idCpu; 950 908 951 for (;;) 909 952 { … … 1008 1051 STAM_PROFILE_STOP(&pVCpu->em.s.StatREMSync, e); 1009 1052 } 1053 emR3RemUnlock(pVM); 1010 1054 1011 1055 STAM_REL_PROFILE_ADV_STOP(&pVCpu->em.s.StatREMTotal, a); … … 1412 1456 STAM_PROFILE_START(&pVCpu->em.s.StatREMEmu, a); 1413 1457 Log(("EMINS: %04x:%RGv RSP=%RGv\n", pCtx->cs, (RTGCPTR)pCtx->rip, (RTGCPTR)pCtx->rsp)); 1458 emR3RemLock(pVM); 1414 1459 rc = REMR3EmulateInstruction(pVM, pVCpu); 1460 emR3RemUnlock(pVM); 1415 1461 STAM_PROFILE_STOP(&pVCpu->em.s.StatREMEmu, a); 1416 1462 … … 2420 2466 case VERR_REM_FLUSHED_PAGES_OVERFLOW: 2421 2467 Assert((pCtx->ss & X86_SEL_RPL) != 1); 2468 emR3RemLock(pVM); 2422 2469 REMR3ReplayInvalidatedPages(pVM, pVCpu); 2470 emR3RemUnlock(pVM); 2423 2471 rc = VINF_SUCCESS; 2424 2472 break; … … 3354 3402 /* Replay the handler notification changes. */ 3355 3403 if (VM_FF_IS_PENDING_EXCEPT(pVM, VM_FF_REM_HANDLER_NOTIFY, VM_FF_PGM_NO_MEMORY)) 3404 { 3405 emR3RemLock(pVM); 3356 3406 REMR3ReplayHandlerNotifications(pVM); 3407 emR3RemUnlock(pVM); 3408 } 3357 3409 3358 3410 /* check that we got them all */ -
trunk/src/VBox/VMM/EMInternal.h
r18927 r19278 29 29 #include <VBox/patm.h> 30 30 #include <VBox/dis.h> 31 #include <VBox/pdmcritsect.h> 31 32 #include <iprt/avl.h> 32 33 #include <setjmp.h> … … 289 290 * See EM2VM(). */ 290 291 RTUINT offVM; 292 293 /** Id of the VCPU that last executed code in the recompiler. */ 294 VMCPUID idLastRemCpu; 295 296 /** PGM critical section. 297 * This protects recompiler usage 298 */ 299 PDMCRITSECT CritSectREM; 291 300 } EM; 292 301 /** Pointer to EM VM instance data. */
Note:
See TracChangeset
for help on using the changeset viewer.