sup.h revision 64cebe9ba3fe3787672cf522c22eb763a8a6dad4
/** @file
* SUP - Support Library. (HDrv)
*/
/*
* Copyright (C) 2006-2012 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
#ifndef ___VBox_sup_h
#define ___VBox_sup_h
struct VTGOBJHDR;
struct VTGPROBELOC;
/** @defgroup grp_sup The Support Library API
* @{
*/
/**
* Physical page descriptor.
*/
typedef struct SUPPAGE
{
/** Physical memory address. */
/** Reserved entry for internal use by the caller. */
} SUPPAGE;
#pragma pack()
/** Pointer to a page descriptor. */
/** Pointer to a const page descriptor. */
/**
* The paging mode.
*
* @remarks Users are making assumptions about the order here!
*/
typedef enum SUPPAGINGMODE
{
/** The usual invalid entry.
* This is returned by SUPR3GetPagingMode() */
/** Normal 32-bit paging, no global pages */
/** Normal 32-bit paging with global pages. */
/** PAE mode, no global pages, no NX. */
/** PAE mode with global pages. */
/** PAE mode with NX, no global pages. */
/** PAE mode with global pages and NX. */
/** AMD64 mode, no global pages. */
/** AMD64 mode with global pages, no NX. */
/** AMD64 mode with NX, no global pages. */
/** AMD64 mode with global pages and NX. */
/**
* Usermode probe context information.
*/
typedef struct SUPDRVTRACERUSRCTX
{
/** The probe ID from the VTG location record. */
/** 32 if X86, 64 if AMD64. */
/** Reserved padding. */
/** Data which format is dictated by the cBits member. */
union
{
/** X86 context info. */
struct
{
} X86;
/** AMD64 context info. */
struct
{
} Amd64;
} u;
/** Pointer to the usermode probe context information. */
typedef SUPDRVTRACERUSRCTX *PSUPDRVTRACERUSRCTX;
/** Pointer to the const usermode probe context information. */
typedef SUPDRVTRACERUSRCTX const *PCSUPDRVTRACERUSRCTX;
/**
* The result of a modification operation (SUPMSRPROBEROP_MODIFY or
* SUPMSRPROBEROP_MODIFY_FASTER).
*/
typedef struct SUPMSRPROBERMODIFYRESULT
{
/** The MSR value prior to the modifications. Valid if fBeforeGp is false */
/** The value that was written. Valid if fBeforeGp is false */
/** The MSR value after the modifications. Valid if AfterGp is false. */
/** Set if we GPed reading the MSR before the modification. */
bool fBeforeGp;
/** Set if we GPed while trying to write the modified value.
* This is set when fBeforeGp is true. */
bool fModifyGp;
/** Set if we GPed while trying to read the MSR after the modification.
* This is set when fBeforeGp is true. */
bool fAfterGp;
/** Set if we GPed while trying to restore the MSR after the modification.
* This is set when fBeforeGp is true. */
bool fRestoreGp;
/** Structure size alignment padding. */
bool afReserved[4];
/**
* The CPU state.
*/
typedef enum SUPGIPCPUSTATE
{
/** Invalid CPU state / unused CPU entry. */
/** The CPU is not present. */
/** The CPU is offline. */
/** The CPU is online. */
/** Force 32-bit enum type. */
SUPGIPCPUSTATE_32_BIT_HACK = 0x7fffffff
/**
* Per CPU data.
*/
typedef struct SUPGIPCPU
{
/** Update transaction number.
* This number is incremented at the start and end of each update. It follows
* thusly that odd numbers indicates update in progress, while even numbers
* indicate stable data. Use this to make sure that the data items you fetch
* are consistent. */
volatile uint32_t u32TransactionId;
/** The interval in TSC ticks between two NanoTS updates.
* This is the average interval over the last 2, 4 or 8 updates + a little slack.
* The slack makes the time go a tiny tiny bit slower and extends the interval enough
* to avoid ending up with too many 1ns increments. */
volatile uint32_t u32UpdateIntervalTSC;
/** Current nanosecond timestamp. */
/** The TSC at the time of u64NanoTS. */
/** Current CPU Frequency. */
/** Number of errors during updating.
/** Index of the head item in au32TSCHistory. */
volatile uint32_t iTSCHistoryHead;
/** Array of recent TSC interval deltas.
* The most recent item is at index iTSCHistoryHead.
* This history is used to calculate u32UpdateIntervalTSC.
*/
/** The interval between the last two NanoTS updates. (experiment for now) */
volatile uint32_t u32PrevUpdateIntervalNS;
/** Reserved for future per processor data. */
/** The CPU state. */
SUPGIPCPUSTATE volatile enmState;
/** The host CPU ID of this CPU (the SUPGIPCPU is indexed by APIC ID). */
/** The CPU set index of this CPU. */
/** The APIC ID of this CPU. */
} SUPGIPCPU;
/** Pointer to per cpu data.
* @remark there is no const version of this typedef, see g_pSUPGlobalInfoPage for details. */
typedef SUPGIPCPU *PSUPGIPCPU;
/**
* Global Information Page.
*
* This page contains useful information and can be mapped into any
* process or VM. It can be accessed thru the g_pSUPGlobalInfoPage
* pointer when a session is open.
*/
typedef struct SUPGLOBALINFOPAGE
{
/** Magic (SUPGLOBALINFOPAGE_MAGIC). */
/** The GIP version. */
/** The GIP update mode, see SUPGIPMODE. */
/** The number of entries in the CPU table.
* (This can work as RTMpGetArraySize().) */
/** The size of the GIP in pages. */
/** The update frequency of the of the NanoTS. */
volatile uint32_t u32UpdateHz;
/** The update interval in nanoseconds. (10^9 / u32UpdateHz) */
volatile uint32_t u32UpdateIntervalNS;
/** The timestamp of the last time we update the update frequency. */
volatile uint64_t u64NanoTSLastUpdateHz;
/** The set of online CPUs. */
/** The set of present CPUs. */
/** The set of possible CPUs. */
/** The number of CPUs that are online. */
volatile uint16_t cOnlineCpus;
/** The number of CPUs present in the system. */
volatile uint16_t cPresentCpus;
/** The highest number of CPUs possible. */
/** The highest number of CPUs possible. */
/** The max CPU ID (RTMpGetMaxCpuId). */
/** Padding / reserved space for future data. */
/** Table indexed by the CPU APIC ID to get the CPU table index. */
/** CPU set index to CPU table index. */
/** Array of per-cpu data.
* This is index by ApicId via the aiCpuFromApicId table.
*
* The clock and frequency information is updated for all CPUs if u32Mode
* is SUPGIPMODE_ASYNC_TSC, otherwise (SUPGIPMODE_SYNC_TSC) only the first
* entry is updated. */
#if defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
#else
#endif
/** Pointer to the global info page.
* @remark there is no const version of this typedef, see g_pSUPGlobalInfoPage for details. */
typedef SUPGLOBALINFOPAGE *PSUPGLOBALINFOPAGE;
/** The value of the SUPGLOBALINFOPAGE::u32Magic field. (Soryo Fuyumi) */
#define SUPGLOBALINFOPAGE_MAGIC 0x19590106
/** The GIP version.
* Upper 16 bits is the major version. Major version is only changed with
* incompatible changes in the GIP. */
#define SUPGLOBALINFOPAGE_VERSION 0x00030000
/**
* SUPGLOBALINFOPAGE::u32Mode values.
*/
typedef enum SUPGIPMODE
{
/** The usual invalid null entry. */
SUPGIPMODE_INVALID = 0,
/** The TSC of the cores and cpus in the system is in sync. */
/** Each core has it's own TSC. */
/** The usual 32-bit hack. */
SUPGIPMODE_32BIT_HACK = 0x7fffffff
} SUPGIPMODE;
/** Pointer to the Global Information Page.
*
* This pointer is valid as long as SUPLib has a open session. Anyone using
* the page must treat this pointer as highly volatile and not trust it beyond
* one transaction.
*
* @remark The GIP page is read-only to everyone but the support driver and
* is actually mapped read only everywhere but in ring-0. However
* it is not marked 'const' as this might confuse compilers into
* thinking that values doesn't change even if members are marked
* as volatile. Thus, there is no PCSUPGLOBALINFOPAGE type.
*/
#else /* IN_RING0 && !RT_OS_WINDOWS */
# define g_pSUPGlobalInfoPage (&g_SUPGlobalInfoPage)
# else
# define g_pSUPGlobalInfoPage (SUPGetGIPHlp())
/** Workaround for ELF+GCC problem on 64-bit hosts.
* (GCC emits a mov with a R_X86_64_32 reloc, we need R_X86_64_64.) */
{
: "=a" (pGIP));
return pGIP;
}
# endif
/** The GIP.
* We save a level of indirection by exporting the GIP instead of a variable
* pointing to it. */
#endif
/**
* Gets the GIP pointer.
*
* @returns Pointer to the GIP or NULL.
*/
#ifdef ___iprt_asm_amd64_x86_h
/**
* Gets the TSC frequency of the calling CPU.
*
* @returns TSC frequency, UINT64_MAX on failure.
* @param pGip The GIP pointer.
*/
{
unsigned iCpu;
return UINT64_MAX;
iCpu = 0;
else
{
return UINT64_MAX;
}
}
#endif
/**
* Request for generic VMMR0Entry calls.
*/
typedef struct SUPVMMR0REQHDR
{
/** The magic. (SUPVMMR0REQHDR_MAGIC) */
/** The size of the request. */
/** Pointer to a ring-0 request header. */
typedef SUPVMMR0REQHDR *PSUPVMMR0REQHDR;
/** the SUPVMMR0REQHDR::u32Magic value (Ethan Iverson - The Bad Plus). */
/** For the fast ioctl path.
* @{
*/
/** @see VMMR0_DO_RAW_RUN. */
#define SUP_VMMR0_DO_RAW_RUN 0
/** @see VMMR0_DO_HM_RUN. */
#define SUP_VMMR0_DO_HM_RUN 1
/** @see VMMR0_DO_NOP */
#define SUP_VMMR0_DO_NOP 2
/** @} */
/** SUPR3QueryVTCaps capability flags
* @{
*/
#define SUPVTCAPS_AMD_V RT_BIT(0)
/** @} */
/**
* Request for generic FNSUPR0SERVICEREQHANDLER calls.
*/
typedef struct SUPR0SERVICEREQHDR
{
/** The magic. (SUPR0SERVICEREQHDR_MAGIC) */
/** The size of the request. */
/** Pointer to a ring-0 service request header. */
typedef SUPR0SERVICEREQHDR *PSUPR0SERVICEREQHDR;
/** the SUPVMMR0REQHDR::u32Magic value (Esbjoern Svensson - E.S.P.). */
/** Event semaphore handle. Ring-0 / ring-3. */
/** Pointer to an event semaphore handle. */
typedef SUPSEMEVENT *PSUPSEMEVENT;
/** Nil event semaphore handle. */
#define NIL_SUPSEMEVENT ((SUPSEMEVENT)0)
/**
* Creates a single release event semaphore.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param phEvent Where to return the handle to the event semaphore.
*/
/**
* Closes a single release event semaphore handle.
*
* @returns VBox status code.
* @retval VINF_OBJECT_DESTROYED if the semaphore was destroyed.
* @retval VINF_SUCCESS if the handle was successfully closed but the semaphore
* object remained alive because of other references.
*
* @param pSession The session handle of the caller.
* @param hEvent The handle. Nil is quietly ignored.
*/
/**
* Signals a single release event semaphore.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEvent The semaphore handle.
*/
#ifdef IN_RING0
/**
* Waits on a single release event semaphore, not interruptible.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEvent The semaphore handle.
* @param cMillies The number of milliseconds to wait.
* @remarks Not available in ring-3.
*/
#endif
/**
* Waits on a single release event semaphore, interruptible.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEvent The semaphore handle.
* @param cMillies The number of milliseconds to wait.
*/
SUPDECL(int) SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies);
/**
* Waits on a single release event semaphore, interruptible.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEvent The semaphore handle.
* @param uNsTimeout The deadline given on the RTTimeNanoTS() clock.
*/
SUPDECL(int) SUPSemEventWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t uNsTimeout);
/**
* Waits on a single release event semaphore, interruptible.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEvent The semaphore handle.
* @param cNsTimeout The number of nanoseconds to wait.
*/
SUPDECL(int) SUPSemEventWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t cNsTimeout);
/**
* Gets the best timeout resolution that SUPSemEventWaitNsAbsIntr and
* SUPSemEventWaitNsAbsIntr can do.
*
* @returns The resolution in nanoseconds.
* @param pSession The session handle of the caller.
*/
/** Multiple release event semaphore handle. Ring-0 / ring-3. */
/** Pointer to an multiple release event semaphore handle. */
typedef SUPSEMEVENTMULTI *PSUPSEMEVENTMULTI;
/** Nil multiple release event semaphore handle. */
#define NIL_SUPSEMEVENTMULTI ((SUPSEMEVENTMULTI)0)
/**
* Creates a multiple release event semaphore.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param phEventMulti Where to return the handle to the event semaphore.
*/
/**
* Closes a multiple release event semaphore handle.
*
* @returns VBox status code.
* @retval VINF_OBJECT_DESTROYED if the semaphore was destroyed.
* @retval VINF_SUCCESS if the handle was successfully closed but the semaphore
* object remained alive because of other references.
*
* @param pSession The session handle of the caller.
* @param hEventMulti The handle. Nil is quietly ignored.
*/
/**
* Signals a multiple release event semaphore.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEventMulti The semaphore handle.
*/
/**
* Resets a multiple release event semaphore.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEventMulti The semaphore handle.
*/
#ifdef IN_RING0
/**
* Waits on a multiple release event semaphore, not interruptible.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEventMulti The semaphore handle.
* @param cMillies The number of milliseconds to wait.
* @remarks Not available in ring-3.
*/
SUPDECL(int) SUPSemEventMultiWait(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies);
#endif
/**
* Waits on a multiple release event semaphore, interruptible.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEventMulti The semaphore handle.
* @param cMillies The number of milliseconds to wait.
*/
SUPDECL(int) SUPSemEventMultiWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies);
/**
* Waits on a multiple release event semaphore, interruptible.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEventMulti The semaphore handle.
* @param uNsTimeout The deadline given on the RTTimeNanoTS() clock.
*/
SUPDECL(int) SUPSemEventMultiWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout);
/**
* Waits on a multiple release event semaphore, interruptible.
*
* @returns VBox status code.
* @param pSession The session handle of the caller.
* @param hEventMulti The semaphore handle.
* @param cNsTimeout The number of nanoseconds to wait.
*/
SUPDECL(int) SUPSemEventMultiWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout);
/**
* Gets the best timeout resolution that SUPSemEventMultiWaitNsAbsIntr and
* SUPSemEventMultiWaitNsRelIntr can do.
*
* @returns The resolution in nanoseconds.
* @param pSession The session handle of the caller.
*/
#ifdef IN_RING3
/** @defgroup grp_sup_r3 SUP Host Context Ring-3 API
* @ingroup grp_sup
* @{
*/
/**
* Installs the support library.
*
* @returns VBox status code.
*/
SUPR3DECL(int) SUPR3Install(void);
/**
* Uninstalls the support library.
*
* @returns VBox status code.
*/
SUPR3DECL(int) SUPR3Uninstall(void);
/**
* Trusted main entry point.
*
* This is exported as "TrustedMain" by the dynamic libraries which contains the
* "real" application binary for which the hardened stub is built. The entry
* point is invoked upon successful initialization of the support library and
* runtime.
*
* @returns main kind of exit code.
* @param argc The argument count.
* @param argv The argument vector.
* @param envp The environment vector.
*/
/** Pointer to FNSUPTRUSTEDMAIN(). */
typedef FNSUPTRUSTEDMAIN *PFNSUPTRUSTEDMAIN;
/** Which operation failed. */
typedef enum SUPINITOP
{
/** Invalid. */
kSupInitOp_Invalid = 0,
/** Installation integrity error. */
/** Setuid related. */
/** Driver related. */
/** IPRT init related. */
/** Miscellaneous. */
/** Place holder. */
} SUPINITOP;
/**
* Trusted error entry point, optional.
*
* This is exported as "TrustedError" by the dynamic libraries which contains
* the "real" application binary for which the hardened stub is built.
*
* @param pszWhere Where the error occurred (function name).
* @param enmWhat Which operation went wrong.
* @param rc The status code.
* @param pszMsgFmt Error message format string.
* @param va The message format arguments.
*/
typedef DECLCALLBACK(void) FNSUPTRUSTEDERROR(const char *pszWhere, SUPINITOP enmWhat, int rc, const char *pszMsgFmt, va_list va);
/** Pointer to FNSUPTRUSTEDERROR. */
typedef FNSUPTRUSTEDERROR *PFNSUPTRUSTEDERROR;
/**
* Secure main.
*
* This is used for the set-user-ID-on-execute binaries on unixy systems
* and when using the open-vboxdrv-via-root-service setup on Windows.
*
* This function will perform the integrity checks of the VirtualBox
* installation, open the support driver, open the root service (later),
* and load the DLL corresponding to \a pszProgName and execute its main
* function.
*
* @returns Return code appropriate for main().
*
* @param pszProgName The program name. This will be used to figure out which
* @param fFlags Flags.
* @param argc The argument count.
* @param argv The argument vector.
* @param envp The environment vector.
*/
DECLHIDDEN(int) SUPR3HardenedMain(const char *pszProgName, uint32_t fFlags, int argc, char **argv, char **envp);
/** @name SUPR3SecureMain flags.
* @{ */
/** Don't open the device. (Intended for VirtualBox without -startvm.) */
#define SUPSECMAIN_FLAGS_DONT_OPEN_DEV RT_BIT_32(0)
/** @} */
/**
* Initializes the support library.
*
* Each successful call to SUPR3Init() or SUPR3InitEx must be countered by a
* call to SUPR3Term(false).
*
* @returns VBox status code.
* @param ppSession Where to store the session handle. Defaults to NULL.
*/
/**
* Initializes the support library, extended version.
*
* Each successful call to SUPR3Init() or SUPR3InitEx must be countered by a
* call to SUPR3Term(false).
*
* @returns VBox status code.
* @param fUnrestricted The desired access.
* @param ppSession Where to store the session handle. Defaults to NULL.
*/
/**
* Terminates the support library.
*
* @returns VBox status code.
* @param fForced Forced termination. This means to ignore the
* init call count and just terminated.
*/
#ifdef __cplusplus
#else
#endif
/**
* Sets the ring-0 VM handle for use with fast IOCtls.
*
* @returns VBox status code.
* @param pVMR0 The ring-0 VM handle.
* NIL_RTR0PTR can be used to unset the handle when the
* VM is about to be destroyed.
*/
/**
* Calls the HC R0 VMM entry point.
* See VMMR0Entry() for more details.
*
* @returns error code specific to uFunction.
* @param pVMR0 Pointer to the Ring-0 (Host Context) mapping of the VM structure.
* @param idCpu The virtual CPU ID.
* @param uOperation Operation to execute.
* @param pvArg Argument.
*/
/**
* Variant of SUPR3CallVMMR0, except that this takes the fast ioclt path
* regardsless of compile-time defaults.
*
* @returns VBox status code.
* @param pVMR0 The ring-0 VM handle.
* @param uOperation The operation; only the SUP_VMMR0_DO_* ones are valid.
* @param idCpu The virtual CPU ID.
*/
/**
* Calls the HC R0 VMM entry point, in a safer but slower manner than
* SUPR3CallVMMR0. When entering using this call the R0 components can call
* into the host kernel (i.e. use the SUPR0 and RT APIs).
*
* See VMMR0Entry() for more details.
*
* @returns error code specific to uFunction.
* @param pVMR0 Pointer to the Ring-0 (Host Context) mapping of the VM structure.
* @param idCpu The virtual CPU ID.
* @param uOperation Operation to execute.
* @param u64Arg Constant argument.
* @param pReqHdr Pointer to a request header. Optional.
* This will be copied in and out of kernel space. There currently is a size
* limit on this, just below 4KB.
*/
SUPR3DECL(int) SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr);
/**
* Calls a ring-0 service.
*
* The operation and the request packet is specific to the service.
*
* @returns error code specific to uFunction.
* @param pszService The service name.
* @param cchService The length of the service name.
* @param uReq The request number.
* @param u64Arg Constant argument.
* @param pReqHdr Pointer to a request header. Optional.
* This will be copied in and out of kernel space. There currently is a size
* limit on this, just below 4KB.
*/
SUPR3DECL(int) SUPR3CallR0Service(const char *pszService, size_t cchService, uint32_t uOperation, uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr);
/** Which logger. */
typedef enum SUPLOGGER
{
SUPLOGGER_DEBUG = 1,
} SUPLOGGER;
/**
* Changes the settings of the specified ring-0 logger.
*
* @returns VBox status code.
* @param enmWhich Which logger.
* @param pszFlags The flags settings.
* @param pszGroups The groups settings.
* @param pszDest The destination specificier.
*/
SUPR3DECL(int) SUPR3LoggerSettings(SUPLOGGER enmWhich, const char *pszFlags, const char *pszGroups, const char *pszDest);
/**
* Creates a ring-0 logger instance.
*
* @returns VBox status code.
* @param enmWhich Which logger to create.
* @param pszFlags The flags settings.
* @param pszGroups The groups settings.
* @param pszDest The destination specificier.
*/
SUPR3DECL(int) SUPR3LoggerCreate(SUPLOGGER enmWhich, const char *pszFlags, const char *pszGroups, const char *pszDest);
/**
* Destroys a ring-0 logger instance.
*
* @returns VBox status code.
* @param enmWhich Which logger.
*/
/**
* Queries the paging mode of the host OS.
*
* @returns The paging mode.
*/
/**
* Allocate zero-filled pages.
*
* Use this to allocate a number of pages suitable for seeding / locking.
* Call SUPR3PageFree() to free the pages once done with them.
*
* @returns VBox status.
* @param cPages Number of pages to allocate.
* @param ppvPages Where to store the base pointer to the allocated pages.
*/
/**
* Frees pages allocated with SUPR3PageAlloc().
*
* @returns VBox status.
* @param pvPages Pointer returned by SUPR3PageAlloc().
* @param cPages Number of pages that was allocated.
*/
/**
* Allocate non-zeroed, locked, pages with user and, optionally, kernel
* mappings.
*
* Use SUPR3PageFreeEx() to free memory allocated with this function.
*
* @returns VBox status code.
* @param cPages The number of pages to allocate.
* @param fFlags Flags, reserved. Must be zero.
* @param ppvPages Where to store the address of the user mapping.
* @param pR0Ptr Where to store the address of the kernel mapping.
* NULL if no kernel mapping is desired.
* @param paPages Where to store the physical addresses of each page.
* Optional.
*/
SUPR3DECL(int) SUPR3PageAllocEx(size_t cPages, uint32_t fFlags, void **ppvPages, PRTR0PTR pR0Ptr, PSUPPAGE paPages);
/**
* Maps a portion of a ring-3 only allocation into kernel space.
*
* @returns VBox status code.
*
* @param pvR3 The address SUPR3PageAllocEx return.
* @param off Offset to start mapping at. Must be page aligned.
* @param cb Number of bytes to map. Must be page aligned.
* @param fFlags Flags, must be zero.
* @param pR0Ptr Where to store the address on success.
*
*/
SUPR3DECL(int) SUPR3PageMapKernel(void *pvR3, uint32_t off, uint32_t cb, uint32_t fFlags, PRTR0PTR pR0Ptr);
/**
* Changes the protection of
*
* @returns VBox status code.
* @retval VERR_NOT_SUPPORTED if the OS doesn't allow us to change page level
* protection. See also RTR0MemObjProtect.
*
* @param pvR3 The ring-3 address SUPR3PageAllocEx returned.
* @param R0Ptr The ring-0 address SUPR3PageAllocEx returned if it
* is desired that the corresponding ring-0 page
* mappings should change protection as well. Pass
* NIL_RTR0PTR if the ring-0 pages should remain
* unaffected.
* @param off Offset to start at which to start chagning the page
* level protection. Must be page aligned.
* @param cb Number of bytes to change. Must be page aligned.
* @param fProt The new page level protection, either a combination
* of RTMEM_PROT_READ, RTMEM_PROT_WRITE and
* RTMEM_PROT_EXEC, or just RTMEM_PROT_NONE.
*/
SUPR3DECL(int) SUPR3PageProtect(void *pvR3, RTR0PTR R0Ptr, uint32_t off, uint32_t cb, uint32_t fProt);
/**
* Free pages allocated by SUPR3PageAllocEx.
*
* @returns VBox status code.
* @param pvPages The address of the user mapping.
* @param cPages The number of pages.
*/
/**
* Allocated memory with page aligned memory with a contiguous and locked physical
* memory backing below 4GB.
*
* @returns Pointer to the allocated memory (virtual address).
* *pHCPhys is set to the physical address of the memory.
* If ppvR0 isn't NULL, *ppvR0 is set to the ring-0 mapping.
* The returned memory must be freed using SUPR3ContFree().
* @returns NULL on failure.
* @param cPages Number of pages to allocate.
* @param pR0Ptr Where to store the ring-0 mapping of the allocation. (optional)
* @param pHCPhys Where to store the physical address of the memory block.
*
* @remark This 2nd version of this API exists because we're not able to map the
* ring-3 mapping executable on WIN64. This is a serious problem in regard to
* the world switchers.
*/
/**
* Frees memory allocated with SUPR3ContAlloc().
*
* @returns VBox status code.
* @param pv Pointer to the memory block which should be freed.
* @param cPages Number of pages to be freed.
*/
/**
* Allocated non contiguous physical memory below 4GB.
*
* The memory isn't zeroed.
*
* @returns VBox status code.
* @returns NULL on failure.
* @param cPages Number of pages to allocate.
* @param ppvPages Where to store the pointer to the allocated memory.
* The pointer stored here on success must be passed to
* SUPR3LowFree when the memory should be released.
* @param ppvPagesR0 Where to store the ring-0 pointer to the allocated memory. optional.
* @param paPages Where to store the physical addresses of the individual pages.
*/
SUPR3DECL(int) SUPR3LowAlloc(size_t cPages, void **ppvPages, PRTR0PTR ppvPagesR0, PSUPPAGE paPages);
/**
* Frees memory allocated with SUPR3LowAlloc().
*
* @returns VBox status code.
* @param pv Pointer to the memory block which should be freed.
* @param cPages Number of pages that was allocated.
*/
/**
* Load a module into R0 HC.
*
* This will verify the file integrity in a similar manner as
* SUPR3HardenedVerifyFile before loading it.
*
* @returns VBox status code.
* @param pszFilename The path to the image file.
* @param pszModule The module name. Max 32 bytes.
* @param ppvImageBase Where to store the image address.
* @param pErrInfo Where to return extended error information.
* Optional.
*/
SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, PRTERRINFO pErrInfo);
/**
* Load a module into R0 HC.
*
* This will verify the file integrity in a similar manner as
* SUPR3HardenedVerifyFile before loading it.
*
* @returns VBox status code.
* @param pszFilename The path to the image file.
* @param pszModule The module name. Max 32 bytes.
* @param pszSrvReqHandler The name of the service request handler entry
* point. See FNSUPR0SERVICEREQHANDLER.
* @param ppvImageBase Where to store the image address.
*/
const char *pszSrvReqHandler, void **ppvImageBase);
/**
* Frees a R0 HC module.
*
* @returns VBox status code.
* @param pszModule The module to free.
* @remark This will not actually 'free' the module, there are of course usage counting.
*/
/**
* Get the address of a symbol in a ring-0 module.
*
* @returns VBox status code.
* @param pszModule The module name.
* @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
* ordinal value rather than a string pointer.
* @param ppvValue Where to store the symbol value.
*/
/**
* Load R0 HC VMM code.
*
* @returns VBox status code.
* @deprecated Use SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase)
*/
/**
* Unloads R0 HC VMM code.
*
* @returns VBox status code.
* @deprecated Use SUPR3FreeModule().
*/
SUPR3DECL(int) SUPR3UnloadVMM(void);
/**
* Get the physical address of the GIP.
*
* @returns VBox status code.
* @param pHCPhys Where to store the physical address of the GIP.
*/
/**
* Initializes only the bits relevant for the SUPR3HardenedVerify* APIs.
*
* This is for users that don't necessarily need to initialize the whole of
* SUPLib. There is no harm in calling this one more time.
*
* @returns VBox status code.
* @remarks Currently not counted, so only call once.
*/
SUPR3DECL(int) SUPR3HardenedVerifyInit(void);
/**
* Reverses the effect of SUPR3HardenedVerifyInit if SUPR3InitEx hasn't been
* called.
*
* Ignored if the support library was initialized using SUPR3Init or
* SUPR3InitEx.
*
* @returns VBox status code.
*/
SUPR3DECL(int) SUPR3HardenedVerifyTerm(void);
/**
* Verifies the integrity of a file, and optionally opens it.
*
* The integrity check is for whether the file is suitable for loading into
* the hypervisor or VM process. The integrity check may include verifying
* the authenticode/elfsign/whatever signature of the file, which can take
* a little while.
*
* @returns VBox status code. On failure it will have printed a LogRel message.
*
* @param pszFilename The file.
* @param pszWhat For the LogRel on failure.
* @param phFile Where to store the handle to the opened file. This is optional, pass NULL
* if the file should not be opened.
* @deprecated Write a new one.
*/
SUPR3DECL(int) SUPR3HardenedVerifyFile(const char *pszFilename, const char *pszWhat, PRTFILE phFile);
/**
* Verifies the integrity of a the current process, including the image
* location and that the invocation was absolute.
*
* This must currently be called after initializing the runtime. The intended
* audience is set-uid-to-root applications, root services and similar.
*
* @returns VBox status code. On failure
* message.
* @param pszArgv0 The first argument to main().
* @param fInternal Set this to @c true if this is an internal
* VirtualBox application. Otherwise pass @c false.
* @param pErrInfo Where to return extended error information.
*/
/**
* Verifies the integrity of an installation directory.
*
* The integrity check verifies that the directory cannot be tampered with by
* normal users on the system. On Unix this translates to root ownership and
* no symbolic linking.
*
* @returns VBox status code. On failure a message will be stored in @a pszErr.
*
* @param pszDirPath The directory path.
* @param fRecursive Whether the check should be recursive or
* not. When set, all sub-directores will be checked,
* including files (@a fCheckFiles is ignored).
* @param fCheckFiles Whether to apply the same basic integrity check to
* the files in the directory as the directory itself.
* @param pErrInfo Where to return extended error information.
* Optional.
*/
SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo);
/**
* Verifies the integrity of a plug-in module.
*
* This is similar to SUPR3HardenedLdrLoad, except it does not load the module
* and that the module does not have to be shipped with VirtualBox.
*
* @returns VBox status code. On failure a message will be stored in @a pszErr.
*
* @param pszFilename The filename of the plug-in module (nothing can be
* omitted here).
* @param pErrInfo Where to return extended error information.
* Optional.
*/
/**
* Same as RTLdrLoad() but will verify the files it loads (hardened builds).
*
* Will add dll suffix if missing and try load the file.
*
* @returns iprt status code.
* @param pszFilename Image filename. This must have a path.
* @param phLdrMod Where to store the handle to the loaded module.
* @param fFlags See RTLDRLOAD_FLAGS_XXX.
* @param pErrInfo Where to return extended error information.
* Optional.
*/
SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
/**
* Same as RTLdrLoadAppPriv() but it will verify the files it loads (hardened
* builds).
*
* Will add dll suffix to the file if missing, then look for it in the
* architecture dependent application directory.
*
* @returns iprt status code.
* @param pszFilename Image filename.
* @param phLdrMod Where to store the handle to the loaded module.
* @param fFlags See RTLDRLOAD_FLAGS_XXX.
* @param pErrInfo Where to return extended error information.
* Optional.
*/
SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
/**
* Same as RTLdrLoad() but will verify the files it loads (hardened builds).
*
* This differs from SUPR3HardenedLdrLoad() in that it can load modules from
* extension packs and anything else safely installed on the system, provided
* they pass the hardening tests.
*
* @returns iprt status code.
* @param pszFilename The full path to the module, with extension.
* @param phLdrMod Where to store the handle to the loaded module.
* @param pErrInfo Where to return extended error information.
* Optional.
*/
SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
/**
* Check if the host kernel can run in VMX root mode.
*
* @returns VINF_SUCCESS if supported, error code indicating why if not.
*/
SUPR3DECL(int) SUPR3QueryVTxSupported(void);
/**
*
* @returns VINF_SUCCESS if supported, error code indicating why if not.
* @param pfCaps Pointer to capability dword (out).
* @todo Intended for main, which means we need to relax the privilege requires
* when accessing certain vboxdrv functions.
*/
/**
* Open the tracer.
*
* @returns VBox status code.
* @param uCookie Cookie identifying the tracer we expect to talk to.
* @param uArg Tracer specific open argument.
*/
/**
* Closes the tracer.
*
* @returns VBox status code.
*/
SUPR3DECL(int) SUPR3TracerClose(void);
/**
* Perform an I/O request on the tracer.
*
* @returns VBox status.
* @param uCmd The tracer command.
* @param uArg The argument.
* @param piRetVal Where to store the tracer return value.
*/
/**
* Registers the user module with the tracer.
*
* @returns VBox status code.
* @param hModNative Native module handle. Pass ~(uintptr_t)0 if not
* at hand.
* @param pszModule The module name.
* @param pVtgHdr The VTG header.
* @param uVtgHdrAddr The address to which the VTG header is loaded
* in the relevant execution context.
* @param fFlags See SUP_TRACER_UMOD_FLAGS_XXX
*/
SUPR3DECL(int) SUPR3TracerRegisterModule(uintptr_t hModNative, const char *pszModule, struct VTGOBJHDR *pVtgHdr,
/**
* Deregisters the user module.
*
* @returns VBox status code.
* @param pVtgHdr The VTG header.
*/
/**
* Fire the probe.
*
* @param pVtgProbeLoc The probe location record.
* @param uArg0 Raw probe argument 0.
* @param uArg1 Raw probe argument 1.
* @param uArg2 Raw probe argument 2.
* @param uArg3 Raw probe argument 3.
* @param uArg4 Raw probe argument 4.
*/
SUPDECL(void) SUPTracerFireProbe(struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
/**
* Attempts to read the value of an MSR.
*
* @returns VBox status code.
* @param uMsr The MSR to read.
* @param idCpu The CPU to read it on, NIL_RTCPUID if it doesn't
* matter which CPU.
* @param puValue Where to return the value.
* @param pfGp Where to store the \#GP indicator for the read
* operation.
*/
/**
* Attempts to write to an MSR.
*
* @returns VBox status code.
* @param uMsr The MSR to write to.
* @param idCpu The CPU to wrtie it on, NIL_RTCPUID if it
* doesn't matter which CPU.
* @param uValue The value to write.
* @param pfGp Where to store the \#GP indicator for the write
* operation.
*/
/**
* Attempts to modify the value of an MSR.
*
* @returns VBox status code.
* @param uMsr The MSR to modify.
* @param idCpu The CPU to modify it on, NIL_RTCPUID if it
* doesn't matter which CPU.
* @param fAndMask The bits to keep in the current MSR value.
* @param fOrMask The bits to set before writing.
* @param pResult The result buffer.
*/
SUPR3DECL(int) SUPR3MsrProberModify(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask,
/**
* Attempts to modify the value of an MSR, extended version.
*
* @returns VBox status code.
* @param uMsr The MSR to modify.
* @param idCpu The CPU to modify it on, NIL_RTCPUID if it
* doesn't matter which CPU.
* @param fAndMask The bits to keep in the current MSR value.
* @param fOrMask The bits to set before writing.
* skipped, otherwise behave like
* SUPR3MsrProberModify.
* @param pResult The result buffer.
*/
SUPR3DECL(int) SUPR3MsrProberModifyEx(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask, bool fFaster,
/**
* Resume built-in keyboard on MacBook Air and Pro hosts.
*
* @returns VBox status code.
*/
SUPR3DECL(int) SUPR3ResumeSuspendedKeyboards(void);
/** @} */
#endif /* IN_RING3 */
/** @name User mode module flags (SUPR3TracerRegisterModule & SUP_IOCTL_TRACER_UMOD_REG).
* @{ */
/** Executable image. */
/** Shared library (DLL, DYLIB, SO, etc). */
/** Image type mask. */
/** @} */
#ifdef IN_RING0
/** @defgroup grp_sup_r0 SUP Host Context Ring-0 API
* @ingroup grp_sup
* @{
*/
/**
* Security objectype.
*/
typedef enum SUPDRVOBJTYPE
{
/** The usual invalid object. */
/** A Virtual Machine instance. */
/** Internal network. */
/** Internal network interface. */
/** Single release event semaphore. */
/** Multiple release event semaphore. */
/** Raw PCI device. */
/** The first invalid object type in this end. */
/** The usual 32-bit type size hack. */
SUPDRVOBJTYPE_32_BIT_HACK = 0x7ffffff
/**
* Object destructor callback.
* This is called for reference counted objectes when the count reaches 0.
*
* @param pvObj The object pointer.
* @param pvUser1 The first user argument.
* @param pvUser2 The second user argument.
*/
/** Pointer to a FNSUPDRVDESTRUCTOR(). */
typedef FNSUPDRVDESTRUCTOR *PFNSUPDRVDESTRUCTOR;
SUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2);
SUPR0DECL(int) SUPR0LockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t cPages, PRTHCPHYS paPages);
SUPR0DECL(int) SUPR0ContAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys);
SUPR0DECL(int) SUPR0LowAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS paPages);
SUPR0DECL(int) SUPR0PageAllocEx(PSUPDRVSESSION pSession, uint32_t cPages, uint32_t fFlags, PRTR3PTR ppvR3, PRTR0PTR ppvR0, PRTHCPHYS paPages);
SUPR0DECL(int) SUPR0PageMapKernel(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t offSub, uint32_t cbSub, uint32_t fFlags, PRTR0PTR ppvR0);
SUPR0DECL(int) SUPR0PageProtect(PSUPDRVSESSION pSession, RTR3PTR pvR3, RTR0PTR pvR0, uint32_t offSub, uint32_t cbSub, uint32_t fProt);
SUPR0DECL(bool) SUPR0SuspendVTxOnCpu(void);
/** @name Absolute symbols
* Take the address of these, don't try call them.
* @{ */
SUPR0DECL(void) SUPR0AbsIs64bit(void);
SUPR0DECL(void) SUPR0Abs64bitKernelCS(void);
SUPR0DECL(void) SUPR0Abs64bitKernelSS(void);
SUPR0DECL(void) SUPR0Abs64bitKernelDS(void);
SUPR0DECL(void) SUPR0AbsKernelCS(void);
SUPR0DECL(void) SUPR0AbsKernelSS(void);
SUPR0DECL(void) SUPR0AbsKernelDS(void);
SUPR0DECL(void) SUPR0AbsKernelES(void);
SUPR0DECL(void) SUPR0AbsKernelFS(void);
SUPR0DECL(void) SUPR0AbsKernelGS(void);
/** @} */
/**
* Support driver component factory.
*
* Component factories are registered by drivers that provides services
* such as the host network interface filtering and access to the host
*
* @remark Module dependencies and making sure that a component doesn't
* get unloaded while in use, is the sole responsibility of the
*/
typedef struct SUPDRVFACTORY
{
/** The (unique) name of the component factory. */
char szName[56];
/**
* Queries a factory interface.
*
* The factory interface is specific to each component and will be be
* found in the header(s) for the component alongside its UUID.
*
* @returns Pointer to the factory interfaces on success, NULL on failure.
*
* @param pSupDrvFactory Pointer to this structure.
* @param pSession The SUPDRV session making the query.
* @param pszInterfaceUuid The UUID of the factory interface.
*/
DECLR0CALLBACKMEMBER(void *, pfnQueryFactoryInterface,(struct SUPDRVFACTORY const *pSupDrvFactory, PSUPDRVSESSION pSession, const char *pszInterfaceUuid));
/** Pointer to a support driver factory. */
typedef SUPDRVFACTORY *PSUPDRVFACTORY;
/** Pointer to a const support driver factory. */
typedef SUPDRVFACTORY const *PCSUPDRVFACTORY;
SUPR0DECL(int) SUPR0ComponentQueryFactory(PSUPDRVSESSION pSession, const char *pszName, const char *pszInterfaceUuid, void **ppvFactoryIf);
/** @name Tracing
* @{ */
/**
* Tracer data associated with a provider.
*/
typedef union SUPDRVTRACERDATA
{
/** Generic */
/** DTrace data. */
struct
{
/** Provider ID. */
/** The number of trace points provided. */
uint32_t volatile cProvidedProbes;
/** Whether we've invalidated this bugger. */
bool fZombie;
} DTrace;
/** Pointer to the tracer data associated with a provider. */
typedef SUPDRVTRACERDATA *PSUPDRVTRACERDATA;
/**
* Probe location info for ring-0.
*
* Since we cannot trust user tracepoint modules, we need to duplicate the probe
* ID and enabled flag in ring-0.
*/
typedef struct SUPDRVPROBELOC
{
/** The probe ID. */
/** Whether it's enabled or not. */
bool fEnabled;
/** Pointer to a ring-0 probe location record. */
typedef SUPDRVPROBELOC *PSUPDRVPROBELOC;
/**
* Probe info for ring-0.
*
* Since we cannot trust user tracepoint modules, we need to duplicate the
* probe enable count.
*/
typedef struct SUPDRVPROBEINFO
{
/** The number of times this probe has been enabled. */
/** Pointer to a ring-0 probe info record. */
typedef SUPDRVPROBEINFO *PSUPDRVPROBEINFO;
/**
* Support driver tracepoint provider core.
*/
typedef struct SUPDRVVDTPROVIDERCORE
{
/** The tracer data member. */
/** Pointer to the provider name (a copy that's always available). */
const char *pszName;
/** Pointer to the module name (a copy that's always available). */
const char *pszModName;
/** The provider descriptor. */
struct VTGDESCPROVIDER *pDesc;
/** The VTG header. */
/** The size of the entries in the pvProbeLocsEn table. */
/** The actual module bit count (corresponds to cbProbeLocsEn). */
/** Set if this is a Umod, otherwise clear.. */
bool fUmod;
/** Explicit alignment padding (paranoia). */
/** The probe locations used for descriptive purposes. */
struct VTGPROBELOC const *paProbeLocsRO;
/** Pointer to the probe location array where the enable flag needs
* flipping. For kernel providers, this will always be SUPDRVPROBELOC,
* while user providers can either be 32-bit or 64-bit. Use
* cbProbeLocsEn to calculate the address of an entry. */
void *pvProbeLocsEn;
/** Pointer to the probe array containing the enabled counts. */
/** The ring-0 probe location info for user tracepoint modules.
* This is NULL if fUmod is false. */
/** The ring-0 probe info for user tracepoint modules.
* This is NULL if fUmod is false. */
/** Pointer to a tracepoint provider core structure. */
typedef SUPDRVVDTPROVIDERCORE *PSUPDRVVDTPROVIDERCORE;
/** Pointer to a tracer registration record. */
typedef struct SUPDRVTRACERREG const *PCSUPDRVTRACERREG;
/**
* Support driver tracer registration record.
*/
typedef struct SUPDRVTRACERREG
{
/** Magic value (SUPDRVTRACERREG_MAGIC). */
/** Version (SUPDRVTRACERREG_VERSION). */
/**
* Fire off a kernel probe.
*
* @param pVtgProbeLoc The probe location record.
* @param uArg0 The first raw probe argument.
* @param uArg1 The second raw probe argument.
* @param uArg2 The third raw probe argument.
* @param uArg3 The fourth raw probe argument.
* @param uArg4 The fifth raw probe argument.
*
* @remarks SUPR0TracerFireProbe will do a tail jump thru this member, so
* no extra stack frames will be added.
* @remarks This does not take a 'this' pointer argument because it doesn't map
* well onto VTG or DTrace.
*
*/
DECLR0CALLBACKMEMBER(void, pfnProbeFireKernel, (struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
/**
* Fire off a user-mode probe.
*
* @param pThis Pointer to the registration record.
*
* @param pVtgProbeLoc The probe location record.
* @param pSession The user session.
* @param pCtx The usermode context info.
* @param pVtgHdr The VTG header (read-only).
* @param pProbeLocRO The read-only probe location record .
*/
DECLR0CALLBACKMEMBER(void, pfnProbeFireUser, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, PCSUPDRVTRACERUSRCTX pCtx,
/**
* Opens up the tracer.
*
* @returns VBox status code.
* @param pThis Pointer to the registration record.
* @param pSession The session doing the opening.
* @param uCookie A cookie (magic) unique to the tracer, so it can
* fend off incompatible clients.
* @param uArg Tracer specific argument.
* @param puSessionData Pointer to the session data variable. This must be
* set to a non-zero value on success.
*/
DECLR0CALLBACKMEMBER(int, pfnTracerOpen, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uint32_t uCookie, uintptr_t uArg,
/**
* I/O control style tracer communication method.
*
*
* @returns VBox status code.
* @param pThis Pointer to the registration record.
* @param pSession The session.
* @param uSessionData The session data value.
* @param uCmd The tracer specific command.
* @param uArg The tracer command specific argument.
* @param piRetVal The tracer specific return value.
*/
DECLR0CALLBACKMEMBER(int, pfnTracerIoCtl, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData,
/**
* Cleans up data the tracer has associated with a session.
*
* @param pThis Pointer to the registration record.
* @param pSession The session handle.
* @param uSessionData The data assoicated with the session.
*/
DECLR0CALLBACKMEMBER(void, pfnTracerClose, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData));
/**
* Registers a provider.
*
* @returns VBox status code.
* @param pThis Pointer to the registration record.
* @param pCore The provider core data.
*
* @todo Kernel vs. Userland providers.
*/
DECLR0CALLBACKMEMBER(int, pfnProviderRegister, (PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore));
/**
* Attempts to deregisters a provider.
*
* @returns VINF_SUCCESS or VERR_TRY_AGAIN. If the latter, the provider
* should be made as harmless as possible before returning as the
* VTG object and associated code will be unloaded upon return.
*
* @param pThis Pointer to the registration record.
* @param pCore The provider core data.
*/
DECLR0CALLBACKMEMBER(int, pfnProviderDeregister, (PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore));
/**
* Make another attempt at unregister a busy provider.
*
* @returns VINF_SUCCESS or VERR_TRY_AGAIN.
* @param pThis Pointer to the registration record.
* @param pCore The provider core data.
*/
DECLR0CALLBACKMEMBER(int, pfnProviderDeregisterZombie, (PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore));
/** End marker (SUPDRVTRACERREG_MAGIC). */
/** Tracer magic (Kenny Garrett). */
/** Tracer registration structure version. */
/** Pointer to a trace helper structure. */
typedef struct SUPDRVTRACERHLP const *PCSUPDRVTRACERHLP;
/**
* Helper structure.
*/
typedef struct SUPDRVTRACERHLP
{
/** The structure version (SUPDRVTRACERHLP_VERSION). */
/** @todo ... */
/** End marker (SUPDRVTRACERHLP_VERSION) */
/** Tracer helper structure version. */
SUPR0DECL(int) SUPR0TracerRegisterImpl(void *hMod, PSUPDRVSESSION pSession, PCSUPDRVTRACERREG pReg, PCSUPDRVTRACERHLP *ppHlp);
SUPR0DECL(int) SUPR0TracerRegisterDrv(PSUPDRVSESSION pSession, struct VTGOBJHDR *pVtgHdr, const char *pszName);
SUPR0DECL(void) SUPR0TracerFireProbe(struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
/** @} */
/**
* Service request callback function.
*
* @returns VBox status code.
* @param pSession The caller's session.
* @param u64Arg 64-bit integer argument.
* @param pReqHdr The request header. Input / Output. Optional.
*/
/** Pointer to a FNR0SERVICEREQHANDLER(). */
/** @defgroup grp_sup_r0_idc The IDC Interface
* @ingroup grp_sup_r0
* @{
*/
/** The current SUPDRV IDC version.
* This follows the usual high word / low word rules, i.e. high word is the
* major number and it signifies incompatible interface changes. */
/**
* Inter-Driver Communication Handle.
*/
typedef union SUPDRVIDCHANDLE
{
/** Padding for opaque usage.
* Must be greater or equal in size than the private struct. */
void *apvPadding[4];
/** The private view. */
struct SUPDRVIDCHANDLEPRIVATE s;
#endif
/** Pointer to a handle. */
typedef SUPDRVIDCHANDLE *PSUPDRVIDCHANDLE;
SUPR0DECL(int) SUPR0IdcComponentRegisterFactory(PSUPDRVIDCHANDLE pHandle, PCSUPDRVFACTORY pFactory);
SUPR0DECL(int) SUPR0IdcComponentDeregisterFactory(PSUPDRVIDCHANDLE pHandle, PCSUPDRVFACTORY pFactory);
/** @} */
/** @name Ring-0 module entry points.
*
* These can be exported by ring-0 modules SUP are told to load.
*
* @{ */
/** @} */
/** @} */
#endif
/** @name Trust Anchors and Certificates
* @{ */
/**
* Trust anchor table entry (in generated Certificates.cpp).
*/
typedef struct SUPTAENTRY
{
/** Pointer to the raw bytes. */
const unsigned char *pch;
/** Number of bytes. */
unsigned cb;
} SUPTAENTRY;
/** Pointer to a trust anchor table entry. */
typedef SUPTAENTRY const *PCSUPTAENTRY;
/** Macro for simplifying generating the trust anchor tables. */
/** All certificates we know. */
extern SUPTAENTRY const g_aSUPAllTAs[];
/** Number of entries in g_aSUPAllTAs. */
extern unsigned const g_cSUPAllTAs;
/** Software publisher certificate roots (Authenticode). */
extern SUPTAENTRY const g_aSUPSpcRootTAs[];
/** Number of entries in g_aSUPSpcRootTAs. */
extern unsigned const g_cSUPSpcRootTAs;
/** Kernel root certificates used by Windows. */
extern SUPTAENTRY const g_aSUPNtKernelRootTAs[];
/** Number of entries in g_aSUPNtKernelRootTAs. */
extern unsigned const g_cSUPNtKernelRootTAs;
/** Timestamp root certificates trusted by Windows. */
extern SUPTAENTRY const g_aSUPTimestampTAs[];
/** Number of entries in g_aSUPTimestampTAs. */
extern unsigned const g_cSUPTimestampTAs;
/** TAs we trust (the build certificate, Oracle VirtualBox). */
extern SUPTAENTRY const g_aSUPTrustedTAs[];
/** Number of entries in g_aSUPTrustedTAs. */
extern unsigned const g_cSUPTrustedTAs;
/** Supplemental certificates, like cross signing certificates. */
extern SUPTAENTRY const g_aSUPSupplementalTAs[];
/** Number of entries in g_aSUPTrustedTAs. */
extern unsigned const g_cSUPSupplementalTAs;
/** The build certificate. */
extern const unsigned char g_abSUPBuildCert[];
/** The size of the build certificate. */
extern const unsigned g_cbSUPBuildCert;
/** @} */
/** @} */
#endif