VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/SUPDrvInternal.h@ 87700

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

SUPDrv,++: Experimental support for wrapping .r0 modules in native kernel modules on linux, so that perf and similar tools work better. Minor IOC version increase as SUP_IOCTL_LDR_OPEN now support just opening a module w/o preparing the loading. SUPDrv must export all the symbols in g_aFunctions the linux way now, or linux won't see them, so introduced a SUPR0_EXPORT_SYMBOL macro similar to RT_EXPORT_SYMBOL. bugref:9937

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 46.1 KB
Line 
1/* $Id: SUPDrvInternal.h 87700 2021-02-10 20:21:04Z vboxsync $ */
2/** @file
3 * VirtualBox Support Driver - Internal header.
4 */
5
6/*
7 * Copyright (C) 2006-2020 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 VBOX_INCLUDED_SRC_Support_SUPDrvInternal_h
28#define VBOX_INCLUDED_SRC_Support_SUPDrvInternal_h
29#ifndef RT_WITHOUT_PRAGMA_ONCE
30# pragma once
31#endif
32
33
34/*********************************************************************************************************************************
35* Header Files *
36*********************************************************************************************************************************/
37#include <VBox/cdefs.h>
38#include <VBox/types.h>
39#include <VBox/sup.h>
40
41#include <iprt/assert.h>
42#include <iprt/list.h>
43#include <iprt/memobj.h>
44#include <iprt/time.h>
45#include <iprt/timer.h>
46#include <iprt/string.h>
47#include <iprt/err.h>
48
49#if defined(SUPDRV_AGNOSTIC) && !defined(RT_OS_LINUX)
50/* do nothing */
51
52#elif defined(RT_OS_WINDOWS)
53# include <iprt/nt/nt.h>
54# include <memory.h>
55
56#elif defined(RT_OS_LINUX)
57# include <iprt/linux/version.h>
58# if RTLNX_VER_MIN(2,6,33)
59# include <generated/autoconf.h>
60# else
61# ifndef AUTOCONF_INCLUDED
62# include <linux/autoconf.h>
63# endif
64# endif
65# if defined(CONFIG_MODVERSIONS) && !defined(MODVERSIONS)
66# define MODVERSIONS
67# if RTLNX_VER_MAX(2,5,71)
68# include <linux/modversions.h>
69# endif
70# endif
71# ifndef KBUILD_STR
72# if RTLNX_VER_MAX(2,6,16)
73# define KBUILD_STR(s) s
74# else
75# define KBUILD_STR(s) #s
76# endif
77# endif
78# ifndef SUPDRV_AGNOSTIC
79# include <linux/string.h>
80# include <linux/spinlock.h>
81# include <linux/slab.h>
82# if RTLNX_VER_MIN(2,6,27)
83# include <linux/semaphore.h>
84# else /* older kernels */
85# include <asm/semaphore.h>
86# endif /* older kernels */
87# include <linux/timer.h>
88# endif
89# if RTLNX_VER_MIN(3,2,0)
90# include <linux/export.h>
91# else
92# include <linux/module.h>
93# endif
94# define SUPR0_EXPORT_SYMBOL(a_Name) EXPORT_SYMBOL(a_Name)
95
96#elif defined(RT_OS_DARWIN)
97# include <libkern/libkern.h>
98# include <iprt/string.h>
99
100#elif defined(RT_OS_OS2)
101
102#elif defined(RT_OS_FREEBSD)
103# define memset libkern_memset /** @todo these are just hacks to get it compiling, check out later. */
104# define memcmp libkern_memcmp
105# define strchr libkern_strchr
106# define strrchr libkern_strrchr
107# define ffsl libkern_ffsl
108# define fls libkern_fls
109# define flsl libkern_flsl
110# include <sys/libkern.h>
111# undef memset
112# undef memcmp
113# undef strchr
114# undef strrchr
115# undef ffs
116# undef ffsl
117# undef fls
118# undef flsl
119# include <iprt/string.h>
120
121#elif defined(RT_OS_SOLARIS)
122# include <sys/cmn_err.h>
123# include <iprt/string.h>
124
125#else
126# error "unsupported OS."
127#endif
128
129#include "SUPDrvIOC.h"
130#include "SUPDrvIDC.h"
131
132
133
134/*********************************************************************************************************************************
135* Defined Constants And Macros *
136*********************************************************************************************************************************/
137/*
138 * Hardcoded cookies.
139 */
140#define BIRD 0x64726962 /* 'bird' */
141#define BIRD_INV 0x62697264 /* 'drib' */
142
143
144#ifdef RT_OS_WINDOWS
145/** Use a normal mutex for the loader so we remain at the same IRQL after
146 * taking it.
147 * @todo fix the mutex implementation on linux and make this the default. */
148# define SUPDRV_USE_MUTEX_FOR_LDR
149
150/** Use a normal mutex for the GIP so we remain at the same IRQL after
151 * taking it.
152 * @todo fix the mutex implementation on linux and make this the default. */
153# define SUPDRV_USE_MUTEX_FOR_GIP
154#endif
155
156#if defined(RT_OS_LINUX) /** @todo make everyone do this */
157/** Use the RTR0MemObj API rather than the RTMemExecAlloc for the images.
158 * This is a good idea in general, but a necessity for @bugref{9801}. */
159# define SUPDRV_USE_MEMOBJ_FOR_LDR_IMAGE
160#endif
161
162#ifndef SUPR0_EXPORT_SYMBOL
163# define SUPR0_EXPORT_SYMBOL(a_Name) extern int g_supDrvExportSymbolDummyVariable
164#endif
165
166/**
167 * OS debug print macro.
168 */
169#define OSDBGPRINT(a) SUPR0Printf a
170
171/** Debug printf macro shared with the ring-3 part. */
172#ifdef DEBUG_bird
173# define SUP_DPRINTF(a) SUPR0Printf a
174#else
175# define SUP_DPRINTF(a) do { } while (0)
176#endif
177
178
179/** @name Context values for the per-session handle tables.
180 * The context value is used to distinguish between the different kinds of
181 * handles, making the handle table API do all the work.
182 * @{ */
183/** Handle context value for single release event handles. */
184#define SUPDRV_HANDLE_CTX_EVENT ((void *)(uintptr_t)(SUPDRVOBJTYPE_SEM_EVENT))
185/** Handle context value for multiple release event handles. */
186#define SUPDRV_HANDLE_CTX_EVENT_MULTI ((void *)(uintptr_t)(SUPDRVOBJTYPE_SEM_EVENT_MULTI))
187/** @} */
188
189
190/**
191 * Validates a session pointer.
192 *
193 * @returns true/false accordingly.
194 * @param pSession The session.
195 */
196#define SUP_IS_SESSION_VALID(pSession) \
197 ( VALID_PTR(pSession) \
198 && pSession->u32Cookie == BIRD_INV)
199
200/**
201 * Validates a device extension pointer.
202 *
203 * @returns true/false accordingly.
204 * @param pDevExt The device extension.
205 */
206#define SUP_IS_DEVEXT_VALID(pDevExt) \
207 ( VALID_PTR(pDevExt)\
208 && pDevExt->u32Cookie == BIRD)
209
210
211/** @def SUPDRV_WITH_MSR_PROBER
212 * Enables the SUP_IOCTL_MSR_PROBER function.
213 * By default, only enabled in DEBUG builds as it's a sensitive feature.
214 */
215#if defined(DEBUG) && !defined(SUPDRV_WITH_MSR_PROBER) && !defined(SUPDRV_WITHOUT_MSR_PROBER)
216# define SUPDRV_WITH_MSR_PROBER
217#endif
218
219/** @def SUPDRV_WITHOUT_MSR_PROBER
220 * Executive overide for disabling the SUP_IOCTL_MSR_PROBER function.
221 */
222#ifdef SUPDRV_WITHOUT_MSR_PROBER
223# undef SUPDRV_WITH_MSR_PROBER
224#endif
225
226#ifdef DOXYGEN_RUNNING
227# define SUPDRV_WITH_MSR_PROBER
228# define SUPDRV_WITHOUT_MSR_PROBER
229#endif
230
231#if 1
232/** @def SUPDRV_USE_TSC_DELTA_THREAD
233 * Use a dedicated kernel thread to service TSC-delta measurement requests.
234 * @todo Test on servers with many CPUs and sockets. */
235# define SUPDRV_USE_TSC_DELTA_THREAD
236#endif
237
238
239/*********************************************************************************************************************************
240* Structures and Typedefs *
241*********************************************************************************************************************************/
242/** Pointer to the device extension. */
243typedef struct SUPDRVDEVEXT *PSUPDRVDEVEXT;
244
245#ifdef SUPDRV_USE_TSC_DELTA_THREAD
246/**
247 * TSC-delta measurement thread state machine.
248 */
249typedef enum SUPDRVTSCDELTATHREADSTATE
250{
251 /** Uninitialized/invalid value. */
252 kTscDeltaThreadState_Invalid = 0,
253 /** The thread is being created.
254 * Next state: Listening, Butchered, Terminating */
255 kTscDeltaThreadState_Creating,
256 /** The thread is listening for events.
257 * Previous state: Creating, Measuring
258 * Next state: WaitAndMeasure, Butchered, Terminated */
259 kTscDeltaThreadState_Listening,
260 /** The thread is sleeping before starting a measurement.
261 * Previous state: Listening, Measuring
262 * Next state: Measuring, Butchered, Terminating
263 * @remarks The thread won't enter this state on its own, it is put into this
264 * state by the GIP timer, the CPU online callback and by the
265 * SUP_IOCTL_TSC_DELTA_MEASURE code. */
266 kTscDeltaThreadState_WaitAndMeasure,
267 /** The thread is currently servicing a measurement request.
268 * Previous state: WaitAndMeasure
269 * Next state: Listening, WaitAndMeasure, Terminate */
270 kTscDeltaThreadState_Measuring,
271 /** The thread is terminating.
272 * @remarks The thread won't enter this state on its own, is put into this state
273 * by supdrvTscDeltaTerm. */
274 kTscDeltaThreadState_Terminating,
275 /** The thread is butchered due to an unexpected error.
276 * Previous State: Creating, Listening, WaitAndMeasure */
277 kTscDeltaThreadState_Butchered,
278 /** The thread is destroyed (final).
279 * Previous state: Terminating */
280 kTscDeltaThreadState_Destroyed,
281 /** The usual 32-bit blowup hack. */
282 kTscDeltaThreadState_32BitHack = 0x7fffffff
283} SUPDRVTSCDELTATHREADSTATE;
284#endif /* SUPDRV_USE_TSC_DELTA_THREAD */
285
286/**
287 * Memory reference types.
288 */
289typedef enum
290{
291 /** Unused entry */
292 MEMREF_TYPE_UNUSED = 0,
293 /** Locked memory (r3 mapping only). */
294 MEMREF_TYPE_LOCKED,
295 /** Continuous memory block (r3 and r0 mapping). */
296 MEMREF_TYPE_CONT,
297 /** Low memory block (r3 and r0 mapping). */
298 MEMREF_TYPE_LOW,
299 /** Memory block (r3 and r0 mapping). */
300 MEMREF_TYPE_MEM,
301 /** Locked memory (r3 mapping only) allocated by the support driver. */
302 MEMREF_TYPE_PAGE,
303 /** Blow the type up to 32-bit and mark the end. */
304 MEMREF_TYPE_32BIT_HACK = 0x7fffffff
305} SUPDRVMEMREFTYPE, *PSUPDRVMEMREFTYPE;
306
307
308/**
309 * Structure used for tracking memory a session
310 * references in one way or another.
311 */
312typedef struct SUPDRVMEMREF
313{
314 /** The memory object handle. */
315 RTR0MEMOBJ MemObj;
316 /** The ring-3 mapping memory object handle. */
317 RTR0MEMOBJ MapObjR3;
318 /** Type of memory. */
319 SUPDRVMEMREFTYPE eType;
320} SUPDRVMEMREF, *PSUPDRVMEMREF;
321
322
323/**
324 * Bundle of locked memory ranges.
325 */
326typedef struct SUPDRVBUNDLE
327{
328 /** Pointer to the next bundle. */
329 struct SUPDRVBUNDLE * volatile pNext;
330 /** Referenced memory. */
331 SUPDRVMEMREF aMem[64];
332 /** Number of entries used. */
333 uint32_t volatile cUsed;
334} SUPDRVBUNDLE, *PSUPDRVBUNDLE;
335
336
337/**
338 * Loaded image.
339 */
340typedef struct SUPDRVLDRIMAGE
341{
342 /** Next in chain. */
343 struct SUPDRVLDRIMAGE * volatile pNext;
344 /** Pointer to the image. */
345 void *pvImage;
346#ifdef SUPDRV_USE_MEMOBJ_FOR_LDR_IMAGE
347 /** The memory object for the module allocation. */
348 RTR0MEMOBJ hMemObjImage;
349#else
350 /** Pointer to the allocated image buffer.
351 * pvImage is 32-byte aligned or it may governed by the native loader (this
352 * member is NULL then). */
353 void *pvImageAlloc;
354#endif
355 /** Magic value (SUPDRVLDRIMAGE_MAGIC). */
356 uint32_t uMagic;
357 /** Size of the image including the tables. This is mainly for verification
358 * of the load request. */
359 uint32_t cbImageWithEverything;
360 /** Size of the image. */
361 uint32_t cbImageBits;
362 /** The number of entries in the symbol table. */
363 uint32_t cSymbols;
364 /** Pointer to the symbol table. */
365 PSUPLDRSYM paSymbols;
366 /** The offset of the string table. */
367 char *pachStrTab;
368 /** Size of the string table. */
369 uint32_t cbStrTab;
370 /** Number of segments. */
371 uint32_t cSegments;
372 /** Segments (for memory protection). */
373 PSUPLDRSEG paSegments;
374 /** Pointer to the optional module initialization callback. */
375 PFNR0MODULEINIT pfnModuleInit;
376 /** Pointer to the optional module termination callback. */
377 PFNR0MODULETERM pfnModuleTerm;
378 /** Service request handler. This is NULL for non-service modules. */
379 PFNSUPR0SERVICEREQHANDLER pfnServiceReqHandler;
380 /** The ldr image state. (IOCtl code of last operation.) */
381 uint32_t uState;
382 /** Usage count. */
383 uint32_t volatile cImgUsage;
384 /** Pointer to the device extension. */
385 struct SUPDRVDEVEXT *pDevExt;
386 /** Image (VMMR0.r0) containing functions/data that this one uses. */
387 struct SUPDRVLDRIMAGE *pImageImport;
388#ifdef RT_OS_WINDOWS
389 /** The section object for the loaded image (fNative=true). */
390 void *pvNtSectionObj;
391 /** Lock object. */
392 RTR0MEMOBJ hMemLock;
393#endif
394#if defined(RT_OS_SOLARIS) && defined(VBOX_WITH_NATIVE_SOLARIS_LOADING)
395 /** The Solaris module ID. */
396 int idSolMod;
397 /** Pointer to the module control structure. */
398 struct modctl *pSolModCtl;
399#endif
400#ifdef RT_OS_LINUX
401 /** Hack for seeing the module in perf, dtrace and other stack crawlers. */
402 struct module *pLnxModHack;
403 /** The wrapper module. */
404 struct module *pLnxWrapperModule;
405 /** Set if we're holding a reference to the wrapper module. */
406 bool fLnxWrapperRef;
407#endif
408#if defined(RT_OS_DARWIN) && defined(VBOX_WITH_DARWIN_R0_DARWIN_IMAGE_VERIFICATION)
409 /** Load module handle. */
410 RTLDRMOD hLdrMod;
411 /** Allocate object. */
412 RTR0MEMOBJ hMemAlloc;
413#endif
414 /** This points to the module info if the image is a wrapped up in a native one. */
415 PCSUPLDRWRAPPEDMODULE pWrappedModInfo;
416 /** OS specific information for wrapped modules. */
417 void *pvWrappedNative;
418 /** Whether it's loaded by the native loader or not. */
419 bool fNative;
420 /** Image name. */
421 char szName[32];
422} SUPDRVLDRIMAGE, *PSUPDRVLDRIMAGE;
423
424/** Magic value for SUPDRVLDRIMAGE::uMagic (Charlotte Bronte). */
425#define SUPDRVLDRIMAGE_MAGIC UINT32_C(0x18160421)
426/** Magic value for SUPDRVLDRIMAGE::uMagic when freed. */
427#define SUPDRVLDRIMAGE_MAGIC_DEAD UINT32_C(0x18550331)
428
429
430/** Image usage record. */
431typedef struct SUPDRVLDRUSAGE
432{
433 /** Next in chain. */
434 struct SUPDRVLDRUSAGE * volatile pNext;
435 /** The image. */
436 PSUPDRVLDRIMAGE pImage;
437 /** Load count (ring-3). */
438 uint32_t volatile cRing3Usage;
439 /** Ring-0 usage counter. */
440 uint32_t volatile cRing0Usage;
441} SUPDRVLDRUSAGE, *PSUPDRVLDRUSAGE;
442
443
444/**
445 * Component factory registration record.
446 */
447typedef struct SUPDRVFACTORYREG
448{
449 /** Pointer to the next registration. */
450 struct SUPDRVFACTORYREG *pNext;
451 /** Pointer to the registered factory. */
452 PCSUPDRVFACTORY pFactory;
453 /** The session owning the factory.
454 * Used for deregistration and session cleanup. */
455 PSUPDRVSESSION pSession;
456 /** Length of the name. */
457 size_t cchName;
458} SUPDRVFACTORYREG;
459/** Pointer to a component factory registration record. */
460typedef SUPDRVFACTORYREG *PSUPDRVFACTORYREG;
461/** Pointer to a const component factory registration record. */
462typedef SUPDRVFACTORYREG const *PCSUPDRVFACTORYREG;
463
464
465/**
466 * Registered object.
467 * This takes care of reference counting and tracking data for access checks.
468 */
469typedef struct SUPDRVOBJ
470{
471 /** Magic value (SUPDRVOBJ_MAGIC). */
472 uint32_t u32Magic;
473 /** The object type. */
474 SUPDRVOBJTYPE enmType;
475 /** Pointer to the next in the global list. */
476 struct SUPDRVOBJ * volatile pNext;
477 /** Pointer to the object destructor.
478 * This may be set to NULL if the image containing the destructor get unloaded. */
479 PFNSUPDRVDESTRUCTOR pfnDestructor;
480 /** User argument 1. */
481 void *pvUser1;
482 /** User argument 2. */
483 void *pvUser2;
484 /** The total sum of all per-session usage. */
485 uint32_t volatile cUsage;
486 /** The creator user id. */
487 RTUID CreatorUid;
488 /** The creator group id. */
489 RTGID CreatorGid;
490 /** The creator process id. */
491 RTPROCESS CreatorProcess;
492} SUPDRVOBJ, *PSUPDRVOBJ;
493
494/** Magic number for SUPDRVOBJ::u32Magic. (Dame Agatha Mary Clarissa Christie). */
495#define SUPDRVOBJ_MAGIC UINT32_C(0x18900915)
496/** Dead number magic for SUPDRVOBJ::u32Magic. */
497#define SUPDRVOBJ_MAGIC_DEAD UINT32_C(0x19760112)
498
499/**
500 * The per-session object usage record.
501 */
502typedef struct SUPDRVUSAGE
503{
504 /** Pointer to the next in the list. */
505 struct SUPDRVUSAGE * volatile pNext;
506 /** Pointer to the object we're recording usage for. */
507 PSUPDRVOBJ pObj;
508 /** The usage count. */
509 uint32_t volatile cUsage;
510} SUPDRVUSAGE, *PSUPDRVUSAGE;
511
512
513/**
514 * I/O control context.
515 */
516typedef struct SUPR0IOCTLCTX
517{
518 /** Magic value (SUPR0IOCTLCTX_MAGIC). */
519 uint32_t u32Magic;
520 /** Reference counter. */
521 uint32_t volatile cRefs;
522#ifdef RT_OS_WINDOWS
523# ifndef SUPDRV_AGNOSTIC
524 /** The file object, referenced. */
525 PFILE_OBJECT pFileObject;
526 /** The device object, not referenced. */
527 PDEVICE_OBJECT pDeviceObject;
528 /** Pointer to fast I/O routine if available. */
529 FAST_IO_DEVICE_CONTROL *pfnFastIoDeviceControl;
530# else
531 void *apvPadding[3];
532# endif
533#endif
534} SUPR0IOCTLCTX;
535/** Magic value for SUPR0IOCTLCTX (Ahmad Jamal). */
536#define SUPR0IOCTLCTX_MAGIC UINT32_C(0x19300702)
537
538
539/**
540 * Per session data.
541 * This is mainly for memory tracking.
542 */
543typedef struct SUPDRVSESSION
544{
545 /** Pointer to the device extension. */
546 PSUPDRVDEVEXT pDevExt;
547 /** Session Cookie. */
548 uint32_t u32Cookie;
549 /** Set if is an unrestricted session, clear if restricted. */
550 bool fUnrestricted;
551
552 /** Set if we're in the hash table, clear if not. Protected by the hash
553 * table spinlock. */
554 bool fInHashTable;
555 /** Reference counter. */
556 uint32_t volatile cRefs;
557 /** Pointer to the next session with the same hash (common hash table).
558 * Protected by the hash table spinlock. */
559 PSUPDRVSESSION pCommonNextHash;
560 /** Pointer to the OS specific session pointer, if available and in use.
561 * This is atomically set and cleared as the session is inserted and removed
562 * from the hash table (protected by the session hash table spinlock). */
563 PSUPDRVSESSION *ppOsSessionPtr;
564 /** The process (id) of the session. */
565 RTPROCESS Process;
566 /** Which process this session is associated with.
567 * This is NIL_RTR0PROCESS for kernel sessions and valid for user ones. */
568 RTR0PROCESS R0Process;
569
570 /** The GVM associated with the session.
571 * This is set by VMMR0. */
572 PGVM pSessionGVM;
573 /** The VM associated with the session.
574 * This is set by VMMR0. */
575 PVM pSessionVM;
576 /** Set to pSessionVM if fast I/O controlls are enabled. */
577 PVM pFastIoCtrlVM;
578 /** Handle table for IPRT semaphore wrapper APIs.
579 * This takes care of its own locking in an IRQ safe manner. */
580 RTHANDLETABLE hHandleTable;
581 /** Load usage records (LIFO!). (protected by SUPDRVDEVEXT::mtxLdr) */
582 PSUPDRVLDRUSAGE volatile pLdrUsage;
583
584 /** Spinlock protecting the bundles, the GIP members and the
585 * fProcessCleanupDone flag. It continues to be valid until the last
586 * reference to the session is released. */
587 RTSPINLOCK Spinlock;
588 /** The ring-3 mapping of the GIP (readonly). */
589 RTR0MEMOBJ GipMapObjR3;
590 /** Set if the session is using the GIP. */
591 uint32_t fGipReferenced;
592 /** Bundle of locked memory objects. */
593 SUPDRVBUNDLE Bundle;
594 /** List of generic usage records. (protected by SUPDRVDEVEXT::SpinLock) */
595 PSUPDRVUSAGE volatile pUsage;
596
597 /** The user id of the session. (Set by the OS part.) */
598 RTUID Uid;
599 /** The group id of the session. (Set by the OS part.) */
600 RTGID Gid;
601 /** Per session tracer specfic data. */
602 uintptr_t uTracerData;
603 /** The thread currently actively talking to the tracer. (One at the time!) */
604 RTNATIVETHREAD hTracerCaller;
605 /** List of tracepoint providers associated with the session
606 * (SUPDRVTPPROVIDER). */
607 RTLISTANCHOR TpProviders;
608 /** The number of providers in TpProviders. */
609 uint32_t cTpProviders;
610 /** The number of threads active in supdrvIOCtl_TracerUmodProbeFire or
611 * SUPR0TracerUmodProbeFire. */
612 uint32_t volatile cTpProbesFiring;
613 /** User tracepoint modules (PSUPDRVTRACKERUMOD). */
614 RTLISTANCHOR TpUmods;
615 /** The user tracepoint module lookup table. */
616 struct SUPDRVTRACERUMOD *apTpLookupTable[32];
617 /** Whether this is a GIP test-mode client session or not. */
618 bool fGipTestMode;
619#ifndef SUPDRV_AGNOSTIC
620# if defined(RT_OS_DARWIN)
621 /** Pointer to the associated org_virtualbox_SupDrvClient object. */
622 void *pvSupDrvClient;
623 /** Whether this session has been opened or not. */
624 bool fOpened;
625# endif
626# if defined(RT_OS_OS2)
627 /** The system file number of this session. */
628 uint16_t sfn;
629 uint16_t Alignment; /**< Alignment */
630# endif
631# if defined(RT_OS_DARWIN) || defined(RT_OS_OS2) || defined(RT_OS_SOLARIS)
632 /** Pointer to the next session with the same hash. */
633 PSUPDRVSESSION pNextHash;
634# endif
635# if defined(RT_OS_WINDOWS) && defined(VBOX_WITH_HARDENING)
636 /** Pointer to the process protection structure for this session. */
637 struct SUPDRVNTPROTECT *pNtProtect;
638# endif
639#endif /* !SUPDRV_AGNOSTIC */
640} SUPDRVSESSION;
641
642
643/**
644 * Device extension.
645 */
646typedef struct SUPDRVDEVEXT
647{
648 /** Global cookie. */
649 uint32_t u32Cookie;
650 /** The actual size of SUPDRVSESSION. (SUPDRV_AGNOSTIC) */
651 uint32_t cbSession;
652
653 /** Spinlock to serialize the initialization, usage counting and objects.
654 * This is IRQ safe because we want to be able signal semaphores from the
655 * special HM context (and later maybe interrupt handlers), so we must be able
656 * to reference and dereference handles when IRQs are disabled. */
657 RTSPINLOCK Spinlock;
658
659 /** List of registered objects. Protected by the spinlock. */
660 PSUPDRVOBJ volatile pObjs;
661 /** List of free object usage records. */
662 PSUPDRVUSAGE volatile pUsageFree;
663
664 /** Loader mutex.
665 * This protects pvVMMR0, pvVMMR0Entry, pImages and SUPDRVSESSION::pLdrUsage. */
666#ifdef SUPDRV_USE_MUTEX_FOR_LDR
667 RTSEMMUTEX mtxLdr;
668#else
669 RTSEMFASTMUTEX mtxLdr;
670#endif
671
672 /** VMM Module 'handle'.
673 * 0 if the code VMM isn't loaded and Idt are nops. */
674 void * volatile pvVMMR0;
675 /** VMMR0EntryFast() pointer. */
676 DECLR0CALLBACKMEMBER(void, pfnVMMR0EntryFast, (PGVM pGVM, PVM pVM, VMCPUID idCpu, uint32_t uOperation));
677 /** VMMR0EntryEx() pointer. */
678 DECLR0CALLBACKMEMBER(int, pfnVMMR0EntryEx, (PGVM pGVM, PVM pVM, VMCPUID idCpu, uint32_t uOperation,
679 PSUPVMMR0REQHDR pReq, uint64_t u64Arg, PSUPDRVSESSION pSession));
680
681 /** Linked list of loaded code. */
682 PSUPDRVLDRIMAGE volatile pLdrImages;
683 /** Set if the image loading interface got disabled after loading all needed images */
684 bool fLdrLockedDown;
685
686 /** @name These members for detecting whether an API caller is in ModuleInit.
687 * Certain APIs are only permitted from ModuleInit, like for instance tracepoint
688 * registration.
689 * @{ */
690 /** The image currently executing its ModuleInit. */
691 PSUPDRVLDRIMAGE volatile pLdrInitImage;
692 /** The thread currently executing a ModuleInit function. */
693 RTNATIVETHREAD volatile hLdrInitThread;
694 /** The thread currently executing a ModuleTerm function. */
695 RTNATIVETHREAD volatile hLdrTermThread;
696 /** @} */
697
698 /** Number of times someone reported bad execution context via SUPR0BadContext.
699 * (This is times EFLAGS.AC is zero when we expected it to be 1.) */
700 uint32_t volatile cBadContextCalls;
701
702 /** GIP mutex.
703 * Any changes to any of the GIP members requires ownership of this mutex,
704 * except on driver init and termination. */
705#ifdef SUPDRV_USE_MUTEX_FOR_GIP
706 RTSEMMUTEX mtxGip;
707#else
708 RTSEMFASTMUTEX mtxGip;
709#endif
710 /** GIP spinlock protecting GIP members during Mp events.
711 * This is IRQ safe since be may get MP callbacks in contexts where IRQs are
712 * disabled (on some platforms). */
713 RTSPINLOCK hGipSpinlock;
714 /** Pointer to the Global Info Page (GIP). */
715 PSUPGLOBALINFOPAGE pGip;
716 /** The physical address of the GIP. */
717 RTHCPHYS HCPhysGip;
718 /** Number of processes using the GIP.
719 * (The updates are suspend while cGipUsers is 0.)*/
720 uint32_t volatile cGipUsers;
721 /** The ring-0 memory object handle for the GIP page. */
722 RTR0MEMOBJ GipMemObj;
723 /** The GIP timer handle. */
724 PRTTIMER pGipTimer;
725 /** If non-zero we've successfully called RTTimerRequestSystemGranularity(). */
726 uint32_t u32SystemTimerGranularityGrant;
727 /** The CPU id of the GIP master.
728 * This CPU is responsible for the updating the common GIP data and it is
729 * the one used to calculate TSC deltas relative to.
730 * (The initial master will have a 0 zero value, but it it goes offline the
731 * new master may have a non-zero value.) */
732 RTCPUID volatile idGipMaster;
733
734 /** Component factory mutex.
735 * This protects pComponentFactoryHead and component factory querying. */
736 RTSEMFASTMUTEX mtxComponentFactory;
737 /** The head of the list of registered component factories. */
738 PSUPDRVFACTORYREG pComponentFactoryHead;
739
740 /** Lock protecting The tracer members. */
741 RTSEMFASTMUTEX mtxTracer;
742 /** List of tracer providers (SUPDRVTPPROVIDER). */
743 RTLISTANCHOR TracerProviderList;
744 /** List of zombie tracer providers (SUPDRVTPPROVIDER). */
745 RTLISTANCHOR TracerProviderZombieList;
746 /** Pointer to the tracer registration record. */
747 PCSUPDRVTRACERREG pTracerOps;
748 /** The ring-0 session of a native tracer provider. */
749 PSUPDRVSESSION pTracerSession;
750 /** The image containing the tracer. */
751 PSUPDRVLDRIMAGE pTracerImage;
752 /** The tracer helpers. */
753 SUPDRVTRACERHLP TracerHlp;
754 /** The number of session having opened the tracer currently. */
755 uint32_t cTracerOpens;
756 /** The number of threads currently calling into the tracer. */
757 uint32_t volatile cTracerCallers;
758 /** Set if the tracer is being unloaded. */
759 bool fTracerUnloading;
760 /** Hash table for user tracer modules (SUPDRVVTGCOPY). */
761 RTLISTANCHOR aTrackerUmodHash[128];
762
763 /** @name Session Handle Table.
764 * @{ */
765 /** Spinlock protecting apSessionHashTab, cSessions,
766 * SUPDRVSESSION::ppOsSessionPtr, SUPDRVSESSION::pCommonNextHash, and possibly
767 * others depending on the OS. */
768 RTSPINLOCK hSessionHashTabSpinlock;
769 /** Session hash table hash table. The size of this table must make sense in
770 * comparison to GVMM_MAX_HANDLES. */
771 PSUPDRVSESSION apSessionHashTab[HC_ARCH_BITS == 64 ? 8191 : 127];
772 /** The number of open sessions. */
773 int32_t cSessions;
774 /** @} */
775
776 /** @name Invariant TSC frequency refinement.
777 * @{ */
778 /** Nanosecond timestamp at the start of the TSC frequency refinement phase. */
779 uint64_t nsStartInvarTscRefine;
780 /** TSC reading at the start of the TSC frequency refinement phase. */
781 uint64_t uTscStartInvarTscRefine;
782 /** The CPU id of the CPU that u64TscAnchor was measured on. */
783 RTCPUID idCpuInvarTscRefine;
784 /** Pointer to the timer used to refine the TSC frequency. */
785 PRTTIMER pInvarTscRefineTimer;
786 /** Stop the timer on the next tick because we saw a power event. */
787 bool volatile fInvTscRefinePowerEvent;
788 /** @} */
789
790 /** @name TSC-delta measurement.
791 * @{ */
792 /** Number of online/offline events, incremented each time a CPU goes online
793 * or offline. */
794 uint32_t volatile cMpOnOffEvents;
795 /** TSC-delta measurement mutext.
796 * At the moment, we don't want to have more than one measurement going on at
797 * any one time. We might be using broadcast IPIs which are heavy and could
798 * perhaps get in each others way. */
799#ifdef SUPDRV_USE_MUTEX_FOR_GIP
800 RTSEMMUTEX mtxTscDelta;
801#else
802 RTSEMFASTMUTEX mtxTscDelta;
803#endif
804 /** The set of CPUs we need to take measurements for. */
805 RTCPUSET TscDeltaCpuSet;
806 /** The set of CPUs we have completed taken measurements for. */
807 RTCPUSET TscDeltaObtainedCpuSet;
808 /** @} */
809
810#ifdef SUPDRV_USE_TSC_DELTA_THREAD
811 /** @name TSC-delta measurement thread.
812 * @{ */
813 /** Spinlock protecting enmTscDeltaThreadState. */
814 RTSPINLOCK hTscDeltaSpinlock;
815 /** TSC-delta measurement thread. */
816 RTTHREAD hTscDeltaThread;
817 /** The event signalled during state changes to the TSC-delta thread. */
818 RTSEMEVENT hTscDeltaEvent;
819 /** The state of the TSC-delta measurement thread. */
820 SUPDRVTSCDELTATHREADSTATE enmTscDeltaThreadState;
821 /** Thread timeout time before rechecking state in ms. */
822 RTMSINTERVAL cMsTscDeltaTimeout;
823 /** Whether the TSC-delta measurement was successful. */
824 int32_t volatile rcTscDelta;
825 /** Tell the thread we want TSC-deltas for all CPUs with retries. */
826 bool fTscThreadRecomputeAllDeltas;
827 /** @} */
828#endif
829
830 /** @name GIP test mode.
831 * @{ */
832 /** Reference counter for GIP test-mode sessions. */
833 uint32_t cGipTestModeRefs;
834 /** Cache of TSC frequency before enabling test-mode on invariant GIP systems. */
835 uint64_t uGipTestModeInvariantCpuHz;
836 /** @} */
837
838 /*
839 * Note! The non-agnostic bits must be at the very end of the structure!
840 */
841#ifndef SUPDRV_AGNOSTIC
842# ifdef RT_OS_WINDOWS
843 /** Callback object returned by ExCreateCallback. */
844 PCALLBACK_OBJECT pObjPowerCallback;
845 /** Callback handle returned by ExRegisterCallback. */
846 PVOID hPowerCallback;
847# elif defined(RT_OS_DARWIN) && defined(VBOX_WITH_DARWIN_R0_DARWIN_IMAGE_VERIFICATION)
848 /** Trusted root certificates for code signing validation. */
849 RTCRSTORE hRootStore;
850 /** Intermedite certificates for code signing validation. */
851 RTCRSTORE hAdditionalStore;
852# endif
853#endif
854} SUPDRVDEVEXT;
855
856/** Calculates the index into g_apSessionHashTab.*/
857#define SUPDRV_SESSION_HASH(a_pid) ( (a_pid) % RT_ELEMENTS(((SUPDRVDEVEXT *)NULL)->apSessionHashTab) )
858
859
860RT_C_DECLS_BEGIN
861
862/*******************************************************************************
863* OS Specific Functions *
864*******************************************************************************/
865/**
866 * Called to clean up the session structure before it's freed.
867 *
868 * @param pDevExt The device globals.
869 * @param pSession The session that's being cleaned up.
870 */
871void VBOXCALL supdrvOSCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
872
873/**
874 * Called to let the OS specfic code perform additional insertion work while
875 * still under the protection of the hash table spinlock.
876 *
877 * @param pDevExt The device globals.
878 * @param pSession The session that was inserted.
879 * @param pvUser User context specified to the insert call.
880 */
881void VBOXCALL supdrvOSSessionHashTabInserted(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser);
882
883/**
884 * Called to let the OS specfic code perform additional removal work while still
885 * under the protection of the hash table spinlock.
886 *
887 * @param pDevExt The device globals.
888 * @param pSession The session that was removed.
889 * @param pvUser User context specified to the remove call.
890 */
891void VBOXCALL supdrvOSSessionHashTabRemoved(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser);
892
893/**
894 * Called during GIP initializtion to calc the CPU group table size.
895 *
896 * This is currently only implemented on windows [lazy bird].
897 *
898 * @returns Number of bytes needed for SUPGIPCPUGROUP structures.
899 * @param pDevExt The device globals.
900 */
901size_t VBOXCALL supdrvOSGipGetGroupTableSize(PSUPDRVDEVEXT pDevExt);
902
903/**
904 * Called during GIP initialization to set up the group table and group count.
905 *
906 * This is currently only implemented on windows [lazy bird].
907 *
908 * @param pDevExt The device globals.
909 * @param pGip The GIP which group table needs initialization.
910 * It's only partially initialized at this point.
911 * @param cbGipCpuGroups What supdrvOSGipGetGroupTableSize returned.
912 */
913int VBOXCALL supdrvOSInitGipGroupTable(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, size_t cbGipCpuGroups);
914
915/**
916 * Initializes the group related members when a CPU is added to the GIP.
917 *
918 * This is called both during GIP initalization and during an CPU online event.
919 *
920 * This is currently only implemented on windows [lazy bird].
921 *
922 * @returns CPU group number.
923 * @param pDevExt The device globals.
924 * @param pGip The GIP.
925 * @param pGipCpu The GIP CPU structure being initialized.
926 */
927void VBOXCALL supdrvOSGipInitGroupBitsForCpu(PSUPDRVDEVEXT pDevExt, PSUPGLOBALINFOPAGE pGip, PSUPGIPCPU pGipCpu);
928
929void VBOXCALL supdrvOSObjInitCreator(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession);
930bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc);
931bool VBOXCALL supdrvOSGetForcedAsyncTscMode(PSUPDRVDEVEXT pDevExt);
932bool VBOXCALL supdrvOSAreCpusOfflinedOnSuspend(void);
933bool VBOXCALL supdrvOSAreTscDeltasInSync(void);
934int VBOXCALL supdrvOSEnableVTx(bool fEnabled);
935RTCCUINTREG VBOXCALL supdrvOSChangeCR4(RTCCUINTREG fOrMask, RTCCUINTREG fAndMask);
936bool VBOXCALL supdrvOSSuspendVTxOnCpu(void);
937void VBOXCALL supdrvOSResumeVTxOnCpu(bool fSuspended);
938int VBOXCALL supdrvOSGetCurrentGdtRw(RTHCUINTPTR *pGdtRw);
939
940/**
941 * Try open the image using the native loader.
942 *
943 * @returns IPRT status code.
944 * @retval VERR_NOT_SUPPORTED if native loading isn't supported.
945 *
946 * @param pDevExt The device globals.
947 * @param pImage The image handle. pvImage should be set on
948 * success, pvImageAlloc can also be set if
949 * appropriate.
950 * @param pszFilename The file name - UTF-8, may containing UNIX
951 * slashes on non-UNIX systems.
952 */
953int VBOXCALL supdrvOSLdrOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename);
954
955/**
956 * Notification call indicating that a image is being opened for the first time.
957 *
958 * Called for both native and non-native images (after supdrvOSLdrOpen). Can be
959 * used to log the load address of the image or inform the kernel about the
960 * alien image.
961 *
962 * @param pDevExt The device globals.
963 * @param pImage The image handle.
964 * @param pszFilename The file name - UTF-8, may containing UNIX
965 * slashes on non-UNIX systems.
966 */
967void VBOXCALL supdrvOSLdrNotifyOpened(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const char *pszFilename);
968
969/**
970 * Validates an entry point address.
971 *
972 * Called before supdrvOSLdrLoad.
973 *
974 * @returns IPRT status code.
975 * @param pDevExt The device globals.
976 * @param pImage The image data (still in the open state).
977 * @param pv The address within the image.
978 * @param pbImageBits The image bits as loaded by ring-3.
979 * @param pszSymbol The name of the entrypoint being checked.
980 */
981int VBOXCALL supdrvOSLdrValidatePointer(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage,
982 void *pv, const uint8_t *pbImageBits, const char *pszSymbol);
983
984/**
985 * Load the image.
986 *
987 * @returns IPRT status code.
988 * @param pDevExt The device globals.
989 * @param pImage The image data (up to date). Adjust entrypoints
990 * and exports if necessary.
991 * @param pbImageBits The image bits as loaded by ring-3.
992 * @param pReq Pointer to the request packet so that the VMMR0
993 * entry points can be adjusted.
994 */
995int VBOXCALL supdrvOSLdrLoad(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage, const uint8_t *pbImageBits, PSUPLDRLOAD pReq);
996
997/**
998 * Unload the image (only called if supdrvOSLdrOpen returned success).
999 *
1000 * @param pDevExt The device globals.
1001 * @param pImage The image data (mostly still valid).
1002 */
1003void VBOXCALL supdrvOSLdrUnload(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);
1004
1005/**
1006 * Notification call indicating that a image is being unloaded.
1007 *
1008 * Called for both native and non-native images. In the former case, it's
1009 * called after supdrvOSLdrUnload.
1010 *
1011 * @param pDevExt The device globals.
1012 * @param pImage The image handle.
1013 */
1014void VBOXCALL supdrvOSLdrNotifyUnloaded(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);
1015
1016/**
1017 * Queries a symbol address is a native module.
1018 *
1019 * @returns IPRT status code.
1020 * @param pDevExt The device globals.
1021 * @param pImage The image to search.
1022 * @param pszSymbol The symbol to search for.
1023 * @param cchSymbol The length of the symbol.
1024 * @param ppvSymbol Where to return the symbol address if found.
1025 */
1026int VBOXCALL supdrvOSLdrQuerySymbol(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage,
1027 const char *pszSymbol, size_t cchSymbol, void **ppvSymbol);
1028
1029/**
1030 * Retains a native wrapper module when it is first being used.
1031 *
1032 * This will be call when pImage->cImgUsage is incremented to 2.
1033 *
1034 * @param pDevExt The device globals.
1035 * @param pImage The wrapped image.
1036 */
1037void VBOXCALL supdrvOSLdrRetainWrapperModule(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);
1038
1039/**
1040 * Release a native wrapper module when it is no longer being used.
1041 *
1042 * This will be call when pImage->cImgUsage is decremented to 1.
1043 *
1044 * @param pDevExt The device globals.
1045 * @param pImage The wrapped image.
1046 */
1047void VBOXCALL supdrvOSLdrReleaseWrapperModule(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);
1048
1049#ifdef SUPDRV_WITH_MSR_PROBER
1050
1051/**
1052 * Tries to read an MSR.
1053 *
1054 * @returns One of the listed VBox status codes.
1055 * @retval VINF_SUCCESS if read successfully, value in *puValue.
1056 * @retval VERR_ACCESS_DENIED if we couldn't read it (GP).
1057 * @retval VERR_NOT_SUPPORTED if not supported.
1058 *
1059 * @param uMsr The MSR to read from.
1060 * @param idCpu The CPU to read the MSR on. NIL_RTCPUID
1061 * indicates any suitable CPU.
1062 * @param puValue Where to return the value.
1063 */
1064int VBOXCALL supdrvOSMsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue);
1065
1066/**
1067 * Tries to write an MSR.
1068 *
1069 * @returns One of the listed VBox status codes.
1070 * @retval VINF_SUCCESS if written successfully.
1071 * @retval VERR_ACCESS_DENIED if we couldn't write the value to it (GP).
1072 * @retval VERR_NOT_SUPPORTED if not supported.
1073 *
1074 * @param uMsr The MSR to write to.
1075 * @param idCpu The CPU to write the MSR on. NIL_RTCPUID
1076 * indicates any suitable CPU.
1077 * @param uValue The value to write.
1078 */
1079int VBOXCALL supdrvOSMsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue);
1080
1081/**
1082 * Tries to modify an MSR value.
1083 *
1084 * @returns One of the listed VBox status codes.
1085 * @retval VINF_SUCCESS if succeeded.
1086 * @retval VERR_NOT_SUPPORTED if not supported.
1087 *
1088 * @param idCpu The CPU to modify the MSR on. NIL_RTCPUID
1089 * indicates any suitable CPU.
1090 * @param pReq The request packet with input arguments and
1091 * where to store the results.
1092 */
1093int VBOXCALL supdrvOSMsrProberModify(RTCPUID idCpu, PSUPMSRPROBER pReq);
1094
1095#endif /* SUPDRV_WITH_MSR_PROBER */
1096
1097#if defined(RT_OS_DARWIN)
1098int VBOXCALL supdrvDarwinResumeSuspendedKbds(void);
1099#endif
1100
1101
1102/*********************************************************************************************************************************
1103* Shared Functions *
1104*********************************************************************************************************************************/
1105/* SUPDrv.c */
1106int VBOXCALL supdrvIOCtl(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPREQHDR pReqHdr, size_t cbReq);
1107int VBOXCALL supdrvIOCtlFast(uintptr_t uOperation, VMCPUID idCpu, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
1108int VBOXCALL supdrvIDC(uintptr_t uIOCtl, PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVIDCREQHDR pReqHdr);
1109int VBOXCALL supdrvInitDevExt(PSUPDRVDEVEXT pDevExt, size_t cbSession);
1110void VBOXCALL supdrvDeleteDevExt(PSUPDRVDEVEXT pDevExt);
1111int VBOXCALL supdrvCreateSession(PSUPDRVDEVEXT pDevExt, bool fUser, bool fUnrestricted, PSUPDRVSESSION *ppSession);
1112int VBOXCALL supdrvSessionHashTabInsert(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVSESSION *ppOsSessionPtr, void *pvUser);
1113int VBOXCALL supdrvSessionHashTabRemove(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, void *pvUser);
1114PSUPDRVSESSION VBOXCALL supdrvSessionHashTabLookup(PSUPDRVDEVEXT pDevExt, RTPROCESS Process, RTR0PROCESS R0Process,
1115 PSUPDRVSESSION *ppOsSessionPtr);
1116uint32_t VBOXCALL supdrvSessionRetain(PSUPDRVSESSION pSession);
1117uint32_t VBOXCALL supdrvSessionRelease(PSUPDRVSESSION pSession);
1118void VBOXCALL supdrvBadContext(PSUPDRVDEVEXT pDevExt, const char *pszFile, uint32_t uLine, const char *pszExtra);
1119int VBOXCALL supdrvQueryVTCapsInternal(uint32_t *pfCaps);
1120int VBOXCALL supdrvLdrLoadError(int rc, PSUPLDRLOAD pReq, const char *pszFormat, ...);
1121int VBOXCALL supdrvLdrGetExportedSymbol(const char *pszSymbol, uintptr_t *puValue);
1122int VBOXCALL supdrvLdrRegisterWrappedModule(PSUPDRVDEVEXT pDevExt, PCSUPLDRWRAPPEDMODULE pWrappedModInfo,
1123 void *pvNative, void **phMod);
1124int VBOXCALL supdrvLdrDeregisterWrappedModule(PSUPDRVDEVEXT pDevExt, PCSUPLDRWRAPPEDMODULE pWrappedModInfo, void **phMod);
1125
1126
1127/* SUPDrvGip.cpp */
1128int VBOXCALL supdrvGipCreate(PSUPDRVDEVEXT pDevExt);
1129void VBOXCALL supdrvGipDestroy(PSUPDRVDEVEXT pDevExt);
1130int VBOXCALL supdrvIOCtl_TscDeltaMeasure(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPTSCDELTAMEASURE pReq);
1131int VBOXCALL supdrvIOCtl_TscRead(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPTSCREAD pReq);
1132int VBOXCALL supdrvIOCtl_GipSetFlags(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, uint32_t fOrMask, uint32_t fAndMask);
1133
1134
1135/* SUPDrvTracer.cpp */
1136int VBOXCALL supdrvTracerInit(PSUPDRVDEVEXT pDevExt);
1137void VBOXCALL supdrvTracerTerm(PSUPDRVDEVEXT pDevExt);
1138void VBOXCALL supdrvTracerModuleUnloading(PSUPDRVDEVEXT pDevExt, PSUPDRVLDRIMAGE pImage);
1139void VBOXCALL supdrvTracerCleanupSession(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
1140int VBOXCALL supdrvIOCtl_TracerUmodRegister(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession,
1141 RTR3PTR R3PtrVtgHdr, RTUINTPTR uVtgHdrAddr,
1142 RTR3PTR R3PtrStrTab, uint32_t cbStrTab,
1143 const char *pszModName, uint32_t fFlags);
1144int VBOXCALL supdrvIOCtl_TracerUmodDeregister(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, RTR3PTR R3PtrVtgHdr);
1145void VBOXCALL supdrvIOCtl_TracerUmodProbeFire(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, PSUPDRVTRACERUSRCTX pCtx);
1146int VBOXCALL supdrvIOCtl_TracerOpen(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, uint32_t uCookie, uintptr_t uArg);
1147int VBOXCALL supdrvIOCtl_TracerClose(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession);
1148int VBOXCALL supdrvIOCtl_TracerIOCtl(PSUPDRVDEVEXT pDevExt, PSUPDRVSESSION pSession, uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal);
1149extern PFNRT g_pfnSupdrvProbeFireKernel;
1150DECLASM(void) supdrvTracerProbeFireStub(void);
1151
1152#ifdef VBOX_WITH_NATIVE_DTRACE
1153const SUPDRVTRACERREG * VBOXCALL supdrvDTraceInit(void);
1154void VBOXCALL supdrvDTraceFini(void);
1155#endif
1156
1157RT_C_DECLS_END
1158
1159#endif /* !VBOX_INCLUDED_SRC_Support_SUPDrvInternal_h */
1160
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