VirtualBox

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

Last change on this file since 90987 was 90982, checked in by vboxsync, 4 years ago

VMM: Removed VMMCALLRING3_VM_R0_PREEMPT. bugref:6695

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 23.9 KB
Line 
1/** @file
2 * VMM - The Virtual Machine Monitor.
3 */
4
5/*
6 * Copyright (C) 2006-2020 Oracle Corporation
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_INCLUDED_vmm_vmm_h
27#define VBOX_INCLUDED_vmm_vmm_h
28#ifndef RT_WITHOUT_PRAGMA_ONCE
29# pragma once
30#endif
31
32#include <VBox/types.h>
33#include <VBox/vmm/vmapi.h>
34#include <VBox/sup.h>
35#include <VBox/log.h>
36#include <iprt/stdarg.h>
37#include <iprt/thread.h>
38
39RT_C_DECLS_BEGIN
40
41/** @defgroup grp_vmm The Virtual Machine Monitor
42 * @{
43 */
44
45/** @defgroup grp_vmm_api The Virtual Machine Monitor API
46 * @{
47 */
48
49
50/**
51 * VMMRZCallRing3 operations.
52 */
53typedef enum VMMCALLRING3
54{
55 /** Invalid operation. */
56 VMMCALLRING3_INVALID = 0,
57 /** Signal a ring 0 assertion. */
58 VMMCALLRING3_VM_R0_ASSERTION,
59 /** Set the VM error message. */
60 VMMCALLRING3_VM_SET_ERROR,
61 /** Set the VM runtime error message. */
62 VMMCALLRING3_VM_SET_RUNTIME_ERROR,
63 /** Grow the PGM shadow page pool. */
64 VMMCALLRING3_PGM_POOL_GROW,
65 /** Maps a chunk into ring-3. */
66 VMMCALLRING3_PGM_MAP_CHUNK,
67 /** Allocates more handy pages. */
68 VMMCALLRING3_PGM_ALLOCATE_HANDY_PAGES,
69 /** Allocates a large (2MB) page. */
70 VMMCALLRING3_PGM_ALLOCATE_LARGE_HANDY_PAGE,
71 /** Acquire the PGM lock. */
72 VMMCALLRING3_PGM_LOCK,
73 /** Acquire the MM hypervisor heap lock. */
74 VMMCALLRING3_MMHYPER_LOCK,
75 /** The usual 32-bit hack. */
76 VMMCALLRING3_32BIT_HACK = 0x7fffffff
77} VMMCALLRING3;
78
79/**
80 * VMMRZCallRing3 notification callback.
81 *
82 * @returns VBox status code.
83 * @param pVCpu The cross context virtual CPU structure.
84 * @param enmOperation The operation causing the ring-3 jump.
85 * @param pvUser The user argument.
86 */
87typedef DECLCALLBACKTYPE(int, FNVMMR0CALLRING3NOTIFICATION,(PVMCPUCC pVCpu, VMMCALLRING3 enmOperation, void *pvUser));
88/** Pointer to a FNRTMPNOTIFICATION(). */
89typedef FNVMMR0CALLRING3NOTIFICATION *PFNVMMR0CALLRING3NOTIFICATION;
90
91/**
92 * Rendezvous callback.
93 *
94 * @returns VBox strict status code - EM scheduling. Do not return
95 * informational status code other than the ones used by EM for
96 * scheduling.
97 *
98 * @param pVM The cross context VM structure.
99 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
100 * @param pvUser The user argument.
101 */
102typedef DECLCALLBACKTYPE(VBOXSTRICTRC, FNVMMEMTRENDEZVOUS,(PVM pVM, PVMCPU pVCpu, void *pvUser));
103/** Pointer to a rendezvous callback function. */
104typedef FNVMMEMTRENDEZVOUS *PFNVMMEMTRENDEZVOUS;
105
106/**
107 * Method table that the VMM uses to call back the user of the VMM.
108 */
109typedef struct VMM2USERMETHODS
110{
111 /** Magic value (VMM2USERMETHODS_MAGIC). */
112 uint32_t u32Magic;
113 /** Structure version (VMM2USERMETHODS_VERSION). */
114 uint32_t u32Version;
115
116 /**
117 * Save the VM state.
118 *
119 * @returns VBox status code.
120 * @param pThis Pointer to the callback method table.
121 * @param pUVM The user mode VM handle.
122 *
123 * @remarks This member shall be set to NULL if the operation is not
124 * supported.
125 */
126 DECLR3CALLBACKMEMBER(int, pfnSaveState,(PCVMM2USERMETHODS pThis, PUVM pUVM));
127 /** @todo Move pfnVMAtError and pfnCFGMConstructor here? */
128
129 /**
130 * EMT initialization notification callback.
131 *
132 * This is intended for doing per-thread initialization for EMTs (like COM
133 * init).
134 *
135 * @param pThis Pointer to the callback method table.
136 * @param pUVM The user mode VM handle.
137 * @param pUVCpu The user mode virtual CPU handle.
138 *
139 * @remarks This is optional and shall be set to NULL if not wanted.
140 */
141 DECLR3CALLBACKMEMBER(void, pfnNotifyEmtInit,(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu));
142
143 /**
144 * EMT termination notification callback.
145 *
146 * This is intended for doing per-thread cleanups for EMTs (like COM).
147 *
148 * @param pThis Pointer to the callback method table.
149 * @param pUVM The user mode VM handle.
150 * @param pUVCpu The user mode virtual CPU handle.
151 *
152 * @remarks This is optional and shall be set to NULL if not wanted.
153 */
154 DECLR3CALLBACKMEMBER(void, pfnNotifyEmtTerm,(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu));
155
156 /**
157 * PDM thread initialization notification callback.
158 *
159 * This is intended for doing per-thread initialization (like COM init).
160 *
161 * @param pThis Pointer to the callback method table.
162 * @param pUVM The user mode VM handle.
163 *
164 * @remarks This is optional and shall be set to NULL if not wanted.
165 */
166 DECLR3CALLBACKMEMBER(void, pfnNotifyPdmtInit,(PCVMM2USERMETHODS pThis, PUVM pUVM));
167
168 /**
169 * EMT termination notification callback.
170 *
171 * This is intended for doing per-thread cleanups for EMTs (like COM).
172 *
173 * @param pThis Pointer to the callback method table.
174 * @param pUVM The user mode VM handle.
175 *
176 * @remarks This is optional and shall be set to NULL if not wanted.
177 */
178 DECLR3CALLBACKMEMBER(void, pfnNotifyPdmtTerm,(PCVMM2USERMETHODS pThis, PUVM pUVM));
179
180 /**
181 * Notification callback that that a VM reset will be turned into a power off.
182 *
183 * @param pThis Pointer to the callback method table.
184 * @param pUVM The user mode VM handle.
185 *
186 * @remarks This is optional and shall be set to NULL if not wanted.
187 */
188 DECLR3CALLBACKMEMBER(void, pfnNotifyResetTurnedIntoPowerOff,(PCVMM2USERMETHODS pThis, PUVM pUVM));
189
190 /**
191 * Generic object query by UUID.
192 *
193 * @returns pointer to queried the object on success, NULL if not found.
194 *
195 * @param pThis Pointer to the callback method table.
196 * @param pUVM The user mode VM handle.
197 * @param pUuid The UUID of what's being queried. The UUIDs and the
198 * usage conventions are defined by the user.
199 *
200 * @remarks This is optional and shall be set to NULL if not wanted.
201 */
202 DECLR3CALLBACKMEMBER(void *, pfnQueryGenericObject,(PCVMM2USERMETHODS pThis, PUVM pUVM, PCRTUUID pUuid));
203
204 /** Magic value (VMM2USERMETHODS_MAGIC) marking the end of the structure. */
205 uint32_t u32EndMagic;
206} VMM2USERMETHODS;
207
208/** Magic value of the VMM2USERMETHODS (Franz Kafka). */
209#define VMM2USERMETHODS_MAGIC UINT32_C(0x18830703)
210/** The VMM2USERMETHODS structure version. */
211#define VMM2USERMETHODS_VERSION UINT32_C(0x00030000)
212
213
214/**
215 * Checks whether we've armed the ring-0 long jump machinery.
216 *
217 * @returns @c true / @c false
218 * @param a_pVCpu The caller's cross context virtual CPU structure.
219 * @thread EMT
220 * @sa VMMR0IsLongJumpArmed
221 */
222#ifdef IN_RING0
223# define VMMIsLongJumpArmed(a_pVCpu) VMMR0IsLongJumpArmed(a_pVCpu)
224#else
225# define VMMIsLongJumpArmed(a_pVCpu) (false)
226#endif
227
228
229VMMDECL(VMCPUID) VMMGetCpuId(PVMCC pVM);
230VMMDECL(PVMCPUCC) VMMGetCpu(PVMCC pVM);
231VMMDECL(PVMCPUCC) VMMGetCpu0(PVMCC pVM);
232VMMDECL(PVMCPUCC) VMMGetCpuById(PVMCC pVM, VMCPUID idCpu);
233VMMR3DECL(PVMCPUCC) VMMR3GetCpuByIdU(PUVM pVM, VMCPUID idCpu);
234VMM_INT_DECL(uint32_t) VMMGetSvnRev(void);
235VMM_INT_DECL(bool) VMMIsInRing3Call(PVMCPUCC pVCpu);
236VMM_INT_DECL(void) VMMTrashVolatileXMMRegs(void);
237
238
239/** @defgroup grp_vmm_api_r0 The VMM Host Context Ring 0 API
240 * @{
241 */
242
243/**
244 * The VMMR0Entry() codes.
245 */
246typedef enum VMMR0OPERATION
247{
248 /** Run guest code using the available hardware acceleration technology. */
249 VMMR0_DO_HM_RUN = SUP_VMMR0_DO_HM_RUN,
250 /** Official NOP that we use for profiling. */
251 VMMR0_DO_NEM_RUN = SUP_VMMR0_DO_NEM_RUN,
252 /** Official NOP that we use for profiling. */
253 VMMR0_DO_NOP = SUP_VMMR0_DO_NOP,
254 /** Official slow iocl NOP that we use for profiling. */
255 VMMR0_DO_SLOW_NOP,
256
257 /** Ask the GVMM to create a new VM. */
258 VMMR0_DO_GVMM_CREATE_VM = 32,
259 /** Ask the GVMM to destroy the VM. */
260 VMMR0_DO_GVMM_DESTROY_VM,
261 /** Call GVMMR0RegisterVCpu(). */
262 VMMR0_DO_GVMM_REGISTER_VMCPU,
263 /** Call GVMMR0DeregisterVCpu(). */
264 VMMR0_DO_GVMM_DEREGISTER_VMCPU,
265 /** Call GVMMR0SchedHalt(). */
266 VMMR0_DO_GVMM_SCHED_HALT,
267 /** Call GVMMR0SchedWakeUp(). */
268 VMMR0_DO_GVMM_SCHED_WAKE_UP,
269 /** Call GVMMR0SchedPoke(). */
270 VMMR0_DO_GVMM_SCHED_POKE,
271 /** Call GVMMR0SchedWakeUpAndPokeCpus(). */
272 VMMR0_DO_GVMM_SCHED_WAKE_UP_AND_POKE_CPUS,
273 /** Call GVMMR0SchedPoll(). */
274 VMMR0_DO_GVMM_SCHED_POLL,
275 /** Call GVMMR0QueryStatistics(). */
276 VMMR0_DO_GVMM_QUERY_STATISTICS,
277 /** Call GVMMR0ResetStatistics(). */
278 VMMR0_DO_GVMM_RESET_STATISTICS,
279
280 /** Call VMMR0 Per VM Init. */
281 VMMR0_DO_VMMR0_INIT = 64,
282 /** Call VMMR0 Per VM EMT Init */
283 VMMR0_DO_VMMR0_INIT_EMT,
284 /** Call VMMR0 Per VM Termination. */
285 VMMR0_DO_VMMR0_TERM,
286 /** Copy logger settings from userland, VMMR0UpdateLoggersReq(). */
287 VMMR0_DO_VMMR0_UPDATE_LOGGERS,
288 /** Used by the log flusher, VMMR0LogFlusher. */
289 VMMR0_DO_VMMR0_LOG_FLUSHER,
290 /** Used by EMTs to wait for the log flusher to finish, VMMR0LogWaitFlushed. */
291 VMMR0_DO_VMMR0_LOG_WAIT_FLUSHED,
292
293 /** Setup hardware-assisted VM session. */
294 VMMR0_DO_HM_SETUP_VM = 128,
295 /** Attempt to enable or disable hardware-assisted mode. */
296 VMMR0_DO_HM_ENABLE,
297
298 /** Call PGMR0PhysAllocateHandyPages(). */
299 VMMR0_DO_PGM_ALLOCATE_HANDY_PAGES = 192,
300 /** Call PGMR0PhysFlushHandyPages(). */
301 VMMR0_DO_PGM_FLUSH_HANDY_PAGES,
302 /** Call PGMR0AllocateLargePage(). */
303 VMMR0_DO_PGM_ALLOCATE_LARGE_HANDY_PAGE,
304 /** Call PGMR0PhysSetupIommu(). */
305 VMMR0_DO_PGM_PHYS_SETUP_IOMMU,
306 /** Call PGMR0PoolGrow(). */
307 VMMR0_DO_PGM_POOL_GROW,
308
309 /** Call GMMR0InitialReservation(). */
310 VMMR0_DO_GMM_INITIAL_RESERVATION = 256,
311 /** Call GMMR0UpdateReservation(). */
312 VMMR0_DO_GMM_UPDATE_RESERVATION,
313 /** Call GMMR0AllocatePages(). */
314 VMMR0_DO_GMM_ALLOCATE_PAGES,
315 /** Call GMMR0FreePages(). */
316 VMMR0_DO_GMM_FREE_PAGES,
317 /** Call GMMR0FreeLargePage(). */
318 VMMR0_DO_GMM_FREE_LARGE_PAGE,
319 /** Call GMMR0QueryHypervisorMemoryStatsReq(). */
320 VMMR0_DO_GMM_QUERY_HYPERVISOR_MEM_STATS,
321 /** Call GMMR0QueryMemoryStatsReq(). */
322 VMMR0_DO_GMM_QUERY_MEM_STATS,
323 /** Call GMMR0BalloonedPages(). */
324 VMMR0_DO_GMM_BALLOONED_PAGES,
325 /** Call GMMR0MapUnmapChunk(). */
326 VMMR0_DO_GMM_MAP_UNMAP_CHUNK,
327 /** Call GMMR0SeedChunk(). */
328 VMMR0_DO_GMM_SEED_CHUNK,
329 /** Call GMMR0RegisterSharedModule. */
330 VMMR0_DO_GMM_REGISTER_SHARED_MODULE,
331 /** Call GMMR0UnregisterSharedModule. */
332 VMMR0_DO_GMM_UNREGISTER_SHARED_MODULE,
333 /** Call GMMR0ResetSharedModules. */
334 VMMR0_DO_GMM_RESET_SHARED_MODULES,
335 /** Call GMMR0CheckSharedModules. */
336 VMMR0_DO_GMM_CHECK_SHARED_MODULES,
337 /** Call GMMR0FindDuplicatePage. */
338 VMMR0_DO_GMM_FIND_DUPLICATE_PAGE,
339 /** Call GMMR0QueryStatistics(). */
340 VMMR0_DO_GMM_QUERY_STATISTICS,
341 /** Call GMMR0ResetStatistics(). */
342 VMMR0_DO_GMM_RESET_STATISTICS,
343
344 /** Call PDMR0DriverCallReqHandler. */
345 VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER = 320,
346 /** Call PDMR0DeviceCreateReqHandler. */
347 VMMR0_DO_PDM_DEVICE_CREATE,
348 /** Call PDMR0DeviceGenCallReqHandler. */
349 VMMR0_DO_PDM_DEVICE_GEN_CALL,
350 /** Old style device compat: Set ring-0 critical section. */
351 VMMR0_DO_PDM_DEVICE_COMPAT_SET_CRITSECT,
352
353 /** Set a GVMM or GMM configuration value. */
354 VMMR0_DO_GCFGM_SET_VALUE = 400,
355 /** Query a GVMM or GMM configuration value. */
356 VMMR0_DO_GCFGM_QUERY_VALUE,
357
358 /** The start of the R0 service operations. */
359 VMMR0_DO_SRV_START = 448,
360 /** Call IntNetR0Open(). */
361 VMMR0_DO_INTNET_OPEN,
362 /** Call IntNetR0IfClose(). */
363 VMMR0_DO_INTNET_IF_CLOSE,
364 /** Call IntNetR0IfGetBufferPtrs(). */
365 VMMR0_DO_INTNET_IF_GET_BUFFER_PTRS,
366 /** Call IntNetR0IfSetPromiscuousMode(). */
367 VMMR0_DO_INTNET_IF_SET_PROMISCUOUS_MODE,
368 /** Call IntNetR0IfSetMacAddress(). */
369 VMMR0_DO_INTNET_IF_SET_MAC_ADDRESS,
370 /** Call IntNetR0IfSetActive(). */
371 VMMR0_DO_INTNET_IF_SET_ACTIVE,
372 /** Call IntNetR0IfSend(). */
373 VMMR0_DO_INTNET_IF_SEND,
374 /** Call IntNetR0IfWait(). */
375 VMMR0_DO_INTNET_IF_WAIT,
376 /** Call IntNetR0IfAbortWait(). */
377 VMMR0_DO_INTNET_IF_ABORT_WAIT,
378
379#if 0
380 /** Forward call to the PCI driver */
381 VMMR0_DO_PCIRAW_REQ = 512,
382#endif
383
384 /** The end of the R0 service operations. */
385 VMMR0_DO_SRV_END,
386
387 /** Call NEMR0InitVM() (host specific). */
388 VMMR0_DO_NEM_INIT_VM = 576,
389 /** Call NEMR0InitVMPart2() (host specific). */
390 VMMR0_DO_NEM_INIT_VM_PART_2,
391 /** Call NEMR0MapPages() (host specific). */
392 VMMR0_DO_NEM_MAP_PAGES,
393 /** Call NEMR0UnmapPages() (host specific). */
394 VMMR0_DO_NEM_UNMAP_PAGES,
395 /** Call NEMR0ExportState() (host specific). */
396 VMMR0_DO_NEM_EXPORT_STATE,
397 /** Call NEMR0ImportState() (host specific). */
398 VMMR0_DO_NEM_IMPORT_STATE,
399 /** Call NEMR0QueryCpuTick() (host specific). */
400 VMMR0_DO_NEM_QUERY_CPU_TICK,
401 /** Call NEMR0ResumeCpuTickOnAll() (host specific). */
402 VMMR0_DO_NEM_RESUME_CPU_TICK_ON_ALL,
403 /** Call NEMR0UpdateStatistics() (host specific). */
404 VMMR0_DO_NEM_UPDATE_STATISTICS,
405 /** Call NEMR0DoExperiment() (host specific, experimental, debug only). */
406 VMMR0_DO_NEM_EXPERIMENT,
407
408 /** Grow the I/O port registration tables. */
409 VMMR0_DO_IOM_GROW_IO_PORTS = 640,
410 /** Grow the I/O port statistics tables. */
411 VMMR0_DO_IOM_GROW_IO_PORT_STATS,
412 /** Grow the MMIO registration tables. */
413 VMMR0_DO_IOM_GROW_MMIO_REGS,
414 /** Grow the MMIO statistics tables. */
415 VMMR0_DO_IOM_GROW_MMIO_STATS,
416 /** Synchronize statistics indices for I/O ports and MMIO regions. */
417 VMMR0_DO_IOM_SYNC_STATS_INDICES,
418
419 /** Call DBGFR0TraceCreateReqHandler. */
420 VMMR0_DO_DBGF_TRACER_CREATE = 704,
421 /** Call DBGFR0TraceCallReqHandler. */
422 VMMR0_DO_DBGF_TRACER_CALL_REQ_HANDLER,
423 /** Call DBGFR0BpInitReqHandler(). */
424 VMMR0_DO_DBGF_BP_INIT,
425 /** Call DBGFR0BpChunkAllocReqHandler(). */
426 VMMR0_DO_DBGF_BP_CHUNK_ALLOC,
427 /** Call DBGFR0BpL2TblChunkAllocReqHandler(). */
428 VMMR0_DO_DBGF_BP_L2_TBL_CHUNK_ALLOC,
429 /** Call DBGFR0BpOwnerInitReqHandler(). */
430 VMMR0_DO_DBGF_BP_OWNER_INIT,
431 /** Call DBGFR0BpPortIoInitReqHandler(). */
432 VMMR0_DO_DBGF_BP_PORTIO_INIT,
433
434 /** Grow a timer queue. */
435 VMMR0_DO_TM_GROW_TIMER_QUEUE = 768,
436
437 /** Official call we use for testing Ring-0 APIs. */
438 VMMR0_DO_TESTS = 2048,
439
440 /** The usual 32-bit type blow up. */
441 VMMR0_DO_32BIT_HACK = 0x7fffffff
442} VMMR0OPERATION;
443
444
445/**
446 * Request buffer for VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE.
447 * @todo Move got GCFGM.h when it's implemented.
448 */
449typedef struct GCFGMVALUEREQ
450{
451 /** The request header.*/
452 SUPVMMR0REQHDR Hdr;
453 /** The support driver session handle. */
454 PSUPDRVSESSION pSession;
455 /** The value.
456 * This is input for the set request and output for the query. */
457 uint64_t u64Value;
458 /** The variable name.
459 * This is fixed sized just to make things simple for the mock-up. */
460 char szName[48];
461} GCFGMVALUEREQ;
462/** Pointer to a VMMR0_DO_GCFGM_SET_VALUE and VMMR0_DO_GCFGM_QUERY_VALUE request buffer.
463 * @todo Move got GCFGM.h when it's implemented.
464 */
465typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
466
467
468/**
469 * Request package for VMMR0_DO_VMMR0_UPDATE_LOGGERS.
470 *
471 * In addition the u64Arg selects the logger sets: @c false for debug, @c true
472 * for release.
473 */
474typedef struct VMMR0UPDATELOGGERSREQ
475{
476 /** The request header. */
477 SUPVMMR0REQHDR Hdr;
478 /** The current logger flags (RTLOGFLAGS). */
479 uint64_t fFlags;
480 /** Groups, assuming same group layout as ring-3. */
481 uint32_t cGroups;
482 /** CRC32 of the group names. */
483 uint32_t uGroupCrc32;
484 /** Per-group settings, variable size. */
485 RT_FLEXIBLE_ARRAY_EXTENSION
486 uint32_t afGroups[RT_FLEXIBLE_ARRAY];
487} VMMR0UPDATELOGGERSREQ;
488/** Pointer to a VMMR0_DO_VMMR0_UPDATE_LOGGERS request. */
489typedef VMMR0UPDATELOGGERSREQ *PVMMR0UPDATELOGGERSREQ;
490
491#if defined(IN_RING0) || defined(DOXYGEN_RUNNING)
492
493/**
494 * Structure VMMR0EmtPrepareToBlock uses to pass info to
495 * VMMR0EmtResumeAfterBlocking.
496 */
497typedef struct VMMR0EMTBLOCKCTX
498{
499 /** Magic value (VMMR0EMTBLOCKCTX_MAGIC). */
500 uint32_t uMagic;
501 /** Set if we were in HM context, clear if not. */
502 bool fWasInHmContext;
503} VMMR0EMTBLOCKCTX;
504/** Pointer to a VMMR0EmtPrepareToBlock context structure. */
505typedef VMMR0EMTBLOCKCTX *PVMMR0EMTBLOCKCTX;
506/** Magic value for VMMR0EMTBLOCKCTX::uMagic (Paul Desmond). */
507#define VMMR0EMTBLOCKCTX_MAGIC UINT32_C(0x19261125)
508/** Magic value for VMMR0EMTBLOCKCTX::uMagic when its out of context. */
509#define VMMR0EMTBLOCKCTX_MAGIC_DEAD UINT32_C(0x19770530)
510
511VMMR0DECL(void) VMMR0EntryFast(PGVM pGVM, PVMCC pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation);
512VMMR0DECL(int) VMMR0EntryEx(PGVM pGVM, PVMCC pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation,
513 PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION);
514VMMR0_INT_DECL(int) VMMR0InitPerVMData(PGVM pGVM);
515VMMR0_INT_DECL(int) VMMR0TermVM(PGVM pGVM, VMCPUID idCpu);
516VMMR0_INT_DECL(void) VMMR0CleanupVM(PGVM pGVM);
517VMMR0_INT_DECL(bool) VMMR0IsLongJumpArmed(PVMCPUCC pVCpu);
518VMMR0_INT_DECL(bool) VMMR0IsInRing3LongJump(PVMCPUCC pVCpu);
519VMMR0_INT_DECL(int) VMMR0ThreadCtxHookCreateForEmt(PVMCPUCC pVCpu);
520VMMR0_INT_DECL(void) VMMR0ThreadCtxHookDestroyForEmt(PVMCPUCC pVCpu);
521VMMR0_INT_DECL(void) VMMR0ThreadCtxHookDisable(PVMCPUCC pVCpu);
522VMMR0_INT_DECL(bool) VMMR0ThreadCtxHookIsEnabled(PVMCPUCC pVCpu);
523VMMR0_INT_DECL(int) VMMR0EmtPrepareToBlock(PVMCPUCC pVCpu, int rcBusy, const char *pszCaller, void *pvLock,
524 PVMMR0EMTBLOCKCTX pCtx);
525VMMR0_INT_DECL(void) VMMR0EmtResumeAfterBlocking(PVMCPUCC pVCpu, PVMMR0EMTBLOCKCTX pCtx);
526VMMR0_INT_DECL(PRTLOGGER) VMMR0GetReleaseLogger(PVMCPUCC pVCpu);
527#endif /* IN_RING0 */
528
529/** @} */
530
531
532#if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
533/** @defgroup grp_vmm_api_r3 The VMM Host Context Ring 3 API
534 * @{
535 */
536VMMR3_INT_DECL(int) VMMR3Init(PVM pVM);
537VMMR3_INT_DECL(int) VMMR3InitR0(PVM pVM);
538VMMR3_INT_DECL(int) VMMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
539VMMR3_INT_DECL(int) VMMR3Term(PVM pVM);
540VMMR3_INT_DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
541VMMR3_INT_DECL(int) VMMR3UpdateLoggers(PVM pVM);
542VMMR3DECL(const char *) VMMR3GetRZAssertMsg1(PVM pVM);
543VMMR3DECL(const char *) VMMR3GetRZAssertMsg2(PVM pVM);
544VMMR3_INT_DECL(int) VMMR3HmRunGC(PVM pVM, PVMCPU pVCpu);
545VMMR3DECL(int) VMMR3CallR0(PVM pVM, uint32_t uOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr);
546VMMR3_INT_DECL(int) VMMR3CallR0Emt(PVM pVM, PVMCPU pVCpu, VMMR0OPERATION enmOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr);
547VMMR3_INT_DECL(VBOXSTRICTRC) VMMR3CallR0EmtFast(PVM pVM, PVMCPU pVCpu, VMMR0OPERATION enmOperation);
548VMMR3DECL(void) VMMR3FatalDump(PVM pVM, PVMCPU pVCpu, int rcErr);
549VMMR3_INT_DECL(void) VMMR3YieldSuspend(PVM pVM);
550VMMR3_INT_DECL(void) VMMR3YieldStop(PVM pVM);
551VMMR3_INT_DECL(void) VMMR3YieldResume(PVM pVM);
552VMMR3_INT_DECL(void) VMMR3SendStartupIpi(PVM pVM, VMCPUID idCpu, uint32_t uVector);
553VMMR3_INT_DECL(void) VMMR3SendInitIpi(PVM pVM, VMCPUID idCpu);
554VMMR3DECL(int) VMMR3RegisterPatchMemory(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
555VMMR3DECL(int) VMMR3DeregisterPatchMemory(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
556VMMR3DECL(int) VMMR3EmtRendezvous(PVM pVM, uint32_t fFlags, PFNVMMEMTRENDEZVOUS pfnRendezvous, void *pvUser);
557/** @defgroup grp_VMMR3EmtRendezvous_fFlags VMMR3EmtRendezvous flags
558 * @{ */
559/** Execution type mask. */
560#define VMMEMTRENDEZVOUS_FLAGS_TYPE_MASK UINT32_C(0x00000007)
561/** Invalid execution type. */
562#define VMMEMTRENDEZVOUS_FLAGS_TYPE_INVALID UINT32_C(0)
563/** Let the EMTs execute the callback one by one (in no particular order).
564 * Recursion from within the callback possible. */
565#define VMMEMTRENDEZVOUS_FLAGS_TYPE_ONE_BY_ONE UINT32_C(1)
566/** Let all the EMTs execute the callback at the same time.
567 * Cannot recurse from the callback. */
568#define VMMEMTRENDEZVOUS_FLAGS_TYPE_ALL_AT_ONCE UINT32_C(2)
569/** Only execute the callback on one EMT (no particular one).
570 * Recursion from within the callback possible. */
571#define VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE UINT32_C(3)
572/** Let the EMTs execute the callback one by one in ascending order.
573 * Recursion from within the callback possible. */
574#define VMMEMTRENDEZVOUS_FLAGS_TYPE_ASCENDING UINT32_C(4)
575/** Let the EMTs execute the callback one by one in descending order.
576 * Recursion from within the callback possible. */
577#define VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING UINT32_C(5)
578/** Stop after the first error.
579 * This is not valid for any execution type where more than one EMT is active
580 * at a time. */
581#define VMMEMTRENDEZVOUS_FLAGS_STOP_ON_ERROR UINT32_C(0x00000008)
582/** Use VMREQFLAGS_PRIORITY when contacting the EMTs. */
583#define VMMEMTRENDEZVOUS_FLAGS_PRIORITY UINT32_C(0x00000010)
584/** The valid flags. */
585#define VMMEMTRENDEZVOUS_FLAGS_VALID_MASK UINT32_C(0x0000001f)
586/** @} */
587VMMR3_INT_DECL(int) VMMR3EmtRendezvousFF(PVM pVM, PVMCPU pVCpu);
588VMMR3_INT_DECL(void) VMMR3SetMayHaltInRing0(PVMCPU pVCpu, bool fMayHaltInRing0, uint32_t cNsSpinBlockThreshold);
589VMMR3_INT_DECL(int) VMMR3ReadR0Stack(PVM pVM, VMCPUID idCpu, RTHCUINTPTR R0Addr, void *pvBuf, size_t cbRead);
590VMMR3_INT_DECL(void) VMMR3InitR0StackUnwindState(PUVM pUVM, VMCPUID idCpu, PRTDBGUNWINDSTATE pState);
591/** @} */
592#endif /* IN_RING3 */
593
594
595#if defined(IN_RC) || defined(IN_RING0) || defined(DOXYGEN_RUNNING)
596/** @defgroup grp_vmm_api_rz The VMM Raw-Mode and Ring-0 Context API
597 * @{
598 */
599VMMRZDECL(int) VMMRZCallRing3(PVMCC pVMCC, PVMCPUCC pVCpu, VMMCALLRING3 enmOperation, uint64_t uArg);
600VMMRZDECL(int) VMMRZCallRing3NoCpu(PVMCC pVM, VMMCALLRING3 enmOperation, uint64_t uArg);
601VMMRZDECL(void) VMMRZCallRing3Disable(PVMCPUCC pVCpu);
602VMMRZDECL(void) VMMRZCallRing3Enable(PVMCPUCC pVCpu);
603VMMRZDECL(bool) VMMRZCallRing3IsEnabled(PVMCPUCC pVCpu);
604VMMRZDECL(int) VMMRZCallRing3SetNotification(PVMCPUCC pVCpu, R0PTRTYPE(PFNVMMR0CALLRING3NOTIFICATION) pfnCallback, RTR0PTR pvUser);
605VMMRZDECL(void) VMMRZCallRing3RemoveNotification(PVMCPUCC pVCpu);
606VMMRZDECL(bool) VMMRZCallRing3IsNotificationSet(PVMCPUCC pVCpu);
607/** @} */
608#endif
609
610
611/** Wrapper around AssertReleaseMsgReturn that avoid tripping up in the
612 * kernel when we don't have a setjmp in place. */
613#ifdef IN_RING0
614# define VMM_ASSERT_RELEASE_MSG_RETURN(a_pVM, a_Expr, a_Msg, a_rc) do { \
615 if (RT_LIKELY(a_Expr)) { /* likely */ } \
616 else \
617 { \
618 PVMCPUCC pVCpuAssert = VMMGetCpu(a_pVM); \
619 if (pVCpuAssert && VMMR0IsLongJumpArmed(pVCpuAssert)) \
620 AssertReleaseMsg(a_Expr, a_Msg); \
621 else \
622 AssertLogRelMsg(a_Expr, a_Msg); \
623 return (a_rc); \
624 } \
625 } while (0)
626#else
627# define VMM_ASSERT_RELEASE_MSG_RETURN(a_pVM, a_Expr, a_Msg, a_rc) AssertReleaseMsgReturn(a_Expr, a_Msg, a_rc)
628#endif
629
630/** @} */
631
632/** @} */
633RT_C_DECLS_END
634
635#endif /* !VBOX_INCLUDED_vmm_vmm_h */
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette