VirtualBox

source: vbox/trunk/include/VBox/vmm.h@ 27149

Last change on this file since 27149 was 27086, checked in by vboxsync, 15 years ago

Missing updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.0 KB
Line 
1/** @file
2 * VMM - The Virtual Machine Monitor. (VMM)
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 <VBox/log.h>
38#include <iprt/stdarg.h>
39
40RT_C_DECLS_BEGIN
41
42/** @defgroup grp_vmm The Virtual Machine Monitor API
43 * @{
44 */
45
46/**
47 * World switcher identifiers.
48 */
49typedef enum VMMSWITCHER
50{
51 /** The usual invalid 0. */
52 VMMSWITCHER_INVALID = 0,
53 /** Switcher for 32-bit host to 32-bit shadow paging. */
54 VMMSWITCHER_32_TO_32,
55 /** Switcher for 32-bit host paging to PAE shadow paging. */
56 VMMSWITCHER_32_TO_PAE,
57 /** Switcher for 32-bit host paging to AMD64 shadow paging. */
58 VMMSWITCHER_32_TO_AMD64,
59 /** Switcher for PAE host to 32-bit shadow paging. */
60 VMMSWITCHER_PAE_TO_32,
61 /** Switcher for PAE host to PAE shadow paging. */
62 VMMSWITCHER_PAE_TO_PAE,
63 /** Switcher for PAE host paging to AMD64 shadow paging. */
64 VMMSWITCHER_PAE_TO_AMD64,
65 /** Switcher for AMD64 host paging to 32-bit shadow paging. */
66 VMMSWITCHER_AMD64_TO_32,
67 /** Switcher for AMD64 host paging to PAE shadow paging. */
68 VMMSWITCHER_AMD64_TO_PAE,
69 /** Switcher for AMD64 host paging to AMD64 shadow paging. */
70 VMMSWITCHER_AMD64_TO_AMD64,
71 /** Used to make a count for array declarations and suchlike. */
72 VMMSWITCHER_MAX,
73 /** The usual 32-bit paranoia. */
74 VMMSWITCHER_32BIT_HACK = 0x7fffffff
75} VMMSWITCHER;
76
77
78/**
79 * VMMRZCallRing3 operations.
80 */
81typedef enum VMMCALLRING3
82{
83 /** Invalid operation. */
84 VMMCALLRING3_INVALID = 0,
85 /** Acquire the PDM lock. */
86 VMMCALLRING3_PDM_LOCK,
87 /** Call PDMR3QueueFlushWorker. */
88 VMMCALLRING3_PDM_QUEUE_FLUSH,
89 /** Acquire the PGM lock. */
90 VMMCALLRING3_PGM_LOCK,
91 /** Grow the PGM shadow page pool. */
92 VMMCALLRING3_PGM_POOL_GROW,
93 /** Maps a chunk into ring-3. */
94 VMMCALLRING3_PGM_MAP_CHUNK,
95 /** Allocates more handy pages. */
96 VMMCALLRING3_PGM_ALLOCATE_HANDY_PAGES,
97 /** Allocates a large (2MB) page. */
98 VMMCALLRING3_PGM_ALLOCATE_LARGE_HANDY_PAGE,
99 /** Acquire the MM hypervisor heap lock. */
100 VMMCALLRING3_MMHYPER_LOCK,
101 /** Replay the REM handler notifications. */
102 VMMCALLRING3_REM_REPLAY_HANDLER_NOTIFICATIONS,
103 /** Flush the GC/R0 logger. */
104 VMMCALLRING3_VMM_LOGGER_FLUSH,
105 /** Set the VM error message. */
106 VMMCALLRING3_VM_SET_ERROR,
107 /** Set the VM runtime error message. */
108 VMMCALLRING3_VM_SET_RUNTIME_ERROR,
109 /** Signal a ring 0 assertion. */
110 VMMCALLRING3_VM_R0_ASSERTION,
111 /** Ring switch to force preemption. */
112 VMMCALLRING3_VM_R0_PREEMPT,
113 /** The usual 32-bit hack. */
114 VMMCALLRING3_32BIT_HACK = 0x7fffffff
115} VMMCALLRING3;
116
117/**
118 * VMMR3AtomicExecuteHandler callback function.
119 *
120 * @returns VBox status code.
121 * @param pVM Pointer to the shared VM structure.
122 * @param pvUser User specified argument
123 *
124 * @todo missing prefix.
125 */
126typedef DECLCALLBACK(int) FNATOMICHANDLER(PVM pVM, void *pvUser);
127/** Pointer to a FNMMATOMICHANDLER(). */
128typedef FNATOMICHANDLER *PFNATOMICHANDLER;
129
130/**
131 * Rendezvous callback.
132 *
133 * @returns VBox strict status code - EM scheduling. Do not return
134 * informational status code other than the ones used by EM for
135 * scheduling.
136 *
137 * @param pVM The VM handle.
138 * @param pVCpu The handle of the calling virtual CPU.
139 * @param pvUser The user argument.
140 */
141typedef DECLCALLBACK(VBOXSTRICTRC) FNVMMEMTRENDEZVOUS(PVM pVM, PVMCPU pVCpu, void *pvUser);
142/** Pointer to a rendezvous callback function. */
143typedef FNVMMEMTRENDEZVOUS *PFNVMMEMTRENDEZVOUS;
144
145
146VMMDECL(RTRCPTR) VMMGetStackRC(PVM pVM);
147VMMDECL(VMCPUID) VMMGetCpuId(PVM pVM);
148VMMDECL(PVMCPU) VMMGetCpu(PVM pVM);
149VMMDECL(PVMCPU) VMMGetCpu0(PVM pVM);
150VMMDECL(PVMCPU) VMMGetCpuById(PVM pVM, VMCPUID idCpu);
151VMMDECL(uint32_t) VMMGetSvnRev(void);
152VMMDECL(VMMSWITCHER) VMMGetSwitcher(PVM pVM);
153VMMDECL(void) VMMTrashVolatileXMMRegs(void);
154
155/** @def VMMIsHwVirtExtForced
156 * Checks if forced to use the hardware assisted virtualization extensions.
157 *
158 * This is intended for making setup decisions where we can save resources when
159 * using hardware assisted virtualization.
160 *
161 * @returns true / false.
162 * @param pVM Pointer to the shared VM structure.
163 */
164#define VMMIsHwVirtExtForced(pVM) ((pVM)->fHwVirtExtForced)
165
166
167#ifdef IN_RING3
168/** @defgroup grp_vmm_r3 The VMM Host Context Ring 3 API
169 * @ingroup grp_vmm
170 * @{
171 */
172VMMR3DECL(int) VMMR3Init(PVM pVM);
173VMMR3DECL(int) VMMR3InitCPU(PVM pVM);
174VMMR3DECL(int) VMMR3InitFinalize(PVM pVM);
175VMMR3DECL(int) VMMR3InitR0(PVM pVM);
176VMMR3DECL(int) VMMR3InitRC(PVM pVM);
177VMMR3DECL(int) VMMR3Term(PVM pVM);
178VMMR3DECL(int) VMMR3TermCPU(PVM pVM);
179VMMR3DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
180VMMR3DECL(int) VMMR3UpdateLoggers(PVM pVM);
181VMMR3DECL(const char *) VMMR3GetRZAssertMsg1(PVM pVM);
182VMMR3DECL(const char *) VMMR3GetRZAssertMsg2(PVM pVM);
183VMMR3DECL(int) VMMR3GetImportRC(PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue);
184VMMR3DECL(int) VMMR3SelectSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
185VMMR3DECL(int) VMMR3DisableSwitcher(PVM pVM);
186VMMR3DECL(RTR0PTR) VMMR3GetHostToGuestSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
187VMMR3DECL(int) VMMR3RawRunGC(PVM pVM, PVMCPU pVCpu);
188VMMR3DECL(int) VMMR3HwAccRunGC(PVM pVM, PVMCPU pVCpu);
189VMMR3DECL(int) VMMR3CallRC(PVM pVM, RTRCPTR RCPtrEntry, unsigned cArgs, ...);
190VMMR3DECL(int) VMMR3CallRCV(PVM pVM, RTRCPTR RCPtrEntry, unsigned cArgs, va_list args);
191VMMR3DECL(int) VMMR3CallR0(PVM pVM, uint32_t uOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr);
192VMMR3DECL(int) VMMR3ResumeHyper(PVM pVM, PVMCPU pVCpu);
193VMMR3DECL(void) VMMR3FatalDump(PVM pVM, PVMCPU pVCpu, int rcErr);
194VMMR3DECL(void) VMMR3YieldSuspend(PVM pVM);
195VMMR3DECL(void) VMMR3YieldStop(PVM pVM);
196VMMR3DECL(void) VMMR3YieldResume(PVM pVM);
197VMMR3DECL(void) VMMR3SendSipi(PVM pVM, VMCPUID idCpu, uint32_t uVector);
198VMMR3DECL(void) VMMR3SendInitIpi(PVM pVM, VMCPUID idCpu);
199VMMR3DECL(int) VMMR3RegisterPatchMemory(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
200VMMR3DECL(int) VMMR3DeregisterPatchMemory(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
201VMMR3DECL(int) VMMR3AtomicExecuteHandler(PVM pVM, PFNATOMICHANDLER pfnHandler, void *pvUser);
202VMMR3DECL(int) VMMR3EmtRendezvous(PVM pVM, uint32_t fFlags, PFNVMMEMTRENDEZVOUS pfnRendezvous, void *pvUser);
203/** @defgroup grp_VMMR3EmtRendezvous_fFlags VMMR3EmtRendezvous flags
204 * @{ */
205/** Execution type mask. */
206#define VMMEMTRENDEZVOUS_FLAGS_TYPE_MASK UINT32_C(0x00000007)
207/** Invalid execution type. */
208#define VMMEMTRENDEZVOUS_FLAGS_TYPE_INVALID UINT32_C(0)
209/** Let the EMTs execute the callback one by one (in no particular order). */
210#define VMMEMTRENDEZVOUS_FLAGS_TYPE_ONE_BY_ONE UINT32_C(1)
211/** Let all the EMTs execute the callback at the same time. */
212#define VMMEMTRENDEZVOUS_FLAGS_TYPE_ALL_AT_ONCE UINT32_C(2)
213/** Only execute the callback on one EMT (no particular one). */
214#define VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE UINT32_C(3)
215/** Let the EMTs execute the callback one by one in ascending order. */
216#define VMMEMTRENDEZVOUS_FLAGS_TYPE_ASCENDING UINT32_C(4)
217/** Let the EMTs execute the callback one by one in descending order. */
218#define VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING UINT32_C(5)
219/** Stop after the first error.
220 * This is not valid for any execution type where more than one EMT is active
221 * at a time. */
222#define VMMEMTRENDEZVOUS_FLAGS_STOP_ON_ERROR UINT32_C(0x00000008)
223/** The valid flags. */
224#define VMMEMTRENDEZVOUS_FLAGS_VALID_MASK UINT32_C(0x0000000f)
225/** @} */
226VMMR3DECL(int) VMMR3EmtRendezvousFF(PVM pVM, PVMCPU pVCpu);
227VMMR3DECL(int) VMMR3ReadR0Stack(PVM pVM, VMCPUID idCpu, RTHCUINTPTR pAddress, void *pvBuf, size_t cbRead);
228/** @} */
229#endif /* IN_RING3 */
230
231
232/** @defgroup grp_vmm_r0 The VMM Host Context Ring 0 API
233 * @ingroup grp_vmm
234 * @{
235 */
236
237/**
238 * The VMMR0Entry() codes.
239 */
240typedef enum VMMR0OPERATION
241{
242 /** Run guest context. */
243 VMMR0_DO_RAW_RUN = SUP_VMMR0_DO_RAW_RUN,
244 /** Run guest code using the available hardware acceleration technology. */
245 VMMR0_DO_HWACC_RUN = SUP_VMMR0_DO_HWACC_RUN,
246 /** Official NOP that we use for profiling. */
247 VMMR0_DO_NOP = SUP_VMMR0_DO_NOP,
248 /** Official slow iocl NOP that we use for profiling. */
249 VMMR0_DO_SLOW_NOP,
250
251 /** Ask the GVMM to create a new VM. */
252 VMMR0_DO_GVMM_CREATE_VM,
253 /** Ask the GVMM to destroy the VM. */
254 VMMR0_DO_GVMM_DESTROY_VM,
255 /** Call GVMMR0SchedHalt(). */
256 VMMR0_DO_GVMM_SCHED_HALT,
257 /** Call GVMMR0SchedWakeUp(). */
258 VMMR0_DO_GVMM_SCHED_WAKE_UP,
259 /** Call GVMMR0SchedPoke(). */
260 VMMR0_DO_GVMM_SCHED_POKE,
261 /** Call GVMMR0SchedWakeUpAndPokeCpus(). */
262 VMMR0_DO_GVMM_SCHED_WAKE_UP_AND_POKE_CPUS,
263 /** Call GVMMR0SchedPoll(). */
264 VMMR0_DO_GVMM_SCHED_POLL,
265 /** Call GVMMR0QueryStatistics(). */
266 VMMR0_DO_GVMM_QUERY_STATISTICS,
267 /** Call GVMMR0ResetStatistics(). */
268 VMMR0_DO_GVMM_RESET_STATISTICS,
269 /** Call GVMMR0RegisterVCpu(). */
270 VMMR0_DO_GVMM_REGISTER_VMCPU,
271
272 /** Call VMMR0 Per VM Init. */
273 VMMR0_DO_VMMR0_INIT,
274 /** Call VMMR0 Per VM Termination. */
275 VMMR0_DO_VMMR0_TERM,
276 /** Setup the hardware accelerated raw-mode session. */
277 VMMR0_DO_HWACC_SETUP_VM,
278 /** Attempt to enable or disable hardware accelerated raw-mode. */
279 VMMR0_DO_HWACC_ENABLE,
280 /** Calls function in the hypervisor.
281 * The caller must setup the hypervisor context so the call will be performed.
282 * The difference between VMMR0_DO_RUN_GC and this one is the handling of
283 * the return GC code. The return code will not be interpreted by this operation.
284 */
285 VMMR0_DO_CALL_HYPERVISOR,
286
287 /** Call PGMR0PhysAllocateHandyPages(). */
288 VMMR0_DO_PGM_ALLOCATE_HANDY_PAGES,
289 /** Call PGMR0AllocateLargePage(). */
290 VMMR0_DO_PGM_ALLOCATE_LARGE_HANDY_PAGE,
291
292 /** Call GMMR0InitialReservation(). */
293 VMMR0_DO_GMM_INITIAL_RESERVATION,
294 /** Call GMMR0UpdateReservation(). */
295 VMMR0_DO_GMM_UPDATE_RESERVATION,
296 /** Call GMMR0AllocatePages(). */
297 VMMR0_DO_GMM_ALLOCATE_PAGES,
298 /** Call GMMR0FreePages(). */
299 VMMR0_DO_GMM_FREE_PAGES,
300 /** Call GMMR0FreeLargePage(). */
301 VMMR0_DO_GMM_FREE_LARGE_PAGE,
302 /** Call GMMR0BalloonedPages(). */
303 VMMR0_DO_GMM_BALLOONED_PAGES,
304 /** Call GMMR0MapUnmapChunk(). */
305 VMMR0_DO_GMM_MAP_UNMAP_CHUNK,
306 /** Call GMMR0SeedChunk(). */
307 VMMR0_DO_GMM_SEED_CHUNK,
308
309 /** Set a GVMM or GMM configuration value. */
310 VMMR0_DO_GCFGM_SET_VALUE,
311 /** Query a GVMM or GMM configuration value. */
312 VMMR0_DO_GCFGM_QUERY_VALUE,
313
314 /** The start of the R0 service operations. */
315 VMMR0_DO_SRV_START,
316 /** Call INTNETR0Open(). */
317 VMMR0_DO_INTNET_OPEN,
318 /** Call INTNETR0IfClose(). */
319 VMMR0_DO_INTNET_IF_CLOSE,
320 /** Call INTNETR0IfGetRing3Buffer(). */
321 VMMR0_DO_INTNET_IF_GET_RING3_BUFFER,
322 /** Call INTNETR0IfSetPromiscuousMode(). */
323 VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE,
324 /** Call INTNETR0IfSetMacAddress(). */
325 VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
326 /** Call INTNETR0IfSetActive(). */
327 VMMR0_DO_INTNET_IF_SET_ACTIVE,
328 /** Call INTNETR0IfSend(). */
329 VMMR0_DO_INTNET_IF_SEND,
330 /** Call INTNETR0IfWait(). */
331 VMMR0_DO_INTNET_IF_WAIT,
332 /** The end of the R0 service operations. */
333 VMMR0_DO_SRV_END,
334
335 /** Official call we use for testing Ring-0 APIs. */
336 VMMR0_DO_TESTS,
337 /** Test the 32->64 bits switcher. */
338 VMMR0_DO_TEST_SWITCHER3264,
339
340 /** The usual 32-bit type blow up. */
341 VMMR0_DO_32BIT_HACK = 0x7fffffff
342} VMMR0OPERATION;
343
344
345/**
346 * Request buffer for VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE.
347 * @todo Move got GCFGM.h when it's implemented.
348 */
349typedef struct GCFGMVALUEREQ
350{
351 /** The request header.*/
352 SUPVMMR0REQHDR Hdr;
353 /** The support driver session handle. */
354 PSUPDRVSESSION pSession;
355 /** The value.
356 * This is input for the set request and output for the query. */
357 uint64_t u64Value;
358 /** The variable name.
359 * This is fixed sized just to make things simple for the mock-up. */
360 char szName[48];
361} GCFGMVALUEREQ;
362/** Pointer to a VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE request buffer.
363 * @todo Move got GCFGM.h when it's implemented.
364 */
365typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
366
367VMMR0DECL(int) VMMR0EntryInt(PVM pVM, VMMR0OPERATION enmOperation, void *pvArg);
368VMMR0DECL(void) VMMR0EntryFast(PVM pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation);
369VMMR0DECL(int) VMMR0EntryEx(PVM pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION);
370VMMR0DECL(int) VMMR0TermVM(PVM pVM, PGVM pGVM);
371
372#ifdef LOG_ENABLED
373VMMR0DECL(void) VMMR0LogFlushDisable(PVMCPU pVCpu);
374VMMR0DECL(void) VMMR0LogFlushEnable(PVMCPU pVCpu);
375#else
376#define VMMR0LogFlushDisable(pVCpu) do { } while(0)
377#define VMMR0LogFlushEnable(pVCpu) do { } while(0)
378#endif
379
380/** @} */
381
382
383#ifdef IN_RC
384/** @defgroup grp_vmm_rc The VMM Raw-Mode Context API
385 * @ingroup grp_vmm
386 * @{
387 */
388VMMRCDECL(int) VMMGCEntry(PVM pVM, unsigned uOperation, unsigned uArg, ...);
389VMMRCDECL(void) VMMGCGuestToHost(PVM pVM, int rc);
390VMMRCDECL(void) VMMGCLogFlushIfFull(PVM pVM);
391/** @} */
392#endif /* IN_RC */
393
394#if defined(IN_RC) || defined(IN_RING0)
395/** @defgroup grp_vmm_rz The VMM Raw-Mode and Ring-0 Context API
396 * @ingroup grp_vmm
397 * @{
398 */
399VMMRZDECL(int) VMMRZCallRing3(PVM pVM, PVMCPU pVCpu, VMMCALLRING3 enmOperation, uint64_t uArg);
400VMMRZDECL(int) VMMRZCallRing3NoCpu(PVM pVM, VMMCALLRING3 enmOperation, uint64_t uArg);
401VMMRZDECL(void) VMMRZCallRing3Disable(PVMCPU pVCpu);
402VMMRZDECL(void) VMMRZCallRing3Enable(PVMCPU pVCpu);
403VMMRZDECL(bool) VMMRZCallRing3IsEnabled(PVMCPU pVCpu);
404/** @} */
405#endif
406
407
408/** @} */
409RT_C_DECLS_END
410
411#endif
412
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