1 | /** @file
|
---|
2 | * HM - Intel/AMD VM Hardware Assisted Virtualization Manager (VMM)
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2013 Oracle Corporation
|
---|
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 |
|
---|
26 | #ifndef ___VBox_vmm_hm_h
|
---|
27 | #define ___VBox_vmm_hm_h
|
---|
28 |
|
---|
29 | #include <VBox/vmm/pgm.h>
|
---|
30 | #include <VBox/vmm/cpum.h>
|
---|
31 | #include <VBox/vmm/vmm.h>
|
---|
32 | #include <iprt/mp.h>
|
---|
33 |
|
---|
34 |
|
---|
35 | /** @defgroup grp_hm The VM Hardware Manager API
|
---|
36 | * @{
|
---|
37 | */
|
---|
38 |
|
---|
39 | RT_C_DECLS_BEGIN
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Query HM state (enabled/disabled)
|
---|
43 | *
|
---|
44 | * @returns 0 - disabled, 1 - enabled
|
---|
45 | * @param a_pVM Pointer to the shared VM structure.
|
---|
46 | * @internal
|
---|
47 | */
|
---|
48 | #define HMIsEnabled(a_pVM) ((a_pVM)->fHMEnabled)
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Check if the current CPU state is valid for emulating IO blocks in the recompiler
|
---|
52 | *
|
---|
53 | * @returns boolean
|
---|
54 | * @param a_pVCpu Pointer to the shared virtual CPU structure.
|
---|
55 | * @internal
|
---|
56 | */
|
---|
57 | #define HMCanEmulateIoBlock(a_pVCpu) (!CPUMIsGuestInPagedProtectedMode(a_pVCpu))
|
---|
58 |
|
---|
59 | /**
|
---|
60 | * Check if the current CPU state is valid for emulating IO blocks in the recompiler
|
---|
61 | *
|
---|
62 | * @returns boolean
|
---|
63 | * @param a_pCtx Pointer to the CPU context (within PVM).
|
---|
64 | * @internal
|
---|
65 | */
|
---|
66 | #define HMCanEmulateIoBlockEx(a_pCtx) (!CPUMIsGuestInPagedProtectedModeEx(a_pCtx))
|
---|
67 |
|
---|
68 | VMM_INT_DECL(int) HMInvalidatePage(PVMCPU pVCpu, RTGCPTR GCVirt);
|
---|
69 | VMM_INT_DECL(bool) HMHasPendingIrq(PVM pVM);
|
---|
70 | VMM_INT_DECL(PX86PDPE) HMGetPaePdpes(PVMCPU pVCpu);
|
---|
71 |
|
---|
72 | #ifndef IN_RC
|
---|
73 | VMM_INT_DECL(int) HMFlushTLB(PVMCPU pVCpu);
|
---|
74 | VMM_INT_DECL(int) HMFlushTLBOnAllVCpus(PVM pVM);
|
---|
75 | VMM_INT_DECL(int) HMInvalidatePageOnAllVCpus(PVM pVM, RTGCPTR GCVirt);
|
---|
76 | VMM_INT_DECL(int) HMInvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys);
|
---|
77 | VMM_INT_DECL(bool) HMIsNestedPagingActive(PVM pVM);
|
---|
78 | VMM_INT_DECL(PGMMODE) HMGetShwPagingMode(PVM pVM);
|
---|
79 | #else /* Nops in RC: */
|
---|
80 | # define HMFlushTLB(pVCpu) do { } while (0)
|
---|
81 | # define HMIsNestedPagingActive(pVM) false
|
---|
82 | # define HMFlushTLBOnAllVCpus(pVM) do { } while (0)
|
---|
83 | #endif
|
---|
84 |
|
---|
85 | #ifdef IN_RING0
|
---|
86 | /** @defgroup grp_hm_r0 The VM Hardware Manager API
|
---|
87 | * @ingroup grp_hm
|
---|
88 | * @{
|
---|
89 | */
|
---|
90 | VMMR0_INT_DECL(int) HMR0Init(void);
|
---|
91 | VMMR0_INT_DECL(int) HMR0Term(void);
|
---|
92 | VMMR0_INT_DECL(int) HMR0InitVM(PVM pVM);
|
---|
93 | VMMR0_INT_DECL(int) HMR0TermVM(PVM pVM);
|
---|
94 | VMMR0_INT_DECL(int) HMR0EnableAllCpus(PVM pVM);
|
---|
95 | VMMR0_INT_DECL(int) HMR0EnterSwitcher(PVM pVM, VMMSWITCHER enmSwitcher, bool *pfVTxDisabled);
|
---|
96 | VMMR0_INT_DECL(void) HMR0LeaveSwitcher(PVM pVM, bool fVTxDisabled);
|
---|
97 |
|
---|
98 | VMMR0_INT_DECL(void) HMR0SavePendingIOPortWrite(PVMCPU pVCpu, RTGCPTR GCPtrRip, RTGCPTR GCPtrRipNext,
|
---|
99 | unsigned uPort, unsigned uAndVal, unsigned cbSize);
|
---|
100 | VMMR0_INT_DECL(void) HMR0SavePendingIOPortRead(PVMCPU pVCpu, RTGCPTR GCPtrRip, RTGCPTR GCPtrRipNext,
|
---|
101 | unsigned uPort, unsigned uAndVal, unsigned cbSize);
|
---|
102 |
|
---|
103 | /** @} */
|
---|
104 | #endif /* IN_RING0 */
|
---|
105 |
|
---|
106 |
|
---|
107 | #ifdef IN_RING3
|
---|
108 | /** @defgroup grp_hm_r3 The VM Hardware Manager API
|
---|
109 | * @ingroup grp_hm
|
---|
110 | * @{
|
---|
111 | */
|
---|
112 | VMMR3DECL(bool) HMR3IsEnabled(PUVM pUVM);
|
---|
113 | VMMR3DECL(bool) HMR3IsNestedPagingActive(PUVM pUVM);
|
---|
114 | VMMR3DECL(bool) HMR3IsVpidActive(PUVM pVUM);
|
---|
115 |
|
---|
116 | VMMR3_INT_DECL(bool) HMR3IsEventPending(PVMCPU pVCpu);
|
---|
117 | VMMR3_INT_DECL(int) HMR3Init(PVM pVM);
|
---|
118 | VMMR3_INT_DECL(int) HMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
|
---|
119 | VMMR3_INT_DECL(void) HMR3Relocate(PVM pVM);
|
---|
120 | VMMR3_INT_DECL(int) HMR3Term(PVM pVM);
|
---|
121 | VMMR3_INT_DECL(void) HMR3Reset(PVM pVM);
|
---|
122 | VMMR3_INT_DECL(void) HMR3ResetCpu(PVMCPU pVCpu);
|
---|
123 | VMMR3_INT_DECL(void) HMR3CheckError(PVM pVM, int iStatusCode);
|
---|
124 | VMMR3DECL(bool) HMR3CanExecuteGuest(PVM pVM, PCPUMCTX pCtx);
|
---|
125 | VMMR3_INT_DECL(void) HMR3NotifyScheduled(PVMCPU pVCpu);
|
---|
126 | VMMR3_INT_DECL(void) HMR3NotifyEmulated(PVMCPU pVCpu);
|
---|
127 | VMMR3_INT_DECL(bool) HMR3IsActive(PVMCPU pVCpu);
|
---|
128 | VMMR3_INT_DECL(bool) HMR3IsAllowed(PVM pVM);
|
---|
129 | VMMR3_INT_DECL(void) HMR3PagingModeChanged(PVM pVM, PVMCPU pVCpu, PGMMODE enmShadowMode, PGMMODE enmGuestMode);
|
---|
130 | VMMR3_INT_DECL(int) HMR3EmulateIoBlock(PVM pVM, PCPUMCTX pCtx);
|
---|
131 | VMMR3_INT_DECL(VBOXSTRICTRC) HMR3RestartPendingIOInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
132 | VMMR3_INT_DECL(int) HMR3EnablePatching(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
|
---|
133 | VMMR3_INT_DECL(int) HMR3DisablePatching(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
|
---|
134 | VMMR3_INT_DECL(int) HMR3PatchTprInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
135 | VMMR3_INT_DECL(bool) HMR3IsRescheduleRequired(PVM pVM, PCPUMCTX pCtx);
|
---|
136 | VMMR3_INT_DECL(bool) HMR3IsVmxPreemptionTimerUsed(PVM pVM);
|
---|
137 |
|
---|
138 | /** @} */
|
---|
139 | #endif /* IN_RING3 */
|
---|
140 |
|
---|
141 | #ifdef IN_RING0
|
---|
142 | /** @addtogroup grp_hm_r0
|
---|
143 | * @{
|
---|
144 | */
|
---|
145 | VMMR0_INT_DECL(int) HMR0SetupVM(PVM pVM);
|
---|
146 | VMMR0_INT_DECL(int) HMR0RunGuestCode(PVM pVM, PVMCPU pVCpu);
|
---|
147 | VMMR0_INT_DECL(int) HMR0Enter(PVM pVM, PVMCPU pVCpu);
|
---|
148 | VMMR0_INT_DECL(int) HMR0Leave(PVM pVM, PVMCPU pVCpu);
|
---|
149 | VMMR0_INT_DECL(bool) HMR0SuspendPending(void);
|
---|
150 |
|
---|
151 | # if HC_ARCH_BITS == 32 && defined(VBOX_WITH_64_BITS_GUESTS)
|
---|
152 | VMMR0_INT_DECL(int) HMR0SaveFPUState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
153 | VMMR0_INT_DECL(int) HMR0SaveDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
154 | VMMR0_INT_DECL(int) HMR0TestSwitcher3264(PVM pVM);
|
---|
155 | # endif
|
---|
156 |
|
---|
157 | /** @} */
|
---|
158 | #endif /* IN_RING0 */
|
---|
159 |
|
---|
160 |
|
---|
161 | /** @} */
|
---|
162 | RT_C_DECLS_END
|
---|
163 |
|
---|
164 |
|
---|
165 | #endif
|
---|
166 |
|
---|