VirtualBox

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

Last change on this file since 7943 was 7416, checked in by vboxsync, 17 years ago

Added VMMR0_DO_HWACC_ENABLE

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