VirtualBox

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

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

Protect the MM hypervisor heap with a critical section.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.1 KB
Line 
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 */
48typedef 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 */
80typedef 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 /** Acquire the MM hypervisor heap lock. */
97 VMMCALLHOST_MMHYPER_LOCK,
98 /** Replay the REM handler notifications. */
99 VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS,
100 /** Flush the GC/R0 logger. */
101 VMMCALLHOST_VMM_LOGGER_FLUSH,
102 /** Set the VM error message. */
103 VMMCALLHOST_VM_SET_ERROR,
104 /** Set the VM runtime error message. */
105 VMMCALLHOST_VM_SET_RUNTIME_ERROR,
106 /** Signal a ring 0 assertion. */
107 VMMCALLHOST_VM_R0_ASSERTION,
108 /** Ring switch to force preemption. */
109 VMMCALLHOST_VM_R0_PREEMPT,
110 /** The usual 32-bit hack. */
111 VMMCALLHOST_32BIT_HACK = 0x7fffffff
112} VMMCALLHOST;
113
114/**
115 * VMMR3AtomicExecuteHandler callback function.
116 *
117 * @returns VBox status code.
118 * @param pVM Pointer to the shared VM structure.
119 * @param pvUser User specified argument
120 */
121typedef DECLCALLBACK(int) FNATOMICHANDLER(PVM pVM, void *pvUser);
122/** Pointer to a FNMMATOMICHANDLER(). */
123typedef FNATOMICHANDLER *PFNATOMICHANDLER;
124
125
126VMMDECL(RTRCPTR) VMMGetStackRC(PVM pVM);
127VMMDECL(VMCPUID) VMMGetCpuId(PVM pVM);
128VMMDECL(PVMCPU) VMMGetCpu(PVM pVM);
129VMMDECL(PVMCPU) VMMGetCpu0(PVM pVM);
130VMMDECL(PVMCPU) VMMGetCpuById(PVM pVM, VMCPUID idCpu);
131VMMDECL(uint32_t) VMMGetSvnRev(void);
132VMMDECL(VMMSWITCHER) VMMGetSwitcher(PVM pVM);
133
134/** @def VMMIsHwVirtExtForced
135 * Checks if forced to use the hardware assisted virtualization extensions.
136 *
137 * This is intended for making setup decisions where we can save resources when
138 * using hardware assisted virtualization.
139 *
140 * @returns true / false.
141 * @param pVM Pointer to the shared VM structure.
142 */
143#define VMMIsHwVirtExtForced(pVM) ((pVM)->fHwVirtExtForced)
144
145
146#ifdef IN_RING3
147/** @defgroup grp_vmm_r3 The VMM Host Context Ring 3 API
148 * @ingroup grp_vmm
149 * @{
150 */
151VMMR3DECL(int) VMMR3Init(PVM pVM);
152VMMR3DECL(int) VMMR3InitCPU(PVM pVM);
153VMMR3DECL(int) VMMR3InitFinalize(PVM pVM);
154VMMR3DECL(int) VMMR3InitR0(PVM pVM);
155VMMR3DECL(int) VMMR3InitRC(PVM pVM);
156VMMR3DECL(int) VMMR3Term(PVM pVM);
157VMMR3DECL(int) VMMR3TermCPU(PVM pVM);
158VMMR3DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
159VMMR3DECL(int) VMMR3UpdateLoggers(PVM pVM);
160VMMR3DECL(const char *) VMMR3GetRZAssertMsg1(PVM pVM);
161VMMR3DECL(const char *) VMMR3GetRZAssertMsg2(PVM pVM);
162VMMR3DECL(int) VMMR3GetImportRC(PVM pVM, const char *pszSymbol, PRTRCPTR pRCPtrValue);
163VMMR3DECL(int) VMMR3SelectSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
164VMMR3DECL(int) VMMR3DisableSwitcher(PVM pVM);
165VMMR3DECL(RTR0PTR) VMMR3GetHostToGuestSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
166VMMR3DECL(int) VMMR3RawRunGC(PVM pVM, PVMCPU pVCpu);
167VMMR3DECL(int) VMMR3HwAccRunGC(PVM pVM, PVMCPU pVCpu);
168VMMR3DECL(int) VMMR3CallRC(PVM pVM, RTRCPTR RCPtrEntry, unsigned cArgs, ...);
169VMMR3DECL(int) VMMR3CallRCV(PVM pVM, RTRCPTR RCPtrEntry, unsigned cArgs, va_list args);
170VMMR3DECL(int) VMMR3CallR0(PVM pVM, uint32_t uOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr);
171VMMR3DECL(int) VMMR3ResumeHyper(PVM pVM, PVMCPU pVCpu);
172VMMR3DECL(void) VMMR3FatalDump(PVM pVM, PVMCPU pVCpu, int rcErr);
173VMMR3DECL(void) VMMR3YieldSuspend(PVM pVM);
174VMMR3DECL(void) VMMR3YieldStop(PVM pVM);
175VMMR3DECL(void) VMMR3YieldResume(PVM pVM);
176VMMR3DECL(void) VMMR3SendSipi(PVM pVM, VMCPUID idCpu, uint32_t uVector);
177VMMR3DECL(void) VMMR3SendInitIpi(PVM pVM, VMCPUID idCpu);
178VMMR3DECL(int) VMMR3AtomicExecuteHandler(PVM pVM, PFNATOMICHANDLER pfnHandler, void *pvUser);
179VMMR3DECL(int) VMMR3ReadR0Stack(PVM pVM, VMCPUID idCpu, RTHCUINTPTR pAddress, void *pvBuf, size_t cbRead);
180/** @} */
181#endif /* IN_RING3 */
182
183
184/** @defgroup grp_vmm_r0 The VMM Host Context Ring 0 API
185 * @ingroup grp_vmm
186 * @{
187 */
188
189/**
190 * The VMMR0Entry() codes.
191 */
192typedef enum VMMR0OPERATION
193{
194 /** Run guest context. */
195 VMMR0_DO_RAW_RUN = SUP_VMMR0_DO_RAW_RUN,
196 /** Run guest code using the available hardware acceleration technology. */
197 VMMR0_DO_HWACC_RUN = SUP_VMMR0_DO_HWACC_RUN,
198 /** Official NOP that we use for profiling. */
199 VMMR0_DO_NOP = SUP_VMMR0_DO_NOP,
200 /** Official slow iocl NOP that we use for profiling. */
201 VMMR0_DO_SLOW_NOP,
202
203 /** Ask the GVMM to create a new VM. */
204 VMMR0_DO_GVMM_CREATE_VM,
205 /** Ask the GVMM to destroy the VM. */
206 VMMR0_DO_GVMM_DESTROY_VM,
207 /** Call GVMMR0SchedHalt(). */
208 VMMR0_DO_GVMM_SCHED_HALT,
209 /** Call GVMMR0SchedWakeUp(). */
210 VMMR0_DO_GVMM_SCHED_WAKE_UP,
211 /** Call GVMMR0SchedPoke(). */
212 VMMR0_DO_GVMM_SCHED_POKE,
213 /** Call GVMMR0SchedWakeUpAndPokeCpus(). */
214 VMMR0_DO_GVMM_SCHED_WAKE_UP_AND_POKE_CPUS,
215 /** Call GVMMR0SchedPoll(). */
216 VMMR0_DO_GVMM_SCHED_POLL,
217 /** Call GVMMR0QueryStatistics(). */
218 VMMR0_DO_GVMM_QUERY_STATISTICS,
219 /** Call GVMMR0ResetStatistics(). */
220 VMMR0_DO_GVMM_RESET_STATISTICS,
221 /** Call GVMMR0RegisterVCpu(). */
222 VMMR0_DO_GVMM_REGISTER_VMCPU,
223
224 /** Call VMMR0 Per VM Init. */
225 VMMR0_DO_VMMR0_INIT,
226 /** Call VMMR0 Per VM Termination. */
227 VMMR0_DO_VMMR0_TERM,
228 /** Setup the hardware accelerated raw-mode session. */
229 VMMR0_DO_HWACC_SETUP_VM,
230 /** Attempt to enable or disable hardware accelerated raw-mode. */
231 VMMR0_DO_HWACC_ENABLE,
232 /** Calls function in the hypervisor.
233 * The caller must setup the hypervisor context so the call will be performed.
234 * The difference between VMMR0_DO_RUN_GC and this one is the handling of
235 * the return GC code. The return code will not be interpreted by this operation.
236 */
237 VMMR0_DO_CALL_HYPERVISOR,
238
239 /** Call PGMR0PhysAllocateHandyPages(). */
240 VMMR0_DO_PGM_ALLOCATE_HANDY_PAGES,
241
242 /** Call GMMR0InitialReservation(). */
243 VMMR0_DO_GMM_INITIAL_RESERVATION,
244 /** Call GMMR0UpdateReservation(). */
245 VMMR0_DO_GMM_UPDATE_RESERVATION,
246 /** Call GMMR0AllocatePages(). */
247 VMMR0_DO_GMM_ALLOCATE_PAGES,
248 /** Call GMMR0FreePages(). */
249 VMMR0_DO_GMM_FREE_PAGES,
250 /** Call GMMR0BalloonedPages(). */
251 VMMR0_DO_GMM_BALLOONED_PAGES,
252 /** Call GMMR0DeflatedBalloon(). */
253 VMMR0_DO_GMM_DEFLATED_BALLOON,
254 /** Call GMMR0MapUnmapChunk(). */
255 VMMR0_DO_GMM_MAP_UNMAP_CHUNK,
256 /** Call GMMR0SeedChunk(). */
257 VMMR0_DO_GMM_SEED_CHUNK,
258
259 /** Set a GVMM or GMM configuration value. */
260 VMMR0_DO_GCFGM_SET_VALUE,
261 /** Query a GVMM or GMM configuration value. */
262 VMMR0_DO_GCFGM_QUERY_VALUE,
263
264 /** The start of the R0 service operations. */
265 VMMR0_DO_SRV_START,
266 /** Call INTNETR0Open(). */
267 VMMR0_DO_INTNET_OPEN,
268 /** Call INTNETR0IfClose(). */
269 VMMR0_DO_INTNET_IF_CLOSE,
270 /** Call INTNETR0IfGetRing3Buffer(). */
271 VMMR0_DO_INTNET_IF_GET_RING3_BUFFER,
272 /** Call INTNETR0IfSetPromiscuousMode(). */
273 VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE,
274 /** Call INTNETR0IfSetMacAddress(). */
275 VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
276 /** Call INTNETR0IfSetActive(). */
277 VMMR0_DO_INTNET_IF_SET_ACTIVE,
278 /** Call INTNETR0IfSend(). */
279 VMMR0_DO_INTNET_IF_SEND,
280 /** Call INTNETR0IfWait(). */
281 VMMR0_DO_INTNET_IF_WAIT,
282 /** The end of the R0 service operations. */
283 VMMR0_DO_SRV_END,
284
285 /** Official call we use for testing Ring-0 APIs. */
286 VMMR0_DO_TESTS,
287 /** Test the 32->64 bits switcher. */
288 VMMR0_DO_TEST_SWITCHER3264,
289
290 /** The usual 32-bit type blow up. */
291 VMMR0_DO_32BIT_HACK = 0x7fffffff
292} VMMR0OPERATION;
293
294
295/**
296 * Request buffer for VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE.
297 * @todo Move got GCFGM.h when it's implemented.
298 */
299typedef struct GCFGMVALUEREQ
300{
301 /** The request header.*/
302 SUPVMMR0REQHDR Hdr;
303 /** The support driver session handle. */
304 PSUPDRVSESSION pSession;
305 /** The value.
306 * This is input for the set request and output for the query. */
307 uint64_t u64Value;
308 /** The variable name.
309 * This is fixed sized just to make things simple for the mock-up. */
310 char szName[48];
311} GCFGMVALUEREQ;
312/** Pointer to a VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE request buffer.
313 * @todo Move got GCFGM.h when it's implemented.
314 */
315typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
316
317VMMR0DECL(int) VMMR0EntryInt(PVM pVM, VMMR0OPERATION enmOperation, void *pvArg);
318VMMR0DECL(void) VMMR0EntryFast(PVM pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation);
319VMMR0DECL(int) VMMR0EntryEx(PVM pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION);
320VMMR0DECL(int) VMMR0TermVM(PVM pVM, PGVM pGVM);
321VMMR0DECL(int) VMMR0CallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
322VMMR0DECL(void) VMMR0LogFlushDisable(PVMCPU pVCpu);
323VMMR0DECL(void) VMMR0LogFlushEnable(PVMCPU pVCpu);
324
325/** @} */
326
327
328#ifdef IN_RC
329/** @defgroup grp_vmm_rc The VMM Raw-Mode Context API
330 * @ingroup grp_vmm
331 * @{
332 */
333VMMRCDECL(int) VMMGCEntry(PVM pVM, unsigned uOperation, unsigned uArg, ...);
334VMMRCDECL(void) VMMGCGuestToHost(PVM pVM, int rc);
335VMMRCDECL(int) VMMGCCallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
336VMMRCDECL(bool) VMMGCLogDisable(PVM pVM);
337VMMRCDECL(void) VMMGCLogRestore(PVM pVM, bool fLog);
338VMMRCDECL(void) VMMGCLogFlushIfFull(PVM pVM);
339/** @} */
340#endif /* IN_RC */
341
342
343/** @} */
344__END_DECLS
345
346#endif
347
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