Changeset 247 in vbox
- Timestamp:
- Jan 23, 2007 5:10:04 PM (18 years ago)
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/MM.cpp
r107 r247 407 407 * 408 408 * @returns VBox status code. 409 * @param pVM The VM handle. 410 * @param pv Pointer to memory range which shall be locked down. 411 * This pointer is page aligned. 412 * @param cb Size of memory range (in bytes). This size is page aligned. 413 * @param eType Memory type. 414 * @param ppLockedMem Where to store the pointer to the created locked memory record. 415 * This is optional, pass NULL if not used. 416 */ 417 int mmr3LockMem(PVM pVM, void *pv, size_t cb, MMLOCKEDTYPE eType, PMMLOCKEDMEM *ppLockedMem) 409 * @param pVM The VM handle. 410 * @param pv Pointer to memory range which shall be locked down. 411 * This pointer is page aligned. 412 * @param cb Size of memory range (in bytes). This size is page aligned. 413 * @param eType Memory type. 414 * @param ppLockedMem Where to store the pointer to the created locked memory record. 415 * This is optional, pass NULL if not used. 416 * @param fSilentFailure Don't raise an error when unsuccessful. Upper layer with deal with it. 417 */ 418 int mmr3LockMem(PVM pVM, void *pv, size_t cb, MMLOCKEDTYPE eType, PMMLOCKEDMEM *ppLockedMem, bool fSilentFailure) 418 419 { 419 420 Assert(RT_ALIGN_P(pv, PAGE_SIZE) == pv); … … 465 466 AssertMsgFailed(("SUPPageLock failed with rc=%d\n", rc)); 466 467 MMR3HeapFree(pLockedMem); 467 rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to lock %d bytes of host memory (out of memory)"), cb); 468 if (!fSilentFailure) 469 rc = VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to lock %d bytes of host memory (out of memory)"), cb); 468 470 } 469 471 -
trunk/src/VBox/VMM/MMInternal.h
r161 r247 656 656 int mmR3HyperInitPaging(PVM pVM); 657 657 658 int mmr3LockMem(PVM pVM, void *pv, size_t cb, MMLOCKEDTYPE eType, PMMLOCKEDMEM *ppLockedMem );658 int mmr3LockMem(PVM pVM, void *pv, size_t cb, MMLOCKEDTYPE eType, PMMLOCKEDMEM *ppLockedMem, bool fSilentFailure = false); 659 659 int mmr3MapLocked(PVM pVM, PMMLOCKEDMEM pLockedMem, RTGCPTR Addr, unsigned iPage, size_t cPages, unsigned fFlags); 660 660 -
trunk/src/VBox/VMM/MMPhys.cpp
r23 r247 148 148 */ 149 149 PMMLOCKEDMEM pLockedMem; 150 rc = mmr3LockMem(pVM, pvRam, cb, MM_LOCKED_TYPE_PHYS, &pLockedMem );150 rc = mmr3LockMem(pVM, pvRam, cb, MM_LOCKED_TYPE_PHYS, &pLockedMem, (enmType == MM_PHYS_TYPE_DYNALLOC_CHUNK) ? false : true /* fSilentFailure */); 151 151 if (VBOX_SUCCESS(rc)) 152 152 { … … 182 182 } 183 183 /* Cleanup is done in VM destruction to which failure of this function will lead. */ 184 /* Not true in case of MM_PHYS_TYPE_DYNALLOC_CHUNK */ 184 185 } 185 186 -
trunk/src/VBox/VMM/PGMPhys.cpp
r80 r247 376 376 if (VBOX_SUCCESS(rc)) 377 377 return rc; 378 378 379 SUPPageFree(pvRam); 380 381 LogRel(("pgmr3PhysGrowRange: out of memory. pause until the user resumes execution.\n")); 382 VMSetRuntimeError(pVM, false, "HostMemoryLow", "Unable to allocate and lock memory. The virtual machine will be paused. Please close applications to free up memory or save and close the VM."); 383 384 rc = VMR3Suspend(pVM); 385 AssertRC(rc); 386 387 /* Wait for resume event; will only return in that case. If the VM is stopped, the EMT thread will be destroyed. */ 388 rc = VMR3WaitForResume(pVM); 389 390 /* Retry */ 391 LogRel(("pgmr3PhysGrowRange: VM execution resumed -> retry.\n")); 392 return pgmr3PhysGrowRange(pVM, GCPhys); 393 379 394 } 380 395 return rc; -
trunk/src/VBox/VMM/VMEmt.cpp
r23 r247 68 68 for (;;) 69 69 { 70 /* Requested to exit the EMT thread out of sync? (currently only VMR3WaitForResume) */ 71 if (setjmp(pVM->vm.s.emtJumpEnv) != 0) 72 break; 70 73 71 74 /* … … 126 129 * Some requests (both VMR3Req* and the DBGF) can potentially 127 130 * resume or start the VM, in that case we'll get a change in 128 * VM status indicating that we're no running.131 * VM status indicating that we're now running. 129 132 */ 130 133 if ( VBOX_SUCCESS(rc) … … 140 143 141 144 /* 142 * Exit ting.145 * Exiting. 143 146 */ 144 147 Log(("vmR3EmulationThread: Terminating emulation thread! Thread=%#x pVM=%p rc=%Vrc enmBefore=%d enmVMState=%d\n", … … 159 162 } 160 163 164 /** 165 * Wait for VM to be resumed. Handle events like vmR3EmulationThread does. 166 * In case the VM is stopped, clean up and long jump to the main EMT loop. 167 * 168 * @returns VINF_SUCCESS or doesn't return 169 * @param pVM VM handle. 170 */ 171 VMR3DECL(int) VMR3WaitForResume(PVM pVM) 172 { 173 /* 174 * The request loop. 175 */ 176 VMSTATE enmBefore; 177 int rc; 178 for (;;) 179 { 180 181 /* 182 * Pending requests which needs servicing? 183 * 184 * We check for state changes in addition to status codes when 185 * servicing requests. (Look after the ifs.) 186 */ 187 enmBefore = pVM->enmVMState; 188 if (VM_FF_ISSET(pVM, VM_FF_TERMINATE)) 189 { 190 rc = VINF_EM_TERMINATE; 191 break; 192 } 193 else if (pVM->vm.s.pReqs) 194 { 195 /* 196 * Service execute in EMT request. 197 */ 198 rc = VMR3ReqProcess(pVM); 199 Log(("vmR3EmulationThread: Req rc=%Vrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState)); 200 } 201 else if (VM_FF_ISSET(pVM, VM_FF_DBGF)) 202 { 203 /* 204 * Service the debugger request. 205 */ 206 rc = DBGFR3VMMForcedAction(pVM); 207 Log(("vmR3EmulationThread: Dbg rc=%Vrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState)); 208 } 209 else if (VM_FF_ISSET(pVM, VM_FF_RESET)) 210 { 211 /* 212 * Service a delay reset request. 213 */ 214 rc = VMR3Reset(pVM); 215 VM_FF_CLEAR(pVM, VM_FF_RESET); 216 Log(("vmR3EmulationThread: Reset rc=%Vrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState)); 217 } 218 else 219 { 220 /* 221 * Nothing important is pending, so wait for something. 222 */ 223 rc = VMR3Wait(pVM); 224 if (VBOX_FAILURE(rc)) 225 break; 226 } 227 228 /* 229 * Check for termination requests, these are extremely high priority. 230 */ 231 if ( rc == VINF_EM_TERMINATE 232 || VM_FF_ISSET(pVM, VM_FF_TERMINATE)) 233 break; 234 235 /* 236 * Some requests (both VMR3Req* and the DBGF) can potentially 237 * resume or start the VM, in that case we'll get a change in 238 * VM status indicating that we're now running. 239 */ 240 if ( VBOX_SUCCESS(rc) 241 && enmBefore != pVM->enmVMState 242 && (pVM->enmVMState == VMSTATE_RUNNING)) 243 { 244 /* Only valid exit reason. */ 245 return VINF_SUCCESS; 246 } 247 248 } /* forever */ 249 250 /* Return to the main loop in vmR3EmulationThread, which will clean up for us. */ 251 longjmp(pVM->vm.s.emtJumpEnv, 1); 252 } 161 253 162 254 /** -
trunk/src/VBox/VMM/VMInternal.h
r234 r247 25 25 #include <VBox/cdefs.h> 26 26 #include <VBox/vmapi.h> 27 27 #include <setjmp.h> 28 28 29 29 #if !defined(IN_VM_R3) && !defined(IN_VM_R0) && !defined(IN_VM_GC) … … 256 256 bool fEMTDoesTheCleanup; 257 257 258 /** vmR3EmulationThread longjmp buffer */ 259 jmp_buf emtJumpEnv; 260 258 261 /** Number of VMR3ReqAlloc returning a new packet. */ 259 262 STAMCOUNTER StatReqAllocNew; -
trunk/src/VBox/VMM/VMMInternal.h
r234 r247 250 250 VMMR0JMPBUF CallHostR0JmpBuf; 251 251 /** @} */ 252 252 253 253 /** Number of VMMR0_DO_RUN_GC calls. */ 254 254 STAMCOUNTER StatRunGC;
Note:
See TracChangeset
for help on using the changeset viewer.