VirtualBox

source: vbox/trunk/src/VBox/VMM/VMEmt.cpp@ 18619

Last change on this file since 18619 was 18619, checked in by vboxsync, 16 years ago

PDM,EM: Killed PDMR3Poll. RIP.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 37.3 KB
Line 
1/* $Id: VMEmt.cpp 18619 2009-04-01 22:14:47Z vboxsync $ */
2/** @file
3 * VM - Virtual Machine, The Emulation Thread.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Header Files *
25*******************************************************************************/
26#define LOG_GROUP LOG_GROUP_VM
27#include <VBox/tm.h>
28#include <VBox/dbgf.h>
29#include <VBox/em.h>
30#include <VBox/pdmapi.h>
31#include <VBox/rem.h>
32#include <VBox/tm.h>
33#include "VMInternal.h"
34#include <VBox/vm.h>
35#include <VBox/uvm.h>
36
37#include <VBox/err.h>
38#include <VBox/log.h>
39#include <iprt/assert.h>
40#include <iprt/asm.h>
41#include <iprt/semaphore.h>
42#include <iprt/string.h>
43#include <iprt/thread.h>
44#include <iprt/time.h>
45
46
47/**
48 * The emulation thread.
49 *
50 * @returns Thread exit code.
51 * @param ThreadSelf The handle to the executing thread.
52 * @param pvArgs Pointer to the user mode VM structure (UVM).
53 */
54DECLCALLBACK(int) vmR3EmulationThread(RTTHREAD ThreadSelf, void *pvArgs)
55{
56 PUVMCPU pUVMCPU = (PUVMCPU)pvArgs;
57 PUVM pUVM = pUVMCPU->pUVM;
58 RTCPUID idCpu = pUVMCPU->idCpu;
59 int rc;
60
61 AssertReleaseMsg(VALID_PTR(pUVM) && pUVM->u32Magic == UVM_MAGIC,
62 ("Invalid arguments to the emulation thread!\n"));
63
64 rc = RTTlsSet(pUVM->vm.s.idxTLS, pUVMCPU);
65 AssertReleaseMsgRCReturn(rc, ("RTTlsSet %x failed with %Rrc\n", pUVM->vm.s.idxTLS, rc), rc);
66
67 /*
68 * The request loop.
69 */
70 rc = VINF_SUCCESS;
71 volatile VMSTATE enmBefore = VMSTATE_CREATING; /* volatile because of setjmp */
72 Log(("vmR3EmulationThread: Emulation thread starting the days work... Thread=%#x pUVM=%p\n", ThreadSelf, pUVM));
73 for (;;)
74 {
75 /* Requested to exit the EMT thread out of sync? (currently only VMR3WaitForResume) */
76 if (setjmp(pUVMCPU->vm.s.emtJumpEnv) != 0)
77 {
78 rc = VINF_SUCCESS;
79 break;
80 }
81
82 /*
83 * During early init there is no pVM, so make a special path
84 * for that to keep things clearly separate.
85 */
86 if (!pUVM->pVM)
87 {
88 /*
89 * Check for termination first.
90 */
91 if (pUVM->vm.s.fTerminateEMT)
92 {
93 rc = VINF_EM_TERMINATE;
94 break;
95 }
96 if (pUVM->vm.s.pReqs)
97 {
98 /*
99 * Service execute in EMT request.
100 */
101 rc = VMR3ReqProcessU(pUVM, VMREQDEST_ANY);
102 Log(("vmR3EmulationThread: Req rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pUVM->pVM ? pUVM->pVM->enmVMState : VMSTATE_CREATING));
103 }
104 else
105 {
106 /*
107 * Nothing important is pending, so wait for something.
108 */
109 rc = VMR3WaitU(pUVM);
110 if (RT_FAILURE(rc))
111 break;
112 }
113 }
114 else
115 {
116
117 /*
118 * Pending requests which needs servicing?
119 *
120 * We check for state changes in addition to status codes when
121 * servicing requests. (Look after the ifs.)
122 */
123 PVM pVM = pUVM->pVM;
124 enmBefore = pVM->enmVMState;
125 if ( VM_FF_ISSET(pVM, VM_FF_TERMINATE)
126 || pUVM->vm.s.fTerminateEMT)
127 {
128 rc = VINF_EM_TERMINATE;
129 break;
130 }
131 if (pUVM->vm.s.pReqs)
132 {
133 /*
134 * Service execute in EMT request.
135 */
136 rc = VMR3ReqProcessU(pUVM, VMREQDEST_ANY);
137 Log(("vmR3EmulationThread: Req rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState));
138 }
139 else if (VM_FF_ISSET(pVM, VM_FF_DBGF))
140 {
141 /*
142 * Service the debugger request.
143 */
144 rc = DBGFR3VMMForcedAction(pVM);
145 Log(("vmR3EmulationThread: Dbg rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState));
146 }
147 else if (VM_FF_ISSET(pVM, VM_FF_RESET))
148 {
149 /*
150 * Service a delayed reset request.
151 */
152 rc = VMR3Reset(pVM);
153 VM_FF_CLEAR(pVM, VM_FF_RESET);
154 Log(("vmR3EmulationThread: Reset rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState));
155 }
156 else
157 {
158 /*
159 * Nothing important is pending, so wait for something.
160 */
161 rc = VMR3WaitU(pUVM);
162 if (RT_FAILURE(rc))
163 break;
164 }
165
166 /*
167 * Check for termination requests, these have extremely high priority.
168 */
169 if ( rc == VINF_EM_TERMINATE
170 || VM_FF_ISSET(pVM, VM_FF_TERMINATE)
171 || pUVM->vm.s.fTerminateEMT)
172 break;
173 }
174
175 /*
176 * Some requests (both VMR3Req* and the DBGF) can potentially
177 * resume or start the VM, in that case we'll get a change in
178 * VM status indicating that we're now running.
179 */
180 if ( RT_SUCCESS(rc)
181 && pUVM->pVM
182 && enmBefore != pUVM->pVM->enmVMState
183 && pUVM->pVM->enmVMState == VMSTATE_RUNNING)
184 {
185 PVM pVM = pUVM->pVM;
186 rc = EMR3ExecuteVM(pVM, idCpu);
187 Log(("vmR3EmulationThread: EMR3ExecuteVM() -> rc=%Rrc, enmVMState=%d\n", rc, pVM->enmVMState));
188 if ( EMGetState(pVM) == EMSTATE_GURU_MEDITATION
189 && pVM->enmVMState == VMSTATE_RUNNING)
190 vmR3SetState(pVM, VMSTATE_GURU_MEDITATION);
191 }
192
193 } /* forever */
194
195
196 /*
197 * Exiting.
198 */
199 Log(("vmR3EmulationThread: Terminating emulation thread! Thread=%#x pUVM=%p rc=%Rrc enmBefore=%d enmVMState=%d\n",
200 ThreadSelf, pUVM, rc, enmBefore, pUVM->pVM ? pUVM->pVM->enmVMState : VMSTATE_TERMINATED));
201 if (pUVM->vm.s.fEMTDoesTheCleanup)
202 {
203 Log(("vmR3EmulationThread: executing delayed Destroy\n"));
204 Assert(pUVM->pVM);
205 vmR3Destroy(pUVM->pVM);
206 vmR3DestroyFinalBitFromEMT(pUVM);
207 }
208 else
209 {
210 vmR3DestroyFinalBitFromEMT(pUVM);
211
212 pUVMCPU->vm.s.NativeThreadEMT = NIL_RTNATIVETHREAD;
213 }
214 Log(("vmR3EmulationThread: EMT is terminated.\n"));
215 return rc;
216}
217
218
219/**
220 * Wait for VM to be resumed. Handle events like vmR3EmulationThread does.
221 * In case the VM is stopped, clean up and long jump to the main EMT loop.
222 *
223 * @returns VINF_SUCCESS or doesn't return
224 * @param pVM VM handle.
225 */
226VMMR3DECL(int) VMR3WaitForResume(PVM pVM)
227{
228 /*
229 * The request loop.
230 */
231 PUVMCPU pUVMCPU;
232 PUVM pUVM = pVM->pUVM;
233 VMSTATE enmBefore;
234 int rc;
235
236 pUVMCPU = (PUVMCPU)RTTlsGet(pUVM->vm.s.idxTLS);
237 AssertReturn(pUVMCPU, VERR_INTERNAL_ERROR);
238
239 for (;;)
240 {
241
242 /*
243 * Pending requests which needs servicing?
244 *
245 * We check for state changes in addition to status codes when
246 * servicing requests. (Look after the ifs.)
247 */
248 enmBefore = pVM->enmVMState;
249 if ( VM_FF_ISSET(pVM, VM_FF_TERMINATE)
250 || pUVM->vm.s.fTerminateEMT)
251 {
252 rc = VINF_EM_TERMINATE;
253 break;
254 }
255 else if (pUVM->vm.s.pReqs)
256 {
257 /*
258 * Service execute in EMT request.
259 */
260 rc = VMR3ReqProcessU(pUVM, VMREQDEST_ANY);
261 Log(("vmR3EmulationThread: Req rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState));
262 }
263 else if (VM_FF_ISSET(pVM, VM_FF_DBGF))
264 {
265 /*
266 * Service the debugger request.
267 */
268 rc = DBGFR3VMMForcedAction(pVM);
269 Log(("vmR3EmulationThread: Dbg rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState));
270 }
271 else if (VM_FF_ISSET(pVM, VM_FF_RESET))
272 {
273 /*
274 * Service a delay reset request.
275 */
276 rc = VMR3Reset(pVM);
277 VM_FF_CLEAR(pVM, VM_FF_RESET);
278 Log(("vmR3EmulationThread: Reset rc=%Rrc, VM state %d -> %d\n", rc, enmBefore, pVM->enmVMState));
279 }
280 else
281 {
282 /*
283 * Nothing important is pending, so wait for something.
284 */
285 rc = VMR3WaitU(pUVM);
286 if (RT_FAILURE(rc))
287 break;
288 }
289
290 /*
291 * Check for termination requests, these are extremely high priority.
292 */
293 if ( rc == VINF_EM_TERMINATE
294 || VM_FF_ISSET(pVM, VM_FF_TERMINATE)
295 || pUVM->vm.s.fTerminateEMT)
296 break;
297
298 /*
299 * Some requests (both VMR3Req* and the DBGF) can potentially
300 * resume or start the VM, in that case we'll get a change in
301 * VM status indicating that we're now running.
302 */
303 if ( RT_SUCCESS(rc)
304 && enmBefore != pVM->enmVMState
305 && pVM->enmVMState == VMSTATE_RUNNING)
306 {
307 /* Only valid exit reason. */
308 return VINF_SUCCESS;
309 }
310
311 } /* forever */
312
313 /* Return to the main loop in vmR3EmulationThread, which will clean up for us. */
314 longjmp(pUVMCPU->vm.s.emtJumpEnv, 1);
315}
316
317
318/**
319 * Gets the name of a halt method.
320 *
321 * @returns Pointer to a read only string.
322 * @param enmMethod The method.
323 */
324static const char *vmR3GetHaltMethodName(VMHALTMETHOD enmMethod)
325{
326 switch (enmMethod)
327 {
328 case VMHALTMETHOD_BOOTSTRAP: return "bootstrap";
329 case VMHALTMETHOD_DEFAULT: return "default";
330 case VMHALTMETHOD_OLD: return "old";
331 case VMHALTMETHOD_1: return "method1";
332 //case VMHALTMETHOD_2: return "method2";
333 case VMHALTMETHOD_GLOBAL_1: return "global1";
334 default: return "unknown";
335 }
336}
337
338
339/**
340 * The old halt loop.
341 *
342 * @param pUVM Pointer to the user mode VM structure.
343 */
344static DECLCALLBACK(int) vmR3HaltOldDoHalt(PUVM pUVM, const uint32_t fMask, uint64_t /* u64Now*/)
345{
346 /*
347 * Halt loop.
348 */
349 PVM pVM = pUVM->pVM;
350 int rc = VINF_SUCCESS;
351 ASMAtomicWriteBool(&pUVM->vm.s.fWait, true);
352 //unsigned cLoops = 0;
353 for (;;)
354 {
355 /*
356 * Work the timers and check if we can exit.
357 * The poll call gives us the ticks left to the next event in
358 * addition to perhaps set an FF.
359 */
360 STAM_REL_PROFILE_START(&pUVM->vm.s.StatHaltTimers, b);
361 TMR3TimerQueuesDo(pVM);
362 STAM_REL_PROFILE_STOP(&pUVM->vm.s.StatHaltTimers, b);
363 if (VM_FF_ISPENDING(pVM, fMask))
364 break;
365 uint64_t u64NanoTS = TMVirtualToNano(pVM, TMTimerPoll(pVM));
366 if (VM_FF_ISPENDING(pVM, fMask))
367 break;
368
369 /*
370 * Wait for a while. Someone will wake us up or interrupt the call if
371 * anything needs our attention.
372 */
373 if (u64NanoTS < 50000)
374 {
375 //RTLogPrintf("u64NanoTS=%RI64 cLoops=%d spin\n", u64NanoTS, cLoops++);
376 /* spin */;
377 }
378 else
379 {
380 VMMR3YieldStop(pVM);
381 //uint64_t u64Start = RTTimeNanoTS();
382 if (u64NanoTS < 870000) /* this is a bit speculative... works fine on linux. */
383 {
384 //RTLogPrintf("u64NanoTS=%RI64 cLoops=%d yield", u64NanoTS, cLoops++);
385 STAM_REL_PROFILE_START(&pUVM->vm.s.StatHaltYield, a);
386 RTThreadYield(); /* this is the best we can do here */
387 STAM_REL_PROFILE_STOP(&pUVM->vm.s.StatHaltYield, a);
388 }
389 else if (u64NanoTS < 2000000)
390 {
391 //RTLogPrintf("u64NanoTS=%RI64 cLoops=%d sleep 1ms", u64NanoTS, cLoops++);
392 STAM_REL_PROFILE_START(&pUVM->vm.s.StatHaltBlock, a);
393 rc = RTSemEventWait(pUVM->vm.s.EventSemWait, 1);
394 STAM_REL_PROFILE_STOP(&pUVM->vm.s.StatHaltBlock, a);
395 }
396 else
397 {
398 //RTLogPrintf("u64NanoTS=%RI64 cLoops=%d sleep %dms", u64NanoTS, cLoops++, (uint32_t)RT_MIN((u64NanoTS - 500000) / 1000000, 15));
399 STAM_REL_PROFILE_START(&pUVM->vm.s.StatHaltBlock, a);
400 rc = RTSemEventWait(pUVM->vm.s.EventSemWait, RT_MIN((u64NanoTS - 1000000) / 1000000, 15));
401 STAM_REL_PROFILE_STOP(&pUVM->vm.s.StatHaltBlock, a);
402 }
403 //uint64_t u64Slept = RTTimeNanoTS() - u64Start;
404 //RTLogPrintf(" -> rc=%Rrc in %RU64 ns / %RI64 ns delta\n", rc, u64Slept, u64NanoTS - u64Slept);
405 }
406 if (rc == VERR_TIMEOUT)
407 rc = VINF_SUCCESS;
408 else if (RT_FAILURE(rc))
409 {
410 AssertRC(rc != VERR_INTERRUPTED);
411 AssertMsgFailed(("RTSemEventWait->%Rrc\n", rc));
412 ASMAtomicUoWriteBool(&pUVM->vm.s.fTerminateEMT, true);
413 VM_FF_SET(pVM, VM_FF_TERMINATE);
414 rc = VERR_INTERNAL_ERROR;
415 break;
416 }
417 }
418
419 ASMAtomicUoWriteBool(&pUVM->vm.s.fWait, false);
420 return rc;
421}
422
423
424/**
425 * Initialize the configuration of halt method 1 & 2.
426 *
427 * @return VBox status code. Failure on invalid CFGM data.
428 * @param pVM The VM handle.
429 */
430static int vmR3HaltMethod12ReadConfigU(PUVM pUVM)
431{
432 /*
433 * The defaults.
434 */
435#if 1 /* DEBUGGING STUFF - REMOVE LATER */
436 pUVM->vm.s.Halt.Method12.u32LagBlockIntervalDivisorCfg = 4;
437 pUVM->vm.s.Halt.Method12.u32MinBlockIntervalCfg = 2*1000000;
438 pUVM->vm.s.Halt.Method12.u32MaxBlockIntervalCfg = 75*1000000;
439 pUVM->vm.s.Halt.Method12.u32StartSpinningCfg = 30*1000000;
440 pUVM->vm.s.Halt.Method12.u32StopSpinningCfg = 20*1000000;
441#else
442 pUVM->vm.s.Halt.Method12.u32LagBlockIntervalDivisorCfg = 4;
443 pUVM->vm.s.Halt.Method12.u32MinBlockIntervalCfg = 5*1000000;
444 pUVM->vm.s.Halt.Method12.u32MaxBlockIntervalCfg = 200*1000000;
445 pUVM->vm.s.Halt.Method12.u32StartSpinningCfg = 20*1000000;
446 pUVM->vm.s.Halt.Method12.u32StopSpinningCfg = 2*1000000;
447#endif
448
449 /*
450 * Query overrides.
451 *
452 * I don't have time to bother with niceities such as invalid value checks
453 * here right now. sorry.
454 */
455 PCFGMNODE pCfg = CFGMR3GetChild(CFGMR3GetRoot(pUVM->pVM), "/VMM/HaltedMethod1");
456 if (pCfg)
457 {
458 uint32_t u32;
459 if (RT_SUCCESS(CFGMR3QueryU32(pCfg, "LagBlockIntervalDivisor", &u32)))
460 pUVM->vm.s.Halt.Method12.u32LagBlockIntervalDivisorCfg = u32;
461 if (RT_SUCCESS(CFGMR3QueryU32(pCfg, "MinBlockInterval", &u32)))
462 pUVM->vm.s.Halt.Method12.u32MinBlockIntervalCfg = u32;
463 if (RT_SUCCESS(CFGMR3QueryU32(pCfg, "MaxBlockInterval", &u32)))
464 pUVM->vm.s.Halt.Method12.u32MaxBlockIntervalCfg = u32;
465 if (RT_SUCCESS(CFGMR3QueryU32(pCfg, "StartSpinning", &u32)))
466 pUVM->vm.s.Halt.Method12.u32StartSpinningCfg = u32;
467 if (RT_SUCCESS(CFGMR3QueryU32(pCfg, "StopSpinning", &u32)))
468 pUVM->vm.s.Halt.Method12.u32StopSpinningCfg = u32;
469 LogRel(("HaltedMethod1 config: %d/%d/%d/%d/%d\n",
470 pUVM->vm.s.Halt.Method12.u32LagBlockIntervalDivisorCfg,
471 pUVM->vm.s.Halt.Method12.u32MinBlockIntervalCfg,
472 pUVM->vm.s.Halt.Method12.u32MaxBlockIntervalCfg,
473 pUVM->vm.s.Halt.Method12.u32StartSpinningCfg,
474 pUVM->vm.s.Halt.Method12.u32StopSpinningCfg));
475 }
476
477 return VINF_SUCCESS;
478}
479
480
481/**
482 * Initialize halt method 1.
483 *
484 * @return VBox status code.
485 * @param pUVM Pointer to the user mode VM structure.
486 */
487static DECLCALLBACK(int) vmR3HaltMethod1Init(PUVM pUVM)
488{
489 return vmR3HaltMethod12ReadConfigU(pUVM);
490}
491
492
493/**
494 * Method 1 - Block whenever possible, and when lagging behind
495 * switch to spinning for 10-30ms with occational blocking until
496 * the lag has been eliminated.
497 */
498static DECLCALLBACK(int) vmR3HaltMethod1Halt(PUVM pUVM, const uint32_t fMask, uint64_t u64Now)
499{
500 PVM pVM = pUVM->pVM;
501
502 /*
503 * To simplify things, we decide up-front whether we should switch to spinning or
504 * not. This makes some ASSUMPTIONS about the cause of the spinning (PIT/RTC/PCNet)
505 * and that it will generate interrupts or other events that will cause us to exit
506 * the halt loop.
507 */
508 bool fBlockOnce = false;
509 bool fSpinning = false;
510 uint32_t u32CatchUpPct = TMVirtualSyncGetCatchUpPct(pVM);
511 if (u32CatchUpPct /* non-zero if catching up */)
512 {
513 if (pUVM->vm.s.Halt.Method12.u64StartSpinTS)
514 {
515 fSpinning = TMVirtualSyncGetLag(pVM) >= pUVM->vm.s.Halt.Method12.u32StopSpinningCfg;
516 if (fSpinning)
517 {
518 uint64_t u64Lag = TMVirtualSyncGetLag(pVM);
519 fBlockOnce = u64Now - pUVM->vm.s.Halt.Method12.u64LastBlockTS
520 > RT_MAX(pUVM->vm.s.Halt.Method12.u32MinBlockIntervalCfg,
521 RT_MIN(u64Lag / pUVM->vm.s.Halt.Method12.u32LagBlockIntervalDivisorCfg,
522 pUVM->vm.s.Halt.Method12.u32MaxBlockIntervalCfg));
523 }
524 else
525 {
526 //RTLogRelPrintf("Stopped spinning (%u ms)\n", (u64Now - pUVM->vm.s.Halt.Method12.u64StartSpinTS) / 1000000);
527 pUVM->vm.s.Halt.Method12.u64StartSpinTS = 0;
528 }
529 }
530 else
531 {
532 fSpinning = TMVirtualSyncGetLag(pVM) >= pUVM->vm.s.Halt.Method12.u32StartSpinningCfg;
533 if (fSpinning)
534 pUVM->vm.s.Halt.Method12.u64StartSpinTS = u64Now;
535 }
536 }
537 else if (pUVM->vm.s.Halt.Method12.u64StartSpinTS)
538 {
539 //RTLogRelPrintf("Stopped spinning (%u ms)\n", (u64Now - pUVM->vm.s.Halt.Method12.u64StartSpinTS) / 1000000);
540 pUVM->vm.s.Halt.Method12.u64StartSpinTS = 0;
541 }
542
543 /*
544 * Halt loop.
545 */
546 int rc = VINF_SUCCESS;
547 ASMAtomicWriteBool(&pUVM->vm.s.fWait, true);
548 unsigned cLoops = 0;
549 for (;; cLoops++)
550 {
551 /*
552 * Work the timers and check if we can exit.
553 */
554 STAM_REL_PROFILE_START(&pUVM->vm.s.StatHaltTimers, b);
555 TMR3TimerQueuesDo(pVM);
556 STAM_REL_PROFILE_STOP(&pUVM->vm.s.StatHaltTimers, b);
557 if (VM_FF_ISPENDING(pVM, fMask))
558 break;
559
560 /*
561 * Estimate time left to the next event.
562 */
563 uint64_t u64NanoTS = TMVirtualToNano(pVM, TMTimerPoll(pVM));
564 if (VM_FF_ISPENDING(pVM, fMask))
565 break;
566
567 /*
568 * Block if we're not spinning and the interval isn't all that small.
569 */
570 if ( ( !fSpinning
571 || fBlockOnce)
572#if 1 /* DEBUGGING STUFF - REMOVE LATER */
573 && u64NanoTS >= 100000) /* 0.100 ms */
574#else
575 && u64NanoTS >= 250000) /* 0.250 ms */
576#endif
577 {
578 const uint64_t Start = pUVM->vm.s.Halt.Method12.u64LastBlockTS = RTTimeNanoTS();
579 VMMR3YieldStop(pVM);
580
581 uint32_t cMilliSecs = RT_MIN(u64NanoTS / 1000000, 15);
582 if (cMilliSecs <= pUVM->vm.s.Halt.Method12.cNSBlockedTooLongAvg)
583 cMilliSecs = 1;
584 else
585 cMilliSecs -= pUVM->vm.s.Halt.Method12.cNSBlockedTooLongAvg;
586 //RTLogRelPrintf("u64NanoTS=%RI64 cLoops=%3d sleep %02dms (%7RU64) ", u64NanoTS, cLoops, cMilliSecs, u64NanoTS);
587 STAM_REL_PROFILE_START(&pUVM->vm.s.StatHaltBlock, a);
588 rc = RTSemEventWait(pUVM->vm.s.EventSemWait, cMilliSecs);
589 STAM_REL_PROFILE_STOP(&pUVM->vm.s.StatHaltBlock, a);
590 if (rc == VERR_TIMEOUT)
591 rc = VINF_SUCCESS;
592 else if (RT_FAILURE(rc))
593 {
594 AssertRC(rc != VERR_INTERRUPTED);
595 AssertMsgFailed(("RTSemEventWait->%Rrc\n", rc));
596 ASMAtomicUoWriteBool(&pUVM->vm.s.fTerminateEMT, true);
597 VM_FF_SET(pVM, VM_FF_TERMINATE);
598 rc = VERR_INTERNAL_ERROR;
599 break;
600 }
601
602 /*
603 * Calc the statistics.
604 * Update averages every 16th time, and flush parts of the history every 64th time.
605 */
606 const uint64_t Elapsed = RTTimeNanoTS() - Start;
607 pUVM->vm.s.Halt.Method12.cNSBlocked += Elapsed;
608 if (Elapsed > u64NanoTS)
609 pUVM->vm.s.Halt.Method12.cNSBlockedTooLong += Elapsed - u64NanoTS;
610 pUVM->vm.s.Halt.Method12.cBlocks++;
611 if (!(pUVM->vm.s.Halt.Method12.cBlocks & 0xf))
612 {
613 pUVM->vm.s.Halt.Method12.cNSBlockedTooLongAvg = pUVM->vm.s.Halt.Method12.cNSBlockedTooLong / pUVM->vm.s.Halt.Method12.cBlocks;
614 if (!(pUVM->vm.s.Halt.Method12.cBlocks & 0x3f))
615 {
616 pUVM->vm.s.Halt.Method12.cNSBlockedTooLong = pUVM->vm.s.Halt.Method12.cNSBlockedTooLongAvg * 0x40;
617 pUVM->vm.s.Halt.Method12.cBlocks = 0x40;
618 }
619 }
620 //RTLogRelPrintf(" -> %7RU64 ns / %7RI64 ns delta%s\n", Elapsed, Elapsed - u64NanoTS, fBlockOnce ? " (block once)" : "");
621
622 /*
623 * Clear the block once flag if we actually blocked.
624 */
625 if ( fBlockOnce
626 && Elapsed > 100000 /* 0.1 ms */)
627 fBlockOnce = false;
628 }
629 }
630 //if (fSpinning) RTLogRelPrintf("spun for %RU64 ns %u loops; lag=%RU64 pct=%d\n", RTTimeNanoTS() - u64Now, cLoops, TMVirtualSyncGetLag(pVM), u32CatchUpPct);
631
632 ASMAtomicUoWriteBool(&pUVM->vm.s.fWait, false);
633 return rc;
634}
635
636
637/**
638 * Initialize the global 1 halt method.
639 *
640 * @return VBox status code.
641 * @param pUVM Pointer to the user mode VM structure.
642 */
643static DECLCALLBACK(int) vmR3HaltGlobal1Init(PUVM pUVM)
644{
645 return VINF_SUCCESS;
646}
647
648
649/**
650 * The global 1 halt method - Block in GMM (ring-0) and let it
651 * try take care of the global scheduling of EMT threads.
652 */
653static DECLCALLBACK(int) vmR3HaltGlobal1Halt(PUVM pUVM, const uint32_t fMask, uint64_t u64Now)
654{
655 PVM pVM = pUVM->pVM;
656
657 /*
658 * Halt loop.
659 */
660 int rc = VINF_SUCCESS;
661 ASMAtomicWriteBool(&pUVM->vm.s.fWait, true);
662 unsigned cLoops = 0;
663 for (;; cLoops++)
664 {
665 /*
666 * Work the timers and check if we can exit.
667 */
668 STAM_REL_PROFILE_START(&pUVM->vm.s.StatHaltTimers, b);
669 TMR3TimerQueuesDo(pVM);
670 STAM_REL_PROFILE_STOP(&pUVM->vm.s.StatHaltTimers, b);
671 if (VM_FF_ISPENDING(pVM, fMask))
672 break;
673
674 /*
675 * Estimate time left to the next event.
676 */
677 uint64_t u64Delta;
678 uint64_t u64GipTime = TMTimerPollGIP(pVM, &u64Delta);
679 if (VM_FF_ISPENDING(pVM, fMask))
680 break;
681
682 /*
683 * Block if we're not spinning and the interval isn't all that small.
684 */
685 if (u64Delta > 50000 /* 0.050ms */)
686 {
687 VMMR3YieldStop(pVM);
688 if (VM_FF_ISPENDING(pVM, fMask))
689 break;
690
691 //RTLogRelPrintf("u64NanoTS=%RI64 cLoops=%3d sleep %02dms (%7RU64) ", u64NanoTS, cLoops, cMilliSecs, u64NanoTS);
692 STAM_REL_PROFILE_START(&pUVM->vm.s.StatHaltBlock, c);
693 rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_GVMM_SCHED_HALT, u64GipTime, NULL);
694 STAM_REL_PROFILE_STOP(&pUVM->vm.s.StatHaltBlock, c);
695 if (rc == VERR_INTERRUPTED)
696 rc = VINF_SUCCESS;
697 else if (RT_FAILURE(rc))
698 {
699 AssertMsgFailed(("VMMR0_DO_GVMM_SCHED_HALT->%Rrc\n", rc));
700 ASMAtomicUoWriteBool(&pUVM->vm.s.fTerminateEMT, true);
701 VM_FF_SET(pVM, VM_FF_TERMINATE);
702 rc = VERR_INTERNAL_ERROR;
703 break;
704 }
705 }
706 /*
707 * When spinning call upon the GVMM and do some wakups once
708 * in a while, it's not like we're actually busy or anything.
709 */
710 else if (!(cLoops & 0x1fff))
711 {
712 STAM_REL_PROFILE_START(&pUVM->vm.s.StatHaltYield, d);
713 rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_GVMM_SCHED_POLL, false /* don't yield */, NULL);
714 STAM_REL_PROFILE_STOP(&pUVM->vm.s.StatHaltYield, d);
715 }
716 }
717 //if (fSpinning) RTLogRelPrintf("spun for %RU64 ns %u loops; lag=%RU64 pct=%d\n", RTTimeNanoTS() - u64Now, cLoops, TMVirtualSyncGetLag(pVM), u32CatchUpPct);
718
719 ASMAtomicUoWriteBool(&pUVM->vm.s.fWait, false);
720 return rc;
721}
722
723
724/**
725 * The global 1 halt method - VMR3Wait() worker.
726 *
727 * @returns VBox status code.
728 * @param pUVM Pointer to the user mode VM structure.
729 */
730static DECLCALLBACK(int) vmR3HaltGlobal1Wait(PUVM pUVM)
731{
732 ASMAtomicWriteBool(&pUVM->vm.s.fWait, true);
733
734 PVM pVM = pUVM->pVM;
735 int rc = VINF_SUCCESS;
736 for (;;)
737 {
738 /*
739 * Check Relevant FFs.
740 */
741 if (VM_FF_ISPENDING(pVM, VM_FF_EXTERNAL_SUSPENDED_MASK))
742 break;
743
744 /*
745 * Wait for a while. Someone will wake us up or interrupt the call if
746 * anything needs our attention.
747 */
748 rc = SUPCallVMMR0Ex(pVM->pVMR0, VMMR0_DO_GVMM_SCHED_HALT, RTTimeNanoTS() + 1000000000 /* +1s */, NULL);
749 if (rc == VERR_INTERRUPTED)
750 rc = VINF_SUCCESS;
751 else if (RT_FAILURE(rc))
752 {
753 AssertMsgFailed(("RTSemEventWait->%Rrc\n", rc));
754 ASMAtomicUoWriteBool(&pUVM->vm.s.fTerminateEMT, true);
755 VM_FF_SET(pVM, VM_FF_TERMINATE);
756 rc = VERR_INTERNAL_ERROR;
757 break;
758 }
759
760 }
761
762 ASMAtomicUoWriteBool(&pUVM->vm.s.fWait, false);
763 return rc;
764}
765
766
767/**
768 * The global 1 halt method - VMR3NotifyFF() worker.
769 *
770 * @param pUVM Pointer to the user mode VM structure.
771 * @param fNotifiedREM See VMR3NotifyFF().
772 */
773static DECLCALLBACK(void) vmR3HaltGlobal1NotifyFF(PUVM pUVM, bool fNotifiedREM)
774{
775 if (pUVM->vm.s.fWait)
776 {
777 int rc = SUPCallVMMR0Ex(pUVM->pVM->pVMR0, VMMR0_DO_GVMM_SCHED_WAKE_UP, 0, NULL);
778 AssertRC(rc);
779 }
780 else if (!fNotifiedREM)
781 REMR3NotifyFF(pUVM->pVM);
782}
783
784
785/**
786 * Bootstrap VMR3Wait() worker.
787 *
788 * @returns VBox status code.
789 * @param pUVM Pointer to the user mode VM structure.
790 */
791static DECLCALLBACK(int) vmR3BootstrapWait(PUVM pUVM)
792{
793 ASMAtomicWriteBool(&pUVM->vm.s.fWait, true);
794
795 int rc = VINF_SUCCESS;
796 for (;;)
797 {
798 /*
799 * Check Relevant FFs.
800 */
801 if (pUVM->vm.s.pReqs)
802 break;
803 if ( pUVM->pVM
804 && VM_FF_ISPENDING(pUVM->pVM, VM_FF_EXTERNAL_SUSPENDED_MASK))
805 break;
806 if (pUVM->vm.s.fTerminateEMT)
807 break;
808
809 /*
810 * Wait for a while. Someone will wake us up or interrupt the call if
811 * anything needs our attention.
812 */
813 rc = RTSemEventWait(pUVM->vm.s.EventSemWait, 1000);
814 if (rc == VERR_TIMEOUT)
815 rc = VINF_SUCCESS;
816 else if (RT_FAILURE(rc))
817 {
818 AssertMsgFailed(("RTSemEventWait->%Rrc\n", rc));
819 ASMAtomicUoWriteBool(&pUVM->vm.s.fTerminateEMT, true);
820 if (pUVM->pVM)
821 VM_FF_SET(pUVM->pVM, VM_FF_TERMINATE);
822 rc = VERR_INTERNAL_ERROR;
823 break;
824 }
825
826 }
827
828 ASMAtomicUoWriteBool(&pUVM->vm.s.fWait, false);
829 return rc;
830}
831
832
833/**
834 * Bootstrap VMR3NotifyFF() worker.
835 *
836 * @param pUVM Pointer to the user mode VM structure.
837 * @param fNotifiedREM See VMR3NotifyFF().
838 */
839static DECLCALLBACK(void) vmR3BootstrapNotifyFF(PUVM pUVM, bool fNotifiedREM)
840{
841 if (pUVM->vm.s.fWait)
842 {
843 int rc = RTSemEventSignal(pUVM->vm.s.EventSemWait);
844 AssertRC(rc);
845 }
846}
847
848
849/**
850 * Default VMR3Wait() worker.
851 *
852 * @returns VBox status code.
853 * @param pUVM Pointer to the user mode VM structure.
854 */
855static DECLCALLBACK(int) vmR3DefaultWait(PUVM pUVM)
856{
857 ASMAtomicWriteBool(&pUVM->vm.s.fWait, true);
858
859 PVM pVM = pUVM->pVM;
860 int rc = VINF_SUCCESS;
861 for (;;)
862 {
863 /*
864 * Check Relevant FFs.
865 */
866 if (VM_FF_ISPENDING(pVM, VM_FF_EXTERNAL_SUSPENDED_MASK))
867 break;
868
869 /*
870 * Wait for a while. Someone will wake us up or interrupt the call if
871 * anything needs our attention.
872 */
873 rc = RTSemEventWait(pUVM->vm.s.EventSemWait, 1000);
874 if (rc == VERR_TIMEOUT)
875 rc = VINF_SUCCESS;
876 else if (RT_FAILURE(rc))
877 {
878 AssertMsgFailed(("RTSemEventWait->%Rrc\n", rc));
879 ASMAtomicUoWriteBool(&pUVM->vm.s.fTerminateEMT, true);
880 VM_FF_SET(pVM, VM_FF_TERMINATE);
881 rc = VERR_INTERNAL_ERROR;
882 break;
883 }
884
885 }
886
887 ASMAtomicUoWriteBool(&pUVM->vm.s.fWait, false);
888 return rc;
889}
890
891
892/**
893 * Default VMR3NotifyFF() worker.
894 *
895 * @param pUVM Pointer to the user mode VM structure.
896 * @param fNotifiedREM See VMR3NotifyFF().
897 */
898static DECLCALLBACK(void) vmR3DefaultNotifyFF(PUVM pUVM, bool fNotifiedREM)
899{
900 if (pUVM->vm.s.fWait)
901 {
902 int rc = RTSemEventSignal(pUVM->vm.s.EventSemWait);
903 AssertRC(rc);
904 }
905 else if (!fNotifiedREM)
906 REMR3NotifyFF(pUVM->pVM);
907}
908
909
910/**
911 * Array with halt method descriptors.
912 * VMINT::iHaltMethod contains an index into this array.
913 */
914static const struct VMHALTMETHODDESC
915{
916 /** The halt method id. */
917 VMHALTMETHOD enmHaltMethod;
918 /** The init function for loading config and initialize variables. */
919 DECLR3CALLBACKMEMBER(int, pfnInit,(PUVM pUVM));
920 /** The term function. */
921 DECLR3CALLBACKMEMBER(void, pfnTerm,(PUVM pUVM));
922 /** The halt function. */
923 DECLR3CALLBACKMEMBER(int, pfnHalt,(PUVM pUVM, const uint32_t fMask, uint64_t u64Now));
924 /** The wait function. */
925 DECLR3CALLBACKMEMBER(int, pfnWait,(PUVM pUVM));
926 /** The notifyFF function. */
927 DECLR3CALLBACKMEMBER(void, pfnNotifyFF,(PUVM pUVM, bool fNotifiedREM));
928} g_aHaltMethods[] =
929{
930 { VMHALTMETHOD_BOOTSTRAP, NULL, NULL, NULL, vmR3BootstrapWait, vmR3BootstrapNotifyFF },
931 { VMHALTMETHOD_OLD, NULL, NULL, vmR3HaltOldDoHalt, vmR3DefaultWait, vmR3DefaultNotifyFF },
932 { VMHALTMETHOD_1, vmR3HaltMethod1Init, NULL, vmR3HaltMethod1Halt, vmR3DefaultWait, vmR3DefaultNotifyFF },
933 //{ VMHALTMETHOD_2, vmR3HaltMethod2Init, vmR3HaltMethod2Term, vmR3HaltMethod2DoHalt, vmR3HaltMethod2Wait, vmR3HaltMethod2NotifyFF },
934 { VMHALTMETHOD_GLOBAL_1,vmR3HaltGlobal1Init, NULL, vmR3HaltGlobal1Halt, vmR3HaltGlobal1Wait, vmR3HaltGlobal1NotifyFF },
935};
936
937
938/**
939 * Notify the emulation thread (EMT) about pending Forced Action (FF).
940 *
941 * This function is called by thread other than EMT to make
942 * sure EMT wakes up and promptly service an FF request.
943 *
944 * @param pVM VM handle.
945 * @param fNotifiedREM Set if REM have already been notified. If clear the
946 * generic REMR3NotifyFF() method is called.
947 */
948VMMR3DECL(void) VMR3NotifyFF(PVM pVM, bool fNotifiedREM)
949{
950 LogFlow(("VMR3NotifyFF:\n"));
951 PUVM pUVM = pVM->pUVM;
952 g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnNotifyFF(pUVM, fNotifiedREM);
953}
954
955
956/**
957 * Notify the emulation thread (EMT) about pending Forced Action (FF).
958 *
959 * This function is called by thread other than EMT to make
960 * sure EMT wakes up and promptly service an FF request.
961 *
962 * @param pUVM Pointer to the user mode VM structure.
963 * @param fNotifiedREM Set if REM have already been notified. If clear the
964 * generic REMR3NotifyFF() method is called.
965 */
966VMMR3DECL(void) VMR3NotifyFFU(PUVM pUVM, bool fNotifiedREM)
967{
968 LogFlow(("VMR3NotifyFF:\n"));
969 g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnNotifyFF(pUVM, fNotifiedREM);
970}
971
972
973/**
974 * Halted VM Wait.
975 * Any external event will unblock the thread.
976 *
977 * @returns VINF_SUCCESS unless a fatal error occured. In the latter
978 * case an appropriate status code is returned.
979 * @param pVM VM handle.
980 * @param fIgnoreInterrupts If set the VM_FF_INTERRUPT flags is ignored.
981 * @thread The emulation thread.
982 */
983VMMR3DECL(int) VMR3WaitHalted(PVM pVM, bool fIgnoreInterrupts)
984{
985 LogFlow(("VMR3WaitHalted: fIgnoreInterrupts=%d\n", fIgnoreInterrupts));
986
987 /*
988 * Check Relevant FFs.
989 */
990 const uint32_t fMask = !fIgnoreInterrupts
991 ? VM_FF_EXTERNAL_HALTED_MASK
992 : VM_FF_EXTERNAL_HALTED_MASK & ~(VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC);
993 if (VM_FF_ISPENDING(pVM, fMask))
994 {
995 LogFlow(("VMR3WaitHalted: returns VINF_SUCCESS (FF %#x)\n", pVM->fForcedActions));
996 return VINF_SUCCESS;
997 }
998
999 /*
1000 * The yielder is suspended while we're halting, while TM might have clock(s) running
1001 * only at certain times and need to be notified..
1002 */
1003 VMMR3YieldSuspend(pVM);
1004 TMNotifyStartOfHalt(pVM);
1005
1006 /*
1007 * Record halt averages for the last second.
1008 */
1009 PUVM pUVM = pVM->pUVM;
1010 uint64_t u64Now = RTTimeNanoTS();
1011 int64_t off = u64Now - pUVM->vm.s.u64HaltsStartTS;
1012 if (off > 1000000000)
1013 {
1014 if (off > _4G || !pUVM->vm.s.cHalts)
1015 {
1016 pUVM->vm.s.HaltInterval = 1000000000 /* 1 sec */;
1017 pUVM->vm.s.HaltFrequency = 1;
1018 }
1019 else
1020 {
1021 pUVM->vm.s.HaltInterval = (uint32_t)off / pUVM->vm.s.cHalts;
1022 pUVM->vm.s.HaltFrequency = ASMMultU64ByU32DivByU32(pUVM->vm.s.cHalts, 1000000000, (uint32_t)off);
1023 }
1024 pUVM->vm.s.u64HaltsStartTS = u64Now;
1025 pUVM->vm.s.cHalts = 0;
1026 }
1027 pUVM->vm.s.cHalts++;
1028
1029 /*
1030 * Do the halt.
1031 */
1032 int rc = g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnHalt(pUVM, fMask, u64Now);
1033
1034 /*
1035 * Notify TM and resume the yielder
1036 */
1037 TMNotifyEndOfHalt(pVM);
1038 VMMR3YieldResume(pVM);
1039
1040 LogFlow(("VMR3WaitHalted: returns %Rrc (FF %#x)\n", rc, pVM->fForcedActions));
1041 return rc;
1042}
1043
1044
1045/**
1046 * Suspended VM Wait.
1047 * Only a handful of forced actions will cause the function to
1048 * return to the caller.
1049 *
1050 * @returns VINF_SUCCESS unless a fatal error occured. In the latter
1051 * case an appropriate status code is returned.
1052 * @param pUVM Pointer to the user mode VM structure.
1053 * @thread The emulation thread.
1054 */
1055VMMR3DECL(int) VMR3WaitU(PUVM pUVM)
1056{
1057 LogFlow(("VMR3WaitU:\n"));
1058
1059 /*
1060 * Check Relevant FFs.
1061 */
1062 PVM pVM = pUVM->pVM;
1063 if ( pVM
1064 && VM_FF_ISPENDING(pVM, VM_FF_EXTERNAL_SUSPENDED_MASK))
1065 {
1066 LogFlow(("VMR3Wait: returns VINF_SUCCESS (FF %#x)\n", pVM->fForcedActions));
1067 return VINF_SUCCESS;
1068 }
1069
1070 /*
1071 * Do waiting according to the halt method (so VMR3NotifyFF
1072 * doesn't have to special case anything).
1073 */
1074 int rc = g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnWait(pUVM);
1075 LogFlow(("VMR3WaitU: returns %Rrc (FF %#x)\n", rc, pVM ? pVM->fForcedActions : 0));
1076 return rc;
1077}
1078
1079
1080/**
1081 * Changes the halt method.
1082 *
1083 * @returns VBox status code.
1084 * @param pUVM Pointer to the user mode VM structure.
1085 * @param enmHaltMethod The new halt method.
1086 * @thread EMT.
1087 */
1088int vmR3SetHaltMethodU(PUVM pUVM, VMHALTMETHOD enmHaltMethod)
1089{
1090 PVM pVM = pUVM->pVM; Assert(pVM);
1091 VM_ASSERT_EMT(pVM);
1092 AssertReturn(enmHaltMethod > VMHALTMETHOD_INVALID && enmHaltMethod < VMHALTMETHOD_END, VERR_INVALID_PARAMETER);
1093
1094 /*
1095 * Resolve default (can be overridden in the configuration).
1096 */
1097 if (enmHaltMethod == VMHALTMETHOD_DEFAULT)
1098 {
1099 uint32_t u32;
1100 int rc = CFGMR3QueryU32(CFGMR3GetChild(CFGMR3GetRoot(pVM), "VM"), "HaltMethod", &u32);
1101 if (RT_SUCCESS(rc))
1102 {
1103 enmHaltMethod = (VMHALTMETHOD)u32;
1104 if (enmHaltMethod <= VMHALTMETHOD_INVALID || enmHaltMethod >= VMHALTMETHOD_END)
1105 return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("Invalid VM/HaltMethod value %d"), enmHaltMethod);
1106 }
1107 else if (rc == VERR_CFGM_VALUE_NOT_FOUND || rc == VERR_CFGM_CHILD_NOT_FOUND)
1108 return VMSetError(pVM, rc, RT_SRC_POS, N_("Failed to Query VM/HaltMethod as uint32_t"));
1109 else
1110 enmHaltMethod = VMHALTMETHOD_GLOBAL_1;
1111 //enmHaltMethod = VMHALTMETHOD_1;
1112 //enmHaltMethod = VMHALTMETHOD_OLD;
1113 }
1114 LogRel(("VM: Halt method %s (%d)\n", vmR3GetHaltMethodName(enmHaltMethod), enmHaltMethod));
1115
1116 /*
1117 * Find the descriptor.
1118 */
1119 unsigned i = 0;
1120 while ( i < RT_ELEMENTS(g_aHaltMethods)
1121 && g_aHaltMethods[i].enmHaltMethod != enmHaltMethod)
1122 i++;
1123 AssertReturn(i < RT_ELEMENTS(g_aHaltMethods), VERR_INVALID_PARAMETER);
1124
1125 /*
1126 * Terminate the old one.
1127 */
1128 if ( pUVM->vm.s.enmHaltMethod != VMHALTMETHOD_INVALID
1129 && g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnTerm)
1130 {
1131 g_aHaltMethods[pUVM->vm.s.iHaltMethod].pfnTerm(pUVM);
1132 pUVM->vm.s.enmHaltMethod = VMHALTMETHOD_INVALID;
1133 }
1134
1135 /*
1136 * Init the new one.
1137 */
1138 memset(&pUVM->vm.s.Halt, 0, sizeof(pUVM->vm.s.Halt));
1139 if (g_aHaltMethods[i].pfnInit)
1140 {
1141 int rc = g_aHaltMethods[i].pfnInit(pUVM);
1142 AssertRCReturn(rc, rc);
1143 }
1144 pUVM->vm.s.enmHaltMethod = enmHaltMethod;
1145
1146 ASMAtomicWriteU32(&pUVM->vm.s.iHaltMethod, i);
1147 return VINF_SUCCESS;
1148}
1149
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette