VirtualBox

source: vbox/trunk/include/VBox/vm.h@ 19043

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

Split up TRPM. (guest SMP)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 26.3 KB
Line 
1/** @file
2 * VM - The Virtual Machine, data.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_vm_h
31#define ___VBox_vm_h
32
33#include <VBox/cdefs.h>
34#include <VBox/types.h>
35#include <VBox/cpum.h>
36#include <VBox/stam.h>
37#include <VBox/vmapi.h>
38#include <VBox/sup.h>
39
40
41/** @defgroup grp_vm The Virtual Machine
42 * @{
43 */
44
45/** Maximum number of virtual CPUs per VM. */
46#define VMCPU_MAX_CPU_COUNT 255
47
48/**
49 * The state of a virtual CPU.
50 *
51 * The VM running states are a sub-states of the VMSTATE_RUNNING state. While
52 * VMCPUSTATE_NOT_RUNNING is a place holder for the other VM states.
53 */
54typedef enum VMCPUSTATE
55{
56 /** The customary invalid zero. */
57 VMCPUSTATE_INVALID = 0,
58
59 /** Running guest code (VM running). */
60 VMCPUSTATE_RUN_EXEC,
61 /** Running guest code in the recompiler (VM running). */
62 VMCPUSTATE_RUN_EXEC_REM,
63 /** Halted (VM running). */
64 VMCPUSTATE_RUN_HALTED,
65 /** All the other bits we do while running a VM (VM running). */
66 VMCPUSTATE_RUN_MISC,
67 /** VM not running, we're servicing requests or whatever. */
68 VMCPUSTATE_NOT_RUNNING,
69 /** The end of valid virtual CPU states. */
70 VMCPUSTATE_END,
71
72 /** Ensure 32-bit type. */
73 VMCPUSTATE_32BIT_HACK = 0x7fffffff
74} VMCPUSTATE;
75
76
77/**
78 * Per virtual CPU data.
79 */
80typedef struct VMCPU
81{
82 /** Per CPU forced action.
83 * See the VMCPU_FF_* \#defines. Updated atomically. */
84 uint32_t volatile fForcedActions;
85 /** The CPU state. */
86 VMCPUSTATE volatile enmState;
87
88 /** Ring-3 Host Context VM Pointer. */
89 PVMR3 pVMR3;
90 /** Ring-0 Host Context VM Pointer. */
91 PVMR0 pVMR0;
92 /** Raw-mode Context VM Pointer. */
93 PVMRC pVMRC;
94 /** The CPU ID.
95 * This is the index into the VM::aCpu array. */
96 VMCPUID idCpu;
97 /** The native thread handle. */
98 RTNATIVETHREAD hNativeThread;
99
100 /** Align the next bit on a 64-byte boundary.
101 *
102 * @remarks The aligments of the members that are larger than 48 bytes should be
103 * 64-byte for cache line reasons. structs containing small amounts of
104 * data could be lumped together at the end with a < 64 byte padding
105 * following it (to grow into and align the struct size).
106 * */
107 uint32_t au32Alignment[HC_ARCH_BITS == 32 ? 9 : 6];
108
109 /** CPUM part. */
110 union
111 {
112#ifdef ___CPUMInternal_h
113 struct CPUMCPU s;
114#endif
115 char padding[4096]; /* multiple of 64 */
116 } cpum;
117 /** VMM part. */
118 union
119 {
120#ifdef ___VMMInternal_h
121 struct VMMCPU s;
122#endif
123 char padding[64]; /* multiple of 64 */
124 } vmm;
125
126 /** PGM part. */
127 union
128 {
129#ifdef ___PGMInternal_h
130 struct PGMCPU s;
131#endif
132 char padding[32*1024]; /* multiple of 64 */
133 } pgm;
134
135 /** HWACCM part. */
136 union
137 {
138#ifdef ___HWACCMInternal_h
139 struct HWACCMCPU s;
140#endif
141 char padding[5120]; /* multiple of 64 */
142 } hwaccm;
143
144 /** EM part. */
145 union
146 {
147#ifdef ___EMInternal_h
148 struct EMCPU s;
149#endif
150 char padding[2048]; /* multiple of 64 */
151 } em;
152
153 /** TRPM part. */
154 union
155 {
156#ifdef ___TRPMInternal_h
157 struct TRPMCPU s;
158#endif
159 char padding[64]; /* multiple of 64 */
160 } trpm;
161
162 /** TM part. */
163 union
164 {
165#ifdef ___TMInternal_h
166 struct TMCPU s;
167#endif
168 char padding[64]; /* multiple of 64 */
169 } tm;
170} VMCPU;
171
172/** Pointer to a VMCPU. */
173#ifndef ___VBox_types_h
174typedef struct VMCPU *PVMCPU;
175#endif
176
177/** The name of the Guest Context VMM Core module. */
178#define VMMGC_MAIN_MODULE_NAME "VMMGC.gc"
179/** The name of the Ring 0 Context VMM Core module. */
180#define VMMR0_MAIN_MODULE_NAME "VMMR0.r0"
181
182/** VM Forced Action Flags.
183 *
184 * Use the VM_FF_SET() and VM_FF_CLEAR() macros to change the force
185 * action mask of a VM.
186 *
187 * @{
188 */
189/** This action forces the VM to service check and pending interrups on the APIC. */
190#define VM_FF_INTERRUPT_APIC RT_BIT_32(0)
191/** This action forces the VM to service check and pending interrups on the PIC. */
192#define VM_FF_INTERRUPT_PIC RT_BIT_32(1)
193/** This action forces the VM to schedule and run pending timer (TM). */
194#define VM_FF_TIMER RT_BIT_32(2)
195/** PDM Queues are pending. */
196#define VM_FF_PDM_QUEUES RT_BIT_32(3)
197/** PDM DMA transfers are pending. */
198#define VM_FF_PDM_DMA RT_BIT_32(4)
199/** PDM critical section unlocking is pending, process promptly upon return to R3. */
200#define VM_FF_PDM_CRITSECT RT_BIT_32(5)
201
202/** This action forces the VM to call DBGF so DBGF can service debugger
203 * requests in the emulation thread.
204 * This action flag stays asserted till DBGF clears it.*/
205#define VM_FF_DBGF RT_BIT_32(8)
206/** This action forces the VM to service pending requests from other
207 * thread or requests which must be executed in another context. */
208#define VM_FF_REQUEST RT_BIT_32(9)
209/** Terminate the VM immediately. */
210#define VM_FF_TERMINATE RT_BIT_32(10)
211/** Reset the VM. (postponed) */
212#define VM_FF_RESET RT_BIT_32(11)
213
214/** This action forces the VM to resync the page tables before going
215 * back to execute guest code. (GLOBAL FLUSH) */
216#define VM_FF_PGM_SYNC_CR3 RT_BIT_32(16)
217/** Same as VM_FF_PGM_SYNC_CR3 except that global pages can be skipped.
218 * (NON-GLOBAL FLUSH) */
219#define VM_FF_PGM_SYNC_CR3_NON_GLOBAL RT_BIT_32(17)
220/** PGM needs to allocate handy pages. */
221#define VM_FF_PGM_NEED_HANDY_PAGES RT_BIT_32(18)
222/** PGM is out of memory.
223 * Abandon all loops and code paths which can be resumed and get up to the EM
224 * loops. */
225#define VM_FF_PGM_NO_MEMORY RT_BIT_32(19)
226/** Check the interupt and trap gates */
227#define VM_FF_TRPM_SYNC_IDT RT_BIT_32(20)
228/** Check Guest's TSS ring 0 stack */
229#define VM_FF_SELM_SYNC_TSS RT_BIT_32(21)
230/** Check Guest's GDT table */
231#define VM_FF_SELM_SYNC_GDT RT_BIT_32(22)
232/** Check Guest's LDT table */
233#define VM_FF_SELM_SYNC_LDT RT_BIT_32(23)
234/** Inhibit interrupts pending. See EMGetInhibitInterruptsPC(). */
235#define VM_FF_INHIBIT_INTERRUPTS RT_BIT_32(24)
236
237/** CSAM needs to scan the page that's being executed */
238#define VM_FF_CSAM_SCAN_PAGE RT_BIT_32(26)
239/** CSAM needs to do some homework. */
240#define VM_FF_CSAM_PENDING_ACTION RT_BIT_32(27)
241
242/** Force return to Ring-3. */
243#define VM_FF_TO_R3 RT_BIT_32(28)
244
245/** REM needs to be informed about handler changes. */
246#define VM_FF_REM_HANDLER_NOTIFY RT_BIT_32(29)
247
248/** Suspend the VM - debug only. */
249#define VM_FF_DEBUG_SUSPEND RT_BIT_32(31)
250
251/** Externally forced actions. Used to quit the idle/wait loop. */
252#define VM_FF_EXTERNAL_SUSPENDED_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_REQUEST)
253/** Externally forced actions. Used to quit the idle/wait loop. */
254#define VM_FF_EXTERNAL_HALTED_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_TIMER | VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_REQUEST | VM_FF_PDM_QUEUES | VM_FF_PDM_DMA)
255/** High priority pre-execution actions. */
256#define VM_FF_HIGH_PRIORITY_PRE_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_INTERRUPT_APIC | VM_FF_INTERRUPT_PIC | VM_FF_TIMER | VM_FF_DEBUG_SUSPEND \
257 | VM_FF_PGM_SYNC_CR3 | VM_FF_PGM_SYNC_CR3_NON_GLOBAL | VM_FF_SELM_SYNC_TSS | VM_FF_TRPM_SYNC_IDT | VM_FF_SELM_SYNC_GDT | VM_FF_SELM_SYNC_LDT | VM_FF_PGM_NEED_HANDY_PAGES | VM_FF_PGM_NO_MEMORY)
258/** High priority pre raw-mode execution mask. */
259#define VM_FF_HIGH_PRIORITY_PRE_RAW_MASK (VM_FF_PGM_SYNC_CR3 | VM_FF_PGM_SYNC_CR3_NON_GLOBAL | VM_FF_SELM_SYNC_TSS | VM_FF_TRPM_SYNC_IDT | VM_FF_SELM_SYNC_GDT | VM_FF_SELM_SYNC_LDT \
260 | VM_FF_PGM_NEED_HANDY_PAGES | VM_FF_INHIBIT_INTERRUPTS | VM_FF_PGM_NO_MEMORY)
261/** High priority post-execution actions. */
262#define VM_FF_HIGH_PRIORITY_POST_MASK (VM_FF_PDM_CRITSECT | VM_FF_CSAM_PENDING_ACTION | VM_FF_PGM_NO_MEMORY)
263/** Normal priority post-execution actions. */
264#define VM_FF_NORMAL_PRIORITY_POST_MASK (VM_FF_TERMINATE | VM_FF_DBGF | VM_FF_RESET | VM_FF_CSAM_SCAN_PAGE | VM_FF_PGM_NO_MEMORY)
265/** Normal priority actions. */
266#define VM_FF_NORMAL_PRIORITY_MASK (VM_FF_REQUEST | VM_FF_PDM_QUEUES | VM_FF_PDM_DMA | VM_FF_REM_HANDLER_NOTIFY)
267/** Flags to clear before resuming guest execution. */
268#define VM_FF_RESUME_GUEST_MASK (VM_FF_TO_R3)
269/** Flags that causes the HWACCM loops to go back to ring-3. */
270#define VM_FF_HWACCM_TO_R3_MASK (VM_FF_TO_R3 | VM_FF_TIMER | VM_FF_PGM_NEED_HANDY_PAGES | VM_FF_PGM_NO_MEMORY)
271/** All the forced flags. */
272#define VM_FF_ALL_MASK (~0U)
273/** All the forced flags. */
274#define VM_FF_ALL_BUT_RAW_MASK (~(VM_FF_HIGH_PRIORITY_PRE_RAW_MASK | VM_FF_CSAM_PENDING_ACTION | VM_FF_PDM_CRITSECT) | VM_FF_PGM_NO_MEMORY)
275
276/** @} */
277
278/** @def VM_FF_SET
279 * Sets a force action flag.
280 *
281 * @param pVM VM Handle.
282 * @param fFlag The flag to set.
283 */
284#if 1
285# define VM_FF_SET(pVM, fFlag) ASMAtomicOrU32(&(pVM)->fForcedActions, (fFlag))
286#else
287# define VM_FF_SET(pVM, fFlag) \
288 do { ASMAtomicOrU32(&(pVM)->fForcedActions, (fFlag)); \
289 RTLogPrintf("VM_FF_SET : %08x %s - %s(%d) %s\n", (pVM)->fForcedActions, #fFlag, __FILE__, __LINE__, __FUNCTION__); \
290 } while (0)
291#endif
292
293/** @def VMCPU_FF_SET
294 * Sets a force action flag for given VCPU.
295 *
296 * @param pVM VM Handle.
297 * @param idCpu Virtual CPU ID.
298 * @param fFlag The flag to set.
299 */
300#ifdef VBOX_WITH_SMP_GUESTS
301# define VMCPU_FF_SET(pVM, idCpu, fFlag) ASMAtomicOrU32(&(pVM)->aCpu[idCpu].fForcedActions, (fFlag))
302#else
303# define VMCPU_FF_SET(pVM, idCpu, fFlag) VM_FF_SET(pVM, fFlag)
304#endif
305
306/** @def VM_FF_CLEAR
307 * Clears a force action flag.
308 *
309 * @param pVM VM Handle.
310 * @param fFlag The flag to clear.
311 */
312#if 1
313# define VM_FF_CLEAR(pVM, fFlag) ASMAtomicAndU32(&(pVM)->fForcedActions, ~(fFlag))
314#else
315# define VM_FF_CLEAR(pVM, fFlag) \
316 do { ASMAtomicAndU32(&(pVM)->fForcedActions, ~(fFlag)); \
317 RTLogPrintf("VM_FF_CLEAR: %08x %s - %s(%d) %s\n", (pVM)->fForcedActions, #fFlag, __FILE__, __LINE__, __FUNCTION__); \
318 } while (0)
319#endif
320
321/** @def VMCPU_FF_CLEAR
322 * Clears a force action flag for given VCPU.
323 *
324 * @param pVM VM Handle.
325 * @param idCpu Virtual CPU ID.
326 * @param fFlag The flag to clear.
327 */
328#ifdef VBOX_WITH_SMP_GUESTS
329# define VMCPU_FF_CLEAR(pVM, idCpu, fFlag) ASMAtomicAndU32(&(pVM)->aCpu[idCpu].fForcedActions, ~(fFlag))
330#else
331# define VMCPU_FF_CLEAR(pVM, idCpu, fFlag) VM_FF_CLEAR(pVM, fFlag)
332#endif
333
334/** @def VM_FF_ISSET
335 * Checks if a force action flag is set.
336 *
337 * @param pVM VM Handle.
338 * @param fFlag The flag to check.
339 */
340#define VM_FF_ISSET(pVM, fFlag) (((pVM)->fForcedActions & (fFlag)) == (fFlag))
341
342/** @def VMCPU_FF_ISSET
343 * Checks if a force action flag is set for given VCPU.
344 *
345 * @param pVM VM Handle.
346 * @param idCpu Virtual CPU ID.
347 * @param fFlag The flag to check.
348 */
349#ifdef VBOX_WITH_SMP_GUESTS
350# define VMCPU_FF_ISSET(pVM, idCpu, fFlag) (((pVM)->aCpu[idCpu].fForcedActions & (fFlag)) == (fFlag))
351#else
352# define VMCPU_FF_ISSET(pVM, idCpu, fFlag) VM_FF_ISSET(pVM, fFlag)
353#endif
354
355/** @def VM_FF_ISPENDING
356 * Checks if one or more force action in the specified set is pending.
357 *
358 * @param pVM VM Handle.
359 * @param fFlags The flags to check for.
360 */
361#define VM_FF_ISPENDING(pVM, fFlags) ((pVM)->fForcedActions & (fFlags))
362
363/** @def VMCPU_FF_ISPENDING
364 * Checks if one or more force action in the specified set is pending for given VCPU.
365 *
366 * @param pVM VM Handle.
367 * @param idCpu Virtual CPU ID.
368 * @param fFlags The flags to check for.
369 */
370#ifdef VBOX_WITH_SMP_GUESTS
371# define VMCPU_FF_ISPENDING(pVM, idCpu, fFlags) ((pVM)->aCpu[idCpu].fForcedActions & (fFlags))
372#else
373# define VMCPU_FF_ISPENDING(pVM, idCpu, fFlags) VM_FF_ISPENDING(pVM, fFlags)
374#endif
375
376/** @def VM_FF_ISPENDING
377 * Checks if one or more force action in the specified set is pending while one
378 * or more other ones are not.
379 *
380 * @param pVM VM Handle.
381 * @param fFlags The flags to check for.
382 * @param fExcpt The flags that should not be set.
383 */
384#define VM_FF_IS_PENDING_EXCEPT(pVM, fFlags, fExcpt) ( ((pVM)->fForcedActions & (fFlags)) && !((pVM)->fForcedActions & (fExcpt)) )
385
386/** @def VMCPU_FF_IS_PENDING_EXCEPT
387 * Checks if one or more force action in the specified set is pending for given
388 * VCPU while one or more other ones are not.
389 *
390 * @param pVM VM Handle.
391 * @param idCpu Virtual CPU ID.
392 * @param fFlags The flags to check for.
393 * @param fExcpt The flags that should not be set.
394 */
395#ifdef VBOX_WITH_SMP_GUESTS
396# define VMCPU_FF_IS_PENDING_EXCEPT(pVM, idCpu, fFlags, fExcpt) ( ((pVM)->aCpu[idCpu].fForcedActions & (fFlags)) && !((pVM)->aCpu[idCpu].fForcedActions & (fExcpt)) )
397#else
398# define VMCPU_FF_IS_PENDING_EXCEPT(pVM, idCpu, fFlags, fExcpt) VM_FF_ISPENDING(pVM, fFlags, fExcpt)
399#endif
400
401/** @def VM_IS_EMT
402 * Checks if the current thread is the emulation thread (EMT).
403 *
404 * @remark The ring-0 variation will need attention if we expand the ring-0
405 * code to let threads other than EMT mess around with the VM.
406 */
407#ifdef IN_RC
408# define VM_IS_EMT(pVM) true
409#elif defined(IN_RING0)
410# define VM_IS_EMT(pVM) true
411#else
412/** @todo need to rework this macro for the case of multiple emulation threads for SMP */
413# define VM_IS_EMT(pVM) (VMR3GetVMCPUNativeThread(pVM) == RTThreadNativeSelf())
414#endif
415
416/** @def VM_ASSERT_EMT
417 * Asserts that the current thread IS the emulation thread (EMT).
418 */
419#ifdef IN_RC
420# define VM_ASSERT_EMT(pVM) Assert(VM_IS_EMT(pVM))
421#elif defined(IN_RING0)
422# define VM_ASSERT_EMT(pVM) Assert(VM_IS_EMT(pVM))
423#else
424# define VM_ASSERT_EMT(pVM) \
425 AssertMsg(VM_IS_EMT(pVM), \
426 ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), VMR3GetVMCPUNativeThread(pVM)))
427#endif
428
429/** @def VM_ASSERT_EMT_RETURN
430 * Asserts that the current thread IS the emulation thread (EMT) and returns if it isn't.
431 */
432#ifdef IN_RC
433# define VM_ASSERT_EMT_RETURN(pVM, rc) AssertReturn(VM_IS_EMT(pVM), (rc))
434#elif defined(IN_RING0)
435# define VM_ASSERT_EMT_RETURN(pVM, rc) AssertReturn(VM_IS_EMT(pVM), (rc))
436#else
437# define VM_ASSERT_EMT_RETURN(pVM, rc) \
438 AssertMsgReturn(VM_IS_EMT(pVM), \
439 ("Not emulation thread! Thread=%RTnthrd ThreadEMT=%RTnthrd\n", RTThreadNativeSelf(), VMR3GetVMCPUNativeThread(pVM)), \
440 (rc))
441#endif
442
443
444/**
445 * Asserts that the current thread is NOT the emulation thread.
446 */
447#define VM_ASSERT_OTHER_THREAD(pVM) \
448 AssertMsg(!VM_IS_EMT(pVM), ("Not other thread!!\n"))
449
450
451/** @def VM_ASSERT_STATE_RETURN
452 * Asserts a certain VM state.
453 */
454#define VM_ASSERT_STATE(pVM, _enmState) \
455 AssertMsg((pVM)->enmVMState == (_enmState), \
456 ("state %s, expected %s\n", VMGetStateName(pVM->enmVMState), VMGetStateName(_enmState)))
457
458/** @def VM_ASSERT_STATE_RETURN
459 * Asserts a certain VM state and returns if it doesn't match.
460 */
461#define VM_ASSERT_STATE_RETURN(pVM, _enmState, rc) \
462 AssertMsgReturn((pVM)->enmVMState == (_enmState), \
463 ("state %s, expected %s\n", VMGetStateName(pVM->enmVMState), VMGetStateName(_enmState)), \
464 (rc))
465
466
467
468
469/** This is the VM structure.
470 *
471 * It contains (nearly?) all the VM data which have to be available in all
472 * contexts. Even if it contains all the data the idea is to use APIs not
473 * to modify all the members all around the place. Therefore we make use of
474 * unions to hide everything which isn't local to the current source module.
475 * This means we'll have to pay a little bit of attention when adding new
476 * members to structures in the unions and make sure to keep the padding sizes
477 * up to date.
478 *
479 * Run tstVMStructSize after update!
480 */
481typedef struct VM
482{
483 /** The state of the VM.
484 * This field is read only to everyone except the VM and EM. */
485 VMSTATE enmVMState;
486 /** Forced action flags.
487 * See the VM_FF_* \#defines. Updated atomically.
488 */
489 volatile uint32_t fForcedActions;
490 /** Pointer to the array of page descriptors for the VM structure allocation. */
491 R3PTRTYPE(PSUPPAGE) paVMPagesR3;
492 /** Session handle. For use when calling SUPR0 APIs. */
493 PSUPDRVSESSION pSession;
494 /** Pointer to the ring-3 VM structure. */
495 PUVM pUVM;
496 /** Ring-3 Host Context VM Pointer. */
497 R3PTRTYPE(struct VM *) pVMR3;
498 /** Ring-0 Host Context VM Pointer. */
499 R0PTRTYPE(struct VM *) pVMR0;
500 /** Raw-mode Context VM Pointer. */
501 RCPTRTYPE(struct VM *) pVMRC;
502
503 /** The GVM VM handle. Only the GVM should modify this field. */
504 uint32_t hSelf;
505 /** Number of virtual CPUs. */
506 uint32_t cCPUs;
507
508 /** Size of the VM structure including the VMCPU array. */
509 uint32_t cbSelf;
510
511 /** Offset to the VMCPU array starting from beginning of this structure. */
512 uint32_t offVMCPU;
513
514 /** Reserved; alignment. */
515 uint32_t u32Reserved[6];
516
517 /** @name Public VMM Switcher APIs
518 * @{ */
519 /**
520 * Assembly switch entry point for returning to host context.
521 * This function will clean up the stack frame.
522 *
523 * @param eax The return code, register.
524 * @param Ctx The guest core context.
525 * @remark Assume interrupts disabled.
526 */
527 RTRCPTR pfnVMMGCGuestToHostAsmGuestCtx/*(int32_t eax, CPUMCTXCORE Ctx)*/;
528
529 /**
530 * Assembly switch entry point for returning to host context.
531 *
532 * This is an alternative entry point which we'll be using when the we have the
533 * hypervisor context and need to save that before going to the host.
534 *
535 * This is typically useful when abandoning the hypervisor because of a trap
536 * and want the trap state to be saved.
537 *
538 * @param eax The return code, register.
539 * @param ecx Pointer to the hypervisor core context, register.
540 * @remark Assume interrupts disabled.
541 */
542 RTRCPTR pfnVMMGCGuestToHostAsmHyperCtx/*(int32_t eax, PCPUMCTXCORE ecx)*/;
543
544 /**
545 * Assembly switch entry point for returning to host context.
546 *
547 * This is an alternative to the two *Ctx APIs and implies that the context has already
548 * been saved, or that it's just a brief return to HC and that the caller intends to resume
549 * whatever it is doing upon 'return' from this call.
550 *
551 * @param eax The return code, register.
552 * @remark Assume interrupts disabled.
553 */
554 RTRCPTR pfnVMMGCGuestToHostAsm/*(int32_t eax)*/;
555 /** @} */
556
557
558 /** @name Various VM data owned by VM.
559 * @{ */
560 RTTHREAD uPadding1;
561 /** The native handle of ThreadEMT. Getting the native handle
562 * is generally faster than getting the IPRT one (except on OS/2 :-). */
563 RTNATIVETHREAD uPadding2;
564 /** @} */
565
566
567 /** @name Various items that are frequently accessed.
568 * @{ */
569 /** Raw ring-3 indicator. */
570 bool fRawR3Enabled;
571 /** Raw ring-0 indicator. */
572 bool fRawR0Enabled;
573 /** PATM enabled flag.
574 * This is placed here for performance reasons. */
575 bool fPATMEnabled;
576 /** CSAM enabled flag.
577 * This is placed here for performance reasons. */
578 bool fCSAMEnabled;
579 /** Hardware VM support is available and enabled.
580 * This is placed here for performance reasons. */
581 bool fHWACCMEnabled;
582 /** Hardware VM support is required and non-optional.
583 * This is initialized together with the rest of the VM structure. */
584 bool fHwVirtExtForced;
585 /** PARAV enabled flag. */
586 bool fPARAVEnabled;
587 /** @} */
588
589
590 /* padding to make gnuc put the StatQemuToGC where msc does. */
591#if HC_ARCH_BITS == 32
592 uint32_t padding0;
593#endif
594
595 /** Profiling the total time from Qemu to GC. */
596 STAMPROFILEADV StatTotalQemuToGC;
597 /** Profiling the total time from GC to Qemu. */
598 STAMPROFILEADV StatTotalGCToQemu;
599 /** Profiling the total time spent in GC. */
600 STAMPROFILEADV StatTotalInGC;
601 /** Profiling the total time spent not in Qemu. */
602 STAMPROFILEADV StatTotalInQemu;
603 /** Profiling the VMMSwitcher code for going to GC. */
604 STAMPROFILEADV StatSwitcherToGC;
605 /** Profiling the VMMSwitcher code for going to HC. */
606 STAMPROFILEADV StatSwitcherToHC;
607 STAMPROFILEADV StatSwitcherSaveRegs;
608 STAMPROFILEADV StatSwitcherSysEnter;
609 STAMPROFILEADV StatSwitcherDebug;
610 STAMPROFILEADV StatSwitcherCR0;
611 STAMPROFILEADV StatSwitcherCR4;
612 STAMPROFILEADV StatSwitcherJmpCR3;
613 STAMPROFILEADV StatSwitcherRstrRegs;
614 STAMPROFILEADV StatSwitcherLgdt;
615 STAMPROFILEADV StatSwitcherLidt;
616 STAMPROFILEADV StatSwitcherLldt;
617 STAMPROFILEADV StatSwitcherTSS;
618
619/** @todo Realign everything on 64 byte boundaries to better match the
620 * cache-line size. */
621 /* padding - the unions must be aligned on 32 bytes boundraries. */
622 uint32_t padding[HC_ARCH_BITS == 32 ? 4+8 : 6];
623
624 /** CPUM part. */
625 union
626 {
627#ifdef ___CPUMInternal_h
628 struct CPUM s;
629#endif
630 char padding[2048]; /* multiple of 32 */
631 } cpum;
632
633 /** VMM part. */
634 union
635 {
636#ifdef ___VMMInternal_h
637 struct VMM s;
638#endif
639 char padding[1600]; /* multiple of 32 */
640 } vmm;
641
642 /** PGM part. */
643 union
644 {
645#ifdef ___PGMInternal_h
646 struct PGM s;
647#endif
648 char padding[16*1024]; /* multiple of 32 */
649 } pgm;
650
651 /** HWACCM part. */
652 union
653 {
654#ifdef ___HWACCMInternal_h
655 struct HWACCM s;
656#endif
657 char padding[512]; /* multiple of 32 */
658 } hwaccm;
659
660 /** TRPM part. */
661 union
662 {
663#ifdef ___TRPMInternal_h
664 struct TRPM s;
665#endif
666 char padding[5344]; /* multiple of 32 */
667 } trpm;
668
669 /** SELM part. */
670 union
671 {
672#ifdef ___SELMInternal_h
673 struct SELM s;
674#endif
675 char padding[544]; /* multiple of 32 */
676 } selm;
677
678 /** MM part. */
679 union
680 {
681#ifdef ___MMInternal_h
682 struct MM s;
683#endif
684 char padding[192]; /* multiple of 32 */
685 } mm;
686
687 /** CFGM part. */
688 union
689 {
690#ifdef ___CFGMInternal_h
691 struct CFGM s;
692#endif
693 char padding[32]; /* multiple of 32 */
694 } cfgm;
695
696 /** PDM part. */
697 union
698 {
699#ifdef ___PDMInternal_h
700 struct PDM s;
701#endif
702 char padding[1824]; /* multiple of 32 */
703 } pdm;
704
705 /** IOM part. */
706 union
707 {
708#ifdef ___IOMInternal_h
709 struct IOM s;
710#endif
711 char padding[4544]; /* multiple of 32 */
712 } iom;
713
714 /** PATM part. */
715 union
716 {
717#ifdef ___PATMInternal_h
718 struct PATM s;
719#endif
720 char padding[768]; /* multiple of 32 */
721 } patm;
722
723 /** CSAM part. */
724 union
725 {
726#ifdef ___CSAMInternal_h
727 struct CSAM s;
728#endif
729 char padding[3328]; /* multiple of 32 */
730 } csam;
731
732 /** PARAV part. */
733 union
734 {
735#ifdef ___PARAVInternal_h
736 struct PARAV s;
737#endif
738 char padding[128];
739 } parav;
740
741 /** EM part. */
742 union
743 {
744#ifdef ___EMInternal_h
745 struct EM s;
746#endif
747 char padding[64]; /* multiple of 32 */
748 } em;
749
750 /** TM part. */
751 union
752 {
753#ifdef ___TMInternal_h
754 struct TM s;
755#endif
756 char padding[1536]; /* multiple of 32 */
757 } tm;
758
759 /** DBGF part. */
760 union
761 {
762#ifdef ___DBGFInternal_h
763 struct DBGF s;
764#endif
765 char padding[2368]; /* multiple of 32 */
766 } dbgf;
767
768 /** SSM part. */
769 union
770 {
771#ifdef ___SSMInternal_h
772 struct SSM s;
773#endif
774 char padding[32]; /* multiple of 32 */
775 } ssm;
776
777 /** VM part. */
778 union
779 {
780#ifdef ___VMInternal_h
781 struct VMINT s;
782#endif
783 char padding[768]; /* multiple of 32 */
784 } vm;
785
786 /** REM part. */
787 union
788 {
789#ifdef ___REMInternal_h
790 struct REM s;
791#endif
792
793/** @def VM_REM_SIZE
794 * Must be multiple of 32 and coherent with REM_ENV_SIZE from REMInternal.h. */
795#if GC_ARCH_BITS == 32
796# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x10800 : 0x10800)
797#else
798# define VM_REM_SIZE (HC_ARCH_BITS == 32 ? 0x10900 : 0x10900)
799#endif
800 char padding[VM_REM_SIZE]; /* multiple of 32 */
801 } rem;
802
803 /** Padding for aligning the cpu array on a 64 byte boundrary. */
804 uint32_t u32Reserved2[8];
805
806 /** VMCPU array for the configured number of virtual CPUs.
807 * Must be aligned on a 64-byte boundrary. */
808 VMCPU aCpus[1];
809} VM;
810
811/** Pointer to a VM. */
812#ifndef ___VBox_types_h
813typedef struct VM *PVM;
814#endif
815
816
817#ifdef IN_RC
818__BEGIN_DECLS
819
820/** The VM structure.
821 * This is imported from the VMMGCBuiltin module, i.e. it's a one
822 * of those magic globals which we should avoid using.
823 */
824extern DECLIMPORT(VM) g_VM;
825
826__END_DECLS
827#endif
828
829/** @} */
830
831#endif
832
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