VirtualBox

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

Last change on this file since 10518 was 10450, checked in by vboxsync, 16 years ago

Added VMMGetSvnRev() (exported) and changed VMMR0Init and VMMGCInit check the the revision is the same. (We've got private interface between ring-3 and ring-0 and GC, not to mention shared structures, so this check is really long overdue.)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 15.6 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 PAE shadow paging. */
65 VMMSWITCHER_AMD64_TO_PAE,
66 /** Switcher for AMD64 host paging to AMD64 shadow paging. */
67 VMMSWITCHER_AMD64_TO_AMD64,
68 /** Used to make a count for array declarations and suchlike. */
69 VMMSWITCHER_MAX,
70 /** The usual 32-bit paranoia. */
71 VMMSWITCHER_32BIT_HACK = 0x7fffffff
72} VMMSWITCHER;
73
74
75/**
76 * VMMGCCallHost operations.
77 */
78typedef enum VMMCALLHOST
79{
80 /** Invalid operation. */
81 VMMCALLHOST_INVALID = 0,
82 /** Acquire the PDM lock. */
83 VMMCALLHOST_PDM_LOCK,
84 /** Call PDMR3QueueFlushWorker. */
85 VMMCALLHOST_PDM_QUEUE_FLUSH,
86 /** Acquire the PGM lock. */
87 VMMCALLHOST_PGM_LOCK,
88 /** Grow the PGM shadow page pool. */
89 VMMCALLHOST_PGM_POOL_GROW,
90 /** Maps a chunk into ring-3. */
91 VMMCALLHOST_PGM_MAP_CHUNK,
92 /** Allocates more handy pages. */
93 VMMCALLHOST_PGM_ALLOCATE_HANDY_PAGES,
94#ifndef VBOX_WITH_NEW_PHYS_CODE
95 /** Dynamically allocate physical guest RAM. */
96 VMMCALLHOST_PGM_RAM_GROW_RANGE,
97#endif
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 hypervisor assertion. */
107 VMMCALLHOST_VM_R0_HYPER_ASSERTION,
108 /** The usual 32-bit hack. */
109 VMMCALLHOST_32BIT_HACK = 0x7fffffff
110} VMMCALLHOST;
111
112
113
114/**
115 * Gets the bottom of the hypervisor stack - GC Ptr.
116 * I.e. the returned address is not actually writable.
117 *
118 * @returns bottom of the stack.
119 * @param pVM The VM handle.
120 */
121RTGCPTR VMMGetStackGC(PVM pVM);
122
123/**
124 * Gets the bottom of the hypervisor stack - HC Ptr.
125 * I.e. the returned address is not actually writable.
126 *
127 * @returns bottom of the stack.
128 * @param pVM The VM handle.
129 */
130RTHCPTR VMMGetHCStack(PVM pVM);
131
132
133VMMDECL(uint32_t) VMMGetSvnRev(void);
134
135
136#ifdef IN_RING3
137/** @defgroup grp_vmm_r3 The VMM Host Context Ring 3 API
138 * @ingroup grp_vmm
139 * @{
140 */
141
142/**
143 * Initializes the VMM.
144 *
145 * @returns VBox status code.
146 * @param pVM The VM to operate on.
147 */
148VMMR3DECL(int) VMMR3Init(PVM pVM);
149
150/**
151 * Ring-3 init finalizing.
152 *
153 * @returns VBox status code.
154 * @param pVM The VM handle.
155 */
156VMMR3DECL(int) VMMR3InitFinalize(PVM pVM);
157
158/**
159 * Initializes the R0 VMM.
160 *
161 * @returns VBox status code.
162 * @param pVM The VM to operate on.
163 */
164VMMR3DECL(int) VMMR3InitR0(PVM pVM);
165
166/**
167 * Initializes the GC VMM.
168 *
169 * @returns VBox status code.
170 * @param pVM The VM to operate on.
171 */
172VMMR3DECL(int) VMMR3InitGC(PVM pVM);
173
174/**
175 * Destroy the VMM bits.
176 *
177 * @returns VINF_SUCCESS.
178 * @param pVM The VM handle.
179 */
180VMMR3DECL(int) VMMR3Term(PVM pVM);
181
182/**
183 * Applies relocations to data and code managed by this
184 * component. This function will be called at init and
185 * whenever the VMM need to relocate it self inside the GC.
186 *
187 * The VMM will need to apply relocations to the core code.
188 *
189 * @param pVM The VM handle.
190 * @param offDelta The relocation delta.
191 */
192VMMR3DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
193
194/**
195 * Updates the settings for the GC (and R0?) loggers.
196 *
197 * @returns VBox status code.
198 * @param pVM The VM handle.
199 */
200VMMR3DECL(int) VMMR3UpdateLoggers(PVM pVM);
201
202/**
203 * Gets the pointer to g_szRTAssertMsg1 in GC.
204 * @returns Pointer to VMMGC::g_szRTAssertMsg1.
205 * Returns NULL if not present.
206 * @param pVM The VM handle.
207 */
208VMMR3DECL(const char *) VMMR3GetGCAssertMsg1(PVM pVM);
209
210/**
211 * Gets the pointer to g_szRTAssertMsg2 in GC.
212 * @returns Pointer to VMMGC::g_szRTAssertMsg2.
213 * Returns NULL if not present.
214 * @param pVM The VM handle.
215 */
216VMMR3DECL(const char *) VMMR3GetGCAssertMsg2(PVM pVM);
217
218/**
219 * Resolve a builtin GC symbol.
220 * Called by PDM when loading or relocating GC modules.
221 *
222 * @returns VBox status.
223 * @param pVM VM Handle.
224 * @param pszSymbol Symbol to resolv
225 * @param pGCPtrValue Where to store the symbol value.
226 * @remark This has to work before VMMR3Relocate() is called.
227 */
228VMMR3DECL(int) VMMR3GetImportGC(PVM pVM, const char *pszSymbol, PRTGCPTR pGCPtrValue);
229
230/**
231 * Selects the switcher to be used for switching to GC.
232 *
233 * @returns VBox status code.
234 * @param pVM VM handle.
235 * @param enmSwitcher The new switcher.
236 * @remark This function may be called before the VMM is initialized.
237 */
238VMMR3DECL(int) VMMR3SelectSwitcher(PVM pVM, VMMSWITCHER enmSwitcher);
239
240/**
241 * Disable the switcher logic permanently.
242 *
243 * @returns VBox status code.
244 * @param pVM VM handle.
245 */
246VMMR3DECL(int) VMMR3DisableSwitcher(PVM pVM);
247
248/**
249 * Executes guest code.
250 *
251 * @param pVM VM handle.
252 */
253VMMR3DECL(int) VMMR3RawRunGC(PVM pVM);
254
255/**
256 * Executes guest code (Intel VMX and AMD SVM).
257 *
258 * @param pVM VM handle.
259 */
260VMMR3DECL(int) VMMR3HwAccRunGC(PVM pVM);
261
262/**
263 * Calls GC a function.
264 *
265 * @param pVM The VM handle.
266 * @param GCPtrEntry The GC function address.
267 * @param cArgs The number of arguments in the ....
268 * @param ... Arguments to the function.
269 */
270VMMR3DECL(int) VMMR3CallGC(PVM pVM, RTGCPTR GCPtrEntry, unsigned cArgs, ...);
271
272/**
273 * Calls GC a function.
274 *
275 * @param pVM The VM handle.
276 * @param GCPtrEntry The GC function address.
277 * @param cArgs The number of arguments in the ....
278 * @param args Arguments to the function.
279 */
280VMMR3DECL(int) VMMR3CallGCV(PVM pVM, RTGCPTR GCPtrEntry, unsigned cArgs, va_list args);
281
282/**
283 * Resumes executing hypervisor code when interrupted
284 * by a queue flush or a debug event.
285 *
286 * @returns VBox status code.
287 * @param pVM VM handle.
288 */
289VMMR3DECL(int) VMMR3ResumeHyper(PVM pVM);
290
291/**
292 * Dumps the VM state on a fatal error.
293 *
294 * @param pVM VM Handle.
295 * @param rcErr VBox status code.
296 */
297VMMR3DECL(void) VMMR3FatalDump(PVM pVM, int rcErr);
298
299/**
300 * Acquire global VM lock
301 *
302 * @returns VBox status code
303 * @param pVM The VM to operate on.
304 */
305VMMR3DECL(int) VMMR3Lock(PVM pVM);
306
307/**
308 * Release global VM lock
309 *
310 * @returns VBox status code
311 * @param pVM The VM to operate on.
312 */
313VMMR3DECL(int) VMMR3Unlock(PVM pVM);
314
315/**
316 * Return global VM lock owner
317 *
318 * @returns NIL_RTNATIVETHREAD -> no owner, otherwise thread id of owner
319 * @param pVM The VM to operate on.
320 */
321VMMR3DECL(RTNATIVETHREAD) VMMR3LockGetOwner(PVM pVM);
322
323/**
324 * Checks if the current thread is the owner of the global VM lock.
325 *
326 * @returns true if owner.
327 * @returns false if not owner.
328 * @param pVM The VM to operate on.
329 */
330VMMR3DECL(bool) VMMR3LockIsOwner(PVM pVM);
331
332/**
333 * Suspends the the CPU yielder.
334 *
335 * @param pVM The VM handle.
336 */
337VMMR3DECL(void) VMMR3YieldSuspend(PVM pVM);
338
339/**
340 * Stops the the CPU yielder.
341 *
342 * @param pVM The VM handle.
343 */
344VMMR3DECL(void) VMMR3YieldStop(PVM pVM);
345
346/**
347 * Resumes the CPU yielder when it has been a suspended or stopped.
348 *
349 * @param pVM The VM handle.
350 */
351VMMR3DECL(void) VMMR3YieldResume(PVM pVM);
352
353/** @} */
354#endif
355
356/** @defgroup grp_vmm_r0 The VMM Host Context Ring 0 API
357 * @ingroup grp_vmm
358 * @{
359 */
360
361/**
362 * The VMMR0Entry() codes.
363 */
364typedef enum VMMR0OPERATION
365{
366 /** Run guest context. */
367 VMMR0_DO_RAW_RUN = SUP_VMMR0_DO_RAW_RUN,
368 /** Run guest code using the available hardware acceleration technology. */
369 VMMR0_DO_HWACC_RUN = SUP_VMMR0_DO_HWACC_RUN,
370 /** Official NOP that we use for profiling. */
371 VMMR0_DO_NOP = SUP_VMMR0_DO_NOP,
372
373 /** Ask the GVMM to create a new VM. */
374 VMMR0_DO_GVMM_CREATE_VM,
375 /** Ask the GVMM to destroy the VM. */
376 VMMR0_DO_GVMM_DESTROY_VM,
377 /** Call GVMMR0SchedHalt(). */
378 VMMR0_DO_GVMM_SCHED_HALT,
379 /** Call GVMMR0SchedWakeUp(). */
380 VMMR0_DO_GVMM_SCHED_WAKE_UP,
381 /** Call GVMMR0SchedPoll(). */
382 VMMR0_DO_GVMM_SCHED_POLL,
383 /** Call GVMMR0QueryStatistics(). */
384 VMMR0_DO_GVMM_QUERY_STATISTICS,
385 /** Call GVMMR0ResetStatistics(). */
386 VMMR0_DO_GVMM_RESET_STATISTICS,
387
388 /** Call VMMR0 Per VM Init. */
389 VMMR0_DO_VMMR0_INIT,
390 /** Call VMMR0 Per VM Termination. */
391 VMMR0_DO_VMMR0_TERM,
392 /** Setup the hardware accelerated raw-mode session. */
393 VMMR0_DO_HWACC_SETUP_VM,
394 /** Attempt to enable or disable hardware accelerated raw-mode. */
395 VMMR0_DO_HWACC_ENABLE,
396 /** Calls function in the hypervisor.
397 * The caller must setup the hypervisor context so the call will be performed.
398 * The difference between VMMR0_DO_RUN_GC and this one is the handling of
399 * the return GC code. The return code will not be interpreted by this operation.
400 */
401 VMMR0_DO_CALL_HYPERVISOR,
402
403 /** Call PGMR0PhysAllocateHandyPages(). */
404 VMMR0_DO_PGM_ALLOCATE_HANDY_PAGES,
405
406 /** Call GMMR0InitialReservation(). */
407 VMMR0_DO_GMM_INITIAL_RESERVATION,
408 /** Call GMMR0UpdateReservation(). */
409 VMMR0_DO_GMM_UPDATE_RESERVATION,
410 /** Call GMMR0AllocatePages(). */
411 VMMR0_DO_GMM_ALLOCATE_PAGES,
412 /** Call GMMR0FreePages(). */
413 VMMR0_DO_GMM_FREE_PAGES,
414 /** Call GMMR0BalloonedPages(). */
415 VMMR0_DO_GMM_BALLOONED_PAGES,
416 /** Call GMMR0DeflatedBalloon(). */
417 VMMR0_DO_GMM_DEFLATED_BALLOON,
418 /** Call GMMR0MapUnmapChunk(). */
419 VMMR0_DO_GMM_MAP_UNMAP_CHUNK,
420 /** Call GMMR0SeedChunk(). */
421 VMMR0_DO_GMM_SEED_CHUNK,
422
423 /** Set a GVMM or GMM configuration value. */
424 VMMR0_DO_GCFGM_SET_VALUE,
425 /** Query a GVMM or GMM configuration value. */
426 VMMR0_DO_GCFGM_QUERY_VALUE,
427
428 /** The start of the R0 service operations. */
429 VMMR0_DO_SRV_START,
430 /** Call INTNETR0Open(). */
431 VMMR0_DO_INTNET_OPEN,
432 /** Call INTNETR0IfClose(). */
433 VMMR0_DO_INTNET_IF_CLOSE,
434 /** Call INTNETR0IfGetRing3Buffer(). */
435 VMMR0_DO_INTNET_IF_GET_RING3_BUFFER,
436 /** Call INTNETR0IfSetPromiscuousMode(). */
437 VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE,
438 /** Call INTNETR0IfSend(). */
439 VMMR0_DO_INTNET_IF_SEND,
440 /** Call INTNETR0IfWait(). */
441 VMMR0_DO_INTNET_IF_WAIT,
442 /** The end of the R0 service operations. */
443 VMMR0_DO_SRV_END,
444
445 /** Official call we use for testing Ring-0 APIs. */
446 VMMR0_DO_TESTS,
447
448 /** The usual 32-bit type blow up. */
449 VMMR0_DO_32BIT_HACK = 0x7fffffff
450} VMMR0OPERATION;
451
452
453/**
454 * Request buffer for VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE.
455 * @todo Move got GCFGM.h when it's implemented.
456 */
457typedef struct GCFGMVALUEREQ
458{
459 /** The request header.*/
460 SUPVMMR0REQHDR Hdr;
461 /** The support driver session handle. */
462 PSUPDRVSESSION pSession;
463 /** The value.
464 * This is input for the set request and output for the query. */
465 uint64_t u64Value;
466 /** The variable name.
467 * This is fixed sized just to make things simple for the mock-up. */
468 char szName[48];
469} GCFGMVALUEREQ;
470/** Pointer to a VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE request buffer.
471 * @todo Move got GCFGM.h when it's implemented.
472 */
473typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
474
475
476/**
477 * The Ring 0 entry point, called by the interrupt gate.
478 *
479 * @returns VBox status code.
480 * @param pVM The VM to operate on.
481 * @param enmOperation Which operation to execute.
482 * @param pvArg Argument to the operation.
483 * @remarks Assume called with interrupts disabled.
484 */
485VMMR0DECL(int) VMMR0EntryInt(PVM pVM, VMMR0OPERATION enmOperation, void *pvArg);
486
487/**
488 * The Ring 0 entry point, called by the fast-ioctl path.
489 *
490 * @returns VBox status code.
491 * @param pVM The VM to operate on.
492 * @param enmOperation Which operation to execute.
493 * @remarks Assume called with interrupts _enabled_.
494 */
495VMMR0DECL(int) VMMR0EntryFast(PVM pVM, VMMR0OPERATION enmOperation);
496
497/**
498 * The Ring 0 entry point, called by the support library (SUP).
499 *
500 * @returns VBox status code.
501 * @param pVM The VM to operate on.
502 * @param enmOperation Which operation to execute.
503 * @param pReq This points to a SUPVMMR0REQHDR packet. Optional.
504 * @param u64Arg Some simple constant argument.
505 * @remarks Assume called with interrupts _enabled_.
506 */
507VMMR0DECL(int) VMMR0EntryEx(PVM pVM, VMMR0OPERATION enmOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg);
508
509/**
510 * Calls the ring-3 host code.
511 *
512 * @returns VBox status code of the ring-3 call.
513 * @param pVM The VM handle.
514 * @param enmOperation The operation.
515 * @param uArg The argument to the operation.
516 */
517VMMR0DECL(int) VMMR0CallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
518
519/** @} */
520
521
522#ifdef IN_GC
523/** @defgroup grp_vmm_gc The VMM Guest Context API
524 * @ingroup grp_vmm
525 * @{
526 */
527
528/**
529 * The GC entry point.
530 *
531 * @returns VBox status code.
532 * @param pVM The VM to operate on.
533 * @param uOperation Which operation to execute (VMMGCOPERATION).
534 * @param uArg Argument to that operation.
535 * @param ... Additional arguments.
536 */
537VMMGCDECL(int) VMMGCEntry(PVM pVM, unsigned uOperation, unsigned uArg, ...);
538
539/**
540 * Switches from guest context to host context.
541 *
542 * @param pVM The VM handle.
543 * @param rc The status code.
544 */
545VMMGCDECL(void) VMMGCGuestToHost(PVM pVM, int rc);
546
547/**
548 * Calls the ring-3 host code.
549 *
550 * @returns VBox status code of the ring-3 call.
551 * @param pVM The VM handle.
552 * @param enmOperation The operation.
553 * @param uArg The argument to the operation.
554 */
555VMMGCDECL(int) VMMGCCallHost(PVM pVM, VMMCALLHOST enmOperation, uint64_t uArg);
556
557/** @} */
558#endif
559
560
561/** @} */
562__END_DECLS
563
564
565#endif
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