VirtualBox

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

Last change on this file since 104840 was 104840, checked in by vboxsync, 6 months ago

VMM/PGM: Refactored RAM ranges, MMIO2 ranges and ROM ranges and added MMIO ranges (to PGM) so we can safely access RAM ranges at runtime w/o fear of them ever being freed up. It is now only possible to create these during VM creation and loading, and they will live till VM destruction (except for MMIO2 which could be destroyed during loading (PCNet fun)). The lookup handling is by table instead of pointer tree. No more ring-0 pointers in shared data. bugref:10687 bugref:10093

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