Changeset 19435 in vbox for trunk/src/VBox/VMM
- Timestamp:
- May 6, 2009 2:01:15 PM (16 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VM.cpp
r19428 r19435 672 672 return rc; 673 673 } 674 674 675 675 676 /** … … 1095 1096 LogFlow(("vmR3PowerOn: pVM=%p\n", pVM)); 1096 1097 1098 /* 1099 * EMT(0) does the actual power on work *before* the other EMTs 1100 * get here, they just need to set their state to STARTED so they 1101 * get out of the EMT loop and into EM. 1102 */ 1097 1103 PVMCPU pVCpu = VMMGetCpu(pVM); 1098 /* Only VCPU 0 does the actual work. */1104 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED); 1099 1105 if (pVCpu->idCpu != 0) 1100 1106 return VINF_SUCCESS; … … 1199 1205 1200 1206 PVMCPU pVCpu = VMMGetCpu(pVM); 1201 /* Only VCPU 0 does the actual work . */1207 /* Only VCPU 0 does the actual work (*after* all the other CPUs has been here). */ 1202 1208 if (pVCpu->idCpu != 0) 1203 1209 return VINF_EM_SUSPEND; … … 1276 1282 1277 1283 PVMCPU pVCpu = VMMGetCpu(pVM); 1278 /* Only VCPU 0 does the actual work . */1284 /* Only VCPU 0 does the actual work (*before* the others wake up). */ 1279 1285 if (pVCpu->idCpu != 0) 1280 1286 return VINF_EM_RESUME; … … 1376 1382 * Change the state and perform the save. 1377 1383 */ 1378 /** @todo implement progress support in SSM */1379 1384 vmR3SetState(pVM, VMSTATE_SAVING); 1380 1385 int rc = SSMR3Save(pVM, pszFilename, SSMAFTER_CONTINUE, pfnProgress, pvUser); … … 1550 1555 } 1551 1556 1557 /* 1558 * EMT(0) does the actual power off work here *after* all the other EMTs 1559 * have been thru and entered the STOPPED state. 1560 */ 1552 1561 PVMCPU pVCpu = VMMGetCpu(pVM); 1553 /* Only VCPU 0 does the actual work. */1562 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STOPPED); 1554 1563 if (pVCpu->idCpu != 0) 1555 1564 return VINF_EM_OFF; … … 2154 2163 PVMREQ pReq = NULL; 2155 2164 rc = VMR3ReqCall(pVM, VMCPUID_ALL_REVERSE, &pReq, RT_INDEFINITE_WAIT, (PFNRT)vmR3Reset, 1, pVM); 2156 /** @note Can this really happen?? */2157 while (rc == VERR_TIMEOUT)2158 rc = VMR3ReqWait(pReq, RT_INDEFINITE_WAIT);2159 2160 2165 if (RT_SUCCESS(rc)) 2161 2166 rc = pReq->iStatus; … … 2183 2188 * Reset request processor. 2184 2189 * 2185 * This is called by the emulation thread as a response to the2190 * This is called by the emulation threads as a response to the 2186 2191 * reset request issued by VMR3Reset(). 2187 2192 * … … 2193 2198 PVMCPU pVCpu = VMMGetCpu(pVM); 2194 2199 2195 /* Only VCPU 0 does the full cleanup. */ 2200 /* 2201 * EMT(0) does the full cleanup *after* all the other EMTs has been 2202 * thru here and been told to enter the EMSTATE_WAIT_SIPI state. 2203 */ 2204 VMCPU_ASSERT_STATE(pVCpu, VMCPUSTATE_STARTED); 2196 2205 if (pVCpu->idCpu != 0) 2197 2206 return VINF_EM_RESET; -
trunk/src/VBox/VMM/VMEmt.cpp
r19423 r19435 88 88 */ 89 89 rc = VINF_SUCCESS; 90 volatile VMSTATE enmBefore = VMSTATE_CREATING; /* volatile because of setjmp */91 90 Log(("vmR3EmulationThread: Emulation thread starting the days work... Thread=%#x pUVM=%p\n", ThreadSelf, pUVM)); 91 VMSTATE enmBefore = VMSTATE_CREATED; /* (only used for logging atm.) */ 92 92 for (;;) 93 93 { 94 /* Requested to exit the EMT thread out of sync? (currently only VMR3WaitForResume) */95 if (setjmp(pUVCpu->vm.s.emtJumpEnv) != 0)96 {97 rc = VINF_SUCCESS;98 break;99 }100 101 94 /* 102 95 * During early init there is no pVM, so make a special path … … 148 141 else 149 142 { 150 151 143 /* 152 144 * Pending requests which needs servicing? … … 216 208 217 209 /* 218 * Some requests (both VMR3Req* and the DBGF) can potentially 219 * resume or start the VM, in that case we'll get a change in220 * VM statusindicating that we're now running.210 * Some requests (both VMR3Req* and the DBGF) can potentially resume 211 * or start the VM, in that case we'll get a change in VM status 212 * indicating that we're now running. 221 213 */ 222 214 if ( RT_SUCCESS(rc) 223 && pUVM->pVM 224 && enmBefore != pUVM->pVM->enmVMState 225 && pUVM->pVM->enmVMState == VMSTATE_RUNNING) 226 { 227 PVM pVM = pUVM->pVM; 215 && pUVM->pVM) 216 { 217 PVM pVM = pUVM->pVM; 228 218 PVMCPU pVCpu = &pVM->aCpus[idCpu]; 229 230 rc = EMR3ExecuteVM(pVM, pVCpu); 231 Log(("vmR3EmulationThread: EMR3ExecuteVM() -> rc=%Rrc, enmVMState=%d\n", rc, pVM->enmVMState)); 232 if ( EMGetState(pVCpu) == EMSTATE_GURU_MEDITATION 233 && pVM->enmVMState == VMSTATE_RUNNING) 234 vmR3SetState(pVM, VMSTATE_GURU_MEDITATION); 219 if ( pVM->enmVMState == VMSTATE_RUNNING 220 && VMCPUSTATE_IS_STARTED(VMCPU_GET_STATE(pVCpu))) 221 { 222 rc = EMR3ExecuteVM(pVM, pVCpu); 223 Log(("vmR3EmulationThread: EMR3ExecuteVM() -> rc=%Rrc, enmVMState=%d\n", rc, pVM->enmVMState)); 224 if ( EMGetState(pVCpu) == EMSTATE_GURU_MEDITATION 225 && pVM->enmVMState == VMSTATE_RUNNING) 226 vmR3SetState(pVM, VMSTATE_GURU_MEDITATION); 227 } 235 228 } 236 229 … … 260 253 } 261 254 262 263 #if 0 /* not used */264 /**265 * Wait for VM to be resumed. Handle events like vmR3EmulationThread does.266 * In case the VM is stopped, clean up and long jump to the main EMT loop.267 *268 * @returns VINF_SUCCESS or doesn't return269 * @param pVM VM handle.270 */271 VMMR3DECL(int) VMR3WaitForResume(PVM pVM)272 {273 /*274 * The request loop.275 */276 PUVMCPU pUVCpu;277 PUVM pUVM = pVM->pUVM;278 VMSTATE enmBefore;279 int rc;280 281 pUVCpu = (PUVMCPU)RTTlsGet(pUVM->vm.s.idxTLS);282 AssertReturn(pUVCpu, VERR_INTERNAL_ERROR);283 284 for (;;)285 {286 287 /*288 * Pending requests which needs servicing?289 *290 * We check for state changes in addition to status codes when291 * servicing requests. (Look after the ifs.)292 */293 enmBefore = pVM->enmVMState;294 if ( VM_FF_ISSET(pVM, VM_FF_TERMINATE)295 || pUVM->vm.s.fTerminateEMT)296 {297 rc = VINF_EM_TERMINATE;298 break;299 }300 else if (pUVM->vm.s.pReqs)301 {302 /*303 * Service execute in EMT request.304 */305 rc = VMR3ReqProcessU(pUVM, VMCPUID_ANY);306 Log(("vmR3EmulationThread: Req rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState));307 }308 else if (pUVCpu->vm.s.pReqs)309 {310 /*311 * Service execute in EMT request.312 */313 rc = VMR3ReqProcessU(pUVM, pUVCpu->idCpu);314 Log(("vmR3EmulationThread: Req (cpu=%u) rc=%Rrc, VM state %d -> %d\n", pUVCpu->idCpu, rc, enmBefore, pVM->enmVMState));315 }316 else if (VM_FF_ISSET(pVM, VM_FF_DBGF))317 {318 /*319 * Service the debugger request.320 */321 rc = DBGFR3VMMForcedAction(pVM);322 Log(("vmR3EmulationThread: Dbg rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState));323 }324 else if (VM_FF_TESTANDCLEAR(pVM, VM_FF_RESET_BIT))325 {326 /*327 * Service a delay reset request.328 */329 rc = VMR3Reset(pVM);330 VM_FF_CLEAR(pVM, VM_FF_RESET);331 Log(("vmR3EmulationThread: Reset rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState));332 }333 else334 {335 /*336 * Nothing important is pending, so wait for something.337 */338 rc = VMR3WaitU(pUVCpu);339 if (RT_FAILURE(rc))340 break;341 }342 343 /*344 * Check for termination requests, these are extremely high priority.345 */346 if ( rc == VINF_EM_TERMINATE347 || VM_FF_ISSET(pVM, VM_FF_TERMINATE)348 || pUVM->vm.s.fTerminateEMT)349 break;350 351 /*352 * Some requests (both VMR3Req* and the DBGF) can potentially353 * resume or start the VM, in that case we'll get a change in354 * VM status indicating that we're now running.355 */356 if ( RT_SUCCESS(rc)357 && enmBefore != pVM->enmVMState358 && pVM->enmVMState == VMSTATE_RUNNING)359 {360 /* Only valid exit reason. */361 return VINF_SUCCESS;362 }363 364 } /* forever */365 366 /* Return to the main loop in vmR3EmulationThread, which will clean up for us. */367 longjmp(pUVCpu->vm.s.emtJumpEnv, 1);368 }369 #endif370 255 371 256 /** … … 848 733 } 849 734 else if ( (fFlags & VMNOTIFYFF_FLAGS_POKE) 850 && pUVCpu->p UVM->pVM851 && pUVCpu->p UVM->pVM->aCpus[pUVCpu->idCpu].enmState == VMCPUSTATE_RUN_EXEC) /** @todo make this easier to access. (pUVCpu->pVCpu) */735 && pUVCpu->pVCpu 736 && pUVCpu->pVCpu->enmState == VMCPUSTATE_STARTED_EXEC) 852 737 { 853 738 int rc = SUPCallVMMR0Ex(pUVCpu->pVM->pVMR0, pUVCpu->idCpu, VMMR0_DO_GVMM_SCHED_POKE, 0, NULL); … … 1125 1010 * Do the halt. 1126 1011 */ 1012 Assert(VMCPU_GET_STATE(pVCpu) == VMCPUSTATE_STARTED); 1013 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED_HALTED); 1127 1014 PUVM pUVM = pUVCpu->pUVM; 1128 1015 int rc = g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnHalt(pUVCpu, fMask, u64Now); 1016 VMCPU_SET_STATE(pVCpu, VMCPUSTATE_STARTED); 1129 1017 1130 1018 /* -
trunk/src/VBox/VMM/VMInternal.h
r19401 r19435 449 449 STAMPROFILE StatHaltPoll; 450 450 /** @} */ 451 452 /** vmR3EmulationThread longjmp buffer. Must be last in the structure. */453 jmp_buf emtJumpEnv;454 451 } VMINTUSERPERVMCPU; 455 452 -
trunk/src/VBox/VMM/VMMR0/GVMMR0.cpp
r19406 r19435 1669 1669 DECLINLINE(int) gvmmR0SchedPokeOne(PGVM pGVM, PVMCPU pVCpu) 1670 1670 { 1671 if (pVCpu->enmState != VMCPUSTATE_ RUN_EXEC)1671 if (pVCpu->enmState != VMCPUSTATE_STARTED_EXEC) 1672 1672 return VINF_GVM_NOT_BUSY_IN_GC; 1673 1673
Note:
See TracChangeset
for help on using the changeset viewer.