- Timestamp:
- Nov 4, 2008 4:12:57 PM (16 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/hwaccm.h
r13778 r13791 70 70 71 71 #ifndef IN_GC 72 VMMDECL(int) HWACCMFlushTLB(PVM pVM);73 VMMDECL(int) HWACCMInvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys);74 VMMDECL(bool) HWACCMIsNestedPagingActive(PVM pVM);72 VMMDECL(int) HWACCMFlushTLB(PVM pVM); 73 VMMDECL(int) HWACCMInvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys); 74 VMMDECL(bool) HWACCMIsNestedPagingActive(PVM pVM); 75 75 VMMDECL(PGMMODE) HWACCMGetPagingMode(PVM pVM); 76 VMMDECL(RTCPUID) HWACCMGetVMCPUId(PVM pVM); 76 77 #else 77 78 /* Nop in GC */ -
trunk/include/VBox/vm.h
r13786 r13791 365 365 #else 366 366 /** @todo need to rework this macro for the case of multiple emulation threads for SMP */ 367 # define VM_IS_EMT(pVM) ( (pVM)->NativeThreadEMT== RTThreadNativeSelf())367 # define VM_IS_EMT(pVM) (VMR3GetVMCPUNativeThread(pVM) == RTThreadNativeSelf()) 368 368 #endif 369 369 … … 378 378 # define VM_ASSERT_EMT(pVM) \ 379 379 AssertMsg(VM_IS_EMT(pVM), \ 380 ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), pVM->NativeThreadEMT))380 ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), VMR3GetVMCPUNativeThread(pVM))) 381 381 #endif 382 382 … … 391 391 # define VM_ASSERT_EMT_RETURN(pVM, rc) \ 392 392 AssertMsgReturn(VM_IS_EMT(pVM), \ 393 ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), pVM->NativeThreadEMT), \393 ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), VMR3GetVMCPUNativeThread(pVM)), \ 394 394 (rc)) 395 #endif 396 397 398 /** @def VM_GET_VMCPUID 399 * Returns the VMCPU id of the current EMT thread. 400 */ 401 #ifdef IN_GC 402 # define VM_GET_VMCPUID(pVM) 0 403 #elif defined(IN_RING0) 404 # define VM_GET_VMCPUID(pVM) HWACCMGetVMCPUId(pVM) 405 #else 406 # define VM_GET_VMCPUID(pVM) VMR3GetVMCPUId(pVM) 395 407 #endif 396 408 … … 517 529 /** The native handle of ThreadEMT. Getting the native handle 518 530 * is generally faster than getting the IPRT one (except on OS/2 :-). */ 519 RTNATIVETHREAD NativeThreadEMT;531 RTNATIVETHREAD uPadding2; 520 532 /** @} */ 521 533 -
trunk/include/VBox/vm.mac
r13784 r13791 67 67 68 68 .uPadding1 RTHCPTR_RES 1 69 . NativeThreadEMTRTHCPTR_RES 169 .uPadding2 RTHCPTR_RES 1 70 70 71 71 .fRawR3Enabled resb 1 -
trunk/include/VBox/vmapi.h
r13782 r13791 432 432 VMMR3DECL(int) VMR3WaitHalted(PVM pVM, bool fIgnoreInterrupts); 433 433 VMMR3DECL(int) VMR3WaitU(PUVM pUVM); 434 VMMR3DECL(RTCPUID) VMR3GetVMCPUId(PVM pVM); 435 VMMR3DECL(RTTHREAD) VMR3GetVMCPUThread(PVM pVM); 436 VMMR3DECL(RTTHREAD) VMR3GetVMCPUThreadU(PUVM pUVM); 437 VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThread(PVM pVM); 438 VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThreadU(PUVM pUVM); 434 439 435 440 /** @} */ -
trunk/src/VBox/VMM/VM.cpp
r13789 r13791 426 426 for (unsigned i=0;i<cCPUs;i++) 427 427 { 428 rc = RTThreadCreate(&pUVM-> vm.s.ThreadEMT, vmR3EmulationThread, &pUVM->aCpu[i], _1M,428 rc = RTThreadCreate(&pUVM->aCpu[i].vm.s.ThreadEMT, vmR3EmulationThread, &pUVM->aCpu[i], _1M, 429 429 RTTHREADTYPE_EMULATION, RTTHREADFLAGS_WAITABLE, "EMT"); 430 430 if (RT_FAILURE(rc)) 431 431 break; 432 433 pUVM->aCpu[i].vm.s.NativeThreadEMT = RTThreadGetNative(pUVM->aCpu[i].vm.s.ThreadEMT); 432 434 } 433 435 … … 501 503 */ 502 504 pVM->pUVM = pUVM; 503 pVM->NativeThreadEMT = pUVM->aCpu[0].vm.s.NativeThreadEMT;504 505 pVM->offVMCPU = RT_OFFSETOF(VM, aCpu); 505 506 … … 552 553 LogFlow(("Ring-3 init succeeded\n")); 553 554 554 /* Initialize the VM 555 /* Initialize the VMCPU components. */ 555 556 rc = vmR3InitVMCpu(pVM); 556 557 if (VBOX_SUCCESS(rc)) … … 1587 1588 */ 1588 1589 Assert(pUVM->vm.s.fTerminateEMT); 1589 rc = RTThreadWait(pUVM->vm.s.ThreadEMT, 30000, NULL); 1590 /** @todo SMP */ 1591 rc = RTThreadWait(pUVM->aCpu[0].vm.s.ThreadEMT, 30000, NULL); 1590 1592 AssertMsgRC(rc, ("EMT thread wait failed, rc=%Rrc\n", rc)); 1591 1593 … … 1741 1743 RTSemEventSignal(pUVM->vm.s.EventSemWait); 1742 1744 1743 int rc2 = RTThreadWait(pUVM->vm.s.ThreadEMT, 2000, NULL); 1745 /** @todo SMP */ 1746 int rc2 = RTThreadWait(pUVM->aCpu[0].vm.s.ThreadEMT, 2000, NULL); 1744 1747 AssertRC(rc2); 1745 1748 } … … 3163 3166 } 3164 3167 3168 /** 3169 * Returns the VMCPU id of the current EMT thread. 3170 * 3171 * @param pVM The VM handle. 3172 * @thread EMT 3173 */ 3174 VMMR3DECL(RTCPUID) VMR3GetVMCPUId(PVM pVM) 3175 { 3176 PUVMCPU pUVMCPU = (PUVMCPU)RTTlsGet(pVM->pUVM->vm.s.idxTLS); 3177 3178 AssertMsg(pUVMCPU, ("RTTlsGet %d failed!\n", pVM->pUVM->vm.s.idxTLS)); 3179 return pUVMCPU->idCPU; 3180 } 3181 3182 /** 3183 * Returns the native handle of the current EMT VMCPU thread. 3184 * 3185 * @returns Handle if this is an EMT thread; NIL_RTNATIVETHREAD otherwise 3186 * @param pVM The VM handle. 3187 * @thread EMT 3188 */ 3189 VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThread(PVM pVM) 3190 { 3191 PUVMCPU pUVMCPU = (PUVMCPU)RTTlsGet(pVM->pUVM->vm.s.idxTLS); 3192 3193 if (!pUVMCPU) 3194 return NIL_RTNATIVETHREAD; 3195 3196 return pUVMCPU->vm.s.NativeThreadEMT; 3197 } 3198 3199 /** 3200 * Returns the native handle of the current EMT VMCPU thread. 3201 * 3202 * @returns Handle if this is an EMT thread; NIL_RTNATIVETHREAD otherwise 3203 * @param pVM The VM handle. 3204 * @thread EMT 3205 */ 3206 VMMR3DECL(RTNATIVETHREAD) VMR3GetVMCPUNativeThreadU(PUVM pUVM) 3207 { 3208 PUVMCPU pUVMCPU = (PUVMCPU)RTTlsGet(pUVM->vm.s.idxTLS); 3209 3210 if (!pUVMCPU) 3211 return NIL_RTNATIVETHREAD; 3212 3213 return pUVMCPU->vm.s.NativeThreadEMT; 3214 } 3215 3216 /** 3217 * Returns the handle of the current EMT VMCPU thread. 3218 * 3219 * @returns Handle if this is an EMT thread; NIL_RTNATIVETHREAD otherwise 3220 * @param pVM The VM handle. 3221 * @thread EMT 3222 */ 3223 VMMR3DECL(RTTHREAD) VMR3GetVMCPUThread(PVM pVM) 3224 { 3225 PUVMCPU pUVMCPU = (PUVMCPU)RTTlsGet(pVM->pUVM->vm.s.idxTLS); 3226 3227 if (!pUVMCPU) 3228 return NIL_RTTHREAD; 3229 3230 return pUVMCPU->vm.s.ThreadEMT; 3231 } 3232 3233 /** 3234 * Returns the handle of the current EMT VMCPU thread. 3235 * 3236 * @returns Handle if this is an EMT thread; NIL_RTNATIVETHREAD otherwise 3237 * @param pVM The VM handle. 3238 * @thread EMT 3239 */ 3240 VMMR3DECL(RTTHREAD) VMR3GetVMCPUThreadU(PUVM pUVM) 3241 { 3242 PUVMCPU pUVMCPU = (PUVMCPU)RTTlsGet(pUVM->vm.s.idxTLS); 3243 3244 if (!pUVMCPU) 3245 return NIL_RTTHREAD; 3246 3247 return pUVMCPU->vm.s.ThreadEMT; 3248 } -
trunk/src/VBox/VMM/VMEmt.cpp
r13785 r13791 66 66 67 67 /* 68 * Init the native thread member.69 */70 pUVM->vm.s.NativeThreadEMT = RTThreadGetNative(ThreadSelf); /* @todo should go away */71 pUVMCPU->vm.s.NativeThreadEMT = RTThreadGetNative(ThreadSelf);72 73 /*74 68 * The request loop. 75 69 */ … … 215 209 vmR3DestroyFinalBitFromEMT(pUVM); 216 210 217 pUVM ->vm.s.NativeThreadEMT = NIL_RTNATIVETHREAD;211 pUVMCPU->vm.s.NativeThreadEMT = NIL_RTNATIVETHREAD; 218 212 } 219 213 Log(("vmR3EmulationThread: EMT is terminated.\n")); -
trunk/src/VBox/VMM/VMInternal.h
r13782 r13791 262 262 PSUPDRVSESSION pSession; 263 263 264 /** The handle to the EMT thread. */265 RTTHREAD ThreadEMT;266 /** The native of the EMT thread. */267 RTNATIVETHREAD NativeThreadEMT;268 264 /** Wait event semaphore. */ 269 265 RTSEMEVENT EventSemWait; -
trunk/src/VBox/VMM/VMMAll/HWACCMAll.cpp
r13025 r13791 142 142 } 143 143 144 #ifndef IN_GC 145 /** 146 * Returns the VMCPU id of the current EMT thread. 147 * 148 * @param pVM The VM to operate on. 149 */ 150 VMMDECL(RTCPUID) HWACCMGetVMCPUId(PVM pVM) 151 { 152 /* @todo */ 153 Assert(pVM->cCPUs == 1); 154 return 0; 155 } 156 #endif -
trunk/src/VBox/VMM/VMMAll/PDMAllCritSect.cpp
r12989 r13791 30 30 #include <VBox/vm.h> 31 31 #include <VBox/err.h> 32 #include <VBox/hwaccm.h> 32 33 33 34 #include <VBox/log.h> … … 67 68 Assert(pVM); 68 69 69 /* 70 * Try take the lock. 70 RTCPUID idCPU = VM_GET_VMCPUID(pVM); 71 72 /* 73 * Try to take the lock. 71 74 */ 72 75 if (ASMAtomicCmpXchgS32(&pCritSect->s.Core.cLockers, 0, -1)) 73 76 { 74 77 pCritSect->s.Core.cNestings = 1; 75 ASMAtomicXchgSize(&pCritSect->s.Core.NativeThreadOwner, pVM->NativeThreadEMT); 78 Assert(pVM->aCpu[idCPU].hNativeThread); 79 ASMAtomicXchgSize(&pCritSect->s.Core.NativeThreadOwner, pVM->aCpu[idCPU].hNativeThread); 76 80 STAM_PROFILE_ADV_START(&pCritSect->s.StatLocked, l); 77 81 return VINF_SUCCESS; … … 81 85 * Nested? 82 86 */ 83 if (pCritSect->s.Core.NativeThreadOwner == pVM-> NativeThreadEMT)87 if (pCritSect->s.Core.NativeThreadOwner == pVM->aCpu[idCPU].hNativeThread) 84 88 { 85 89 pCritSect->s.Core.cNestings++; … … 159 163 PVM pVM = pCritSect->s.CTX_SUFF(pVM); 160 164 Assert(pVM); 161 Assert (pCritSect->s.Core.NativeThreadOwner == pVM->NativeThreadEMT);165 AssertMsg(pCritSect->s.Core.NativeThreadOwner == pVM->aCpu[VM_GET_VMCPUID(pVM)].hNativeThread, ("Owner %RX64 emt=%RX64\n", pCritSect->s.Core.NativeThreadOwner, pVM->aCpu[VM_GET_VMCPUID(pVM)].hNativeThread)); 162 166 163 167 /* … … 183 187 184 188 /* darn, someone raced in on us. */ 185 ASMAtomicXchgSize(&pCritSect->s.Core.NativeThreadOwner, pVM->NativeThreadEMT); 189 Assert(pVM->aCpu[VM_GET_VMCPUID(pVM)].hNativeThread); 190 ASMAtomicXchgSize(&pCritSect->s.Core.NativeThreadOwner, pVM->aCpu[VM_GET_VMCPUID(pVM)].hNativeThread); 186 191 STAM_PROFILE_ADV_START(&pCritSect->s.StatLocked, l); 187 192 } … … 217 222 PVM pVM = pCritSect->s.CTX_SUFF(pVM); 218 223 Assert(pVM); 219 return pCritSect->s.Core.NativeThreadOwner == pVM-> NativeThreadEMT;224 return pCritSect->s.Core.NativeThreadOwner == pVM->aCpu[VM_GET_VMCPUID(pVM)].hNativeThread; 220 225 #endif 221 226 } -
trunk/src/recompiler/VBoxREMWrapper.cpp
r13755 r13791 906 906 }; 907 907 908 909 908 /* IPRT args */ 910 909 static const REMPARMDESC g_aArgsAssertMsg1[] = … … 1143 1142 { "VMR3ReqCall", (void *)(uintptr_t)&VMR3ReqCall, &g_aArgsVMR3ReqCall[0], RT_ELEMENTS(g_aArgsVMR3ReqCall), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1144 1143 { "VMR3ReqFree", (void *)(uintptr_t)&VMR3ReqFree, &g_aArgsVMR3ReqFree[0], RT_ELEMENTS(g_aArgsVMR3ReqFree), REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_ELLIPSIS, sizeof(int), NULL }, 1144 { "VMR3GetVMCPUId", (void *)(uintptr_t)&VMR3GetVMCPUId, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1145 { "VMR3GetVMCPUNativeThread", (void *)(uintptr_t)&VMR3GetVMCPUNativeThread, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1145 1146 // { "", (void *)(uintptr_t)&, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1146 1147 }; -
trunk/src/recompiler_new/VBoxREMWrapper.cpp
r13755 r13791 337 337 static DECLCALLBACKPTR(int, pfnREMR3EmulateInstruction)(PVM); 338 338 static DECLCALLBACKPTR(int, pfnREMR3Run)(PVM); 339 static DECLCALLBACKPTR(int, pfnREMR3State)(PVM , bool fFlushTBs);339 static DECLCALLBACKPTR(int, pfnREMR3State)(PVM); 340 340 static DECLCALLBACKPTR(int, pfnREMR3StateBack)(PVM); 341 341 static DECLCALLBACKPTR(void, pfnREMR3StateUpdate)(PVM); … … 495 495 static const REMPARMDESC g_aArgsCPUMQueryGuestCtxPtr[] = 496 496 { 497 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }, 498 { REMPARMDESC_FLAGS_INT, sizeof(PCPUMCTX *), NULL } 497 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL } 499 498 }; 500 499 static const REMPARMDESC g_aArgsCSAMR3MonitorPage[] = … … 907 906 }; 908 907 909 910 908 /* IPRT args */ 911 909 static const REMPARMDESC g_aArgsAssertMsg1[] = … … 989 987 { REMPARMDESC_FLAGS_INT, sizeof(int), NULL }, 990 988 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL } 991 };992 static const REMPARMDESC g_aArgsState[] =993 {994 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },995 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }996 989 }; 997 990 … … 1011 1004 { "REMR3EmulateInstruction", (void *)&pfnREMR3EmulateInstruction, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1012 1005 { "REMR3Run", (void *)&pfnREMR3Run, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1013 { "REMR3State", (void *)&pfnREMR3State, &g_aArgs State[0], RT_ELEMENTS(g_aArgsState),REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },1006 { "REMR3State", (void *)&pfnREMR3State, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1014 1007 { "REMR3StateBack", (void *)&pfnREMR3StateBack, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1015 1008 { "REMR3StateUpdate", (void *)&pfnREMR3StateUpdate, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL }, … … 1059 1052 { "CPUMGetGuestCS", (void *)(uintptr_t)&CPUMGetGuestCS, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(RTSEL), NULL }, 1060 1053 { "CPUMGetGuestSS", (void *)(uintptr_t)&CPUMGetGuestSS, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(RTSEL), NULL }, 1061 { "CPUMQueryGuestCtxPtr", (void *)(uintptr_t)&CPUMQueryGuestCtxPtr, &g_aArgsCPUMQueryGuestCtxPtr[0], RT_ELEMENTS(g_aArgsCPUMQueryGuestCtxPtr), REMFNDESC_FLAGS_RET_INT, sizeof( int),NULL },1054 { "CPUMQueryGuestCtxPtr", (void *)(uintptr_t)&CPUMQueryGuestCtxPtr, &g_aArgsCPUMQueryGuestCtxPtr[0], RT_ELEMENTS(g_aArgsCPUMQueryGuestCtxPtr), REMFNDESC_FLAGS_RET_INT, sizeof(PCPUMCTX), NULL }, 1062 1055 { "CSAMR3MonitorPage", (void *)(uintptr_t)&CSAMR3MonitorPage, &g_aArgsCSAMR3MonitorPage[0], RT_ELEMENTS(g_aArgsCSAMR3MonitorPage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1063 1056 { "CSAMR3UnmonitorPage", (void *)(uintptr_t)&CSAMR3UnmonitorPage, &g_aArgsCSAMR3UnmonitorPage[0], RT_ELEMENTS(g_aArgsCSAMR3UnmonitorPage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, … … 1149 1142 { "VMR3ReqCall", (void *)(uintptr_t)&VMR3ReqCall, &g_aArgsVMR3ReqCall[0], RT_ELEMENTS(g_aArgsVMR3ReqCall), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1150 1143 { "VMR3ReqFree", (void *)(uintptr_t)&VMR3ReqFree, &g_aArgsVMR3ReqFree[0], RT_ELEMENTS(g_aArgsVMR3ReqFree), REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_ELLIPSIS, sizeof(int), NULL }, 1144 { "VMR3GetVMCPUId", (void *)(uintptr_t)&VMR3GetVMCPUId, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1145 { "VMR3GetVMCPUNativeThread", (void *)(uintptr_t)&VMR3GetVMCPUNativeThread, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }, 1151 1146 // { "", (void *)(uintptr_t)&, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL }, 1152 1147 }; … … 1993 1988 } 1994 1989 1995 REMR3DECL(int) REMR3State(PVM pVM , bool fFlushTBs)1990 REMR3DECL(int) REMR3State(PVM pVM) 1996 1991 { 1997 1992 #ifdef USE_REM_STUBS … … 1999 1994 #else 2000 1995 Assert(VALID_PTR(pfnREMR3State)); 2001 return pfnREMR3State(pVM , fFlushTBs);1996 return pfnREMR3State(pVM); 2002 1997 #endif 2003 1998 }
Note:
See TracChangeset
for help on using the changeset viewer.