1 | /** @file
|
---|
2 | * VMM - The Virtual Machine Monitor.
|
---|
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_vmm_h
|
---|
31 | #define ___VBox_vmm_h
|
---|
32 |
|
---|
33 | #include <VBox/cdefs.h>
|
---|
34 | #include <VBox/types.h>
|
---|
35 | #include <VBox/vmapi.h>
|
---|
36 | #include <VBox/sup.h>
|
---|
37 | #include <iprt/stdarg.h>
|
---|
38 |
|
---|
39 | __BEGIN_DECLS
|
---|
40 |
|
---|
41 | /** @defgroup grp_vmm The Virtual Machine Monitor API
|
---|
42 | * @{
|
---|
43 | */
|
---|
44 |
|
---|
45 | /**
|
---|
46 | * World switcher identifiers.
|
---|
47 | */
|
---|
48 | typedef enum VMMSWITCHER
|
---|
49 | {
|
---|
50 | /** The usual invalid 0. */
|
---|
51 | VMMSWITCHER_INVALID = 0,
|
---|
52 | /** Switcher for 32-bit host to 32-bit shadow paging. */
|
---|
53 | VMMSWITCHER_32_TO_32,
|
---|
54 | /** Switcher for 32-bit host paging to PAE shadow paging. */
|
---|
55 | VMMSWITCHER_32_TO_PAE,
|
---|
56 | /** Switcher for 32-bit host paging to AMD64 shadow paging. */
|
---|
57 | VMMSWITCHER_32_TO_AMD64,
|
---|
58 | /** Switcher for PAE host to 32-bit shadow paging. */
|
---|
59 | VMMSWITCHER_PAE_TO_32,
|
---|
60 | /** Switcher for PAE host to PAE shadow paging. */
|
---|
61 | VMMSWITCHER_PAE_TO_PAE,
|
---|
62 | /** Switcher for PAE host paging to AMD64 shadow paging. */
|
---|
63 | VMMSWITCHER_PAE_TO_AMD64,
|
---|
64 | /** Switcher for AMD64 host paging to 32-bit shadow paging. */
|
---|
65 | VMMSWITCHER_AMD64_TO_32,
|
---|
66 | /** Switcher for AMD64 host paging to PAE shadow paging. */
|
---|
67 | VMMSWITCHER_AMD64_TO_PAE,
|
---|
68 | /** Switcher for AMD64 host paging to AMD64 shadow paging. */
|
---|
69 | VMMSWITCHER_AMD64_TO_AMD64,
|
---|
70 | /** Used to make a count for array declarations and suchlike. */
|
---|
71 | VMMSWITCHER_MAX,
|
---|
72 | /** The usual 32-bit paranoia. */
|
---|
73 | VMMSWITCHER_32BIT_HACK = 0x7fffffff
|
---|
74 | } VMMSWITCHER;
|
---|
75 |
|
---|
76 |
|
---|
77 | /**
|
---|
78 | * VMMGCCallHost operations.
|
---|
79 | */
|
---|
80 | typedef enum VMMCALLHOST
|
---|
81 | {
|
---|
82 | /** Invalid operation. */
|
---|
83 | VMMCALLHOST_INVALID = 0,
|
---|
84 | /** Acquire the PDM lock. */
|
---|
85 | VMMCALLHOST_PDM_LOCK,
|
---|
86 | /** Call PDMR3QueueFlushWorker. */
|
---|
87 | VMMCALLHOST_PDM_QUEUE_FLUSH,
|
---|
88 | /** Acquire the PGM lock. */
|
---|
89 | VMMCALLHOST_PGM_LOCK,
|
---|
90 | /** Grow the PGM shadow page pool. */
|
---|
91 | VMMCALLHOST_PGM_POOL_GROW,
|
---|
92 | /** Maps a chunk into ring-3. */
|
---|
93 | VMMCALLHOST_PGM_MAP_CHUNK,
|
---|
94 | /** Allocates more handy pages. */
|
---|
95 | VMMCALLHOST_PGM_ALLOCATE_HANDY_PAGES,
|
---|
96 | #ifndef VBOX_WITH_NEW_PHYS_CODE
|
---|
97 | /** Dynamically allocate physical guest RAM. */
|
---|
98 | VMMCALLHOST_PGM_RAM_GROW_RANGE,
|
---|
99 | #endif
|
---|
100 | /** Replay the REM handler notifications. */
|
---|
101 | VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS,
|
---|
102 | /** Flush the GC/R0 logger. */
|
---|
103 | VMMCALLHOST_VMM_LOGGER_FLUSH,
|
---|
104 | /** Set the VM error message. */
|
---|
105 | VMMCALLHOST_VM_SET_ERROR,
|
---|
106 | /** Set the VM runtime error message. */
|
---|
107 | VMMCALLHOST_VM_SET_RUNTIME_ERROR,
|
---|
108 | /** Signal a ring 0 assertion. */
|
---|
109 | VMMCALLHOST_VM_R0_ASSERTION,
|
---|
110 | /** The usual 32-bit hack. */
|
---|
111 | VMMCALLHOST_32BIT_HACK = 0x7fffffff
|
---|
112 | } VMMCALLHOST;
|
---|
113 |
|
---|
114 | RTRCPTR VMMGetStackRC(PVM pVM);
|
---|
115 | VMCPUID VMMGetCpuId(PVM pVM);
|
---|
116 | PVMCPU VMMGetCpu(PVM pVM);
|
---|
117 | VMMDECL(PVMCPU) VMMGetCpuEx(PVM pVM, RTCPUID idCpu);
|
---|
118 | VMMDECL(uint32_t) VMMGetSvnRev(void);
|
---|
119 |
|
---|
120 | /** @def VMMIsHwVirtExtForced
|
---|
121 | * Checks if forced to use the hardware assisted virtualization extensions.
|
---|
122 | *
|
---|
123 | * This is intended for making setup decisions where we can save resources when
|
---|
124 | * using hardware assisted virtualization.
|
---|
125 | *
|
---|
126 | * @returns true / false.
|
---|
127 | * @param pVM Pointer to the shared VM structure. */
|
---|
128 | #define VMMIsHwVirtExtForced(pVM) ((pVM)->fHwVirtExtForced)
|
---|
129 |
|
---|
130 |
|
---|
131 | #ifdef IN_RING3
|
---|
132 | /** @defgroup grp_vmm_r3 The VMM Host Context Ring 3 API
|
---|
133 | * @ingroup grp_vmm
|
---|
134 | * @{
|
---|
135 | */
|
---|
136 | VMMR3DECL(int) VMMR3Init(PVM pVM);
|
---|
137 | VMMR3DECL(int) VMMR3InitCPU(PVM pVM);
|
---|
138 | VMMR3DECL(int) VMMR3InitFinalize(PVM pVM);
|
---|
139 | VMMR3DECL(int) VMMR3InitR0(PVM pVM);
|
---|
140 | VMMR3DECL(int) VMMR3InitRC(PVM pVM);
|
---|
141 | VMMR3DECL(int) VMMR3Term(PVM pVM);
|
---|
142 | VMMR3DECL(int) VMMR3TermCPU(PVM pVM);
|
---|
143 | VMMR3DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
144 | VMMR3DECL(int) VMMR3UpdateLoggers(PVM pVM);
|
---|
145 | VMMR3DECL(const char *) VMMR3GetRZAssertMsg1(PVM pVM);
|
---|
146 | VMMR3DECL(const char *) VMMR3GetRZAssertMsg2(PVM pVM);
|
---|
147 | VMMR3DECL(int) VMMR3GetImportRC(PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue);
|
---|
148 | VMMR3DECL(int) VMMR3SelectSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
|
---|
149 | VMMR3DECL(int) VMMR3DisableSwitcher(PVM pVM);
|
---|
150 | VMMR3DECL(RTR0PTR) VMMR3GetHostToGuestSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
|
---|
151 | VMMR3DECL(int) VMMR3RawRunGC(PVM pVM);
|
---|
152 | VMMR3DECL(int) VMMR3HwAccRunGC(PVM pVM, RTCPUID idCpu);
|
---|
153 | VMMR3DECL(int) VMMR3CallRC(PVM pVM, RTRCPTR RCPtrEntry, unsigned cArgs, ...);
|
---|
154 | VMMR3DECL(int) VMMR3CallRCV(PVM pVM, RTRCPTR RCPtrEntry, unsigned cArgs, va_list args);
|
---|
155 | VMMR3DECL(int) VMMR3ResumeHyper(PVM pVM);
|
---|
156 | VMMR3DECL(void) VMMR3FatalDump(PVM pVM, int rcErr);
|
---|
157 | VMMR3DECL(int) VMMR3Lock(PVM pVM);
|
---|
158 | VMMR3DECL(int) VMMR3Unlock(PVM pVM);
|
---|
159 | VMMR3DECL(RTNATIVETHREAD) VMMR3LockGetOwner(PVM pVM);
|
---|
160 | VMMR3DECL(bool) VMMR3LockIsOwner(PVM pVM);
|
---|
161 | VMMR3DECL(void) VMMR3YieldSuspend(PVM pVM);
|
---|
162 | VMMR3DECL(void) VMMR3YieldStop(PVM pVM);
|
---|
163 | VMMR3DECL(void) VMMR3YieldResume(PVM pVM);
|
---|
164 | /** @} */
|
---|
165 | #endif /* IN_RING3 */
|
---|
166 |
|
---|
167 |
|
---|
168 | /** @defgroup grp_vmm_r0 The VMM Host Context Ring 0 API
|
---|
169 | * @ingroup grp_vmm
|
---|
170 | * @{
|
---|
171 | */
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * The VMMR0Entry() codes.
|
---|
175 | */
|
---|
176 | typedef enum VMMR0OPERATION
|
---|
177 | {
|
---|
178 | /** Run guest context. */
|
---|
179 | VMMR0_DO_RAW_RUN = SUP_VMMR0_DO_RAW_RUN,
|
---|
180 | /** Run guest code using the available hardware acceleration technology. */
|
---|
181 | VMMR0_DO_HWACC_RUN = SUP_VMMR0_DO_HWACC_RUN,
|
---|
182 | /** Official NOP that we use for profiling. */
|
---|
183 | VMMR0_DO_NOP = SUP_VMMR0_DO_NOP,
|
---|
184 | /** Official slow iocl NOP that we use for profiling. */
|
---|
185 | VMMR0_DO_SLOW_NOP,
|
---|
186 |
|
---|
187 | /** Ask the GVMM to create a new VM. */
|
---|
188 | VMMR0_DO_GVMM_CREATE_VM,
|
---|
189 | /** Ask the GVMM to destroy the VM. */
|
---|
190 | VMMR0_DO_GVMM_DESTROY_VM,
|
---|
191 | /** Call GVMMR0SchedHalt(). */
|
---|
192 | VMMR0_DO_GVMM_SCHED_HALT,
|
---|
193 | /** Call GVMMR0SchedWakeUp(). */
|
---|
194 | VMMR0_DO_GVMM_SCHED_WAKE_UP,
|
---|
195 | /** Call GVMMR0SchedPoll(). */
|
---|
196 | VMMR0_DO_GVMM_SCHED_POLL,
|
---|
197 | /** Call GVMMR0QueryStatistics(). */
|
---|
198 | VMMR0_DO_GVMM_QUERY_STATISTICS,
|
---|
199 | /** Call GVMMR0ResetStatistics(). */
|
---|
200 | VMMR0_DO_GVMM_RESET_STATISTICS,
|
---|
201 |
|
---|
202 | /** Call VMMR0 Per VM Init. */
|
---|
203 | VMMR0_DO_VMMR0_INIT,
|
---|
204 | /** Call VMMR0 Per VM Termination. */
|
---|
205 | VMMR0_DO_VMMR0_TERM,
|
---|
206 | /** Setup the hardware accelerated raw-mode session. */
|
---|
207 | VMMR0_DO_HWACC_SETUP_VM,
|
---|
208 | /** Attempt to enable or disable hardware accelerated raw-mode. */
|
---|
209 | VMMR0_DO_HWACC_ENABLE,
|
---|
210 | /** Calls function in the hypervisor.
|
---|
211 | * The caller must setup the hypervisor context so the call will be performed.
|
---|
212 | * The difference between VMMR0_DO_RUN_GC and this one is the handling of
|
---|
213 | * the return GC code. The return code will not be interpreted by this operation.
|
---|
214 | */
|
---|
215 | VMMR0_DO_CALL_HYPERVISOR,
|
---|
216 |
|
---|
217 | /** Call PGMR0PhysAllocateHandyPages(). */
|
---|
218 | VMMR0_DO_PGM_ALLOCATE_HANDY_PAGES,
|
---|
219 |
|
---|
220 | /** Call GMMR0InitialReservation(). */
|
---|
221 | VMMR0_DO_GMM_INITIAL_RESERVATION,
|
---|
222 | /** Call GMMR0UpdateReservation(). */
|
---|
223 | VMMR0_DO_GMM_UPDATE_RESERVATION,
|
---|
224 | /** Call GMMR0AllocatePages(). */
|
---|
225 | VMMR0_DO_GMM_ALLOCATE_PAGES,
|
---|
226 | /** Call GMMR0FreePages(). */
|
---|
227 | VMMR0_DO_GMM_FREE_PAGES,
|
---|
228 | /** Call GMMR0BalloonedPages(). */
|
---|
229 | VMMR0_DO_GMM_BALLOONED_PAGES,
|
---|
230 | /** Call GMMR0DeflatedBalloon(). */
|
---|
231 | VMMR0_DO_GMM_DEFLATED_BALLOON,
|
---|
232 | /** Call GMMR0MapUnmapChunk(). */
|
---|
233 | VMMR0_DO_GMM_MAP_UNMAP_CHUNK,
|
---|
234 | /** Call GMMR0SeedChunk(). */
|
---|
235 | VMMR0_DO_GMM_SEED_CHUNK,
|
---|
236 |
|
---|
237 | /** Set a GVMM or GMM configuration value. */
|
---|
238 | VMMR0_DO_GCFGM_SET_VALUE,
|
---|
239 | /** Query a GVMM or GMM configuration value. */
|
---|
240 | VMMR0_DO_GCFGM_QUERY_VALUE,
|
---|
241 |
|
---|
242 | /** The start of the R0 service operations. */
|
---|
243 | VMMR0_DO_SRV_START,
|
---|
244 | /** Call INTNETR0Open(). */
|
---|
245 | VMMR0_DO_INTNET_OPEN,
|
---|
246 | /** Call INTNETR0IfClose(). */
|
---|
247 | VMMR0_DO_INTNET_IF_CLOSE,
|
---|
248 | /** Call INTNETR0IfGetRing3Buffer(). */
|
---|
249 | VMMR0_DO_INTNET_IF_GET_RING3_BUFFER,
|
---|
250 | /** Call INTNETR0IfSetPromiscuousMode(). */
|
---|
251 | VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE,
|
---|
252 | /** Call INTNETR0IfSetMacAddress(). */
|
---|
253 | VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
|
---|
254 | /** Call INTNETR0IfSetActive(). */
|
---|
255 | VMMR0_DO_INTNET_IF_SET_ACTIVE,
|
---|
256 | /** Call INTNETR0IfSend(). */
|
---|
257 | VMMR0_DO_INTNET_IF_SEND,
|
---|
258 | /** Call INTNETR0IfWait(). */
|
---|
259 | VMMR0_DO_INTNET_IF_WAIT,
|
---|
260 | /** The end of the R0 service operations. */
|
---|
261 | VMMR0_DO_SRV_END,
|
---|
262 |
|
---|
263 | /** Official call we use for testing Ring-0 APIs. */
|
---|
264 | VMMR0_DO_TESTS,
|
---|
265 |
|
---|
266 | /** The usual 32-bit type blow up. */
|
---|
267 | VMMR0_DO_32BIT_HACK = 0x7fffffff
|
---|
268 | } VMMR0OPERATION;
|
---|
269 |
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * Request buffer for VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE.
|
---|
273 | * @todo Move got GCFGM.h when it's implemented.
|
---|
274 | */
|
---|
275 | typedef struct GCFGMVALUEREQ
|
---|
276 | {
|
---|
277 | /** The request header.*/
|
---|
278 | SUPVMMR0REQHDR Hdr;
|
---|
279 | /** The support driver session handle. */
|
---|
280 | PSUPDRVSESSION pSession;
|
---|
281 | /** The value.
|
---|
282 | * This is input for the set request and output for the query. */
|
---|
283 | uint64_t u64Value;
|
---|
284 | /** The variable name.
|
---|
285 | * This is fixed sized just to make things simple for the mock-up. */
|
---|
286 | char szName[48];
|
---|
287 | } GCFGMVALUEREQ;
|
---|
288 | /** Pointer to a VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE request buffer.
|
---|
289 | * @todo Move got GCFGM.h when it's implemented.
|
---|
290 | */
|
---|
291 | typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
|
---|
292 |
|
---|
293 | VMMR0DECL(int) VMMR0EntryInt(PVM pVM, VMMR0OPERATION enmOperation, void *pvArg);
|
---|
294 | VMMR0DECL(void) VMMR0EntryFast(PVM pVM, unsigned idCpu, VMMR0OPERATION enmOperation);
|
---|
295 | VMMR0DECL(int) VMMR0EntryEx(PVM pVM, VMMR0OPERATION enmOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION);
|
---|
296 | VMMR0DECL(int) VMMR0TermVM(PVM pVM, PGVM pGVM);
|
---|
297 | VMMR0DECL(int) VMMR0CallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
|
---|
298 | VMMR0DECL(void) VMMR0LogFlushDisable(PVMCPU pVCpu);
|
---|
299 | VMMR0DECL(void) VMMR0LogFlushEnable(PVMCPU pVCpu);
|
---|
300 |
|
---|
301 | /** @} */
|
---|
302 |
|
---|
303 |
|
---|
304 | #ifdef IN_RC
|
---|
305 | /** @defgroup grp_vmm_rc The VMM Raw-Mode Context API
|
---|
306 | * @ingroup grp_vmm
|
---|
307 | * @{
|
---|
308 | */
|
---|
309 | VMMRCDECL(int) VMMGCEntry(PVM pVM, unsigned uOperation, unsigned uArg, ...);
|
---|
310 | VMMRCDECL(void) VMMGCGuestToHost(PVM pVM, int rc);
|
---|
311 | VMMRCDECL(int) VMMGCCallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
|
---|
312 | /** @} */
|
---|
313 | #endif /* IN_RC */
|
---|
314 |
|
---|
315 |
|
---|
316 | /** @} */
|
---|
317 | __END_DECLS
|
---|
318 |
|
---|
319 | #endif
|
---|
320 |
|
---|