1 | /* $Id: SUPDrvInternal.h 53054 2014-10-14 14:52:50Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VirtualBox Support Driver - Internal header.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2013 Oracle Corporation
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef ___SUPDrvInternal_h
|
---|
28 | #define ___SUPDrvInternal_h
|
---|
29 |
|
---|
30 |
|
---|
31 | /*******************************************************************************
|
---|
32 | * Header Files *
|
---|
33 | *******************************************************************************/
|
---|
34 | #include <VBox/cdefs.h>
|
---|
35 | #include <VBox/types.h>
|
---|
36 | #include <VBox/sup.h>
|
---|
37 |
|
---|
38 | #include <iprt/assert.h>
|
---|
39 | #include <iprt/list.h>
|
---|
40 | #include <iprt/memobj.h>
|
---|
41 | #include <iprt/time.h>
|
---|
42 | #include <iprt/timer.h>
|
---|
43 | #include <iprt/string.h>
|
---|
44 | #include <iprt/err.h>
|
---|
45 |
|
---|
46 | #ifdef SUPDRV_AGNOSTIC
|
---|
47 | /* do nothing */
|
---|
48 |
|
---|
49 | #elif defined(RT_OS_WINDOWS)
|
---|
50 | RT_C_DECLS_BEGIN
|
---|
51 | # if (_MSC_VER >= 1400) && !defined(VBOX_WITH_PATCHED_DDK)
|
---|
52 | # define _InterlockedExchange _InterlockedExchange_StupidDDKVsCompilerCrap
|
---|
53 | # define _InterlockedExchangeAdd _InterlockedExchangeAdd_StupidDDKVsCompilerCrap
|
---|
54 | # define _InterlockedCompareExchange _InterlockedCompareExchange_StupidDDKVsCompilerCrap
|
---|
55 | # define _InterlockedAddLargeStatistic _InterlockedAddLargeStatistic_StupidDDKVsCompilerCrap
|
---|
56 | # define _interlockedbittestandset _interlockedbittestandset_StupidDDKVsCompilerCrap
|
---|
57 | # define _interlockedbittestandreset _interlockedbittestandreset_StupidDDKVsCompilerCrap
|
---|
58 | # define _interlockedbittestandset64 _interlockedbittestandset64_StupidDDKVsCompilerCrap
|
---|
59 | # define _interlockedbittestandreset64 _interlockedbittestandreset64_StupidDDKVsCompilerCrap
|
---|
60 | # pragma warning(disable : 4163)
|
---|
61 | # include <iprt/nt/nt.h>
|
---|
62 | # pragma warning(default : 4163)
|
---|
63 | # undef _InterlockedExchange
|
---|
64 | # undef _InterlockedExchangeAdd
|
---|
65 | # undef _InterlockedCompareExchange
|
---|
66 | # undef _InterlockedAddLargeStatistic
|
---|
67 | # undef _interlockedbittestandset
|
---|
68 | # undef _interlockedbittestandreset
|
---|
69 | # undef _interlockedbittestandset64
|
---|
70 | # undef _interlockedbittestandreset64
|
---|
71 | # else
|
---|
72 | # include <iprt/nt/nt.h>
|
---|
73 | # endif
|
---|
74 | # include <memory.h>
|
---|
75 | RT_C_DECLS_END
|
---|
76 |
|
---|
77 | #elif defined(RT_OS_LINUX)
|
---|
78 | # include <linux/version.h>
|
---|
79 | # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 33)
|
---|
80 | # include <generated/autoconf.h>
|
---|
81 | # else
|
---|
82 | # ifndef AUTOCONF_INCLUDED
|
---|
83 | # include <linux/autoconf.h>
|
---|
84 | # endif
|
---|
85 | # endif
|
---|
86 | # if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
|
---|
87 | # define MODVERSIONS
|
---|
88 | # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 5, 71)
|
---|
89 | # include <linux/modversions.h>
|
---|
90 | # endif
|
---|
91 | # endif
|
---|
92 | # if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 0)
|
---|
93 | # undef ALIGN
|
---|
94 | # endif
|
---|
95 | # ifndef KBUILD_STR
|
---|
96 | # if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 16)
|
---|
97 | # define KBUILD_STR(s) s
|
---|
98 | # else
|
---|
99 | # define KBUILD_STR(s) #s
|
---|
100 | # endif
|
---|
101 | # endif
|
---|
102 | # include <linux/string.h>
|
---|
103 | # include <linux/spinlock.h>
|
---|
104 | # include <linux/slab.h>
|
---|
105 | # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27)
|
---|
106 | # include <linux/semaphore.h>
|
---|
107 | # else /* older kernels */
|
---|
108 | # include <asm/semaphore.h>
|
---|
109 | # endif /* older kernels */
|
---|
110 | # include <linux/timer.h>
|
---|
111 |
|
---|
112 | #elif defined(RT_OS_DARWIN)
|
---|
113 | # include <libkern/libkern.h>
|
---|
114 | # include <iprt/string.h>
|
---|
115 |
|
---|
116 | #elif defined(RT_OS_OS2)
|
---|
117 |
|
---|
118 | #elif defined(RT_OS_FREEBSD)
|
---|
119 | # define memset libkern_memset /** @todo these are just hacks to get it compiling, check out later. */
|
---|
120 | # define memcmp libkern_memcmp
|
---|
121 | # define strchr libkern_strchr
|
---|
122 | # define strrchr libkern_strrchr
|
---|
123 | # define ffsl libkern_ffsl
|
---|
124 | # define fls libkern_fls
|
---|
125 | # define flsl libkern_flsl
|
---|
126 | # include <sys/libkern.h>
|
---|
127 | # undef memset
|
---|
128 | # undef memcmp
|
---|
129 | # undef strchr
|
---|
130 | # undef strrchr
|
---|
131 | # undef ffs
|
---|
132 | # undef ffsl
|
---|
133 | # undef fls
|
---|
134 | # undef flsl
|
---|
135 | # include <iprt/string.h>
|
---|
136 |
|
---|
137 | #elif defined(RT_OS_SOLARIS)
|
---|
138 | # include <sys/cmn_err.h>
|
---|
139 | # include <iprt/string.h>
|
---|
140 |
|
---|
141 | #else
|
---|
142 | # error "unsupported OS."
|
---|
143 | #endif
|
---|
144 |
|
---|
145 | #include "SUPDrvIOC.h"
|
---|
146 | #include "SUPDrvIDC.h"
|
---|
147 |
|
---|
148 |
|
---|
149 |
|
---|
150 | /*******************************************************************************
|
---|
151 | * Defined Constants And Macros *
|
---|
152 | *******************************************************************************/
|
---|
153 | /*
|
---|
154 | * Hardcoded cookies.
|
---|
155 | */
|
---|
156 | #define BIRD 0x64726962 /* 'bird' */
|
---|
157 | #define BIRD_INV 0x62697264 /* 'drib' */
|
---|
158 |
|
---|
159 |
|
---|
160 | #ifdef RT_OS_WINDOWS
|
---|
161 | /** Use a normal mutex for the loader so we remain at the same IRQL after
|
---|
162 | * taking it.
|
---|
163 | * @todo fix the mutex implementation on linux and make this the default. */
|
---|
164 | # define SUPDRV_USE_MUTEX_FOR_LDR
|
---|
165 |
|
---|
166 | /** Use a normal mutex for the GIP so we remain at the same IRQL after
|
---|
167 | * taking it.
|
---|
168 | * @todo fix the mutex implementation on linux and make this the default. */
|
---|
169 | # define SUPDRV_USE_MUTEX_FOR_GIP
|
---|
170 | #endif
|
---|
171 |
|
---|
172 |
|
---|
173 | /**
|
---|
174 | * OS debug print macro.
|
---|
175 | */
|
---|
176 | #define OSDBGPRINT(a) SUPR0Printf a
|
---|
177 |
|
---|
178 | /** Debug printf macro shared with the ring-3 part. */
|
---|
179 | #ifdef DEBUG_bird
|
---|
180 | # define SUP_DPRINTF(a) SUPR0Printf a
|
---|
181 | #else
|
---|
182 | # define SUP_DPRINTF(a) do { } while (0)
|
---|
183 | #endif
|
---|
184 |
|
---|
185 |
|
---|
186 | /** @name Context values for the per-session handle tables.
|
---|
187 | * The context value is used to distinguish between the different kinds of
|
---|
188 | * handles, making the handle table API do all the work.
|
---|
189 | * @{ */
|
---|
190 | /** Handle context value for single release event handles. */
|
---|
191 | #define SUPDRV_HANDLE_CTX_EVENT ((void *)(uintptr_t)(SUPDRVOBJTYPE_SEM_EVENT))
|
---|
192 | /** Handle context value for multiple release event handles. */
|
---|
193 | #define SUPDRV_HANDLE_CTX_EVENT_MULTI ((void *)(uintptr_t)(SUPDRVOBJTYPE_SEM_EVENT_MULTI))
|
---|
194 | /** @} */
|
---|
195 |
|
---|
196 |
|
---|
197 | /**
|
---|
198 | * Validates a session pointer.
|
---|
199 | *
|
---|
200 | * @returns true/false accordingly.
|
---|
201 | * @param pSession The session.
|
---|
202 | */
|
---|
203 | #define SUP_IS_SESSION_VALID(pSession) \
|
---|
204 | ( VALID_PTR(pSession) \
|
---|
205 | && pSession->u32Cookie == BIRD_INV)
|
---|
206 |
|
---|
207 | /**
|
---|
208 | * Validates a device extension pointer.
|
---|
209 | *
|
---|
210 | * @returns true/false accordingly.
|
---|
211 | * @param pDevExt The device extension.
|
---|
212 | */
|
---|
213 | #define SUP_IS_DEVEXT_VALID(pDevExt) \
|
---|
214 | ( VALID_PTR(pDevExt)\
|
---|
215 | && pDevExt->u32Cookie == BIRD)
|
---|
216 |
|
---|
217 |
|
---|
218 | /** @def SUPDRV_WITH_MSR_PROBER
|
---|
219 | * Enables the SUP_IOCTL_MSR_PROBER function.
|
---|
220 | * By default, only enabled in DEBUG builds as it's a sensitive feature.
|
---|
221 | */
|
---|
222 | #if defined(DEBUG) && !defined(SUPDRV_WITH_MSR_PROBER) && !defined(SUPDRV_WITHOUT_MSR_PROBER)
|
---|
223 | # define SUPDRV_WITH_MSR_PROBER
|
---|
224 | #endif
|
---|
225 |
|
---|
226 | /** @def SUPDRV_WITHOUT_MSR_PROBER
|
---|
227 | * Executive overide for disabling the SUP_IOCTL_MSR_PROBER function.
|
---|
228 | */
|
---|
229 | #ifdef SUPDRV_WITHOUT_MSR_PROBER
|
---|
230 | # undef SUPDRV_WITH_MSR_PROBER
|
---|
231 | #endif
|
---|
232 |
|
---|
233 | #if 0
|
---|
234 | /** Use a dedicated kernel thread to service TSC-delta measurement requests. */
|
---|
235 | #define SUPDRV_USE_TSC_DELTA_THREAD
|
---|
236 | #endif
|
---|
237 |
|
---|
238 | /*******************************************************************************
|
---|
239 | * Structures and Typedefs *
|
---|
240 | *******************************************************************************/
|
---|
241 | /** Pointer to the device extension. */
|
---|
242 | typedef struct SUPDRVDEVEXT *PSUPDRVDEVEXT;
|
---|
243 |
|
---|
244 | #ifdef SUPDRV_USE_TSC_DELTA_THREAD
|
---|
245 | /**
|
---|
246 | * TSC-delta measurement thread state machine.
|
---|
247 | */
|
---|
248 | typedef enum SUPDRVTSCDELTASTATE
|
---|
249 | {
|
---|
250 | /** Uninitialized/invalid value. */
|
---|
251 | kSupDrvTscDeltaState_Invalid = 0,
|
---|
252 | /** The thread is being created. */
|
---|
253 | kSupDrvTscDeltaState_Creating,
|
---|
254 | /** The thread is listening for events. */
|
---|
255 | kSupDrvTscDeltaState_Listening,
|
---|
256 | /** The thread is sleeping before starting a measurement. */
|
---|
257 | kSupDrvTscDeltaState_WaitAndMeasure,
|
---|
258 | /** The thread is currently servicing a measurement request. */
|
---|
259 | kSupDrvTscDeltaState_Measuring,
|
---|
260 | /** The thread is terminating. */
|
---|
261 | kSupDrvTscDeltaState_Terminating,
|
---|
262 | /** The thread is butchered due to an unexpected error. */
|
---|
263 | kSupDrvTscDeltaState_Butchered,
|
---|
264 | /** The thread is destroyed. */
|
---|
265 | kSupDrvTscDeltaState_Destroyed,
|
---|
266 | /** The usual 32-bit blowup hack. */
|
---|
267 | kSupDrvTscDeltaState_32BitHack = 0x7fffffff
|
---|
268 | } SUPDRVTSCDELTASTATE;
|
---|
269 | #endif
|
---|
270 |
|
---|
271 | /**
|
---|
272 | * Memory reference types.
|
---|
273 | */
|
---|
274 | typedef enum
|
---|
275 | {
|
---|
276 | /** Unused entry */
|
---|
277 | MEMREF_TYPE_UNUSED = 0,
|
---|
278 | /** Locked memory (r3 mapping only). */
|
---|
279 | MEMREF_TYPE_LOCKED,
|
---|
280 | /** Continuous memory block (r3 and r0 mapping). */
|
---|
281 | MEMREF_TYPE_CONT,
|
---|
282 | /** Low memory block (r3 and r0 mapping). */
|
---|
283 | MEMREF_TYPE_LOW,
|
---|
284 | /** Memory block (r3 and r0 mapping). */
|
---|
285 | MEMREF_TYPE_MEM,
|
---|
286 | /** Locked memory (r3 mapping only) allocated by the support driver. */
|
---|
287 | MEMREF_TYPE_PAGE,
|
---|
288 | /** Blow the type up to 32-bit and mark the end. */
|
---|
289 | MEMREF_TYPE_32BIT_HACK = 0x7fffffff
|
---|
290 | } SUPDRVMEMREFTYPE, *PSUPDRVMEMREFTYPE;
|
---|
291 |
|
---|
292 |
|
---|
293 | /**
|
---|
294 | * Structure used for tracking memory a session
|
---|
295 | * references in one way or another.
|
---|
296 | */
|
---|
297 | typedef struct SUPDRVMEMREF
|
---|
298 | {
|
---|
299 | /** The memory object handle. */
|
---|
300 | RTR0MEMOBJ MemObj;
|
---|
301 | /** The ring-3 mapping memory object handle. */
|
---|
302 | RTR0MEMOBJ MapObjR3;
|
---|
303 | /** Type of memory. */
|
---|
304 | SUPDRVMEMREFTYPE eType;
|
---|
305 | } SUPDRVMEMREF, *PSUPDRVMEMREF;
|
---|
306 |
|
---|
307 |
|
---|
308 | /**
|
---|
309 | * Bundle of locked memory ranges.
|
---|
310 | */
|
---|
311 | typedef struct SUPDRVBUNDLE
|
---|
312 | {
|
---|
313 | /** Pointer to the next bundle. */
|
---|
314 | struct SUPDRVBUNDLE * volatile pNext;
|
---|
315 | /** Referenced memory. */
|
---|
316 | SUPDRVMEMREF aMem[64];
|
---|
317 | /** Number of entries used. */
|
---|
318 | uint32_t volatile cUsed;
|
---|
319 | } SUPDRVBUNDLE, *PSUPDRVBUNDLE;
|
---|
320 |
|
---|
321 |
|
---|
322 | /**
|
---|
323 | * Loaded image.
|
---|
324 | */
|
---|
325 | typedef struct SUPDRVLDRIMAGE
|
---|
326 | {
|
---|
327 | /** Next in chain. */
|
---|
328 | struct SUPDRVLDRIMAGE * volatile pNext;
|
---|
329 | /** Pointer to the image. */
|
---|
330 | void *pvImage;
|
---|
331 | /** Pointer to the allocated image buffer.
|
---|
332 | * pvImage is 32-byte aligned or it may governed by the native loader (this
|
---|
333 | * member is NULL then). */
|
---|
334 | void *pvImageAlloc;
|
---|
335 | /** Size of the image including the tables. This is mainly for verification
|
---|
336 | * of the load request. */
|
---|
337 | uint32_t cbImageWithTabs;
|
---|
338 | /** Size of the image. */
|
---|
339 | uint32_t cbImageBits;
|
---|
340 | /** The number of entries in the symbol table. */
|
---|
341 | uint32_t cSymbols;
|
---|
342 | /** Pointer to the symbol table. */
|
---|
343 | PSUPLDRSYM paSymbols;
|
---|
344 | /** The offset of the string table. */
|
---|
345 | char *pachStrTab;
|
---|
346 | /** Size of the string table. */
|
---|
347 | uint32_t cbStrTab;
|
---|
348 | /** Pointer to the optional module initialization callback. */
|
---|
349 | PFNR0MODULEINIT pfnModuleInit;
|
---|
350 | /** Pointer to the optional module termination callback. */
|
---|
351 | PFNR0MODULETERM pfnModuleTerm;
|
---|
352 | /** Service request handler. This is NULL for non-service modules. */
|
---|
353 | PFNSUPR0SERVICEREQHANDLER pfnServiceReqHandler;
|
---|
354 | /** The ldr image state. (IOCtl code of last operation.) */
|
---|
355 | uint32_t uState;
|
---|
356 | /** Usage count. */
|
---|
357 | uint32_t volatile cUsage;
|
---|
358 | /** Pointer to the device extension. */
|
---|
359 | struct SUPDRVDEVEXT *pDevExt;
|
---|
360 | #ifdef RT_OS_WINDOWS
|
---|
361 | /** The section object for the loaded image (fNative=true). */
|
---|
362 | void *pvNtSectionObj;
|
---|
363 | /** Lock object. */
|
---|
364 | RTR0MEMOBJ hMemLock;
|
---|
365 | #endif
|
---|
366 | #if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_NATIVE_SOLARIS_LOADING)
|
---|
367 | /** The Solaris module ID. */
|
---|
368 | int idSolMod;
|
---|
369 | /** Pointer to the module control structure. */
|
---|
370 | struct modctl *pSolModCtl;
|
---|
371 | #endif
|
---|
372 | /** Whether it's loaded by the native loader or not. */
|
---|
373 | bool fNative;
|
---|
374 | /** Image name. */
|
---|
375 | char szName[32];
|
---|
376 | } SUPDRVLDRIMAGE, *PSUPDRVLDRIMAGE;
|
---|
377 |
|
---|
378 |
|
---|
379 | /** Image usage record. */
|
---|
380 | typedef struct SUPDRVLDRUSAGE
|
---|
381 | {
|
---|
382 | /** Next in chain. */
|
---|
383 | struct SUPDRVLDRUSAGE * volatile pNext;
|
---|
384 | /** The image. */
|
---|
385 | PSUPDRVLDRIMAGE pImage;
|
---|
386 | /** Load count. */
|
---|
387 | uint32_t volatile cUsage;
|
---|
388 | } SUPDRVLDRUSAGE, *PSUPDRVLDRUSAGE;
|
---|
389 |
|
---|
390 |
|
---|
391 | /**
|
---|
392 | * Component factory registration record.
|
---|
393 | */
|
---|
394 | typedef struct SUPDRVFACTORYREG
|
---|
395 | {
|
---|
396 | /** Pointer to the next registration. */
|
---|
397 | struct SUPDRVFACTORYREG *pNext;
|
---|
398 | /** Pointer to the registered factory. */
|
---|
399 | PCSUPDRVFACTORY pFactory;
|
---|
400 | /** The session owning the factory.
|
---|
401 | * Used for deregistration and session cleanup. */
|
---|
402 | PSUPDRVSESSION pSession;
|
---|
403 | /** Length of the name. */
|
---|
404 | size_t cchName;
|
---|
405 | } SUPDRVFACTORYREG;
|
---|
406 | /** Pointer to a component factory registration record. */
|
---|
407 | typedef SUPDRVFACTORYREG *PSUPDRVFACTORYREG;
|
---|
408 | /** Pointer to a const component factory registration record. */
|
---|
409 | typedef SUPDRVFACTORYREG const *PCSUPDRVFACTORYREG;
|
---|
410 |
|
---|
411 |
|
---|
412 | /**
|
---|
413 | * Registered object.
|
---|
414 | * This takes care of reference counting and tracking data for access checks.
|
---|
415 | */
|
---|
416 | typedef struct SUPDRVOBJ
|
---|
417 | {
|
---|
418 | /** Magic value (SUPDRVOBJ_MAGIC). */
|
---|
419 | uint32_t u32Magic;
|
---|
420 | /** The object type. */
|
---|
421 | SUPDRVOBJTYPE enmType;
|
---|
422 | /** Pointer to the next in the global list. */
|
---|
423 | struct SUPDRVOBJ * volatile pNext;
|
---|
424 | /** Pointer to the object destructor.
|
---|
425 | * This may be set to NULL if the image containing the destructor get unloaded. */
|
---|
426 | PFNSUPDRVDESTRUCTOR pfnDestructor;
|
---|
427 | /** User argument 1. */
|
---|
428 | void *pvUser1;
|
---|
429 | /** User argument 2. */
|
---|
430 | void *pvUser2;
|
---|
431 | /** The total sum of all per-session usage. */
|
---|
432 | uint32_t volatile cUsage;
|
---|
433 | /** The creator user id. */
|
---|
434 | RTUID CreatorUid;
|
---|
435 | /** The creator group id. */
|
---|
436 | RTGID CreatorGid;
|
---|
437 | /** The creator process id. */
|
---|
438 | RTPROCESS CreatorProcess;
|
---|
439 | } SUPDRVOBJ, *PSUPDRVOBJ;
|
---|
440 |
|
---|
441 | /** Magic number for SUPDRVOBJ::u32Magic. (Dame Agatha Mary Clarissa Christie). */
|
---|
442 | #define SUPDRVOBJ_MAGIC UINT32_C(0x18900915)
|
---|
443 | /** Dead number magic for SUPDRVOBJ::u32Magic. */
|
---|
444 | #define SUPDRVOBJ_MAGIC_DEAD UINT32_C(0x19760112)
|
---|
445 |
|
---|
446 | /**
|
---|
447 | * The per-session object usage record.
|
---|
448 | */
|
---|
449 | typedef struct SUPDRVUSAGE
|
---|
450 | {
|
---|
451 | /** Pointer to the next in the list. */
|
---|
452 | struct SUPDRVUSAGE * volatile pNext;
|
---|
453 | /** Pointer to the object we're recording usage for. */
|
---|
454 | PSUPDRVOBJ pObj;
|
---|
455 | /** The usage count. */
|
---|
456 | uint32_t volatile cUsage;
|
---|
457 | } SUPDRVUSAGE, *PSUPDRVUSAGE;
|
---|
458 |
|
---|
459 |
|
---|
460 | /**
|
---|
461 | * Per session data.
|
---|
462 | * This is mainly for memory tracking.
|
---|
463 | */
|
---|
464 | typedef struct SUPDRVSESSION
|
---|
465 | {
|
---|
466 | /** Pointer to the device extension. */
|
---|
467 | PSUPDRVDEVEXT pDevExt;
|
---|
468 | /** Session Cookie. */
|
---|
469 | uint32_t u32Cookie;
|
---|
470 | /** Set if is an unrestricted session, clear if restricted. */
|
---|
471 | bool fUnrestricted;
|
---|
472 |
|
---|
473 | /** Set if we're in the hash table, clear if not. Protected by the hash
|
---|
474 | * table spinlock. */
|
---|
475 | bool fInHashTable;
|
---|
476 | /** Reference counter. */
|
---|
477 | uint32_t volatile cRefs;
|
---|
478 | /** Pointer to the next session with the same hash (common hash table).
|
---|
479 | * Protected by the hash table spinlock. */
|
---|
480 | PSUPDRVSESSION pCommonNextHash;
|
---|
481 | /** Pointer to the OS specific session pointer, if available and in use.
|
---|
482 | * This is atomically set and cleared as the session is inserted and removed
|
---|
483 | * from the hash table (protected by the session hash table spinlock). */
|
---|
484 | PSUPDRVSESSION *ppOsSessionPtr;
|
---|
485 | /** The process (id) of the session. */
|
---|
486 | RTPROCESS Process;
|
---|
487 | /** Which process this session is associated with.
|
---|
488 | * This is NIL_RTR0PROCESS for kernel sessions and valid for user ones. */
|
---|
489 | RTR0PROCESS R0Process;
|
---|
490 |
|
---|
491 | /** The VM associated with the session. */
|
---|
492 | PVM pVM;
|
---|
493 | /** Handle table for IPRT semaphore wrapper APIs.
|
---|
494 | * This takes care of its own locking in an IRQ safe manner. */
|
---|
495 | RTHANDLETABLE hHandleTable;
|
---|
496 | /** Load usage records. (protected by SUPDRVDEVEXT::mtxLdr) */
|
---|
497 | PSUPDRVLDRUSAGE volatile pLdrUsage;
|
---|
498 |
|
---|
499 | /** Spinlock protecting the bundles, the GIP members and the
|
---|
500 | * fProcessCleanupDone flag. It continues to be valid until the last
|
---|
501 | * reference to the session is released. */
|
---|
502 | RTSPINLOCK Spinlock;
|
---|
503 | /** The ring-3 mapping of the GIP (readonly). */
|
---|
504 | RTR0MEMOBJ GipMapObjR3;
|
---|
505 | /** Set if the session is using the GIP. */
|
---|
506 | uint32_t fGipReferenced;
|
---|
507 | /** Bundle of locked memory objects. */
|
---|
508 | SUPDRVBUNDLE Bundle;
|
---|
509 | /** List of generic usage records. (protected by SUPDRVDEVEXT::SpinLock) */
|
---|
510 | PSUPDRVUSAGE volatile pUsage;
|
---|
511 |
|
---|
512 | /** The user id of the session. (Set by the OS part.) */
|
---|
513 | RTUID Uid;
|
---|
514 | /** The group id of the session. (Set by the OS part.) */
|
---|
515 | RTGID Gid;
|
---|
516 | /** Per session tracer specfic data. */
|
---|
517 | uintptr_t uTracerData;
|
---|
518 | /** The thread currently actively talking to the tracer. (One at the time!) */
|
---|
519 | RTNATIVETHREAD hTracerCaller;
|
---|
520 | /** List of tracepoint providers associated with the session
|
---|
521 | * (SUPDRVTPPROVIDER). */
|
---|
522 | RTLISTANCHOR TpProviders;
|
---|
523 | /** The number of providers in TpProviders. */
|
---|
524 | uint32_t cTpProviders;
|
---|
525 | /** The number of threads active in supdrvIOCtl_TracerUmodProbeFire or
|
---|
526 | * SUPR0TracerUmodProbeFire. */
|
---|
527 | uint32_t volatile cTpProbesFiring;
|
---|
528 | /** User tracepoint modules (PSUPDRVTRACKERUMOD). */
|
---|
529 | RTLISTANCHOR TpUmods;
|
---|
530 | /** The user tracepoint module lookup table. */
|
---|
531 | struct SUPDRVTRACERUMOD *apTpLookupTable[32];
|
---|
532 | #ifndef SUPDRV_AGNOSTIC
|
---|
533 | # if defined(RT_OS_DARWIN)
|
---|
534 | /** Pointer to the associated org_virtualbox_SupDrvClient object. */
|
---|
535 | void *pvSupDrvClient;
|
---|
536 | /** Whether this session has been opened or not. */
|
---|
537 | bool fOpened;
|
---|
538 | # endif
|
---|
539 | # if defined(RT_OS_OS2)
|
---|
540 | /** The system file number of this session. */
|
---|
541 | uint16_t sfn;
|
---|
542 | uint16_t Alignment; /**< Alignment */
|
---|
543 | # endif
|
---|
544 | # if defined(RT_OS_DARWIN) || defined(RT_OS_OS2) || defined(RT_OS_SOLARIS)
|
---|
545 | /** Pointer to the next session with the same hash. */
|
---|
546 | PSUPDRVSESSION pNextHash;
|
---|
547 | # endif
|
---|
548 | # if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_HARDENING)
|
---|
549 | /** Pointer to the process protection structure for this session. */
|
---|
550 | struct SUPDRVNTPROTECT *pNtProtect;
|
---|
551 | # endif
|
---|
552 | #endif /* !SUPDRV_AGNOSTIC */
|
---|
553 | } SUPDRVSESSION;
|
---|
554 |
|
---|
555 |
|
---|
556 | /**
|
---|
557 | * Device extension.
|
---|
558 | */
|
---|
559 | typedef struct SUPDRVDEVEXT
|
---|
560 | {
|
---|
561 | /** Global cookie. */
|
---|
562 | uint32_t u32Cookie;
|
---|
563 | /** The actual size of SUPDRVSESSION. (SUPDRV_AGNOSTIC) */
|
---|
564 | uint32_t cbSession;
|
---|
565 |
|
---|
566 | /** Spinlock to serialize the initialization, usage counting and objects.
|
---|
567 | * This is IRQ safe because we want to be able signal semaphores from the
|
---|
568 | * special HM context (and later maybe interrupt handlers), so we must be able
|
---|
569 | * to reference and dereference handles when IRQs are disabled. */
|
---|
570 | RTSPINLOCK Spinlock;
|
---|
571 |
|
---|
572 | /** List of registered objects. Protected by the spinlock. */
|
---|
573 | PSUPDRVOBJ volatile pObjs;
|
---|
574 | /** List of free object usage records. */
|
---|
575 | PSUPDRVUSAGE volatile pUsageFree;
|
---|
576 |
|
---|
577 | /** Loader mutex.
|
---|
578 | * This protects pvVMMR0, pvVMMR0Entry, pImages and SUPDRVSESSION::pLdrUsage. */
|
---|
579 | #ifdef SUPDRV_USE_MUTEX_FOR_LDR
|
---|
580 | RTSEMMUTEX mtxLdr;
|
---|
581 | #else
|
---|
582 | RTSEMFASTMUTEX mtxLdr;
|
---|
583 | #endif
|
---|
584 |
|
---|
585 | /** VMM Module 'handle'.
|
---|
586 | * 0 if the code VMM isn't loaded and Idt are nops. */
|
---|
587 | void * volatile pvVMMR0;
|
---|
588 | /** VMMR0EntryInt() pointer. */
|
---|
589 | DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryInt, (PVM pVM, unsigned uOperation, void *pvArg));
|
---|
590 | /** VMMR0EntryFast() pointer. */
|
---|
591 | DECLR0CALLBACKMEMBER(void, pfnVMMR0EntryFast, (PVM pVM, VMCPUID idCpu, unsigned uOperation));
|
---|
592 | /** VMMR0EntryEx() pointer. */
|
---|
593 | DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryEx, (PVM pVM, VMCPUID idCpu, unsigned uOperation, PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession));
|
---|
594 |
|
---|
595 | /** Linked list of loaded code. */
|
---|
596 | PSUPDRVLDRIMAGE volatile pLdrImages;
|
---|
597 |
|
---|
598 | /** @name These members for detecting whether an API caller is in ModuleInit.
|
---|
599 | * Certain APIs are only permitted from ModuleInit, like for instance tracepoint
|
---|
600 | * registration.
|
---|
601 | * @{ */
|
---|
602 | /** The image currently executing its ModuleInit. */
|
---|
603 | PSUPDRVLDRIMAGE volatile pLdrInitImage;
|
---|
604 | /** The thread currently executing a ModuleInit function. */
|
---|
605 | RTNATIVETHREAD volatile hLdrInitThread;
|
---|
606 | /** @} */
|
---|
607 |
|
---|
608 |
|
---|
609 | /** GIP mutex.
|
---|
610 | * Any changes to any of the GIP members requires ownership of this mutex,
|
---|
611 | * except on driver init and termination. */
|
---|
612 | #ifdef SUPDRV_USE_MUTEX_FOR_GIP
|
---|
613 | RTSEMMUTEX mtxGip;
|
---|
614 | #else
|
---|
615 | RTSEMFASTMUTEX mtxGip;
|
---|
616 | #endif
|
---|
617 | /** GIP spinlock protecting GIP members during Mp events.
|
---|
618 | * This is IRQ safe since be may get MP callbacks in contexts where IRQs are
|
---|
619 | * disabled (on some platforms). */
|
---|
620 | RTSPINLOCK hGipSpinlock;
|
---|
621 | /** Pointer to the Global Info Page (GIP). */
|
---|
622 | PSUPGLOBALINFOPAGE pGip;
|
---|
623 | /** The physical address of the GIP. */
|
---|
624 | RTHCPHYS HCPhysGip;
|
---|
625 | /** Number of processes using the GIP.
|
---|
626 | * (The updates are suspend while cGipUsers is 0.)*/
|
---|
627 | uint32_t volatile cGipUsers;
|
---|
628 | /** The ring-0 memory object handle for the GIP page. */
|
---|
629 | RTR0MEMOBJ GipMemObj;
|
---|
630 | /** The GIP timer handle. */
|
---|
631 | PRTTIMER pGipTimer;
|
---|
632 | /** If non-zero we've successfully called RTTimerRequestSystemGranularity(). */
|
---|
633 | uint32_t u32SystemTimerGranularityGrant;
|
---|
634 | /** The CPU id of the GIP master.
|
---|
635 | * This CPU is responsible for the updating the common GIP data. */
|
---|
636 | RTCPUID volatile idGipMaster;
|
---|
637 |
|
---|
638 | /** Component factory mutex.
|
---|
639 | * This protects pComponentFactoryHead and component factory querying. */
|
---|
640 | RTSEMFASTMUTEX mtxComponentFactory;
|
---|
641 | /** The head of the list of registered component factories. */
|
---|
642 | PSUPDRVFACTORYREG pComponentFactoryHead;
|
---|
643 |
|
---|
644 | /** Lock protecting The tracer members. */
|
---|
645 | RTSEMFASTMUTEX mtxTracer;
|
---|
646 | /** List of tracer providers (SUPDRVTPPROVIDER). */
|
---|
647 | RTLISTANCHOR TracerProviderList;
|
---|
648 | /** List of zombie tracer providers (SUPDRVTPPROVIDER). */
|
---|
649 | RTLISTANCHOR TracerProviderZombieList;
|
---|
650 | /** Pointer to the tracer registration record. */
|
---|
651 | PCSUPDRVTRACERREG pTracerOps;
|
---|
652 | /** The ring-0 session of a native tracer provider. */
|
---|
653 | PSUPDRVSESSION pTracerSession;
|
---|
654 | /** The image containing the tracer. */
|
---|
655 | PSUPDRVLDRIMAGE pTracerImage;
|
---|
656 | /** The tracer helpers. */
|
---|
657 | SUPDRVTRACERHLP TracerHlp;
|
---|
658 | /** The number of session having opened the tracer currently. */
|
---|
659 | uint32_t cTracerOpens;
|
---|
660 | /** The number of threads currently calling into the tracer. */
|
---|
661 | uint32_t volatile cTracerCallers;
|
---|
662 | /** Set if the tracer is being unloaded. */
|
---|
663 | bool fTracerUnloading;
|
---|
664 | /** Hash table for user tracer modules (SUPDRVVTGCOPY). */
|
---|
665 | RTLISTANCHOR aTrackerUmodHash[128];
|
---|
666 |
|
---|
667 | /** @name Session Handle Table.
|
---|
668 | * @{ */
|
---|
669 | /** Spinlock protecting apSessionHashTab, cSessions,
|
---|
670 | * SUPDRVSESSION::ppOsSessionPtr, SUPDRVSESSION::pCommonNextHash, and possibly
|
---|
671 | * others depending on the OS. */
|
---|
672 | RTSPINLOCK hSessionHashTabSpinlock;
|
---|
673 | /** Session hash table hash table. The size of this table must make sense in
|
---|
674 | * comparison to GVMM_MAX_HANDLES. */
|
---|
675 | PSUPDRVSESSION apSessionHashTab[HC_ARCH_BITS == 64 ? 8191 : 127];
|
---|
676 | /** The number of open sessions. */
|
---|
677 | int32_t cSessions;
|
---|
678 | /** @} */
|
---|
679 |
|
---|
680 | #ifdef SUPDRV_USE_TSC_DELTA_THREAD
|
---|
681 | /** @name TSC-delta measurement.
|
---|
682 | * @{ */
|
---|
683 | /** Spinlock protecting enmTscDeltaState. */
|
---|
684 | RTSPINLOCK hTscDeltaSpinlock;
|
---|
685 | /** TSC-delta measurement thread. */
|
---|
686 | RTTHREAD hTscDeltaThread;
|
---|
687 | /** The event signalled during state changes to the TSC-delta thread. */
|
---|
688 | RTSEMEVENT hTscDeltaEvent;
|
---|
689 | /** The state of the TSC-delta measurement thread. */
|
---|
690 | SUPDRVTSCDELTASTATE enmTscDeltaState;
|
---|
691 | /** Thread timeout time before rechecking state in ms. */
|
---|
692 | RTMSINTERVAL cMsTscDeltaTimeout;
|
---|
693 | /** The set of CPUs we need to take measurements for. */
|
---|
694 | RTCPUSET TscDeltaCpuSet;
|
---|
695 | /** Whether the TSC-delta measurement was successful. */
|
---|
696 | int rcTscDelta;
|
---|
697 | /** @} */
|
---|
698 | #endif
|
---|
699 |
|
---|
700 | /*
|
---|
701 | * Note! The non-agnostic bits must be at the very end of the structure!
|
---|
702 | */
|
---|
703 | #ifndef SUPDRV_AGNOSTIC
|
---|
704 | # ifdef RT_OS_WINDOWS
|
---|
705 | /** Callback object returned by ExCreateCallback. */
|
---|
706 | PCALLBACK_OBJECT pObjPowerCallback;
|
---|
707 | /** Callback handle returned by ExRegisterCallback. */
|
---|
708 | PVOID hPowerCallback;
|
---|
709 | # endif
|
---|
710 | #endif
|
---|
711 | } SUPDRVDEVEXT;
|
---|
712 |
|
---|
713 | /** Calculates the index into g_apSessionHashTab.*/
|
---|
714 | #define SUPDRV_SESSION_HASH(a_pid) ( (a_pid) % RT_ELEMENTS(((SUPDRVDEVEXT *)NULL)->apSessionHashTab) )
|
---|
715 |
|
---|
716 |
|
---|
717 | RT_C_DECLS_BEGIN
|
---|
718 |
|
---|
719 | /*******************************************************************************
|
---|
720 | * OS Specific Functions *
|
---|
721 | *******************************************************************************/
|
---|
722 | /**
|
---|
723 | * Called to clean up the session structure before it's freed.
|
---|
724 | *
|
---|
725 | * @param pDevExt The device globals.
|
---|
726 | * @param pSession The session that's being cleaned up.
|
---|
727 | */
|
---|
728 | void VBOXCALL supdrvOSCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
|
---|
729 |
|
---|
730 | /**
|
---|
731 | * Called to let the OS specfic code perform additional insertion work while
|
---|
732 | * still under the protection of the hash table spinlock.
|
---|
733 | *
|
---|
734 | * @param pDevExt The device globals.
|
---|
735 | * @param pSession The session that was inserted.
|
---|
736 | * @param pvUser User context specified to the insert call.
|
---|
737 | */
|
---|
738 | void VBOXCALL supdrvOSSessionHashTabInserted(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser);
|
---|
739 |
|
---|
740 | /**
|
---|
741 | * Called to let the OS specfic code perform additional removal work while still
|
---|
742 | * under the protection of the hash table spinlock.
|
---|
743 | *
|
---|
744 | * @param pDevExt The device globals.
|
---|
745 | * @param pSession The session that was removed.
|
---|
746 | * @param pvUser User context specified to the remove call.
|
---|
747 | */
|
---|
748 | void VBOXCALL supdrvOSSessionHashTabRemoved(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser);
|
---|
749 |
|
---|
750 | void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession);
|
---|
751 | bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
|
---|
752 | bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt);
|
---|
753 | int VBOXCALL supdrvOSEnableVTx(bool fEnabled);
|
---|
754 | bool VBOXCALL supdrvOSSuspendVTxOnCpu(void);
|
---|
755 | void VBOXCALL supdrvOSResumeVTxOnCpu(bool fSuspended);
|
---|
756 |
|
---|
757 | /**
|
---|
758 | * Try open the image using the native loader.
|
---|
759 | *
|
---|
760 | * @returns IPRT status code.
|
---|
761 | * @retval VERR_NOT_SUPPORTED if native loading isn't supported.
|
---|
762 | *
|
---|
763 | * @param pDevExt The device globals.
|
---|
764 | * @param pImage The image handle. pvImage should be set on
|
---|
765 | * success, pvImageAlloc can also be set if
|
---|
766 | * appropriate.
|
---|
767 | * @param pszFilename The file name - UTF-8, may containing UNIX
|
---|
768 | * slashes on non-UNIX systems.
|
---|
769 | */
|
---|
770 | int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename);
|
---|
771 |
|
---|
772 | /**
|
---|
773 | * Notification call indicating that a image is being opened for the first time.
|
---|
774 | *
|
---|
775 | * Can be used to log the load address of the image.
|
---|
776 | *
|
---|
777 | * @param pDevExt The device globals.
|
---|
778 | * @param pImage The image handle.
|
---|
779 | */
|
---|
780 | void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);
|
---|
781 |
|
---|
782 | /**
|
---|
783 | * Validates an entry point address.
|
---|
784 | *
|
---|
785 | * Called before supdrvOSLdrLoad.
|
---|
786 | *
|
---|
787 | * @returns IPRT status code.
|
---|
788 | * @param pDevExt The device globals.
|
---|
789 | * @param pImage The image data (still in the open state).
|
---|
790 | * @param pv The address within the image.
|
---|
791 | * @param pbImageBits The image bits as loaded by ring-3.
|
---|
792 | */
|
---|
793 | int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage,
|
---|
794 | void *pv, const uint8_t *pbImageBits);
|
---|
795 |
|
---|
796 | /**
|
---|
797 | * Load the image.
|
---|
798 | *
|
---|
799 | * @returns IPRT status code.
|
---|
800 | * @param pDevExt The device globals.
|
---|
801 | * @param pImage The image data (up to date). Adjust entrypoints
|
---|
802 | * and exports if necessary.
|
---|
803 | * @param pbImageBits The image bits as loaded by ring-3.
|
---|
804 | * @param pReq Pointer to the request packet so that the VMMR0
|
---|
805 | * entry points can be adjusted.
|
---|
806 | */
|
---|
807 | int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq);
|
---|
808 |
|
---|
809 |
|
---|
810 | /**
|
---|
811 | * Unload the image.
|
---|
812 | *
|
---|
813 | * @param pDevExt The device globals.
|
---|
814 | * @param pImage The image data (mostly still valid).
|
---|
815 | */
|
---|
816 | void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);
|
---|
817 |
|
---|
818 |
|
---|
819 | #ifdef SUPDRV_WITH_MSR_PROBER
|
---|
820 |
|
---|
821 | /**
|
---|
822 | * Tries to read an MSR.
|
---|
823 | *
|
---|
824 | * @returns One of the listed VBox status codes.
|
---|
825 | * @retval VINF_SUCCESS if read successfully, value in *puValue.
|
---|
826 | * @retval VERR_ACCESS_DENIED if we couldn't read it (GP).
|
---|
827 | * @retval VERR_NOT_SUPPORTED if not supported.
|
---|
828 | *
|
---|
829 | * @param uMsr The MSR to read from.
|
---|
830 | * @param idCpu The CPU to read the MSR on. NIL_RTCPUID
|
---|
831 | * indicates any suitable CPU.
|
---|
832 | * @param puValue Where to return the value.
|
---|
833 | */
|
---|
834 | int VBOXCALL supdrvOSMsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue);
|
---|
835 |
|
---|
836 | /**
|
---|
837 | * Tries to write an MSR.
|
---|
838 | *
|
---|
839 | * @returns One of the listed VBox status codes.
|
---|
840 | * @retval VINF_SUCCESS if written successfully.
|
---|
841 | * @retval VERR_ACCESS_DENIED if we couldn't write the value to it (GP).
|
---|
842 | * @retval VERR_NOT_SUPPORTED if not supported.
|
---|
843 | *
|
---|
844 | * @param uMsr The MSR to write to.
|
---|
845 | * @param idCpu The CPU to write the MSR on. NIL_RTCPUID
|
---|
846 | * indicates any suitable CPU.
|
---|
847 | * @param uValue The value to write.
|
---|
848 | */
|
---|
849 | int VBOXCALL supdrvOSMsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue);
|
---|
850 |
|
---|
851 | /**
|
---|
852 | * Tries to modify an MSR value.
|
---|
853 | *
|
---|
854 | * @returns One of the listed VBox status codes.
|
---|
855 | * @retval VINF_SUCCESS if succeeded.
|
---|
856 | * @retval VERR_NOT_SUPPORTED if not supported.
|
---|
857 | *
|
---|
858 | * @param idCpu The CPU to modify the MSR on. NIL_RTCPUID
|
---|
859 | * indicates any suitable CPU.
|
---|
860 | * @param pReq The request packet with input arguments and
|
---|
861 | * where to store the results.
|
---|
862 | */
|
---|
863 | int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu, PSUPMSRPROBER pReq);
|
---|
864 |
|
---|
865 | #endif /* SUPDRV_WITH_MSR_PROBER */
|
---|
866 |
|
---|
867 | #if defined(RT_OS_DARWIN)
|
---|
868 | int VBOXCALL supdrvDarwinResumeSuspendedKbds(void);
|
---|
869 | #endif
|
---|
870 |
|
---|
871 | /*******************************************************************************
|
---|
872 | * Shared Functions *
|
---|
873 | *******************************************************************************/
|
---|
874 | /* SUPDrv.c */
|
---|
875 | int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr, size_t cbReq);
|
---|
876 | int VBOXCALL supdrvIOCtlFast(uintptr_t uIOCtl, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
|
---|
877 | int VBOXCALL supdrvIDC(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr);
|
---|
878 | int VBOXCALL supdrvInitDevExt(PSUPDRVDEVEXT pDevExt, size_t cbSession);
|
---|
879 | void VBOXCALL supdrvDeleteDevExt(PSUPDRVDEVEXT pDevExt);
|
---|
880 | int VBOXCALL supdrvCreateSession(PSUPDRVDEVEXT pDevExt, bool fUser, bool fUnrestricted, PSUPDRVSESSION *ppSession);
|
---|
881 | int VBOXCALL supdrvSessionHashTabInsert(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVSESSION *ppOsSessionPtr, void *pvUser);
|
---|
882 | int VBOXCALL supdrvSessionHashTabRemove(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser);
|
---|
883 | PSUPDRVSESSION VBOXCALL supdrvSessionHashTabLookup(PSUPDRVDEVEXT pDevExt, RTPROCESS Process, RTR0PROCESS R0Process,
|
---|
884 | PSUPDRVSESSION *ppOsSessionPtr);
|
---|
885 | uint32_t VBOXCALL supdrvSessionRetain(PSUPDRVSESSION pSession);
|
---|
886 | uint32_t VBOXCALL supdrvSessionRelease(PSUPDRVSESSION pSession);
|
---|
887 |
|
---|
888 | int VBOXCALL supdrvTracerInit(PSUPDRVDEVEXT pDevExt);
|
---|
889 | void VBOXCALL supdrvTracerTerm(PSUPDRVDEVEXT pDevExt);
|
---|
890 | void VBOXCALL supdrvTracerModuleUnloading(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);
|
---|
891 | void VBOXCALL supdrvTracerCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
|
---|
892 | int VBOXCALL supdrvIOCtl_TracerUmodRegister(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession,
|
---|
893 | RTR3PTR R3PtrVtgHdr, RTUINTPTR uVtgHdrAddr,
|
---|
894 | RTR3PTR R3PtrStrTab, uint32_t cbStrTab,
|
---|
895 | const char *pszModName, uint32_t fFlags);
|
---|
896 | int VBOXCALL supdrvIOCtl_TracerUmodDeregister(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, RTR3PTR R3PtrVtgHdr);
|
---|
897 | void VBOXCALL supdrvIOCtl_TracerUmodProbeFire(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVTRACERUSRCTX pCtx);
|
---|
898 | int VBOXCALL supdrvIOCtl_TracerOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, uint32_t uCookie, uintptr_t uArg);
|
---|
899 | int VBOXCALL supdrvIOCtl_TracerClose(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
|
---|
900 | int VBOXCALL supdrvIOCtl_TracerIOCtl(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal);
|
---|
901 | extern PFNRT g_pfnSupdrvProbeFireKernel;
|
---|
902 | DECLASM(void) supdrvTracerProbeFireStub(void);
|
---|
903 |
|
---|
904 | #ifdef VBOX_WITH_NATIVE_DTRACE
|
---|
905 | const SUPDRVTRACERREG * VBOXCALL supdrvDTraceInit(void);
|
---|
906 | #endif
|
---|
907 |
|
---|
908 | RT_C_DECLS_END
|
---|
909 |
|
---|
910 | #endif
|
---|
911 |
|
---|