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 |
|
---|
39 | RT_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 | */
|
---|
53 | typedef enum VMMCALLRING3
|
---|
54 | {
|
---|
55 | /** Invalid operation. */
|
---|
56 | VMMCALLRING3_INVALID = 0,
|
---|
57 | /** Signal a ring 0 assertion. */
|
---|
58 | VMMCALLRING3_VM_R0_ASSERTION,
|
---|
59 |
|
---|
60 | /** Allocates more handy pages. */
|
---|
61 | VMMCALLRING3_PGM_ALLOCATE_HANDY_PAGES,
|
---|
62 | /** Allocates a large (2MB) page. */
|
---|
63 | VMMCALLRING3_PGM_ALLOCATE_LARGE_HANDY_PAGE,
|
---|
64 | /** The usual 32-bit hack. */
|
---|
65 | VMMCALLRING3_32BIT_HACK = 0x7fffffff
|
---|
66 | } VMMCALLRING3;
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * VMMRZCallRing3 notification callback.
|
---|
70 | *
|
---|
71 | * @returns VBox status code.
|
---|
72 | * @param pVCpu The cross context virtual CPU structure.
|
---|
73 | * @param enmOperation The operation causing the ring-3 jump.
|
---|
74 | * @param pvUser The user argument.
|
---|
75 | */
|
---|
76 | typedef DECLCALLBACKTYPE(int, FNVMMR0CALLRING3NOTIFICATION,(PVMCPUCC pVCpu, VMMCALLRING3 enmOperation, void *pvUser));
|
---|
77 | /** Pointer to a FNRTMPNOTIFICATION(). */
|
---|
78 | typedef FNVMMR0CALLRING3NOTIFICATION *PFNVMMR0CALLRING3NOTIFICATION;
|
---|
79 |
|
---|
80 | /**
|
---|
81 | * Rendezvous callback.
|
---|
82 | *
|
---|
83 | * @returns VBox strict status code - EM scheduling. Do not return
|
---|
84 | * informational status code other than the ones used by EM for
|
---|
85 | * scheduling.
|
---|
86 | *
|
---|
87 | * @param pVM The cross context VM structure.
|
---|
88 | * @param pVCpu The cross context virtual CPU structure of the calling EMT.
|
---|
89 | * @param pvUser The user argument.
|
---|
90 | */
|
---|
91 | typedef DECLCALLBACKTYPE(VBOXSTRICTRC, FNVMMEMTRENDEZVOUS,(PVM pVM, PVMCPU pVCpu, void *pvUser));
|
---|
92 | /** Pointer to a rendezvous callback function. */
|
---|
93 | typedef FNVMMEMTRENDEZVOUS *PFNVMMEMTRENDEZVOUS;
|
---|
94 |
|
---|
95 | /**
|
---|
96 | * Method table that the VMM uses to call back the user of the VMM.
|
---|
97 | */
|
---|
98 | typedef struct VMM2USERMETHODS
|
---|
99 | {
|
---|
100 | /** Magic value (VMM2USERMETHODS_MAGIC). */
|
---|
101 | uint32_t u32Magic;
|
---|
102 | /** Structure version (VMM2USERMETHODS_VERSION). */
|
---|
103 | uint32_t u32Version;
|
---|
104 |
|
---|
105 | /**
|
---|
106 | * Save the VM state.
|
---|
107 | *
|
---|
108 | * @returns VBox status code.
|
---|
109 | * @param pThis Pointer to the callback method table.
|
---|
110 | * @param pUVM The user mode VM handle.
|
---|
111 | *
|
---|
112 | * @remarks This member shall be set to NULL if the operation is not
|
---|
113 | * supported.
|
---|
114 | */
|
---|
115 | DECLR3CALLBACKMEMBER(int, pfnSaveState,(PCVMM2USERMETHODS pThis, PUVM pUVM));
|
---|
116 | /** @todo Move pfnVMAtError and pfnCFGMConstructor here? */
|
---|
117 |
|
---|
118 | /**
|
---|
119 | * EMT initialization notification callback.
|
---|
120 | *
|
---|
121 | * This is intended for doing per-thread initialization for EMTs (like COM
|
---|
122 | * init).
|
---|
123 | *
|
---|
124 | * @param pThis Pointer to the callback method table.
|
---|
125 | * @param pUVM The user mode VM handle.
|
---|
126 | * @param pUVCpu The user mode virtual CPU handle.
|
---|
127 | *
|
---|
128 | * @remarks This is optional and shall be set to NULL if not wanted.
|
---|
129 | */
|
---|
130 | DECLR3CALLBACKMEMBER(void, pfnNotifyEmtInit,(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu));
|
---|
131 |
|
---|
132 | /**
|
---|
133 | * EMT termination notification callback.
|
---|
134 | *
|
---|
135 | * This is intended for doing per-thread cleanups for EMTs (like COM).
|
---|
136 | *
|
---|
137 | * @param pThis Pointer to the callback method table.
|
---|
138 | * @param pUVM The user mode VM handle.
|
---|
139 | * @param pUVCpu The user mode virtual CPU handle.
|
---|
140 | *
|
---|
141 | * @remarks This is optional and shall be set to NULL if not wanted.
|
---|
142 | */
|
---|
143 | DECLR3CALLBACKMEMBER(void, pfnNotifyEmtTerm,(PCVMM2USERMETHODS pThis, PUVM pUVM, PUVMCPU pUVCpu));
|
---|
144 |
|
---|
145 | /**
|
---|
146 | * PDM thread initialization notification callback.
|
---|
147 | *
|
---|
148 | * This is intended for doing per-thread initialization (like COM init).
|
---|
149 | *
|
---|
150 | * @param pThis Pointer to the callback method table.
|
---|
151 | * @param pUVM The user mode VM handle.
|
---|
152 | *
|
---|
153 | * @remarks This is optional and shall be set to NULL if not wanted.
|
---|
154 | */
|
---|
155 | DECLR3CALLBACKMEMBER(void, pfnNotifyPdmtInit,(PCVMM2USERMETHODS pThis, PUVM pUVM));
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * EMT termination notification callback.
|
---|
159 | *
|
---|
160 | * This is intended for doing per-thread cleanups for EMTs (like COM).
|
---|
161 | *
|
---|
162 | * @param pThis Pointer to the callback method table.
|
---|
163 | * @param pUVM The user mode VM handle.
|
---|
164 | *
|
---|
165 | * @remarks This is optional and shall be set to NULL if not wanted.
|
---|
166 | */
|
---|
167 | DECLR3CALLBACKMEMBER(void, pfnNotifyPdmtTerm,(PCVMM2USERMETHODS pThis, PUVM pUVM));
|
---|
168 |
|
---|
169 | /**
|
---|
170 | * Notification callback that that a VM reset will be turned into a power off.
|
---|
171 | *
|
---|
172 | * @param pThis Pointer to the callback method table.
|
---|
173 | * @param pUVM The user mode VM handle.
|
---|
174 | *
|
---|
175 | * @remarks This is optional and shall be set to NULL if not wanted.
|
---|
176 | */
|
---|
177 | DECLR3CALLBACKMEMBER(void, pfnNotifyResetTurnedIntoPowerOff,(PCVMM2USERMETHODS pThis, PUVM pUVM));
|
---|
178 |
|
---|
179 | /**
|
---|
180 | * Generic object query by UUID.
|
---|
181 | *
|
---|
182 | * @returns pointer to queried the object on success, NULL if not found.
|
---|
183 | *
|
---|
184 | * @param pThis Pointer to the callback method table.
|
---|
185 | * @param pUVM The user mode VM handle.
|
---|
186 | * @param pUuid The UUID of what's being queried. The UUIDs and the
|
---|
187 | * usage conventions are defined by the user.
|
---|
188 | *
|
---|
189 | * @remarks This is optional and shall be set to NULL if not wanted.
|
---|
190 | */
|
---|
191 | DECLR3CALLBACKMEMBER(void *, pfnQueryGenericObject,(PCVMM2USERMETHODS pThis, PUVM pUVM, PCRTUUID pUuid));
|
---|
192 |
|
---|
193 | /** Magic value (VMM2USERMETHODS_MAGIC) marking the end of the structure. */
|
---|
194 | uint32_t u32EndMagic;
|
---|
195 | } VMM2USERMETHODS;
|
---|
196 |
|
---|
197 | /** Magic value of the VMM2USERMETHODS (Franz Kafka). */
|
---|
198 | #define VMM2USERMETHODS_MAGIC UINT32_C(0x18830703)
|
---|
199 | /** The VMM2USERMETHODS structure version. */
|
---|
200 | #define VMM2USERMETHODS_VERSION UINT32_C(0x00030000)
|
---|
201 |
|
---|
202 |
|
---|
203 | /**
|
---|
204 | * Checks whether we've armed the ring-0 long jump machinery.
|
---|
205 | *
|
---|
206 | * @returns @c true / @c false
|
---|
207 | * @param a_pVCpu The caller's cross context virtual CPU structure.
|
---|
208 | * @thread EMT
|
---|
209 | * @sa VMMR0IsLongJumpArmed
|
---|
210 | */
|
---|
211 | #ifdef IN_RING0
|
---|
212 | # define VMMIsLongJumpArmed(a_pVCpu) VMMR0IsLongJumpArmed(a_pVCpu)
|
---|
213 | #else
|
---|
214 | # define VMMIsLongJumpArmed(a_pVCpu) (false)
|
---|
215 | #endif
|
---|
216 |
|
---|
217 |
|
---|
218 | VMMDECL(VMCPUID) VMMGetCpuId(PVMCC pVM);
|
---|
219 | VMMDECL(PVMCPUCC) VMMGetCpu(PVMCC pVM);
|
---|
220 | VMMDECL(PVMCPUCC) VMMGetCpu0(PVMCC pVM);
|
---|
221 | VMMDECL(PVMCPUCC) VMMGetCpuById(PVMCC pVM, VMCPUID idCpu);
|
---|
222 | VMMR3DECL(PVMCPUCC) VMMR3GetCpuByIdU(PUVM pVM, VMCPUID idCpu);
|
---|
223 | VMM_INT_DECL(uint32_t) VMMGetSvnRev(void);
|
---|
224 | VMM_INT_DECL(bool) VMMIsInRing3Call(PVMCPUCC pVCpu);
|
---|
225 | VMM_INT_DECL(void) VMMTrashVolatileXMMRegs(void);
|
---|
226 |
|
---|
227 |
|
---|
228 | /** @defgroup grp_vmm_api_r0 The VMM Host Context Ring 0 API
|
---|
229 | * @{
|
---|
230 | */
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * The VMMR0Entry() codes.
|
---|
234 | */
|
---|
235 | typedef enum VMMR0OPERATION
|
---|
236 | {
|
---|
237 | /** Run guest code using the available hardware acceleration technology. */
|
---|
238 | VMMR0_DO_HM_RUN = SUP_VMMR0_DO_HM_RUN,
|
---|
239 | /** Official NOP that we use for profiling. */
|
---|
240 | VMMR0_DO_NEM_RUN = SUP_VMMR0_DO_NEM_RUN,
|
---|
241 | /** Official NOP that we use for profiling. */
|
---|
242 | VMMR0_DO_NOP = SUP_VMMR0_DO_NOP,
|
---|
243 | /** Official slow iocl NOP that we use for profiling. */
|
---|
244 | VMMR0_DO_SLOW_NOP,
|
---|
245 |
|
---|
246 | /** Ask the GVMM to create a new VM. */
|
---|
247 | VMMR0_DO_GVMM_CREATE_VM = 32,
|
---|
248 | /** Ask the GVMM to destroy the VM. */
|
---|
249 | VMMR0_DO_GVMM_DESTROY_VM,
|
---|
250 | /** Call GVMMR0RegisterVCpu(). */
|
---|
251 | VMMR0_DO_GVMM_REGISTER_VMCPU,
|
---|
252 | /** Call GVMMR0DeregisterVCpu(). */
|
---|
253 | VMMR0_DO_GVMM_DEREGISTER_VMCPU,
|
---|
254 | /** Call GVMMR0RegisterWorkerThread(). */
|
---|
255 | VMMR0_DO_GVMM_REGISTER_WORKER_THREAD,
|
---|
256 | /** Call GVMMR0DeregisterWorkerThread(). */
|
---|
257 | VMMR0_DO_GVMM_DEREGISTER_WORKER_THREAD,
|
---|
258 | /** Call GVMMR0SchedHalt(). */
|
---|
259 | VMMR0_DO_GVMM_SCHED_HALT,
|
---|
260 | /** Call GVMMR0SchedWakeUp(). */
|
---|
261 | VMMR0_DO_GVMM_SCHED_WAKE_UP,
|
---|
262 | /** Call GVMMR0SchedPoke(). */
|
---|
263 | VMMR0_DO_GVMM_SCHED_POKE,
|
---|
264 | /** Call GVMMR0SchedWakeUpAndPokeCpus(). */
|
---|
265 | VMMR0_DO_GVMM_SCHED_WAKE_UP_AND_POKE_CPUS,
|
---|
266 | /** Call GVMMR0SchedPoll(). */
|
---|
267 | VMMR0_DO_GVMM_SCHED_POLL,
|
---|
268 | /** Call GVMMR0QueryStatistics(). */
|
---|
269 | VMMR0_DO_GVMM_QUERY_STATISTICS,
|
---|
270 | /** Call GVMMR0ResetStatistics(). */
|
---|
271 | VMMR0_DO_GVMM_RESET_STATISTICS,
|
---|
272 |
|
---|
273 | /** Call VMMR0 Per VM Init. */
|
---|
274 | VMMR0_DO_VMMR0_INIT = 64,
|
---|
275 | /** Call VMMR0 Per VM EMT Init */
|
---|
276 | VMMR0_DO_VMMR0_INIT_EMT,
|
---|
277 | /** Call VMMR0 Per VM Termination. */
|
---|
278 | VMMR0_DO_VMMR0_TERM,
|
---|
279 | /** Copy logger settings from userland, VMMR0UpdateLoggersReq(). */
|
---|
280 | VMMR0_DO_VMMR0_UPDATE_LOGGERS,
|
---|
281 | /** Used by the log flusher, VMMR0LogFlusher. */
|
---|
282 | VMMR0_DO_VMMR0_LOG_FLUSHER,
|
---|
283 | /** Used by EMTs to wait for the log flusher to finish, VMMR0LogWaitFlushed. */
|
---|
284 | VMMR0_DO_VMMR0_LOG_WAIT_FLUSHED,
|
---|
285 |
|
---|
286 | /** Setup hardware-assisted VM session. */
|
---|
287 | VMMR0_DO_HM_SETUP_VM = 128,
|
---|
288 | /** Attempt to enable or disable hardware-assisted mode. */
|
---|
289 | VMMR0_DO_HM_ENABLE,
|
---|
290 |
|
---|
291 | /** Call PGMR0PhysAllocateHandyPages(). */
|
---|
292 | VMMR0_DO_PGM_ALLOCATE_HANDY_PAGES = 192,
|
---|
293 | /** Call PGMR0PhysFlushHandyPages(). */
|
---|
294 | VMMR0_DO_PGM_FLUSH_HANDY_PAGES,
|
---|
295 | /** Call PGMR0AllocateLargePage(). */
|
---|
296 | VMMR0_DO_PGM_ALLOCATE_LARGE_HANDY_PAGE,
|
---|
297 | /** Call PGMR0PhysSetupIommu(). */
|
---|
298 | VMMR0_DO_PGM_PHYS_SETUP_IOMMU,
|
---|
299 | /** Call PGMR0PoolGrow(). */
|
---|
300 | VMMR0_DO_PGM_POOL_GROW,
|
---|
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 GMMR0SeedChunk(). */
|
---|
321 | VMMR0_DO_GMM_SEED_CHUNK,
|
---|
322 | /** Call GMMR0RegisterSharedModule. */
|
---|
323 | VMMR0_DO_GMM_REGISTER_SHARED_MODULE,
|
---|
324 | /** Call GMMR0UnregisterSharedModule. */
|
---|
325 | VMMR0_DO_GMM_UNREGISTER_SHARED_MODULE,
|
---|
326 | /** Call GMMR0ResetSharedModules. */
|
---|
327 | VMMR0_DO_GMM_RESET_SHARED_MODULES,
|
---|
328 | /** Call GMMR0CheckSharedModules. */
|
---|
329 | VMMR0_DO_GMM_CHECK_SHARED_MODULES,
|
---|
330 | /** Call GMMR0FindDuplicatePage. */
|
---|
331 | VMMR0_DO_GMM_FIND_DUPLICATE_PAGE,
|
---|
332 | /** Call GMMR0QueryStatistics(). */
|
---|
333 | VMMR0_DO_GMM_QUERY_STATISTICS,
|
---|
334 | /** Call GMMR0ResetStatistics(). */
|
---|
335 | VMMR0_DO_GMM_RESET_STATISTICS,
|
---|
336 |
|
---|
337 | /** Call PDMR0DriverCallReqHandler. */
|
---|
338 | VMMR0_DO_PDM_DRIVER_CALL_REQ_HANDLER = 320,
|
---|
339 | /** Call PDMR0DeviceCreateReqHandler. */
|
---|
340 | VMMR0_DO_PDM_DEVICE_CREATE,
|
---|
341 | /** Call PDMR0DeviceGenCallReqHandler. */
|
---|
342 | VMMR0_DO_PDM_DEVICE_GEN_CALL,
|
---|
343 | /** Old style device compat: Set ring-0 critical section. */
|
---|
344 | VMMR0_DO_PDM_DEVICE_COMPAT_SET_CRITSECT,
|
---|
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 | */
|
---|
442 | typedef 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 | */
|
---|
458 | typedef GCFGMVALUEREQ *PGCFGMVALUEREQ;
|
---|
459 |
|
---|
460 |
|
---|
461 | /**
|
---|
462 | * Request package for VMMR0_DO_VMMR0_UPDATE_LOGGERS.
|
---|
463 | *
|
---|
464 | * In addition the u64Arg selects the logger sets: @c false for debug, @c true
|
---|
465 | * for release.
|
---|
466 | */
|
---|
467 | typedef 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. */
|
---|
482 | typedef VMMR0UPDATELOGGERSREQ *PVMMR0UPDATELOGGERSREQ;
|
---|
483 |
|
---|
484 | #if defined(IN_RING0) || defined(DOXYGEN_RUNNING)
|
---|
485 |
|
---|
486 | /**
|
---|
487 | * Structure VMMR0EmtPrepareToBlock uses to pass info to
|
---|
488 | * VMMR0EmtResumeAfterBlocking.
|
---|
489 | */
|
---|
490 | typedef struct VMMR0EMTBLOCKCTX
|
---|
491 | {
|
---|
492 | /** Magic value (VMMR0EMTBLOCKCTX_MAGIC). */
|
---|
493 | uint32_t uMagic;
|
---|
494 | /** Set if we were in HM context, clear if not. */
|
---|
495 | bool fWasInHmContext;
|
---|
496 | } VMMR0EMTBLOCKCTX;
|
---|
497 | /** Pointer to a VMMR0EmtPrepareToBlock context structure. */
|
---|
498 | typedef VMMR0EMTBLOCKCTX *PVMMR0EMTBLOCKCTX;
|
---|
499 | /** Magic value for VMMR0EMTBLOCKCTX::uMagic (Paul Desmond). */
|
---|
500 | #define VMMR0EMTBLOCKCTX_MAGIC UINT32_C(0x19261125)
|
---|
501 | /** Magic value for VMMR0EMTBLOCKCTX::uMagic when its out of context. */
|
---|
502 | #define VMMR0EMTBLOCKCTX_MAGIC_DEAD UINT32_C(0x19770530)
|
---|
503 |
|
---|
504 | VMMR0DECL(void) VMMR0EntryFast(PGVM pGVM, PVMCC pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation);
|
---|
505 | VMMR0DECL(int) VMMR0EntryEx(PGVM pGVM, PVMCC pVM, VMCPUID idCpu, VMMR0OPERATION enmOperation,
|
---|
506 | PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION);
|
---|
507 | VMMR0_INT_DECL(int) VMMR0InitPerVMData(PGVM pGVM);
|
---|
508 | VMMR0_INT_DECL(int) VMMR0TermVM(PGVM pGVM, VMCPUID idCpu);
|
---|
509 | VMMR0_INT_DECL(void) VMMR0CleanupVM(PGVM pGVM);
|
---|
510 | VMMR0_INT_DECL(bool) VMMR0IsLongJumpArmed(PVMCPUCC pVCpu);
|
---|
511 | VMMR0_INT_DECL(bool) VMMR0IsInRing3LongJump(PVMCPUCC pVCpu);
|
---|
512 | VMMR0_INT_DECL(int) VMMR0ThreadCtxHookCreateForEmt(PVMCPUCC pVCpu);
|
---|
513 | VMMR0_INT_DECL(void) VMMR0ThreadCtxHookDestroyForEmt(PVMCPUCC pVCpu);
|
---|
514 | VMMR0_INT_DECL(void) VMMR0ThreadCtxHookDisable(PVMCPUCC pVCpu);
|
---|
515 | VMMR0_INT_DECL(bool) VMMR0ThreadCtxHookIsEnabled(PVMCPUCC pVCpu);
|
---|
516 | VMMR0_INT_DECL(int) VMMR0EmtPrepareToBlock(PVMCPUCC pVCpu, int rcBusy, const char *pszCaller, void *pvLock,
|
---|
517 | PVMMR0EMTBLOCKCTX pCtx);
|
---|
518 | VMMR0_INT_DECL(void) VMMR0EmtResumeAfterBlocking(PVMCPUCC pVCpu, PVMMR0EMTBLOCKCTX pCtx);
|
---|
519 | VMMR0_INT_DECL(int) VMMR0EmtWaitEventInner(PGVMCPU pGVCpu, uint32_t fFlags, RTSEMEVENT hEvent, RTMSINTERVAL cMsTimeout);
|
---|
520 | VMMR0_INT_DECL(int) VMMR0EmtSignalSupEvent(PGVM pGVM, PGVMCPU pGVCpu, SUPSEMEVENT hEvent);
|
---|
521 | VMMR0_INT_DECL(int) VMMR0EmtSignalSupEventByGVM(PGVM pGVM, SUPSEMEVENT hEvent);
|
---|
522 |
|
---|
523 | /** @name VMMR0EMTWAIT_F_XXX - flags for VMMR0EmtWaitEventInner and friends.
|
---|
524 | * @{ */
|
---|
525 | /** Try suppress VERR_INTERRUPTED for a little while (~10 sec). */
|
---|
526 | #define VMMR0EMTWAIT_F_TRY_SUPPRESS_INTERRUPTED RT_BIT_32(0)
|
---|
527 | /** @} */
|
---|
528 | #endif /* IN_RING0 */
|
---|
529 |
|
---|
530 | VMMR0_INT_DECL(PRTLOGGER) VMMR0GetReleaseLogger(PVMCPUCC pVCpu);
|
---|
531 | /** @} */
|
---|
532 |
|
---|
533 |
|
---|
534 | #if defined(IN_RING3) || defined(DOXYGEN_RUNNING)
|
---|
535 | /** @defgroup grp_vmm_api_r3 The VMM Host Context Ring 3 API
|
---|
536 | * @{
|
---|
537 | */
|
---|
538 | VMMR3_INT_DECL(int) VMMR3Init(PVM pVM);
|
---|
539 | VMMR3_INT_DECL(int) VMMR3InitR0(PVM pVM);
|
---|
540 | VMMR3_INT_DECL(int) VMMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
|
---|
541 | VMMR3_INT_DECL(int) VMMR3Term(PVM pVM);
|
---|
542 | VMMR3_INT_DECL(void) VMMR3Relocate(PVM pVM, RTGCINTPTR offDelta);
|
---|
543 | VMMR3_INT_DECL(int) VMMR3UpdateLoggers(PVM pVM);
|
---|
544 | VMMR3DECL(const char *) VMMR3GetRZAssertMsg1(PVM pVM);
|
---|
545 | VMMR3DECL(const char *) VMMR3GetRZAssertMsg2(PVM pVM);
|
---|
546 | VMMR3_INT_DECL(int) VMMR3HmRunGC(PVM pVM, PVMCPU pVCpu);
|
---|
547 | VMMR3DECL(int) VMMR3CallR0(PVM pVM, uint32_t uOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr);
|
---|
548 | VMMR3_INT_DECL(int) VMMR3CallR0Emt(PVM pVM, PVMCPU pVCpu, VMMR0OPERATION enmOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr);
|
---|
549 | VMMR3_INT_DECL(VBOXSTRICTRC) VMMR3CallR0EmtFast(PVM pVM, PVMCPU pVCpu, VMMR0OPERATION enmOperation);
|
---|
550 | VMMR3DECL(void) VMMR3FatalDump(PVM pVM, PVMCPU pVCpu, int rcErr);
|
---|
551 | VMMR3_INT_DECL(void) VMMR3YieldSuspend(PVM pVM);
|
---|
552 | VMMR3_INT_DECL(void) VMMR3YieldStop(PVM pVM);
|
---|
553 | VMMR3_INT_DECL(void) VMMR3YieldResume(PVM pVM);
|
---|
554 | VMMR3_INT_DECL(void) VMMR3SendStartupIpi(PVM pVM, VMCPUID idCpu, uint32_t uVector);
|
---|
555 | VMMR3_INT_DECL(void) VMMR3SendInitIpi(PVM pVM, VMCPUID idCpu);
|
---|
556 | VMMR3DECL(int) VMMR3RegisterPatchMemory(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
|
---|
557 | VMMR3DECL(int) VMMR3DeregisterPatchMemory(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
|
---|
558 | VMMR3DECL(int) VMMR3EmtRendezvous(PVM pVM, uint32_t fFlags, PFNVMMEMTRENDEZVOUS pfnRendezvous, void *pvUser);
|
---|
559 | /** @defgroup grp_VMMR3EmtRendezvous_fFlags VMMR3EmtRendezvous flags
|
---|
560 | * @{ */
|
---|
561 | /** Execution type mask. */
|
---|
562 | #define VMMEMTRENDEZVOUS_FLAGS_TYPE_MASK UINT32_C(0x00000007)
|
---|
563 | /** Invalid execution type. */
|
---|
564 | #define VMMEMTRENDEZVOUS_FLAGS_TYPE_INVALID UINT32_C(0)
|
---|
565 | /** Let the EMTs execute the callback one by one (in no particular order).
|
---|
566 | * Recursion from within the callback possible. */
|
---|
567 | #define VMMEMTRENDEZVOUS_FLAGS_TYPE_ONE_BY_ONE UINT32_C(1)
|
---|
568 | /** Let all the EMTs execute the callback at the same time.
|
---|
569 | * Cannot recurse from the callback. */
|
---|
570 | #define VMMEMTRENDEZVOUS_FLAGS_TYPE_ALL_AT_ONCE UINT32_C(2)
|
---|
571 | /** Only execute the callback on one EMT (no particular one).
|
---|
572 | * Recursion from within the callback possible. */
|
---|
573 | #define VMMEMTRENDEZVOUS_FLAGS_TYPE_ONCE UINT32_C(3)
|
---|
574 | /** Let the EMTs execute the callback one by one in ascending order.
|
---|
575 | * Recursion from within the callback possible. */
|
---|
576 | #define VMMEMTRENDEZVOUS_FLAGS_TYPE_ASCENDING UINT32_C(4)
|
---|
577 | /** Let the EMTs execute the callback one by one in descending order.
|
---|
578 | * Recursion from within the callback possible. */
|
---|
579 | #define VMMEMTRENDEZVOUS_FLAGS_TYPE_DESCENDING UINT32_C(5)
|
---|
580 | /** Stop after the first error.
|
---|
581 | * This is not valid for any execution type where more than one EMT is active
|
---|
582 | * at a time. */
|
---|
583 | #define VMMEMTRENDEZVOUS_FLAGS_STOP_ON_ERROR UINT32_C(0x00000008)
|
---|
584 | /** Use VMREQFLAGS_PRIORITY when contacting the EMTs. */
|
---|
585 | #define VMMEMTRENDEZVOUS_FLAGS_PRIORITY UINT32_C(0x00000010)
|
---|
586 | /** The valid flags. */
|
---|
587 | #define VMMEMTRENDEZVOUS_FLAGS_VALID_MASK UINT32_C(0x0000001f)
|
---|
588 | /** @} */
|
---|
589 | VMMR3_INT_DECL(int) VMMR3EmtRendezvousFF(PVM pVM, PVMCPU pVCpu);
|
---|
590 | VMMR3_INT_DECL(void) VMMR3SetMayHaltInRing0(PVMCPU pVCpu, bool fMayHaltInRing0, uint32_t cNsSpinBlockThreshold);
|
---|
591 | VMMR3_INT_DECL(int) VMMR3ReadR0Stack(PVM pVM, VMCPUID idCpu, RTHCUINTPTR R0Addr, void *pvBuf, size_t cbRead);
|
---|
592 | VMMR3_INT_DECL(void) VMMR3InitR0StackUnwindState(PUVM pUVM, VMCPUID idCpu, PRTDBGUNWINDSTATE pState);
|
---|
593 | /** @} */
|
---|
594 | #endif /* IN_RING3 */
|
---|
595 |
|
---|
596 |
|
---|
597 | #if defined(IN_RC) || defined(IN_RING0) || defined(DOXYGEN_RUNNING)
|
---|
598 | /** @defgroup grp_vmm_api_rz The VMM Raw-Mode and Ring-0 Context API
|
---|
599 | * @{
|
---|
600 | */
|
---|
601 | VMMRZDECL(int) VMMRZCallRing3(PVMCC pVMCC, PVMCPUCC pVCpu, VMMCALLRING3 enmOperation, uint64_t uArg);
|
---|
602 | VMMRZDECL(int) VMMRZCallRing3NoCpu(PVMCC pVM, VMMCALLRING3 enmOperation, uint64_t uArg);
|
---|
603 | VMMRZDECL(void) VMMRZCallRing3Disable(PVMCPUCC pVCpu);
|
---|
604 | VMMRZDECL(void) VMMRZCallRing3Enable(PVMCPUCC pVCpu);
|
---|
605 | VMMRZDECL(bool) VMMRZCallRing3IsEnabled(PVMCPUCC pVCpu);
|
---|
606 | VMMRZDECL(int) VMMRZCallRing3SetNotification(PVMCPUCC pVCpu, R0PTRTYPE(PFNVMMR0CALLRING3NOTIFICATION) pfnCallback, RTR0PTR pvUser);
|
---|
607 | VMMRZDECL(void) VMMRZCallRing3RemoveNotification(PVMCPUCC pVCpu);
|
---|
608 | VMMRZDECL(bool) VMMRZCallRing3IsNotificationSet(PVMCPUCC pVCpu);
|
---|
609 | /** @} */
|
---|
610 | #endif
|
---|
611 |
|
---|
612 |
|
---|
613 | /** Wrapper around AssertReleaseMsgReturn that avoid tripping up in the
|
---|
614 | * kernel when we don't have a setjmp in place. */
|
---|
615 | #ifdef IN_RING0
|
---|
616 | # define VMM_ASSERT_RELEASE_MSG_RETURN(a_pVM, a_Expr, a_Msg, a_rc) do { \
|
---|
617 | if (RT_LIKELY(a_Expr)) { /* likely */ } \
|
---|
618 | else \
|
---|
619 | { \
|
---|
620 | PVMCPUCC pVCpuAssert = VMMGetCpu(a_pVM); \
|
---|
621 | if (pVCpuAssert && VMMR0IsLongJumpArmed(pVCpuAssert)) \
|
---|
622 | AssertReleaseMsg(a_Expr, a_Msg); \
|
---|
623 | else \
|
---|
624 | AssertLogRelMsg(a_Expr, a_Msg); \
|
---|
625 | return (a_rc); \
|
---|
626 | } \
|
---|
627 | } while (0)
|
---|
628 | #else
|
---|
629 | # define VMM_ASSERT_RELEASE_MSG_RETURN(a_pVM, a_Expr, a_Msg, a_rc) AssertReleaseMsgReturn(a_Expr, a_Msg, a_rc)
|
---|
630 | #endif
|
---|
631 |
|
---|
632 | /** @} */
|
---|
633 |
|
---|
634 | /** @} */
|
---|
635 | RT_C_DECLS_END
|
---|
636 |
|
---|
637 | #endif /* !VBOX_INCLUDED_vmm_vmm_h */
|
---|