[1] | 1 | /** @file
|
---|
[21217] | 2 | * SUP - Support Library. (HDrv)
|
---|
[1] | 3 | */
|
---|
| 4 |
|
---|
| 5 | /*
|
---|
[69107] | 6 | * Copyright (C) 2006-2017 Oracle Corporation
|
---|
[1] | 7 | *
|
---|
| 8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
| 9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
| 10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
[5999] | 11 | * General Public License (GPL) as published by the Free Software
|
---|
| 12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
| 13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
| 14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
| 15 | *
|
---|
| 16 | * The contents of this file may alternatively be used under the terms
|
---|
| 17 | * of the Common Development and Distribution License Version 1.0
|
---|
| 18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
| 19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
| 20 | * CDDL are applicable instead of those of the GPL.
|
---|
| 21 | *
|
---|
| 22 | * You may elect to license modified versions of this file under the
|
---|
| 23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
[1] | 24 | */
|
---|
| 25 |
|
---|
[3632] | 26 | #ifndef ___VBox_sup_h
|
---|
| 27 | #define ___VBox_sup_h
|
---|
[1] | 28 |
|
---|
| 29 | #include <VBox/cdefs.h>
|
---|
| 30 | #include <VBox/types.h>
|
---|
[53212] | 31 | #include <VBox/err.h>
|
---|
[1027] | 32 | #include <iprt/assert.h>
|
---|
[13458] | 33 | #include <iprt/stdarg.h>
|
---|
[36254] | 34 | #include <iprt/cpuset.h>
|
---|
[53435] | 35 | #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
|
---|
| 36 | # include <iprt/asm-amd64-x86.h>
|
---|
| 37 | #endif
|
---|
[1] | 38 |
|
---|
[20374] | 39 | RT_C_DECLS_BEGIN
|
---|
[1] | 40 |
|
---|
[40983] | 41 | struct VTGOBJHDR;
|
---|
| 42 | struct VTGPROBELOC;
|
---|
| 43 |
|
---|
| 44 |
|
---|
[1] | 45 | /** @defgroup grp_sup The Support Library API
|
---|
| 46 | * @{
|
---|
| 47 | */
|
---|
| 48 |
|
---|
[3393] | 49 | /**
|
---|
[1480] | 50 | * Physical page descriptor.
|
---|
[1] | 51 | */
|
---|
| 52 | #pragma pack(4) /* space is more important. */
|
---|
| 53 | typedef struct SUPPAGE
|
---|
| 54 | {
|
---|
| 55 | /** Physical memory address. */
|
---|
| 56 | RTHCPHYS Phys;
|
---|
| 57 | /** Reserved entry for internal use by the caller. */
|
---|
| 58 | RTHCUINTPTR uReserved;
|
---|
[1480] | 59 | } SUPPAGE;
|
---|
[1] | 60 | #pragma pack()
|
---|
[1480] | 61 | /** Pointer to a page descriptor. */
|
---|
| 62 | typedef SUPPAGE *PSUPPAGE;
|
---|
| 63 | /** Pointer to a const page descriptor. */
|
---|
| 64 | typedef const SUPPAGE *PCSUPPAGE;
|
---|
[1] | 65 |
|
---|
| 66 | /**
|
---|
| 67 | * The paging mode.
|
---|
[15397] | 68 | *
|
---|
| 69 | * @remarks Users are making assumptions about the order here!
|
---|
[1] | 70 | */
|
---|
| 71 | typedef enum SUPPAGINGMODE
|
---|
| 72 | {
|
---|
| 73 | /** The usual invalid entry.
|
---|
[20864] | 74 | * This is returned by SUPR3GetPagingMode() */
|
---|
[1] | 75 | SUPPAGINGMODE_INVALID = 0,
|
---|
| 76 | /** Normal 32-bit paging, no global pages */
|
---|
| 77 | SUPPAGINGMODE_32_BIT,
|
---|
| 78 | /** Normal 32-bit paging with global pages. */
|
---|
| 79 | SUPPAGINGMODE_32_BIT_GLOBAL,
|
---|
| 80 | /** PAE mode, no global pages, no NX. */
|
---|
| 81 | SUPPAGINGMODE_PAE,
|
---|
| 82 | /** PAE mode with global pages. */
|
---|
| 83 | SUPPAGINGMODE_PAE_GLOBAL,
|
---|
| 84 | /** PAE mode with NX, no global pages. */
|
---|
| 85 | SUPPAGINGMODE_PAE_NX,
|
---|
| 86 | /** PAE mode with global pages and NX. */
|
---|
| 87 | SUPPAGINGMODE_PAE_GLOBAL_NX,
|
---|
| 88 | /** AMD64 mode, no global pages. */
|
---|
| 89 | SUPPAGINGMODE_AMD64,
|
---|
| 90 | /** AMD64 mode with global pages, no NX. */
|
---|
| 91 | SUPPAGINGMODE_AMD64_GLOBAL,
|
---|
| 92 | /** AMD64 mode with NX, no global pages. */
|
---|
| 93 | SUPPAGINGMODE_AMD64_NX,
|
---|
| 94 | /** AMD64 mode with global pages and NX. */
|
---|
| 95 | SUPPAGINGMODE_AMD64_GLOBAL_NX
|
---|
| 96 | } SUPPAGINGMODE;
|
---|
| 97 |
|
---|
[52192] | 98 |
|
---|
[52392] | 99 | /** @name Flags returned by SUPR0GetKernelFeatures().
|
---|
[52192] | 100 | * @{
|
---|
| 101 | */
|
---|
| 102 | /** GDT is read-only. */
|
---|
[67136] | 103 | #define SUPKERNELFEATURES_GDT_READ_ONLY RT_BIT(0)
|
---|
[57108] | 104 | /** SMAP is possibly enabled. */
|
---|
[67136] | 105 | #define SUPKERNELFEATURES_SMAP RT_BIT(1)
|
---|
| 106 | /** GDT is read-only but the writable GDT can be fetched by SUPR0GetCurrentGdtRw(). */
|
---|
| 107 | #define SUPKERNELFEATURES_GDT_NEED_WRITABLE RT_BIT(2)
|
---|
[52192] | 108 | /** @} */
|
---|
| 109 |
|
---|
| 110 |
|
---|
[41117] | 111 | /**
|
---|
| 112 | * Usermode probe context information.
|
---|
| 113 | */
|
---|
| 114 | typedef struct SUPDRVTRACERUSRCTX
|
---|
| 115 | {
|
---|
| 116 | /** The probe ID from the VTG location record. */
|
---|
| 117 | uint32_t idProbe;
|
---|
| 118 | /** 32 if X86, 64 if AMD64. */
|
---|
| 119 | uint8_t cBits;
|
---|
| 120 | /** Reserved padding. */
|
---|
| 121 | uint8_t abReserved[3];
|
---|
| 122 | /** Data which format is dictated by the cBits member. */
|
---|
| 123 | union
|
---|
| 124 | {
|
---|
| 125 | /** X86 context info. */
|
---|
| 126 | struct
|
---|
| 127 | {
|
---|
| 128 | uint32_t uVtgProbeLoc; /**< Location record address. */
|
---|
| 129 | uint32_t aArgs[20]; /**< Raw arguments. */
|
---|
| 130 | uint32_t eip;
|
---|
| 131 | uint32_t eflags;
|
---|
| 132 | uint32_t eax;
|
---|
| 133 | uint32_t ecx;
|
---|
| 134 | uint32_t edx;
|
---|
| 135 | uint32_t ebx;
|
---|
| 136 | uint32_t esp;
|
---|
| 137 | uint32_t ebp;
|
---|
| 138 | uint32_t esi;
|
---|
| 139 | uint32_t edi;
|
---|
| 140 | uint16_t cs;
|
---|
| 141 | uint16_t ss;
|
---|
| 142 | uint16_t ds;
|
---|
| 143 | uint16_t es;
|
---|
| 144 | uint16_t fs;
|
---|
| 145 | uint16_t gs;
|
---|
| 146 | } X86;
|
---|
[1] | 147 |
|
---|
[41117] | 148 | /** AMD64 context info. */
|
---|
| 149 | struct
|
---|
| 150 | {
|
---|
| 151 | uint64_t uVtgProbeLoc; /**< Location record address. */
|
---|
| 152 | uint64_t aArgs[10]; /**< Raw arguments. */
|
---|
| 153 | uint64_t rip;
|
---|
| 154 | uint64_t rflags;
|
---|
| 155 | uint64_t rax;
|
---|
| 156 | uint64_t rcx;
|
---|
| 157 | uint64_t rdx;
|
---|
| 158 | uint64_t rbx;
|
---|
| 159 | uint64_t rsp;
|
---|
| 160 | uint64_t rbp;
|
---|
| 161 | uint64_t rsi;
|
---|
| 162 | uint64_t rdi;
|
---|
| 163 | uint64_t r8;
|
---|
| 164 | uint64_t r9;
|
---|
| 165 | uint64_t r10;
|
---|
| 166 | uint64_t r11;
|
---|
| 167 | uint64_t r12;
|
---|
| 168 | uint64_t r13;
|
---|
| 169 | uint64_t r14;
|
---|
| 170 | uint64_t r15;
|
---|
| 171 | } Amd64;
|
---|
| 172 | } u;
|
---|
| 173 | } SUPDRVTRACERUSRCTX;
|
---|
| 174 | /** Pointer to the usermode probe context information. */
|
---|
| 175 | typedef SUPDRVTRACERUSRCTX *PSUPDRVTRACERUSRCTX;
|
---|
| 176 | /** Pointer to the const usermode probe context information. */
|
---|
| 177 | typedef SUPDRVTRACERUSRCTX const *PCSUPDRVTRACERUSRCTX;
|
---|
| 178 |
|
---|
[36254] | 179 | /**
|
---|
[49634] | 180 | * The result of a modification operation (SUPMSRPROBEROP_MODIFY or
|
---|
| 181 | * SUPMSRPROBEROP_MODIFY_FASTER).
|
---|
| 182 | */
|
---|
| 183 | typedef struct SUPMSRPROBERMODIFYRESULT
|
---|
| 184 | {
|
---|
| 185 | /** The MSR value prior to the modifications. Valid if fBeforeGp is false */
|
---|
| 186 | uint64_t uBefore;
|
---|
| 187 | /** The value that was written. Valid if fBeforeGp is false */
|
---|
| 188 | uint64_t uWritten;
|
---|
| 189 | /** The MSR value after the modifications. Valid if AfterGp is false. */
|
---|
| 190 | uint64_t uAfter;
|
---|
| 191 | /** Set if we GPed reading the MSR before the modification. */
|
---|
| 192 | bool fBeforeGp;
|
---|
| 193 | /** Set if we GPed while trying to write the modified value.
|
---|
| 194 | * This is set when fBeforeGp is true. */
|
---|
| 195 | bool fModifyGp;
|
---|
| 196 | /** Set if we GPed while trying to read the MSR after the modification.
|
---|
| 197 | * This is set when fBeforeGp is true. */
|
---|
| 198 | bool fAfterGp;
|
---|
| 199 | /** Set if we GPed while trying to restore the MSR after the modification.
|
---|
| 200 | * This is set when fBeforeGp is true. */
|
---|
| 201 | bool fRestoreGp;
|
---|
| 202 | /** Structure size alignment padding. */
|
---|
| 203 | bool afReserved[4];
|
---|
| 204 | } SUPMSRPROBERMODIFYRESULT, *PSUPMSRPROBERMODIFYRESULT;
|
---|
| 205 |
|
---|
| 206 |
|
---|
| 207 | /**
|
---|
[36254] | 208 | * The CPU state.
|
---|
| 209 | */
|
---|
| 210 | typedef enum SUPGIPCPUSTATE
|
---|
| 211 | {
|
---|
| 212 | /** Invalid CPU state / unused CPU entry. */
|
---|
| 213 | SUPGIPCPUSTATE_INVALID = 0,
|
---|
| 214 | /** The CPU is not present. */
|
---|
| 215 | SUPGIPCPUSTATE_ABSENT,
|
---|
| 216 | /** The CPU is offline. */
|
---|
| 217 | SUPGIPCPUSTATE_OFFLINE,
|
---|
| 218 | /** The CPU is online. */
|
---|
| 219 | SUPGIPCPUSTATE_ONLINE,
|
---|
| 220 | /** Force 32-bit enum type. */
|
---|
| 221 | SUPGIPCPUSTATE_32_BIT_HACK = 0x7fffffff
|
---|
| 222 | } SUPGIPCPUSTATE;
|
---|
[1027] | 223 |
|
---|
[1] | 224 | /**
|
---|
[1027] | 225 | * Per CPU data.
|
---|
[1] | 226 | */
|
---|
[1027] | 227 | typedef struct SUPGIPCPU
|
---|
[1] | 228 | {
|
---|
| 229 | /** Update transaction number.
|
---|
| 230 | * This number is incremented at the start and end of each update. It follows
|
---|
| 231 | * thusly that odd numbers indicates update in progress, while even numbers
|
---|
| 232 | * indicate stable data. Use this to make sure that the data items you fetch
|
---|
[1027] | 233 | * are consistent. */
|
---|
[64255] | 234 | volatile uint32_t u32TransactionId;
|
---|
[1] | 235 | /** The interval in TSC ticks between two NanoTS updates.
|
---|
| 236 | * This is the average interval over the last 2, 4 or 8 updates + a little slack.
|
---|
| 237 | * The slack makes the time go a tiny tiny bit slower and extends the interval enough
|
---|
[1027] | 238 | * to avoid ending up with too many 1ns increments. */
|
---|
[64255] | 239 | volatile uint32_t u32UpdateIntervalTSC;
|
---|
[1] | 240 | /** Current nanosecond timestamp. */
|
---|
[64255] | 241 | volatile uint64_t u64NanoTS;
|
---|
[1] | 242 | /** The TSC at the time of u64NanoTS. */
|
---|
[64255] | 243 | volatile uint64_t u64TSC;
|
---|
[1] | 244 | /** Current CPU Frequency. */
|
---|
[64255] | 245 | volatile uint64_t u64CpuHz;
|
---|
[54224] | 246 | /** The TSC delta with reference to the master TSC, subtract from RDTSC. */
|
---|
[64255] | 247 | volatile int64_t i64TSCDelta;
|
---|
[1] | 248 | /** Number of errors during updating.
|
---|
| 249 | * Typical errors are under/overflows. */
|
---|
[64255] | 250 | volatile uint32_t cErrors;
|
---|
[1] | 251 | /** Index of the head item in au32TSCHistory. */
|
---|
[64255] | 252 | volatile uint32_t iTSCHistoryHead;
|
---|
[1] | 253 | /** Array of recent TSC interval deltas.
|
---|
| 254 | * The most recent item is at index iTSCHistoryHead.
|
---|
| 255 | * This history is used to calculate u32UpdateIntervalTSC.
|
---|
| 256 | */
|
---|
[64255] | 257 | volatile uint32_t au32TSCHistory[8];
|
---|
[22235] | 258 | /** The interval between the last two NanoTS updates. (experiment for now) */
|
---|
[64255] | 259 | volatile uint32_t u32PrevUpdateIntervalNS;
|
---|
[36254] | 260 |
|
---|
[1027] | 261 | /** Reserved for future per processor data. */
|
---|
[64255] | 262 | volatile uint32_t u32Reserved;
|
---|
[52618] | 263 | /** The TSC value read while doing TSC delta measurements across CPUs. */
|
---|
[64255] | 264 | volatile uint64_t u64TSCSample;
|
---|
[52618] | 265 | /** Reserved for future per processor data. */
|
---|
[64255] | 266 | volatile uint32_t au32Reserved1[3];
|
---|
[52618] | 267 |
|
---|
[36254] | 268 | /** The CPU state. */
|
---|
| 269 | SUPGIPCPUSTATE volatile enmState;
|
---|
| 270 | /** The host CPU ID of this CPU (the SUPGIPCPU is indexed by APIC ID). */
|
---|
| 271 | RTCPUID idCpu;
|
---|
| 272 | /** The CPU set index of this CPU. */
|
---|
| 273 | int16_t iCpuSet;
|
---|
[64255] | 274 | /** CPU group number (always zero, except on windows). */
|
---|
| 275 | uint16_t iCpuGroup;
|
---|
[64281] | 276 | /** CPU group member number (same as iCpuSet, except on windows). */
|
---|
[64255] | 277 | uint16_t iCpuGroupMember;
|
---|
[36254] | 278 | /** The APIC ID of this CPU. */
|
---|
| 279 | uint16_t idApic;
|
---|
[64255] | 280 | /** @todo Add topology/NUMA info. */
|
---|
| 281 | uint32_t iReservedForNumaNode;
|
---|
[1027] | 282 | } SUPGIPCPU;
|
---|
[36254] | 283 | AssertCompileSize(RTCPUID, 4);
|
---|
| 284 | AssertCompileSize(SUPGIPCPU, 128);
|
---|
| 285 | AssertCompileMemberAlignment(SUPGIPCPU, u64NanoTS, 8);
|
---|
| 286 | AssertCompileMemberAlignment(SUPGIPCPU, u64TSC, 8);
|
---|
[64255] | 287 | AssertCompileMemberAlignment(SUPGIPCPU, u64TSCSample, 8);
|
---|
[1027] | 288 |
|
---|
[3393] | 289 | /** Pointer to per cpu data.
|
---|
| 290 | * @remark there is no const version of this typedef, see g_pSUPGlobalInfoPage for details. */
|
---|
[1027] | 291 | typedef SUPGIPCPU *PSUPGIPCPU;
|
---|
| 292 |
|
---|
[64281] | 293 | /**
|
---|
| 294 | * CPU group information.
|
---|
| 295 | * @remarks Windows only.
|
---|
| 296 | */
|
---|
| 297 | typedef struct SUPGIPCPUGROUP
|
---|
| 298 | {
|
---|
| 299 | /** Current number of CPUs in this group. */
|
---|
| 300 | uint16_t volatile cMembers;
|
---|
| 301 | /** Maximum number of CPUs in the group. */
|
---|
| 302 | uint16_t cMaxMembers;
|
---|
| 303 | /** The CPU set index of the members. This table has cMaxMembers entries.
|
---|
| 304 | * @note For various reasons, entries from cMembers and up to cMaxMembers are
|
---|
| 305 | * may change as the host OS does set dynamic assignments during CPU
|
---|
| 306 | * hotplugging. */
|
---|
| 307 | int16_t aiCpuSetIdxs[1];
|
---|
| 308 | } SUPGIPCPUGROUP;
|
---|
| 309 | /** Pointer to a GIP CPU group structure. */
|
---|
| 310 | typedef SUPGIPCPUGROUP *PSUPGIPCPUGROUP;
|
---|
| 311 | /** Pointer to a const GIP CPU group structure. */
|
---|
| 312 | typedef SUPGIPCPUGROUP const *PCSUPGIPCPUGROUP;
|
---|
[36254] | 313 |
|
---|
[54252] | 314 | /**
|
---|
| 315 | * The rules concerning the applicability of SUPGIPCPU::i64TscDelta.
|
---|
| 316 | */
|
---|
| 317 | typedef enum SUPGIPUSETSCDELTA
|
---|
| 318 | {
|
---|
| 319 | /** Value for SUPGIPMODE_ASYNC_TSC. */
|
---|
| 320 | SUPGIPUSETSCDELTA_NOT_APPLICABLE = 0,
|
---|
| 321 | /** The OS specific part of SUPDrv (or the user) claims the TSC is as
|
---|
| 322 | * good as zero. */
|
---|
| 323 | SUPGIPUSETSCDELTA_ZERO_CLAIMED,
|
---|
| 324 | /** The differences in RDTSC output between the CPUs/cores/threads should
|
---|
| 325 | * be considered zero for all practical purposes. */
|
---|
| 326 | SUPGIPUSETSCDELTA_PRACTICALLY_ZERO,
|
---|
| 327 | /** The differences in RDTSC output between the CPUs/cores/threads are a few
|
---|
| 328 | * hundred ticks or less. (Probably not worth calling ASMGetApicId two times
|
---|
| 329 | * just to apply deltas.) */
|
---|
| 330 | SUPGIPUSETSCDELTA_ROUGHLY_ZERO,
|
---|
| 331 | /** Significant differences in RDTSC output between the CPUs/cores/threads,
|
---|
| 332 | * deltas must be applied. */
|
---|
| 333 | SUPGIPUSETSCDELTA_NOT_ZERO,
|
---|
| 334 | /** End of valid values (exclusive). */
|
---|
| 335 | SUPGIPUSETSCDELTA_END,
|
---|
| 336 | /** Make sure the type is 32-bit sized. */
|
---|
| 337 | SUPGIPUSETSCDELTA_32BIT_HACK = 0x7fffffff
|
---|
| 338 | } SUPGIPUSETSCDELTA;
|
---|
[36254] | 339 |
|
---|
[54252] | 340 |
|
---|
| 341 | /** @name SUPGIPGETCPU_XXX - methods that aCPUs can be indexed.
|
---|
[64255] | 342 | *
|
---|
| 343 | * @note Linux offers information via selector 0x78, and Windows via selector
|
---|
| 344 | * 0x53. But since they both support RDTSCP as well, and because most
|
---|
| 345 | * CPUs now have RDTSCP, we prefer it over LSL. We can implement more
|
---|
| 346 | * alternatives if it becomes necessary.
|
---|
| 347 | *
|
---|
[54252] | 348 | * @{
|
---|
| 349 | */
|
---|
| 350 | /** Use ASMGetApicId (or equivalent) and translate the result via
|
---|
| 351 | * aiCpuFromApicId. */
|
---|
| 352 | #define SUPGIPGETCPU_APIC_ID RT_BIT_32(0)
|
---|
| 353 | /** Use RDTSCP and translate the first RTCPUSET_MAX_CPUS of ECX via
|
---|
| 354 | * aiCpuFromCpuSetIdx.
|
---|
| 355 | *
|
---|
| 356 | * Linux stores the RTMpCpuId() value in ECX[11:0] and NUMA node number in
|
---|
| 357 | * ECX[12:31]. Solaris only stores RTMpCpuId() in ECX. On both systems
|
---|
| 358 | * RTMpCpuId() == RTMpCpuIdToSetIndex(RTMpCpuId()). RTCPUSET_MAX_CPUS is
|
---|
| 359 | * currently 64, 256 or 1024 in size, which lower than
|
---|
| 360 | * 4096, so there shouldn't be any range issues. */
|
---|
| 361 | #define SUPGIPGETCPU_RDTSCP_MASK_MAX_SET_CPUS RT_BIT_32(1)
|
---|
| 362 | /** Subtract the max IDT size from IDTR.LIMIT, extract the
|
---|
| 363 | * first RTCPUSET_MAX_CPUS and translate it via aiCpuFromCpuSetIdx.
|
---|
| 364 | *
|
---|
| 365 | * Darwin stores the RTMpCpuId() (== RTMpCpuIdToSetIndex(RTMpCpuId()))
|
---|
| 366 | * value in the IDT limit. The masking is a precaution against what linux
|
---|
| 367 | * does with RDTSCP. */
|
---|
| 368 | #define SUPGIPGETCPU_IDTR_LIMIT_MASK_MAX_SET_CPUS RT_BIT_32(2)
|
---|
[64255] | 369 | /** Windows specific RDTSCP variant, where CH gives you the group and CL gives
|
---|
| 370 | * you the CPU number within that group.
|
---|
| 371 | *
|
---|
| 372 | * Use SUPGLOBALINFOPAGE::aidFirstCpuFromCpuGroup to get the group base CPU set
|
---|
| 373 | * index, then translate the sum of thru aiCpuFromCpuSetIdx to find the aCPUs
|
---|
| 374 | * entry.
|
---|
| 375 | *
|
---|
| 376 | * @note The group number is actually 16-bit wide (ECX[23:8]), but we simplify
|
---|
| 377 | * it since we only support 256 CPUs/groups at the moment.
|
---|
| 378 | */
|
---|
| 379 | #define SUPGIPGETCPU_RDTSCP_GROUP_IN_CH_NUMBER_IN_CL RT_BIT_32(3)
|
---|
[54252] | 380 | /** @} */
|
---|
| 381 |
|
---|
[64281] | 382 | /** @def SUPGIP_MAX_CPU_GROUPS
|
---|
| 383 | * Maximum number of CPU groups. */
|
---|
| 384 | #if RTCPUSET_MAX_CPUS >= 256
|
---|
| 385 | # define SUPGIP_MAX_CPU_GROUPS 256
|
---|
| 386 | #else
|
---|
[64304] | 387 | # define SUPGIP_MAX_CPU_GROUPS RTCPUSET_MAX_CPUS
|
---|
[64281] | 388 | #endif
|
---|
[54252] | 389 |
|
---|
[1027] | 390 | /**
|
---|
| 391 | * Global Information Page.
|
---|
| 392 | *
|
---|
| 393 | * This page contains useful information and can be mapped into any
|
---|
| 394 | * process or VM. It can be accessed thru the g_pSUPGlobalInfoPage
|
---|
| 395 | * pointer when a session is open.
|
---|
| 396 | */
|
---|
| 397 | typedef struct SUPGLOBALINFOPAGE
|
---|
| 398 | {
|
---|
| 399 | /** Magic (SUPGLOBALINFOPAGE_MAGIC). */
|
---|
| 400 | uint32_t u32Magic;
|
---|
[1840] | 401 | /** The GIP version. */
|
---|
| 402 | uint32_t u32Version;
|
---|
[1027] | 403 |
|
---|
| 404 | /** The GIP update mode, see SUPGIPMODE. */
|
---|
| 405 | uint32_t u32Mode;
|
---|
[36254] | 406 | /** The number of entries in the CPU table.
|
---|
| 407 | * (This can work as RTMpGetArraySize().) */
|
---|
| 408 | uint16_t cCpus;
|
---|
| 409 | /** The size of the GIP in pages. */
|
---|
| 410 | uint16_t cPages;
|
---|
[1027] | 411 | /** The update frequency of the of the NanoTS. */
|
---|
| 412 | volatile uint32_t u32UpdateHz;
|
---|
| 413 | /** The update interval in nanoseconds. (10^9 / u32UpdateHz) */
|
---|
| 414 | volatile uint32_t u32UpdateIntervalNS;
|
---|
[1] | 415 | /** The timestamp of the last time we update the update frequency. */
|
---|
| 416 | volatile uint64_t u64NanoTSLastUpdateHz;
|
---|
[53269] | 417 | /** The TSC frequency of the system. */
|
---|
| 418 | uint64_t u64CpuHz;
|
---|
[36254] | 419 | /** The set of online CPUs. */
|
---|
| 420 | RTCPUSET OnlineCpuSet;
|
---|
| 421 | /** The set of present CPUs. */
|
---|
| 422 | RTCPUSET PresentCpuSet;
|
---|
| 423 | /** The set of possible CPUs. */
|
---|
| 424 | RTCPUSET PossibleCpuSet;
|
---|
[36262] | 425 | /** The number of CPUs that are online. */
|
---|
| 426 | volatile uint16_t cOnlineCpus;
|
---|
| 427 | /** The number of CPUs present in the system. */
|
---|
| 428 | volatile uint16_t cPresentCpus;
|
---|
[36254] | 429 | /** The highest number of CPUs possible. */
|
---|
[36262] | 430 | uint16_t cPossibleCpus;
|
---|
[64255] | 431 | /** The highest number of CPU groups possible. */
|
---|
| 432 | uint16_t cPossibleCpuGroups;
|
---|
[36254] | 433 | /** The max CPU ID (RTMpGetMaxCpuId). */
|
---|
| 434 | RTCPUID idCpuMax;
|
---|
[54252] | 435 | /** The applicability of SUPGIPCPU::i64TscDelta. */
|
---|
| 436 | SUPGIPUSETSCDELTA enmUseTscDelta;
|
---|
| 437 | /** Mask of SUPGIPGETCPU_XXX values that indicates different ways that aCPU
|
---|
| 438 | * can be accessed from ring-3 and raw-mode context. */
|
---|
| 439 | uint32_t fGetGipCpu;
|
---|
[57218] | 440 | /** GIP flags, see SUPGIP_FLAGS_XXX. */
|
---|
| 441 | volatile uint32_t fFlags;
|
---|
[1027] | 442 |
|
---|
| 443 | /** Padding / reserved space for future data. */
|
---|
[57218] | 444 | uint32_t au32Padding1[24];
|
---|
[1027] | 445 |
|
---|
[36254] | 446 | /** Table indexed by the CPU APIC ID to get the CPU table index. */
|
---|
[36262] | 447 | uint16_t aiCpuFromApicId[256];
|
---|
[36254] | 448 | /** CPU set index to CPU table index. */
|
---|
[36262] | 449 | uint16_t aiCpuFromCpuSetIdx[RTCPUSET_MAX_CPUS];
|
---|
[64281] | 450 | /** Table indexed by CPU group to containing offsets to SUPGIPCPUGROUP
|
---|
| 451 | * structures, invalid entries are set to UINT16_MAX. The offsets are relative
|
---|
| 452 | * to the start of this structure.
|
---|
| 453 | * @note Windows only. The other hosts sets all entries to UINT16_MAX! */
|
---|
| 454 | uint16_t aoffCpuGroup[SUPGIP_MAX_CPU_GROUPS];
|
---|
[36254] | 455 |
|
---|
[1027] | 456 | /** Array of per-cpu data.
|
---|
[36254] | 457 | * This is index by ApicId via the aiCpuFromApicId table.
|
---|
| 458 | *
|
---|
[53430] | 459 | * The clock and frequency information is updated for all CPUs if @c u32Mode
|
---|
| 460 | * is SUPGIPMODE_ASYNC_TSC. If @c u32Mode is SUPGIPMODE_SYNC_TSC only the first
|
---|
| 461 | * entry is updated. If @c u32Mode is SUPGIPMODE_SYNC_TSC the TSC frequency in
|
---|
| 462 | * @c u64CpuHz is copied to all CPUs. */
|
---|
[36254] | 463 | SUPGIPCPU aCPUs[1];
|
---|
[1] | 464 | } SUPGLOBALINFOPAGE;
|
---|
[36254] | 465 | AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, u64NanoTSLastUpdateHz, 8);
|
---|
[40950] | 466 | #if defined(RT_ARCH_SPARC) || defined(RT_ARCH_SPARC64)
|
---|
| 467 | AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs, 32);
|
---|
| 468 | #else
|
---|
[36263] | 469 | AssertCompileMemberAlignment(SUPGLOBALINFOPAGE, aCPUs, 256);
|
---|
[40950] | 470 | #endif
|
---|
[64255] | 471 | AssertCompile(sizeof(SUPGLOBALINFOPAGE) <= 0x1000); /* Keeping it less or equal to a page for raw-mode (saved state). */
|
---|
[1027] | 472 |
|
---|
[3393] | 473 | /** Pointer to the global info page.
|
---|
| 474 | * @remark there is no const version of this typedef, see g_pSUPGlobalInfoPage for details. */
|
---|
[1] | 475 | typedef SUPGLOBALINFOPAGE *PSUPGLOBALINFOPAGE;
|
---|
| 476 |
|
---|
| 477 |
|
---|
[1027] | 478 | /** The value of the SUPGLOBALINFOPAGE::u32Magic field. (Soryo Fuyumi) */
|
---|
| 479 | #define SUPGLOBALINFOPAGE_MAGIC 0x19590106
|
---|
[3393] | 480 | /** The GIP version.
|
---|
| 481 | * Upper 16 bits is the major version. Major version is only changed with
|
---|
[1840] | 482 | * incompatible changes in the GIP. */
|
---|
[64281] | 483 | #define SUPGLOBALINFOPAGE_VERSION 0x00080000
|
---|
[1027] | 484 |
|
---|
[3393] | 485 | /**
|
---|
[1027] | 486 | * SUPGLOBALINFOPAGE::u32Mode values.
|
---|
| 487 | */
|
---|
| 488 | typedef enum SUPGIPMODE
|
---|
| 489 | {
|
---|
| 490 | /** The usual invalid null entry. */
|
---|
| 491 | SUPGIPMODE_INVALID = 0,
|
---|
| 492 | /** The TSC of the cores and cpus in the system is in sync. */
|
---|
| 493 | SUPGIPMODE_SYNC_TSC,
|
---|
| 494 | /** Each core has it's own TSC. */
|
---|
| 495 | SUPGIPMODE_ASYNC_TSC,
|
---|
[53430] | 496 | /** The TSC of the cores are non-stop and have a constant frequency. */
|
---|
| 497 | SUPGIPMODE_INVARIANT_TSC,
|
---|
[54270] | 498 | /** End of valid GIP mode values (exclusive). */
|
---|
| 499 | SUPGIPMODE_END,
|
---|
[1027] | 500 | /** The usual 32-bit hack. */
|
---|
| 501 | SUPGIPMODE_32BIT_HACK = 0x7fffffff
|
---|
| 502 | } SUPGIPMODE;
|
---|
| 503 |
|
---|
[1] | 504 | /** Pointer to the Global Information Page.
|
---|
| 505 | *
|
---|
| 506 | * This pointer is valid as long as SUPLib has a open session. Anyone using
|
---|
[33540] | 507 | * the page must treat this pointer as highly volatile and not trust it beyond
|
---|
[1] | 508 | * one transaction.
|
---|
[3393] | 509 | *
|
---|
| 510 | * @remark The GIP page is read-only to everyone but the support driver and
|
---|
| 511 | * is actually mapped read only everywhere but in ring-0. However
|
---|
| 512 | * it is not marked 'const' as this might confuse compilers into
|
---|
| 513 | * thinking that values doesn't change even if members are marked
|
---|
| 514 | * as volatile. Thus, there is no PCSUPGLOBALINFOPAGE type.
|
---|
[1] | 515 | */
|
---|
[54309] | 516 | #if defined(IN_SUP_R3) || defined(IN_SUP_R0)
|
---|
[3393] | 517 | extern DECLEXPORT(PSUPGLOBALINFOPAGE) g_pSUPGlobalInfoPage;
|
---|
[25278] | 518 |
|
---|
[37228] | 519 | #elif !defined(IN_RING0) || defined(RT_OS_WINDOWS) || defined(RT_OS_SOLARIS)
|
---|
[25278] | 520 | extern DECLIMPORT(PSUPGLOBALINFOPAGE) g_pSUPGlobalInfoPage;
|
---|
| 521 |
|
---|
| 522 | #else /* IN_RING0 && !RT_OS_WINDOWS */
|
---|
| 523 | # if !defined(__GNUC__) || defined(RT_OS_DARWIN) || !defined(RT_ARCH_AMD64)
|
---|
| 524 | # define g_pSUPGlobalInfoPage (&g_SUPGlobalInfoPage)
|
---|
[25275] | 525 | # else
|
---|
[54310] | 526 | # define g_pSUPGlobalInfoPage (SUPGetGIPHlp())
|
---|
[335] | 527 | /** Workaround for ELF+GCC problem on 64-bit hosts.
|
---|
| 528 | * (GCC emits a mov with a R_X86_64_32 reloc, we need R_X86_64_64.) */
|
---|
[25275] | 529 | DECLINLINE(PSUPGLOBALINFOPAGE) SUPGetGIPHlp(void)
|
---|
[335] | 530 | {
|
---|
[3393] | 531 | PSUPGLOBALINFOPAGE pGIP;
|
---|
[3283] | 532 | __asm__ __volatile__ ("movabs $g_SUPGlobalInfoPage,%0\n\t"
|
---|
[335] | 533 | : "=a" (pGIP));
|
---|
| 534 | return pGIP;
|
---|
| 535 | }
|
---|
[3363] | 536 | # endif
|
---|
[25278] | 537 | /** The GIP.
|
---|
| 538 | * We save a level of indirection by exporting the GIP instead of a variable
|
---|
| 539 | * pointing to it. */
|
---|
| 540 | extern DECLIMPORT(SUPGLOBALINFOPAGE) g_SUPGlobalInfoPage;
|
---|
[1] | 541 | #endif
|
---|
| 542 |
|
---|
[25275] | 543 | /**
|
---|
| 544 | * Gets the GIP pointer.
|
---|
| 545 | *
|
---|
| 546 | * @returns Pointer to the GIP or NULL.
|
---|
| 547 | */
|
---|
| 548 | SUPDECL(PSUPGLOBALINFOPAGE) SUPGetGIP(void);
|
---|
[1] | 549 |
|
---|
[57218] | 550 | /** @name SUPGIP_FLAGS_XXX - SUPR3GipSetFlags flags.
|
---|
| 551 | * @{ */
|
---|
| 552 | /** Enable GIP test mode. */
|
---|
| 553 | #define SUPGIP_FLAGS_TESTING_ENABLE RT_BIT_32(0)
|
---|
| 554 | /** Valid mask of flags that can be set through the ioctl. */
|
---|
| 555 | #define SUPGIP_FLAGS_VALID_MASK RT_BIT_32(0)
|
---|
| 556 | /** GIP test mode needs to be checked (e.g. when enabled or being disabled). */
|
---|
| 557 | #define SUPGIP_FLAGS_TESTING RT_BIT_32(24)
|
---|
| 558 | /** Prepare to start GIP test mode. */
|
---|
| 559 | #define SUPGIP_FLAGS_TESTING_START RT_BIT_32(25)
|
---|
| 560 | /** Prepare to stop GIP test mode. */
|
---|
| 561 | #define SUPGIP_FLAGS_TESTING_STOP RT_BIT_32(26)
|
---|
| 562 | /** @} */
|
---|
[53800] | 563 |
|
---|
[54308] | 564 | /** @internal */
|
---|
| 565 | SUPDECL(uint64_t) SUPGetCpuHzFromGipForAsyncMode(PSUPGLOBALINFOPAGE pGip);
|
---|
[57090] | 566 | SUPDECL(bool) SUPIsTscFreqCompatible(uint64_t uCpuHz, uint64_t *puGipCpuHz, bool fRelax);
|
---|
| 567 | SUPDECL(bool) SUPIsTscFreqCompatibleEx(uint64_t uBaseCpuHz, uint64_t uCpuHz, bool fRelax);
|
---|
[54215] | 568 |
|
---|
[57090] | 569 |
|
---|
[1027] | 570 | /**
|
---|
| 571 | * Gets the TSC frequency of the calling CPU.
|
---|
[3393] | 572 | *
|
---|
[54352] | 573 | * @returns TSC frequency, UINT64_MAX on failure (asserted).
|
---|
[1027] | 574 | * @param pGip The GIP pointer.
|
---|
| 575 | */
|
---|
[54308] | 576 | DECLINLINE(uint64_t) SUPGetCpuHzFromGip(PSUPGLOBALINFOPAGE pGip)
|
---|
[1027] | 577 | {
|
---|
[54308] | 578 | if (RT_LIKELY( pGip
|
---|
[54352] | 579 | && pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC))
|
---|
[54308] | 580 | {
|
---|
| 581 | switch (pGip->u32Mode)
|
---|
| 582 | {
|
---|
| 583 | case SUPGIPMODE_INVARIANT_TSC:
|
---|
| 584 | case SUPGIPMODE_SYNC_TSC:
|
---|
| 585 | return pGip->aCPUs[0].u64CpuHz;
|
---|
| 586 | case SUPGIPMODE_ASYNC_TSC:
|
---|
| 587 | return SUPGetCpuHzFromGipForAsyncMode(pGip);
|
---|
| 588 | default: break; /* shut up gcc */
|
---|
| 589 | }
|
---|
| 590 | }
|
---|
| 591 | AssertFailed();
|
---|
| 592 | return UINT64_MAX;
|
---|
| 593 | }
|
---|
[1] | 594 |
|
---|
[1027] | 595 |
|
---|
[54308] | 596 | /**
|
---|
| 597 | * Gets the TSC frequency of the specified CPU.
|
---|
| 598 | *
|
---|
[54352] | 599 | * @returns TSC frequency, UINT64_MAX on failure (asserted).
|
---|
[54308] | 600 | * @param pGip The GIP pointer.
|
---|
| 601 | * @param iCpuSet The CPU set index of the CPU in question.
|
---|
| 602 | */
|
---|
| 603 | DECLINLINE(uint64_t) SUPGetCpuHzFromGipBySetIndex(PSUPGLOBALINFOPAGE pGip, uint32_t iCpuSet)
|
---|
| 604 | {
|
---|
| 605 | if (RT_LIKELY( pGip
|
---|
[54352] | 606 | && pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC))
|
---|
[1027] | 607 | {
|
---|
[54308] | 608 | switch (pGip->u32Mode)
|
---|
| 609 | {
|
---|
| 610 | case SUPGIPMODE_INVARIANT_TSC:
|
---|
| 611 | case SUPGIPMODE_SYNC_TSC:
|
---|
| 612 | return pGip->aCPUs[0].u64CpuHz;
|
---|
| 613 | case SUPGIPMODE_ASYNC_TSC:
|
---|
| 614 | if (RT_LIKELY(iCpuSet < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx)))
|
---|
| 615 | {
|
---|
| 616 | uint16_t iCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet];
|
---|
| 617 | if (RT_LIKELY(iCpu < pGip->cCpus))
|
---|
| 618 | return pGip->aCPUs[iCpu].u64CpuHz;
|
---|
| 619 | }
|
---|
| 620 | break;
|
---|
| 621 | default: break; /* shut up gcc */
|
---|
| 622 | }
|
---|
[1027] | 623 | }
|
---|
[54308] | 624 | AssertFailed();
|
---|
| 625 | return UINT64_MAX;
|
---|
| 626 | }
|
---|
[1027] | 627 |
|
---|
[54308] | 628 |
|
---|
[64255] | 629 | /**
|
---|
| 630 | * Gets the pointer to the per CPU data for a CPU given by its set index.
|
---|
| 631 | *
|
---|
| 632 | * @returns Pointer to the corresponding per CPU structure, or NULL if invalid.
|
---|
| 633 | * @param pGip The GIP pointer.
|
---|
| 634 | * @param iCpuSet The CPU set index of the CPU which we want.
|
---|
| 635 | */
|
---|
| 636 | DECLINLINE(PSUPGIPCPU) SUPGetGipCpuBySetIndex(PSUPGLOBALINFOPAGE pGip, uint32_t iCpuSet)
|
---|
| 637 | {
|
---|
| 638 | if (RT_LIKELY( pGip
|
---|
| 639 | && pGip->u32Magic == SUPGLOBALINFOPAGE_MAGIC))
|
---|
| 640 | {
|
---|
| 641 | if (RT_LIKELY(iCpuSet < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx)))
|
---|
| 642 | {
|
---|
| 643 | uint16_t iCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet];
|
---|
| 644 | if (RT_LIKELY(iCpu < pGip->cCpus))
|
---|
| 645 | return &pGip->aCPUs[iCpu];
|
---|
| 646 | }
|
---|
| 647 | }
|
---|
| 648 | return NULL;
|
---|
| 649 | }
|
---|
| 650 |
|
---|
| 651 |
|
---|
[54308] | 652 | #if defined(RT_ARCH_AMD64) || defined(RT_ARCH_X86)
|
---|
| 653 |
|
---|
| 654 | /** @internal */
|
---|
| 655 | SUPDECL(uint64_t) SUPReadTscWithDelta(PSUPGLOBALINFOPAGE pGip);
|
---|
| 656 |
|
---|
| 657 | /**
|
---|
| 658 | * Read the host TSC value and applies the TSC delta if appropriate.
|
---|
| 659 | *
|
---|
| 660 | * @returns the TSC value.
|
---|
| 661 | * @remarks Requires GIP to be initialized and valid.
|
---|
| 662 | */
|
---|
| 663 | DECLINLINE(uint64_t) SUPReadTsc(void)
|
---|
| 664 | {
|
---|
| 665 | PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
|
---|
| 666 | if (pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ROUGHLY_ZERO)
|
---|
| 667 | return ASMReadTSC();
|
---|
| 668 | return SUPReadTscWithDelta(pGip);
|
---|
| 669 | }
|
---|
| 670 |
|
---|
[53435] | 671 | #endif /* X86 || AMD64 */
|
---|
[1027] | 672 |
|
---|
[54308] | 673 | /** @internal */
|
---|
| 674 | SUPDECL(uint64_t) SUPGetTscDeltaSlow(PSUPGLOBALINFOPAGE pGip);
|
---|
| 675 |
|
---|
[4800] | 676 | /**
|
---|
[54308] | 677 | * Gets the TSC delta for the current CPU.
|
---|
| 678 | *
|
---|
| 679 | * @returns The TSC delta value (will not return the special INT64_MAX value).
|
---|
| 680 | * @remarks Requires GIP to be initialized and valid.
|
---|
| 681 | */
|
---|
| 682 | DECLINLINE(int64_t) SUPGetTscDelta(void)
|
---|
| 683 | {
|
---|
| 684 | PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
|
---|
| 685 | if (pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ROUGHLY_ZERO)
|
---|
| 686 | return 0;
|
---|
| 687 | return SUPGetTscDeltaSlow(pGip);
|
---|
| 688 | }
|
---|
| 689 |
|
---|
| 690 |
|
---|
| 691 | /**
|
---|
| 692 | * Gets the TSC delta for a given CPU.
|
---|
| 693 | *
|
---|
| 694 | * @returns The TSC delta value (will not return the special INT64_MAX value).
|
---|
| 695 | * @param iCpuSet The CPU set index of the CPU which TSC delta we want.
|
---|
| 696 | * @remarks Requires GIP to be initialized and valid.
|
---|
| 697 | */
|
---|
| 698 | DECLINLINE(int64_t) SUPGetTscDeltaByCpuSetIndex(uint32_t iCpuSet)
|
---|
| 699 | {
|
---|
| 700 | PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
|
---|
| 701 | if (pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ROUGHLY_ZERO)
|
---|
| 702 | return 0;
|
---|
| 703 | if (RT_LIKELY(iCpuSet < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx)))
|
---|
| 704 | {
|
---|
| 705 | uint16_t iCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet];
|
---|
| 706 | if (RT_LIKELY(iCpu < pGip->cCpus))
|
---|
| 707 | {
|
---|
| 708 | int64_t iTscDelta = pGip->aCPUs[iCpu].i64TSCDelta;
|
---|
| 709 | if (iTscDelta != INT64_MAX)
|
---|
| 710 | return iTscDelta;
|
---|
| 711 | }
|
---|
| 712 | }
|
---|
| 713 | AssertFailed();
|
---|
| 714 | return 0;
|
---|
| 715 | }
|
---|
| 716 |
|
---|
| 717 |
|
---|
| 718 | /**
|
---|
[54333] | 719 | * Checks if the TSC delta is available for a given CPU (if TSC-deltas are
|
---|
| 720 | * relevant).
|
---|
| 721 | *
|
---|
| 722 | * @returns true if it's okay to read the TSC, false otherwise.
|
---|
| 723 | *
|
---|
| 724 | * @param iCpuSet The CPU set index of the CPU which TSC delta we check.
|
---|
| 725 | * @remarks Requires GIP to be initialized and valid.
|
---|
| 726 | */
|
---|
| 727 | DECLINLINE(bool) SUPIsTscDeltaAvailableForCpuSetIndex(uint32_t iCpuSet)
|
---|
| 728 | {
|
---|
| 729 | PSUPGLOBALINFOPAGE pGip = g_pSUPGlobalInfoPage;
|
---|
| 730 | if (pGip->enmUseTscDelta <= SUPGIPUSETSCDELTA_ROUGHLY_ZERO)
|
---|
| 731 | return true;
|
---|
| 732 | if (RT_LIKELY(iCpuSet < RT_ELEMENTS(pGip->aiCpuFromCpuSetIdx)))
|
---|
| 733 | {
|
---|
| 734 | uint16_t iCpu = pGip->aiCpuFromCpuSetIdx[iCpuSet];
|
---|
| 735 | if (RT_LIKELY(iCpu < pGip->cCpus))
|
---|
| 736 | {
|
---|
| 737 | int64_t iTscDelta = pGip->aCPUs[iCpu].i64TSCDelta;
|
---|
| 738 | if (iTscDelta != INT64_MAX)
|
---|
| 739 | return true;
|
---|
| 740 | }
|
---|
| 741 | }
|
---|
| 742 | return false;
|
---|
| 743 | }
|
---|
| 744 |
|
---|
| 745 |
|
---|
| 746 | /**
|
---|
[54308] | 747 | * Gets the descriptive GIP mode name.
|
---|
| 748 | *
|
---|
| 749 | * @returns The name.
|
---|
| 750 | * @param pGip Pointer to the GIP.
|
---|
| 751 | */
|
---|
| 752 | DECLINLINE(const char *) SUPGetGIPModeName(PSUPGLOBALINFOPAGE pGip)
|
---|
| 753 | {
|
---|
| 754 | AssertReturn(pGip, NULL);
|
---|
| 755 | switch (pGip->u32Mode)
|
---|
| 756 | {
|
---|
| 757 | case SUPGIPMODE_INVARIANT_TSC: return "Invariant";
|
---|
| 758 | case SUPGIPMODE_SYNC_TSC: return "Synchronous";
|
---|
| 759 | case SUPGIPMODE_ASYNC_TSC: return "Asynchronous";
|
---|
| 760 | case SUPGIPMODE_INVALID: return "Invalid";
|
---|
| 761 | default: return "???";
|
---|
| 762 | }
|
---|
| 763 | }
|
---|
| 764 |
|
---|
| 765 |
|
---|
| 766 | /**
|
---|
[55157] | 767 | * Gets the descriptive TSC-delta enum name.
|
---|
| 768 | *
|
---|
| 769 | * @returns The name.
|
---|
| 770 | * @param pGip Pointer to the GIP.
|
---|
| 771 | */
|
---|
| 772 | DECLINLINE(const char *) SUPGetGIPTscDeltaModeName(PSUPGLOBALINFOPAGE pGip)
|
---|
| 773 | {
|
---|
| 774 | AssertReturn(pGip, NULL);
|
---|
| 775 | switch (pGip->enmUseTscDelta)
|
---|
| 776 | {
|
---|
| 777 | case SUPGIPUSETSCDELTA_NOT_APPLICABLE: return "Not Applicable";
|
---|
| 778 | case SUPGIPUSETSCDELTA_ZERO_CLAIMED: return "Zero Claimed";
|
---|
[69949] | 779 | case SUPGIPUSETSCDELTA_PRACTICALLY_ZERO: return "Practically Zero";
|
---|
[55157] | 780 | case SUPGIPUSETSCDELTA_ROUGHLY_ZERO: return "Roughly Zero";
|
---|
| 781 | case SUPGIPUSETSCDELTA_NOT_ZERO: return "Not Zero";
|
---|
| 782 | default: return "???";
|
---|
| 783 | }
|
---|
| 784 | }
|
---|
| 785 |
|
---|
| 786 |
|
---|
| 787 | /**
|
---|
[4800] | 788 | * Request for generic VMMR0Entry calls.
|
---|
| 789 | */
|
---|
| 790 | typedef struct SUPVMMR0REQHDR
|
---|
| 791 | {
|
---|
| 792 | /** The magic. (SUPVMMR0REQHDR_MAGIC) */
|
---|
| 793 | uint32_t u32Magic;
|
---|
| 794 | /** The size of the request. */
|
---|
| 795 | uint32_t cbReq;
|
---|
| 796 | } SUPVMMR0REQHDR;
|
---|
| 797 | /** Pointer to a ring-0 request header. */
|
---|
| 798 | typedef SUPVMMR0REQHDR *PSUPVMMR0REQHDR;
|
---|
| 799 | /** the SUPVMMR0REQHDR::u32Magic value (Ethan Iverson - The Bad Plus). */
|
---|
[14332] | 800 | #define SUPVMMR0REQHDR_MAGIC UINT32_C(0x19730211)
|
---|
[4800] | 801 |
|
---|
| 802 |
|
---|
[4811] | 803 | /** For the fast ioctl path.
|
---|
| 804 | * @{
|
---|
| 805 | */
|
---|
| 806 | /** @see VMMR0_DO_RAW_RUN. */
|
---|
| 807 | #define SUP_VMMR0_DO_RAW_RUN 0
|
---|
[43394] | 808 | /** @see VMMR0_DO_HM_RUN. */
|
---|
[49246] | 809 | #define SUP_VMMR0_DO_HM_RUN 1
|
---|
[4811] | 810 | /** @see VMMR0_DO_NOP */
|
---|
| 811 | #define SUP_VMMR0_DO_NOP 2
|
---|
[71198] | 812 | /** @see VMMR0_DO_NEM_RUN */
|
---|
| 813 | #define SUP_VMMR0_DO_NEM_RUN 3
|
---|
[4811] | 814 | /** @} */
|
---|
[4800] | 815 |
|
---|
[73362] | 816 | /** SUPR3QueryVTCaps capability flags.
|
---|
[23699] | 817 | * @{
|
---|
| 818 | */
|
---|
[54874] | 819 | /** AMD-V support. */
|
---|
| 820 | #define SUPVTCAPS_AMD_V RT_BIT(0)
|
---|
| 821 | /** VT-x support. */
|
---|
| 822 | #define SUPVTCAPS_VT_X RT_BIT(1)
|
---|
| 823 | /** Nested paging is supported. */
|
---|
| 824 | #define SUPVTCAPS_NESTED_PAGING RT_BIT(2)
|
---|
| 825 | /** VT-x: Unrestricted guest execution is supported. */
|
---|
| 826 | #define SUPVTCAPS_VTX_UNRESTRICTED_GUEST RT_BIT(3)
|
---|
[23699] | 827 | /** @} */
|
---|
[4811] | 828 |
|
---|
[14332] | 829 | /**
|
---|
| 830 | * Request for generic FNSUPR0SERVICEREQHANDLER calls.
|
---|
| 831 | */
|
---|
| 832 | typedef struct SUPR0SERVICEREQHDR
|
---|
| 833 | {
|
---|
| 834 | /** The magic. (SUPR0SERVICEREQHDR_MAGIC) */
|
---|
| 835 | uint32_t u32Magic;
|
---|
| 836 | /** The size of the request. */
|
---|
| 837 | uint32_t cbReq;
|
---|
| 838 | } SUPR0SERVICEREQHDR;
|
---|
| 839 | /** Pointer to a ring-0 service request header. */
|
---|
| 840 | typedef SUPR0SERVICEREQHDR *PSUPR0SERVICEREQHDR;
|
---|
| 841 | /** the SUPVMMR0REQHDR::u32Magic value (Esbjoern Svensson - E.S.P.). */
|
---|
| 842 | #define SUPR0SERVICEREQHDR_MAGIC UINT32_C(0x19640416)
|
---|
[4811] | 843 |
|
---|
[14332] | 844 |
|
---|
[19866] | 845 | /**
|
---|
| 846 | * Creates a single release event semaphore.
|
---|
| 847 | *
|
---|
| 848 | * @returns VBox status code.
|
---|
| 849 | * @param pSession The session handle of the caller.
|
---|
| 850 | * @param phEvent Where to return the handle to the event semaphore.
|
---|
| 851 | */
|
---|
| 852 | SUPDECL(int) SUPSemEventCreate(PSUPDRVSESSION pSession, PSUPSEMEVENT phEvent);
|
---|
| 853 |
|
---|
| 854 | /**
|
---|
| 855 | * Closes a single release event semaphore handle.
|
---|
| 856 | *
|
---|
| 857 | * @returns VBox status code.
|
---|
[19891] | 858 | * @retval VINF_OBJECT_DESTROYED if the semaphore was destroyed.
|
---|
[33540] | 859 | * @retval VINF_SUCCESS if the handle was successfully closed but the semaphore
|
---|
[19891] | 860 | * object remained alive because of other references.
|
---|
| 861 | *
|
---|
[19866] | 862 | * @param pSession The session handle of the caller.
|
---|
| 863 | * @param hEvent The handle. Nil is quietly ignored.
|
---|
| 864 | */
|
---|
| 865 | SUPDECL(int) SUPSemEventClose(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent);
|
---|
| 866 |
|
---|
| 867 | /**
|
---|
| 868 | * Signals a single release event semaphore.
|
---|
| 869 | *
|
---|
| 870 | * @returns VBox status code.
|
---|
| 871 | * @param pSession The session handle of the caller.
|
---|
| 872 | * @param hEvent The semaphore handle.
|
---|
| 873 | */
|
---|
| 874 | SUPDECL(int) SUPSemEventSignal(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent);
|
---|
| 875 |
|
---|
| 876 | #ifdef IN_RING0
|
---|
| 877 | /**
|
---|
| 878 | * Waits on a single release event semaphore, not interruptible.
|
---|
| 879 | *
|
---|
| 880 | * @returns VBox status code.
|
---|
| 881 | * @param pSession The session handle of the caller.
|
---|
| 882 | * @param hEvent The semaphore handle.
|
---|
| 883 | * @param cMillies The number of milliseconds to wait.
|
---|
| 884 | * @remarks Not available in ring-3.
|
---|
| 885 | */
|
---|
| 886 | SUPDECL(int) SUPSemEventWait(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies);
|
---|
| 887 | #endif
|
---|
| 888 |
|
---|
| 889 | /**
|
---|
| 890 | * Waits on a single release event semaphore, interruptible.
|
---|
| 891 | *
|
---|
| 892 | * @returns VBox status code.
|
---|
| 893 | * @param pSession The session handle of the caller.
|
---|
| 894 | * @param hEvent The semaphore handle.
|
---|
| 895 | * @param cMillies The number of milliseconds to wait.
|
---|
| 896 | */
|
---|
| 897 | SUPDECL(int) SUPSemEventWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint32_t cMillies);
|
---|
| 898 |
|
---|
[33167] | 899 | /**
|
---|
| 900 | * Waits on a single release event semaphore, interruptible.
|
---|
| 901 | *
|
---|
| 902 | * @returns VBox status code.
|
---|
| 903 | * @param pSession The session handle of the caller.
|
---|
| 904 | * @param hEvent The semaphore handle.
|
---|
| 905 | * @param uNsTimeout The deadline given on the RTTimeNanoTS() clock.
|
---|
| 906 | */
|
---|
| 907 | SUPDECL(int) SUPSemEventWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t uNsTimeout);
|
---|
[19866] | 908 |
|
---|
[33167] | 909 | /**
|
---|
| 910 | * Waits on a single release event semaphore, interruptible.
|
---|
| 911 | *
|
---|
| 912 | * @returns VBox status code.
|
---|
| 913 | * @param pSession The session handle of the caller.
|
---|
| 914 | * @param hEvent The semaphore handle.
|
---|
| 915 | * @param cNsTimeout The number of nanoseconds to wait.
|
---|
| 916 | */
|
---|
| 917 | SUPDECL(int) SUPSemEventWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENT hEvent, uint64_t cNsTimeout);
|
---|
| 918 |
|
---|
| 919 | /**
|
---|
| 920 | * Gets the best timeout resolution that SUPSemEventWaitNsAbsIntr and
|
---|
| 921 | * SUPSemEventWaitNsAbsIntr can do.
|
---|
| 922 | *
|
---|
| 923 | * @returns The resolution in nanoseconds.
|
---|
| 924 | * @param pSession The session handle of the caller.
|
---|
| 925 | */
|
---|
| 926 | SUPDECL(uint32_t) SUPSemEventGetResolution(PSUPDRVSESSION pSession);
|
---|
| 927 |
|
---|
| 928 |
|
---|
[19866] | 929 | /**
|
---|
| 930 | * Creates a multiple release event semaphore.
|
---|
| 931 | *
|
---|
| 932 | * @returns VBox status code.
|
---|
| 933 | * @param pSession The session handle of the caller.
|
---|
| 934 | * @param phEventMulti Where to return the handle to the event semaphore.
|
---|
| 935 | */
|
---|
| 936 | SUPDECL(int) SUPSemEventMultiCreate(PSUPDRVSESSION pSession, PSUPSEMEVENTMULTI phEventMulti);
|
---|
| 937 |
|
---|
| 938 | /**
|
---|
| 939 | * Closes a multiple release event semaphore handle.
|
---|
| 940 | *
|
---|
| 941 | * @returns VBox status code.
|
---|
[19891] | 942 | * @retval VINF_OBJECT_DESTROYED if the semaphore was destroyed.
|
---|
[33540] | 943 | * @retval VINF_SUCCESS if the handle was successfully closed but the semaphore
|
---|
[19891] | 944 | * object remained alive because of other references.
|
---|
| 945 | *
|
---|
[19866] | 946 | * @param pSession The session handle of the caller.
|
---|
| 947 | * @param hEventMulti The handle. Nil is quietly ignored.
|
---|
| 948 | */
|
---|
| 949 | SUPDECL(int) SUPSemEventMultiClose(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti);
|
---|
| 950 |
|
---|
| 951 | /**
|
---|
| 952 | * Signals a multiple release event semaphore.
|
---|
| 953 | *
|
---|
| 954 | * @returns VBox status code.
|
---|
| 955 | * @param pSession The session handle of the caller.
|
---|
| 956 | * @param hEventMulti The semaphore handle.
|
---|
| 957 | */
|
---|
| 958 | SUPDECL(int) SUPSemEventMultiSignal(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti);
|
---|
| 959 |
|
---|
| 960 | /**
|
---|
| 961 | * Resets a multiple release event semaphore.
|
---|
| 962 | *
|
---|
| 963 | * @returns VBox status code.
|
---|
| 964 | * @param pSession The session handle of the caller.
|
---|
| 965 | * @param hEventMulti The semaphore handle.
|
---|
| 966 | */
|
---|
| 967 | SUPDECL(int) SUPSemEventMultiReset(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti);
|
---|
| 968 |
|
---|
| 969 | #ifdef IN_RING0
|
---|
| 970 | /**
|
---|
| 971 | * Waits on a multiple release event semaphore, not interruptible.
|
---|
| 972 | *
|
---|
| 973 | * @returns VBox status code.
|
---|
| 974 | * @param pSession The session handle of the caller.
|
---|
| 975 | * @param hEventMulti The semaphore handle.
|
---|
| 976 | * @param cMillies The number of milliseconds to wait.
|
---|
| 977 | * @remarks Not available in ring-3.
|
---|
| 978 | */
|
---|
| 979 | SUPDECL(int) SUPSemEventMultiWait(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies);
|
---|
| 980 | #endif
|
---|
| 981 |
|
---|
| 982 | /**
|
---|
| 983 | * Waits on a multiple release event semaphore, interruptible.
|
---|
| 984 | *
|
---|
| 985 | * @returns VBox status code.
|
---|
| 986 | * @param pSession The session handle of the caller.
|
---|
| 987 | * @param hEventMulti The semaphore handle.
|
---|
| 988 | * @param cMillies The number of milliseconds to wait.
|
---|
| 989 | */
|
---|
| 990 | SUPDECL(int) SUPSemEventMultiWaitNoResume(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint32_t cMillies);
|
---|
| 991 |
|
---|
[33167] | 992 | /**
|
---|
| 993 | * Waits on a multiple release event semaphore, interruptible.
|
---|
| 994 | *
|
---|
| 995 | * @returns VBox status code.
|
---|
| 996 | * @param pSession The session handle of the caller.
|
---|
| 997 | * @param hEventMulti The semaphore handle.
|
---|
| 998 | * @param uNsTimeout The deadline given on the RTTimeNanoTS() clock.
|
---|
| 999 | */
|
---|
| 1000 | SUPDECL(int) SUPSemEventMultiWaitNsAbsIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t uNsTimeout);
|
---|
[19866] | 1001 |
|
---|
[33167] | 1002 | /**
|
---|
| 1003 | * Waits on a multiple release event semaphore, interruptible.
|
---|
| 1004 | *
|
---|
| 1005 | * @returns VBox status code.
|
---|
| 1006 | * @param pSession The session handle of the caller.
|
---|
| 1007 | * @param hEventMulti The semaphore handle.
|
---|
| 1008 | * @param cNsTimeout The number of nanoseconds to wait.
|
---|
| 1009 | */
|
---|
| 1010 | SUPDECL(int) SUPSemEventMultiWaitNsRelIntr(PSUPDRVSESSION pSession, SUPSEMEVENTMULTI hEventMulti, uint64_t cNsTimeout);
|
---|
| 1011 |
|
---|
| 1012 | /**
|
---|
| 1013 | * Gets the best timeout resolution that SUPSemEventMultiWaitNsAbsIntr and
|
---|
| 1014 | * SUPSemEventMultiWaitNsRelIntr can do.
|
---|
| 1015 | *
|
---|
| 1016 | * @returns The resolution in nanoseconds.
|
---|
| 1017 | * @param pSession The session handle of the caller.
|
---|
| 1018 | */
|
---|
| 1019 | SUPDECL(uint32_t) SUPSemEventMultiGetResolution(PSUPDRVSESSION pSession);
|
---|
| 1020 |
|
---|
| 1021 |
|
---|
[1] | 1022 | #ifdef IN_RING3
|
---|
| 1023 |
|
---|
[26227] | 1024 | /** @defgroup grp_sup_r3 SUP Host Context Ring-3 API
|
---|
[1] | 1025 | * @{
|
---|
| 1026 | */
|
---|
| 1027 |
|
---|
| 1028 | /**
|
---|
| 1029 | * Installs the support library.
|
---|
| 1030 | *
|
---|
| 1031 | * @returns VBox status code.
|
---|
| 1032 | */
|
---|
[20864] | 1033 | SUPR3DECL(int) SUPR3Install(void);
|
---|
[1] | 1034 |
|
---|
| 1035 | /**
|
---|
| 1036 | * Uninstalls the support library.
|
---|
| 1037 | *
|
---|
| 1038 | * @returns VBox status code.
|
---|
| 1039 | */
|
---|
[20864] | 1040 | SUPR3DECL(int) SUPR3Uninstall(void);
|
---|
[1] | 1041 |
|
---|
| 1042 | /**
|
---|
[13458] | 1043 | * Trusted main entry point.
|
---|
| 1044 | *
|
---|
| 1045 | * This is exported as "TrustedMain" by the dynamic libraries which contains the
|
---|
| 1046 | * "real" application binary for which the hardened stub is built. The entry
|
---|
[33540] | 1047 | * point is invoked upon successful initialization of the support library and
|
---|
[13458] | 1048 | * runtime.
|
---|
| 1049 | *
|
---|
| 1050 | * @returns main kind of exit code.
|
---|
| 1051 | * @param argc The argument count.
|
---|
| 1052 | * @param argv The argument vector.
|
---|
| 1053 | * @param envp The environment vector.
|
---|
| 1054 | */
|
---|
| 1055 | typedef DECLCALLBACK(int) FNSUPTRUSTEDMAIN(int argc, char **argv, char **envp);
|
---|
| 1056 | /** Pointer to FNSUPTRUSTEDMAIN(). */
|
---|
| 1057 | typedef FNSUPTRUSTEDMAIN *PFNSUPTRUSTEDMAIN;
|
---|
| 1058 |
|
---|
| 1059 | /** Which operation failed. */
|
---|
| 1060 | typedef enum SUPINITOP
|
---|
| 1061 | {
|
---|
| 1062 | /** Invalid. */
|
---|
| 1063 | kSupInitOp_Invalid = 0,
|
---|
| 1064 | /** Installation integrity error. */
|
---|
| 1065 | kSupInitOp_Integrity,
|
---|
| 1066 | /** Setuid related. */
|
---|
| 1067 | kSupInitOp_RootCheck,
|
---|
| 1068 | /** Driver related. */
|
---|
| 1069 | kSupInitOp_Driver,
|
---|
| 1070 | /** IPRT init related. */
|
---|
| 1071 | kSupInitOp_IPRT,
|
---|
[51770] | 1072 | /** Miscellaneous. */
|
---|
| 1073 | kSupInitOp_Misc,
|
---|
[13458] | 1074 | /** Place holder. */
|
---|
| 1075 | kSupInitOp_End
|
---|
| 1076 | } SUPINITOP;
|
---|
| 1077 |
|
---|
| 1078 | /**
|
---|
| 1079 | * Trusted error entry point, optional.
|
---|
| 1080 | *
|
---|
| 1081 | * This is exported as "TrustedError" by the dynamic libraries which contains
|
---|
[52424] | 1082 | * the "real" application binary for which the hardened stub is built. The
|
---|
| 1083 | * hardened main() must specify SUPSECMAIN_FLAGS_TRUSTED_ERROR when calling
|
---|
| 1084 | * SUPR3HardenedMain.
|
---|
[13458] | 1085 | *
|
---|
[33540] | 1086 | * @param pszWhere Where the error occurred (function name).
|
---|
[13458] | 1087 | * @param enmWhat Which operation went wrong.
|
---|
| 1088 | * @param rc The status code.
|
---|
| 1089 | * @param pszMsgFmt Error message format string.
|
---|
| 1090 | * @param va The message format arguments.
|
---|
| 1091 | */
|
---|
[57006] | 1092 | typedef DECLCALLBACK(void) FNSUPTRUSTEDERROR(const char *pszWhere, SUPINITOP enmWhat, int rc,
|
---|
| 1093 | const char *pszMsgFmt, va_list va) RT_IPRT_FORMAT_ATTR(4, 0);
|
---|
[13458] | 1094 | /** Pointer to FNSUPTRUSTEDERROR. */
|
---|
| 1095 | typedef FNSUPTRUSTEDERROR *PFNSUPTRUSTEDERROR;
|
---|
| 1096 |
|
---|
| 1097 | /**
|
---|
[11725] | 1098 | * Secure main.
|
---|
| 1099 | *
|
---|
| 1100 | * This is used for the set-user-ID-on-execute binaries on unixy systems
|
---|
| 1101 | * and when using the open-vboxdrv-via-root-service setup on Windows.
|
---|
| 1102 | *
|
---|
| 1103 | * This function will perform the integrity checks of the VirtualBox
|
---|
| 1104 | * installation, open the support driver, open the root service (later),
|
---|
| 1105 | * and load the DLL corresponding to \a pszProgName and execute its main
|
---|
| 1106 | * function.
|
---|
| 1107 | *
|
---|
| 1108 | * @returns Return code appropriate for main().
|
---|
| 1109 | *
|
---|
| 1110 | * @param pszProgName The program name. This will be used to figure out which
|
---|
| 1111 | * DLL/SO/DYLIB to load and execute.
|
---|
| 1112 | * @param fFlags Flags.
|
---|
| 1113 | * @param argc The argument count.
|
---|
| 1114 | * @param argv The argument vector.
|
---|
| 1115 | * @param envp The environment vector.
|
---|
| 1116 | */
|
---|
| 1117 | DECLHIDDEN(int) SUPR3HardenedMain(const char *pszProgName, uint32_t fFlags, int argc, char **argv, char **envp);
|
---|
| 1118 |
|
---|
[52424] | 1119 | /** @name SUPR3HardenedMain flags.
|
---|
[11725] | 1120 | * @{ */
|
---|
| 1121 | /** Don't open the device. (Intended for VirtualBox without -startvm.) */
|
---|
| 1122 | #define SUPSECMAIN_FLAGS_DONT_OPEN_DEV RT_BIT_32(0)
|
---|
[52424] | 1123 | /** The hardened DLL has a "TrustedError" function (see FNSUPTRUSTEDERROR). */
|
---|
| 1124 | #define SUPSECMAIN_FLAGS_TRUSTED_ERROR RT_BIT_32(1)
|
---|
[56817] | 1125 | /** Hack for making VirtualBoxVM use VirtualBox.dylib on Mac OS X. */
|
---|
| 1126 | #define SUPSECMAIN_FLAGS_OSX_VM_APP RT_BIT_32(2)
|
---|
[56733] | 1127 | /** Program binary location mask. */
|
---|
| 1128 | #define SUPSECMAIN_FLAGS_LOC_MASK UINT32_C(0x00000010)
|
---|
| 1129 | /** Default binary location is the application binary directory. Does
|
---|
| 1130 | * not need to be given explicitly (it's 0). */
|
---|
| 1131 | #define SUPSECMAIN_FLAGS_LOC_APP_BIN UINT32_C(0x00000000)
|
---|
| 1132 | /** The binary is located in the testcase directory instead of the
|
---|
| 1133 | * default application binary directory. */
|
---|
| 1134 | #define SUPSECMAIN_FLAGS_LOC_TESTCASE UINT32_C(0x00000010)
|
---|
[11725] | 1135 | /** @} */
|
---|
| 1136 |
|
---|
| 1137 | /**
|
---|
[1] | 1138 | * Initializes the support library.
|
---|
[44173] | 1139 | *
|
---|
[55436] | 1140 | * Each successful call to SUPR3Init() or SUPR3InitEx must be countered by a
|
---|
[20864] | 1141 | * call to SUPR3Term(false).
|
---|
[1] | 1142 | *
|
---|
| 1143 | * @returns VBox status code.
|
---|
| 1144 | * @param ppSession Where to store the session handle. Defaults to NULL.
|
---|
| 1145 | */
|
---|
[11794] | 1146 | SUPR3DECL(int) SUPR3Init(PSUPDRVSESSION *ppSession);
|
---|
[1] | 1147 |
|
---|
| 1148 | /**
|
---|
[44173] | 1149 | * Initializes the support library, extended version.
|
---|
| 1150 | *
|
---|
[55436] | 1151 | * Each successful call to SUPR3Init() or SUPR3InitEx must be countered by a
|
---|
[44173] | 1152 | * call to SUPR3Term(false).
|
---|
| 1153 | *
|
---|
| 1154 | * @returns VBox status code.
|
---|
| 1155 | * @param fUnrestricted The desired access.
|
---|
| 1156 | * @param ppSession Where to store the session handle. Defaults to NULL.
|
---|
| 1157 | */
|
---|
| 1158 | SUPR3DECL(int) SUPR3InitEx(bool fUnrestricted, PSUPDRVSESSION *ppSession);
|
---|
| 1159 |
|
---|
| 1160 | /**
|
---|
[1] | 1161 | * Terminates the support library.
|
---|
| 1162 | *
|
---|
| 1163 | * @returns VBox status code.
|
---|
| 1164 | * @param fForced Forced termination. This means to ignore the
|
---|
| 1165 | * init call count and just terminated.
|
---|
| 1166 | */
|
---|
| 1167 | #ifdef __cplusplus
|
---|
[20864] | 1168 | SUPR3DECL(int) SUPR3Term(bool fForced = false);
|
---|
[1] | 1169 | #else
|
---|
[20864] | 1170 | SUPR3DECL(int) SUPR3Term(int fForced);
|
---|
[1] | 1171 | #endif
|
---|
| 1172 |
|
---|
| 1173 | /**
|
---|
| 1174 | * Sets the ring-0 VM handle for use with fast IOCtls.
|
---|
| 1175 | *
|
---|
| 1176 | * @returns VBox status code.
|
---|
| 1177 | * @param pVMR0 The ring-0 VM handle.
|
---|
| 1178 | * NIL_RTR0PTR can be used to unset the handle when the
|
---|
| 1179 | * VM is about to be destroyed.
|
---|
| 1180 | */
|
---|
[20864] | 1181 | SUPR3DECL(int) SUPR3SetVMForFastIOCtl(PVMR0 pVMR0);
|
---|
[1] | 1182 |
|
---|
| 1183 | /**
|
---|
| 1184 | * Calls the HC R0 VMM entry point.
|
---|
| 1185 | * See VMMR0Entry() for more details.
|
---|
| 1186 | *
|
---|
| 1187 | * @returns error code specific to uFunction.
|
---|
[914] | 1188 | * @param pVMR0 Pointer to the Ring-0 (Host Context) mapping of the VM structure.
|
---|
[19454] | 1189 | * @param idCpu The virtual CPU ID.
|
---|
[1] | 1190 | * @param uOperation Operation to execute.
|
---|
| 1191 | * @param pvArg Argument.
|
---|
| 1192 | */
|
---|
[20864] | 1193 | SUPR3DECL(int) SUPR3CallVMMR0(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation, void *pvArg);
|
---|
[1] | 1194 |
|
---|
| 1195 | /**
|
---|
[20864] | 1196 | * Variant of SUPR3CallVMMR0, except that this takes the fast ioclt path
|
---|
[4811] | 1197 | * regardsless of compile-time defaults.
|
---|
| 1198 | *
|
---|
| 1199 | * @returns VBox status code.
|
---|
| 1200 | * @param pVMR0 The ring-0 VM handle.
|
---|
| 1201 | * @param uOperation The operation; only the SUP_VMMR0_DO_* ones are valid.
|
---|
[19454] | 1202 | * @param idCpu The virtual CPU ID.
|
---|
[4811] | 1203 | */
|
---|
[20864] | 1204 | SUPR3DECL(int) SUPR3CallVMMR0Fast(PVMR0 pVMR0, unsigned uOperation, VMCPUID idCpu);
|
---|
[4811] | 1205 |
|
---|
| 1206 | /**
|
---|
[20864] | 1207 | * Calls the HC R0 VMM entry point, in a safer but slower manner than
|
---|
| 1208 | * SUPR3CallVMMR0. When entering using this call the R0 components can call
|
---|
| 1209 | * into the host kernel (i.e. use the SUPR0 and RT APIs).
|
---|
[1] | 1210 | *
|
---|
| 1211 | * See VMMR0Entry() for more details.
|
---|
| 1212 | *
|
---|
| 1213 | * @returns error code specific to uFunction.
|
---|
[914] | 1214 | * @param pVMR0 Pointer to the Ring-0 (Host Context) mapping of the VM structure.
|
---|
[19454] | 1215 | * @param idCpu The virtual CPU ID.
|
---|
[1] | 1216 | * @param uOperation Operation to execute.
|
---|
[4811] | 1217 | * @param u64Arg Constant argument.
|
---|
| 1218 | * @param pReqHdr Pointer to a request header. Optional.
|
---|
| 1219 | * This will be copied in and out of kernel space. There currently is a size
|
---|
| 1220 | * limit on this, just below 4KB.
|
---|
[1] | 1221 | */
|
---|
[20864] | 1222 | SUPR3DECL(int) SUPR3CallVMMR0Ex(PVMR0 pVMR0, VMCPUID idCpu, unsigned uOperation, uint64_t u64Arg, PSUPVMMR0REQHDR pReqHdr);
|
---|
[1] | 1223 |
|
---|
| 1224 | /**
|
---|
[14332] | 1225 | * Calls a ring-0 service.
|
---|
| 1226 | *
|
---|
| 1227 | * The operation and the request packet is specific to the service.
|
---|
| 1228 | *
|
---|
| 1229 | * @returns error code specific to uFunction.
|
---|
| 1230 | * @param pszService The service name.
|
---|
| 1231 | * @param cchService The length of the service name.
|
---|
[58106] | 1232 | * @param uOperation The request number.
|
---|
[14332] | 1233 | * @param u64Arg Constant argument.
|
---|
| 1234 | * @param pReqHdr Pointer to a request header. Optional.
|
---|
| 1235 | * This will be copied in and out of kernel space. There currently is a size
|
---|
| 1236 | * limit on this, just below 4KB.
|
---|
| 1237 | */
|
---|
| 1238 | SUPR3DECL(int) SUPR3CallR0Service(const char *pszService, size_t cchService, uint32_t uOperation, uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr);
|
---|
| 1239 |
|
---|
[18191] | 1240 | /** Which logger. */
|
---|
| 1241 | typedef enum SUPLOGGER
|
---|
| 1242 | {
|
---|
| 1243 | SUPLOGGER_DEBUG = 1,
|
---|
| 1244 | SUPLOGGER_RELEASE
|
---|
| 1245 | } SUPLOGGER;
|
---|
| 1246 |
|
---|
[14332] | 1247 | /**
|
---|
[18191] | 1248 | * Changes the settings of the specified ring-0 logger.
|
---|
| 1249 | *
|
---|
| 1250 | * @returns VBox status code.
|
---|
| 1251 | * @param enmWhich Which logger.
|
---|
| 1252 | * @param pszFlags The flags settings.
|
---|
| 1253 | * @param pszGroups The groups settings.
|
---|
[33540] | 1254 | * @param pszDest The destination specificier.
|
---|
[18191] | 1255 | */
|
---|
| 1256 | SUPR3DECL(int) SUPR3LoggerSettings(SUPLOGGER enmWhich, const char *pszFlags, const char *pszGroups, const char *pszDest);
|
---|
| 1257 |
|
---|
| 1258 | /**
|
---|
| 1259 | * Creates a ring-0 logger instance.
|
---|
| 1260 | *
|
---|
| 1261 | * @returns VBox status code.
|
---|
| 1262 | * @param enmWhich Which logger to create.
|
---|
| 1263 | * @param pszFlags The flags settings.
|
---|
| 1264 | * @param pszGroups The groups settings.
|
---|
[33540] | 1265 | * @param pszDest The destination specificier.
|
---|
[18191] | 1266 | */
|
---|
| 1267 | SUPR3DECL(int) SUPR3LoggerCreate(SUPLOGGER enmWhich, const char *pszFlags, const char *pszGroups, const char *pszDest);
|
---|
| 1268 |
|
---|
| 1269 | /**
|
---|
| 1270 | * Destroys a ring-0 logger instance.
|
---|
| 1271 | *
|
---|
| 1272 | * @returns VBox status code.
|
---|
| 1273 | * @param enmWhich Which logger.
|
---|
| 1274 | */
|
---|
| 1275 | SUPR3DECL(int) SUPR3LoggerDestroy(SUPLOGGER enmWhich);
|
---|
| 1276 |
|
---|
| 1277 | /**
|
---|
[1] | 1278 | * Queries the paging mode of the host OS.
|
---|
| 1279 | *
|
---|
| 1280 | * @returns The paging mode.
|
---|
| 1281 | */
|
---|
[20864] | 1282 | SUPR3DECL(SUPPAGINGMODE) SUPR3GetPagingMode(void);
|
---|
[1] | 1283 |
|
---|
| 1284 | /**
|
---|
| 1285 | * Allocate zero-filled pages.
|
---|
| 1286 | *
|
---|
[20864] | 1287 | * Use this to allocate a number of pages suitable for seeding / locking.
|
---|
| 1288 | * Call SUPR3PageFree() to free the pages once done with them.
|
---|
[1] | 1289 | *
|
---|
| 1290 | * @returns VBox status.
|
---|
[4800] | 1291 | * @param cPages Number of pages to allocate.
|
---|
| 1292 | * @param ppvPages Where to store the base pointer to the allocated pages.
|
---|
[1] | 1293 | */
|
---|
[20864] | 1294 | SUPR3DECL(int) SUPR3PageAlloc(size_t cPages, void **ppvPages);
|
---|
[1] | 1295 |
|
---|
| 1296 | /**
|
---|
[20864] | 1297 | * Frees pages allocated with SUPR3PageAlloc().
|
---|
[1] | 1298 | *
|
---|
| 1299 | * @returns VBox status.
|
---|
[20864] | 1300 | * @param pvPages Pointer returned by SUPR3PageAlloc().
|
---|
[4800] | 1301 | * @param cPages Number of pages that was allocated.
|
---|
[1] | 1302 | */
|
---|
[20864] | 1303 | SUPR3DECL(int) SUPR3PageFree(void *pvPages, size_t cPages);
|
---|
[1] | 1304 |
|
---|
| 1305 | /**
|
---|
[14589] | 1306 | * Allocate non-zeroed, locked, pages with user and, optionally, kernel
|
---|
[14575] | 1307 | * mappings.
|
---|
| 1308 | *
|
---|
| 1309 | * Use SUPR3PageFreeEx() to free memory allocated with this function.
|
---|
| 1310 | *
|
---|
| 1311 | * @returns VBox status code.
|
---|
| 1312 | * @param cPages The number of pages to allocate.
|
---|
| 1313 | * @param fFlags Flags, reserved. Must be zero.
|
---|
| 1314 | * @param ppvPages Where to store the address of the user mapping.
|
---|
| 1315 | * @param pR0Ptr Where to store the address of the kernel mapping.
|
---|
| 1316 | * NULL if no kernel mapping is desired.
|
---|
| 1317 | * @param paPages Where to store the physical addresses of each page.
|
---|
| 1318 | * Optional.
|
---|
| 1319 | */
|
---|
| 1320 | SUPR3DECL(int) SUPR3PageAllocEx(size_t cPages, uint32_t fFlags, void **ppvPages, PRTR0PTR pR0Ptr, PSUPPAGE paPages);
|
---|
| 1321 |
|
---|
| 1322 | /**
|
---|
[14825] | 1323 | * Maps a portion of a ring-3 only allocation into kernel space.
|
---|
| 1324 | *
|
---|
[20528] | 1325 | * @returns VBox status code.
|
---|
[14825] | 1326 | *
|
---|
[20528] | 1327 | * @param pvR3 The address SUPR3PageAllocEx return.
|
---|
| 1328 | * @param off Offset to start mapping at. Must be page aligned.
|
---|
| 1329 | * @param cb Number of bytes to map. Must be page aligned.
|
---|
| 1330 | * @param fFlags Flags, must be zero.
|
---|
| 1331 | * @param pR0Ptr Where to store the address on success.
|
---|
[14825] | 1332 | *
|
---|
| 1333 | */
|
---|
| 1334 | SUPR3DECL(int) SUPR3PageMapKernel(void *pvR3, uint32_t off, uint32_t cb, uint32_t fFlags, PRTR0PTR pR0Ptr);
|
---|
| 1335 |
|
---|
| 1336 | /**
|
---|
[20528] | 1337 | * Changes the protection of
|
---|
| 1338 | *
|
---|
| 1339 | * @returns VBox status code.
|
---|
| 1340 | * @retval VERR_NOT_SUPPORTED if the OS doesn't allow us to change page level
|
---|
| 1341 | * protection. See also RTR0MemObjProtect.
|
---|
| 1342 | *
|
---|
| 1343 | * @param pvR3 The ring-3 address SUPR3PageAllocEx returned.
|
---|
| 1344 | * @param R0Ptr The ring-0 address SUPR3PageAllocEx returned if it
|
---|
| 1345 | * is desired that the corresponding ring-0 page
|
---|
| 1346 | * mappings should change protection as well. Pass
|
---|
| 1347 | * NIL_RTR0PTR if the ring-0 pages should remain
|
---|
| 1348 | * unaffected.
|
---|
| 1349 | * @param off Offset to start at which to start chagning the page
|
---|
| 1350 | * level protection. Must be page aligned.
|
---|
| 1351 | * @param cb Number of bytes to change. Must be page aligned.
|
---|
| 1352 | * @param fProt The new page level protection, either a combination
|
---|
| 1353 | * of RTMEM_PROT_READ, RTMEM_PROT_WRITE and
|
---|
| 1354 | * RTMEM_PROT_EXEC, or just RTMEM_PROT_NONE.
|
---|
| 1355 | */
|
---|
| 1356 | SUPR3DECL(int) SUPR3PageProtect(void *pvR3, RTR0PTR R0Ptr, uint32_t off, uint32_t cb, uint32_t fProt);
|
---|
| 1357 |
|
---|
| 1358 | /**
|
---|
[14575] | 1359 | * Free pages allocated by SUPR3PageAllocEx.
|
---|
| 1360 | *
|
---|
| 1361 | * @returns VBox status code.
|
---|
| 1362 | * @param pvPages The address of the user mapping.
|
---|
| 1363 | * @param cPages The number of pages.
|
---|
| 1364 | */
|
---|
| 1365 | SUPR3DECL(int) SUPR3PageFreeEx(void *pvPages, size_t cPages);
|
---|
| 1366 |
|
---|
| 1367 | /**
|
---|
[1] | 1368 | * Allocated memory with page aligned memory with a contiguous and locked physical
|
---|
| 1369 | * memory backing below 4GB.
|
---|
| 1370 | *
|
---|
| 1371 | * @returns Pointer to the allocated memory (virtual address).
|
---|
| 1372 | * *pHCPhys is set to the physical address of the memory.
|
---|
| 1373 | * If ppvR0 isn't NULL, *ppvR0 is set to the ring-0 mapping.
|
---|
[20864] | 1374 | * The returned memory must be freed using SUPR3ContFree().
|
---|
[1] | 1375 | * @returns NULL on failure.
|
---|
[1890] | 1376 | * @param cPages Number of pages to allocate.
|
---|
[914] | 1377 | * @param pR0Ptr Where to store the ring-0 mapping of the allocation. (optional)
|
---|
[1] | 1378 | * @param pHCPhys Where to store the physical address of the memory block.
|
---|
| 1379 | *
|
---|
| 1380 | * @remark This 2nd version of this API exists because we're not able to map the
|
---|
| 1381 | * ring-3 mapping executable on WIN64. This is a serious problem in regard to
|
---|
| 1382 | * the world switchers.
|
---|
| 1383 | */
|
---|
[20864] | 1384 | SUPR3DECL(void *) SUPR3ContAlloc(size_t cPages, PRTR0PTR pR0Ptr, PRTHCPHYS pHCPhys);
|
---|
[1] | 1385 |
|
---|
| 1386 | /**
|
---|
[20864] | 1387 | * Frees memory allocated with SUPR3ContAlloc().
|
---|
[1] | 1388 | *
|
---|
| 1389 | * @returns VBox status code.
|
---|
[1890] | 1390 | * @param pv Pointer to the memory block which should be freed.
|
---|
| 1391 | * @param cPages Number of pages to be freed.
|
---|
[1] | 1392 | */
|
---|
[20864] | 1393 | SUPR3DECL(int) SUPR3ContFree(void *pv, size_t cPages);
|
---|
[1] | 1394 |
|
---|
| 1395 | /**
|
---|
| 1396 | * Allocated non contiguous physical memory below 4GB.
|
---|
| 1397 | *
|
---|
[6791] | 1398 | * The memory isn't zeroed.
|
---|
| 1399 | *
|
---|
[1] | 1400 | * @returns VBox status code.
|
---|
| 1401 | * @returns NULL on failure.
|
---|
| 1402 | * @param cPages Number of pages to allocate.
|
---|
| 1403 | * @param ppvPages Where to store the pointer to the allocated memory.
|
---|
[20864] | 1404 | * The pointer stored here on success must be passed to
|
---|
| 1405 | * SUPR3LowFree when the memory should be released.
|
---|
[1480] | 1406 | * @param ppvPagesR0 Where to store the ring-0 pointer to the allocated memory. optional.
|
---|
[1] | 1407 | * @param paPages Where to store the physical addresses of the individual pages.
|
---|
| 1408 | */
|
---|
[20864] | 1409 | SUPR3DECL(int) SUPR3LowAlloc(size_t cPages, void **ppvPages, PRTR0PTR ppvPagesR0, PSUPPAGE paPages);
|
---|
[1] | 1410 |
|
---|
| 1411 | /**
|
---|
[20864] | 1412 | * Frees memory allocated with SUPR3LowAlloc().
|
---|
[1] | 1413 | *
|
---|
| 1414 | * @returns VBox status code.
|
---|
[1890] | 1415 | * @param pv Pointer to the memory block which should be freed.
|
---|
[2014] | 1416 | * @param cPages Number of pages that was allocated.
|
---|
[1] | 1417 | */
|
---|
[20864] | 1418 | SUPR3DECL(int) SUPR3LowFree(void *pv, size_t cPages);
|
---|
[1] | 1419 |
|
---|
| 1420 | /**
|
---|
[12423] | 1421 | * Load a module into R0 HC.
|
---|
| 1422 | *
|
---|
| 1423 | * This will verify the file integrity in a similar manner as
|
---|
[11889] | 1424 | * SUPR3HardenedVerifyFile before loading it.
|
---|
[1] | 1425 | *
|
---|
| 1426 | * @returns VBox status code.
|
---|
| 1427 | * @param pszFilename The path to the image file.
|
---|
| 1428 | * @param pszModule The module name. Max 32 bytes.
|
---|
[34241] | 1429 | * @param ppvImageBase Where to store the image address.
|
---|
[35188] | 1430 | * @param pErrInfo Where to return extended error information.
|
---|
| 1431 | * Optional.
|
---|
[1] | 1432 | */
|
---|
[35188] | 1433 | SUPR3DECL(int) SUPR3LoadModule(const char *pszFilename, const char *pszModule, void **ppvImageBase, PRTERRINFO pErrInfo);
|
---|
[1] | 1434 |
|
---|
| 1435 | /**
|
---|
[14332] | 1436 | * Load a module into R0 HC.
|
---|
| 1437 | *
|
---|
| 1438 | * This will verify the file integrity in a similar manner as
|
---|
| 1439 | * SUPR3HardenedVerifyFile before loading it.
|
---|
| 1440 | *
|
---|
| 1441 | * @returns VBox status code.
|
---|
| 1442 | * @param pszFilename The path to the image file.
|
---|
| 1443 | * @param pszModule The module name. Max 32 bytes.
|
---|
| 1444 | * @param pszSrvReqHandler The name of the service request handler entry
|
---|
| 1445 | * point. See FNSUPR0SERVICEREQHANDLER.
|
---|
| 1446 | * @param ppvImageBase Where to store the image address.
|
---|
| 1447 | */
|
---|
| 1448 | SUPR3DECL(int) SUPR3LoadServiceModule(const char *pszFilename, const char *pszModule,
|
---|
| 1449 | const char *pszSrvReqHandler, void **ppvImageBase);
|
---|
| 1450 |
|
---|
| 1451 | /**
|
---|
[1] | 1452 | * Frees a R0 HC module.
|
---|
| 1453 | *
|
---|
| 1454 | * @returns VBox status code.
|
---|
[58106] | 1455 | * @param pvImageBase The base address of the image to free.
|
---|
[1] | 1456 | * @remark This will not actually 'free' the module, there are of course usage counting.
|
---|
| 1457 | */
|
---|
[20864] | 1458 | SUPR3DECL(int) SUPR3FreeModule(void *pvImageBase);
|
---|
[1] | 1459 |
|
---|
| 1460 | /**
|
---|
[54013] | 1461 | * Lock down the module loader interface.
|
---|
| 1462 | *
|
---|
| 1463 | * This will lock down the module loader interface. No new modules can be
|
---|
| 1464 | * loaded and all loaded modules can no longer be freed.
|
---|
| 1465 | *
|
---|
| 1466 | * @returns VBox status code.
|
---|
| 1467 | * @param pErrInfo Where to return extended error information.
|
---|
| 1468 | * Optional.
|
---|
| 1469 | */
|
---|
| 1470 | SUPR3DECL(int) SUPR3LockDownLoader(PRTERRINFO pErrInfo);
|
---|
| 1471 |
|
---|
| 1472 | /**
|
---|
[1] | 1473 | * Get the address of a symbol in a ring-0 module.
|
---|
| 1474 | *
|
---|
| 1475 | * @returns VBox status code.
|
---|
[58106] | 1476 | * @param pvImageBase The base address of the image to search.
|
---|
[1] | 1477 | * @param pszSymbol Symbol name. If it's value is less than 64k it's treated like a
|
---|
| 1478 | * ordinal value rather than a string pointer.
|
---|
| 1479 | * @param ppvValue Where to store the symbol value.
|
---|
| 1480 | */
|
---|
[20864] | 1481 | SUPR3DECL(int) SUPR3GetSymbolR0(void *pvImageBase, const char *pszSymbol, void **ppvValue);
|
---|
[1] | 1482 |
|
---|
| 1483 | /**
|
---|
| 1484 | * Load R0 HC VMM code.
|
---|
| 1485 | *
|
---|
| 1486 | * @returns VBox status code.
|
---|
[20864] | 1487 | * @deprecated Use SUPR3LoadModule(pszFilename, "VMMR0.r0", &pvImageBase)
|
---|
[1] | 1488 | */
|
---|
[20864] | 1489 | SUPR3DECL(int) SUPR3LoadVMM(const char *pszFilename);
|
---|
[1] | 1490 |
|
---|
| 1491 | /**
|
---|
| 1492 | * Unloads R0 HC VMM code.
|
---|
| 1493 | *
|
---|
| 1494 | * @returns VBox status code.
|
---|
[20864] | 1495 | * @deprecated Use SUPR3FreeModule().
|
---|
[1] | 1496 | */
|
---|
[20864] | 1497 | SUPR3DECL(int) SUPR3UnloadVMM(void);
|
---|
[1] | 1498 |
|
---|
| 1499 | /**
|
---|
| 1500 | * Get the physical address of the GIP.
|
---|
| 1501 | *
|
---|
| 1502 | * @returns VBox status code.
|
---|
| 1503 | * @param pHCPhys Where to store the physical address of the GIP.
|
---|
| 1504 | */
|
---|
[20864] | 1505 | SUPR3DECL(int) SUPR3GipGetPhys(PRTHCPHYS pHCPhys);
|
---|
[1] | 1506 |
|
---|
[12423] | 1507 | /**
|
---|
[51978] | 1508 | * Initializes only the bits relevant for the SUPR3HardenedVerify* APIs.
|
---|
| 1509 | *
|
---|
| 1510 | * This is for users that don't necessarily need to initialize the whole of
|
---|
| 1511 | * SUPLib. There is no harm in calling this one more time.
|
---|
| 1512 | *
|
---|
| 1513 | * @returns VBox status code.
|
---|
| 1514 | * @remarks Currently not counted, so only call once.
|
---|
| 1515 | */
|
---|
| 1516 | SUPR3DECL(int) SUPR3HardenedVerifyInit(void);
|
---|
| 1517 |
|
---|
| 1518 | /**
|
---|
| 1519 | * Reverses the effect of SUPR3HardenedVerifyInit if SUPR3InitEx hasn't been
|
---|
| 1520 | * called.
|
---|
| 1521 | *
|
---|
| 1522 | * Ignored if the support library was initialized using SUPR3Init or
|
---|
| 1523 | * SUPR3InitEx.
|
---|
| 1524 | *
|
---|
| 1525 | * @returns VBox status code.
|
---|
| 1526 | */
|
---|
| 1527 | SUPR3DECL(int) SUPR3HardenedVerifyTerm(void);
|
---|
| 1528 |
|
---|
| 1529 | /**
|
---|
[12423] | 1530 | * Verifies the integrity of a file, and optionally opens it.
|
---|
| 1531 | *
|
---|
| 1532 | * The integrity check is for whether the file is suitable for loading into
|
---|
| 1533 | * the hypervisor or VM process. The integrity check may include verifying
|
---|
| 1534 | * the authenticode/elfsign/whatever signature of the file, which can take
|
---|
| 1535 | * a little while.
|
---|
| 1536 | *
|
---|
| 1537 | * @returns VBox status code. On failure it will have printed a LogRel message.
|
---|
| 1538 | *
|
---|
| 1539 | * @param pszFilename The file.
|
---|
| 1540 | * @param pszWhat For the LogRel on failure.
|
---|
| 1541 | * @param phFile Where to store the handle to the opened file. This is optional, pass NULL
|
---|
| 1542 | * if the file should not be opened.
|
---|
[33806] | 1543 | * @deprecated Write a new one.
|
---|
[12423] | 1544 | */
|
---|
| 1545 | SUPR3DECL(int) SUPR3HardenedVerifyFile(const char *pszFilename, const char *pszWhat, PRTFILE phFile);
|
---|
| 1546 |
|
---|
| 1547 | /**
|
---|
[33806] | 1548 | * Verifies the integrity of a the current process, including the image
|
---|
| 1549 | * location and that the invocation was absolute.
|
---|
| 1550 | *
|
---|
| 1551 | * This must currently be called after initializing the runtime. The intended
|
---|
| 1552 | * audience is set-uid-to-root applications, root services and similar.
|
---|
| 1553 | *
|
---|
| 1554 | * @returns VBox status code. On failure
|
---|
| 1555 | * message.
|
---|
| 1556 | * @param pszArgv0 The first argument to main().
|
---|
| 1557 | * @param fInternal Set this to @c true if this is an internal
|
---|
| 1558 | * VirtualBox application. Otherwise pass @c false.
|
---|
[35188] | 1559 | * @param pErrInfo Where to return extended error information.
|
---|
[33806] | 1560 | */
|
---|
[35188] | 1561 | SUPR3DECL(int) SUPR3HardenedVerifySelf(const char *pszArgv0, bool fInternal, PRTERRINFO pErrInfo);
|
---|
[33806] | 1562 |
|
---|
| 1563 | /**
|
---|
[33623] | 1564 | * Verifies the integrity of an installation directory.
|
---|
| 1565 | *
|
---|
| 1566 | * The integrity check verifies that the directory cannot be tampered with by
|
---|
| 1567 | * normal users on the system. On Unix this translates to root ownership and
|
---|
| 1568 | * no symbolic linking.
|
---|
| 1569 | *
|
---|
| 1570 | * @returns VBox status code. On failure a message will be stored in @a pszErr.
|
---|
| 1571 | *
|
---|
| 1572 | * @param pszDirPath The directory path.
|
---|
| 1573 | * @param fRecursive Whether the check should be recursive or
|
---|
[33739] | 1574 | * not. When set, all sub-directores will be checked,
|
---|
| 1575 | * including files (@a fCheckFiles is ignored).
|
---|
[33623] | 1576 | * @param fCheckFiles Whether to apply the same basic integrity check to
|
---|
| 1577 | * the files in the directory as the directory itself.
|
---|
[35188] | 1578 | * @param pErrInfo Where to return extended error information.
|
---|
| 1579 | * Optional.
|
---|
[33623] | 1580 | */
|
---|
[35188] | 1581 | SUPR3DECL(int) SUPR3HardenedVerifyDir(const char *pszDirPath, bool fRecursive, bool fCheckFiles, PRTERRINFO pErrInfo);
|
---|
[33623] | 1582 |
|
---|
| 1583 | /**
|
---|
| 1584 | * Verifies the integrity of a plug-in module.
|
---|
| 1585 | *
|
---|
| 1586 | * This is similar to SUPR3HardenedLdrLoad, except it does not load the module
|
---|
| 1587 | * and that the module does not have to be shipped with VirtualBox.
|
---|
| 1588 | *
|
---|
| 1589 | * @returns VBox status code. On failure a message will be stored in @a pszErr.
|
---|
| 1590 | *
|
---|
| 1591 | * @param pszFilename The filename of the plug-in module (nothing can be
|
---|
| 1592 | * omitted here).
|
---|
[35188] | 1593 | * @param pErrInfo Where to return extended error information.
|
---|
| 1594 | * Optional.
|
---|
[33623] | 1595 | */
|
---|
[35188] | 1596 | SUPR3DECL(int) SUPR3HardenedVerifyPlugIn(const char *pszFilename, PRTERRINFO pErrInfo);
|
---|
[33623] | 1597 |
|
---|
| 1598 | /**
|
---|
[12423] | 1599 | * Same as RTLdrLoad() but will verify the files it loads (hardened builds).
|
---|
| 1600 | *
|
---|
| 1601 | * Will add dll suffix if missing and try load the file.
|
---|
| 1602 | *
|
---|
| 1603 | * @returns iprt status code.
|
---|
[34959] | 1604 | * @param pszFilename Image filename. This must have a path.
|
---|
| 1605 | * @param phLdrMod Where to store the handle to the loaded module.
|
---|
[35191] | 1606 | * @param fFlags See RTLDRLOAD_FLAGS_XXX.
|
---|
[35188] | 1607 | * @param pErrInfo Where to return extended error information.
|
---|
| 1608 | * Optional.
|
---|
[12423] | 1609 | */
|
---|
[35188] | 1610 | SUPR3DECL(int) SUPR3HardenedLdrLoad(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
|
---|
[12423] | 1611 |
|
---|
| 1612 | /**
|
---|
| 1613 | * Same as RTLdrLoadAppPriv() but it will verify the files it loads (hardened
|
---|
| 1614 | * builds).
|
---|
| 1615 | *
|
---|
| 1616 | * Will add dll suffix to the file if missing, then look for it in the
|
---|
| 1617 | * architecture dependent application directory.
|
---|
| 1618 | *
|
---|
| 1619 | * @returns iprt status code.
|
---|
[35152] | 1620 | * @param pszFilename Image filename.
|
---|
| 1621 | * @param phLdrMod Where to store the handle to the loaded module.
|
---|
[35191] | 1622 | * @param fFlags See RTLDRLOAD_FLAGS_XXX.
|
---|
[35188] | 1623 | * @param pErrInfo Where to return extended error information.
|
---|
| 1624 | * Optional.
|
---|
[12423] | 1625 | */
|
---|
[35188] | 1626 | SUPR3DECL(int) SUPR3HardenedLdrLoadAppPriv(const char *pszFilename, PRTLDRMOD phLdrMod, uint32_t fFlags, PRTERRINFO pErrInfo);
|
---|
[12423] | 1627 |
|
---|
[34241] | 1628 | /**
|
---|
| 1629 | * Same as RTLdrLoad() but will verify the files it loads (hardened builds).
|
---|
| 1630 | *
|
---|
| 1631 | * This differs from SUPR3HardenedLdrLoad() in that it can load modules from
|
---|
| 1632 | * extension packs and anything else safely installed on the system, provided
|
---|
| 1633 | * they pass the hardening tests.
|
---|
| 1634 | *
|
---|
| 1635 | * @returns iprt status code.
|
---|
| 1636 | * @param pszFilename The full path to the module, with extension.
|
---|
| 1637 | * @param phLdrMod Where to store the handle to the loaded module.
|
---|
[35188] | 1638 | * @param pErrInfo Where to return extended error information.
|
---|
| 1639 | * Optional.
|
---|
[34241] | 1640 | */
|
---|
[35188] | 1641 | SUPR3DECL(int) SUPR3HardenedLdrLoadPlugIn(const char *pszFilename, PRTLDRMOD phLdrMod, PRTERRINFO pErrInfo);
|
---|
[22615] | 1642 |
|
---|
| 1643 | /**
|
---|
[23725] | 1644 | * Check if the host kernel can run in VMX root mode.
|
---|
| 1645 | *
|
---|
| 1646 | * @returns VINF_SUCCESS if supported, error code indicating why if not.
|
---|
[70918] | 1647 | * @param ppszWhy Where to return an explanatory message on failure.
|
---|
[22615] | 1648 | */
|
---|
[70918] | 1649 | SUPR3DECL(int) SUPR3QueryVTxSupported(const char **ppszWhy);
|
---|
[22615] | 1650 |
|
---|
[23699] | 1651 | /**
|
---|
[23725] | 1652 | * Return VT-x/AMD-V capabilities.
|
---|
| 1653 | *
|
---|
| 1654 | * @returns VINF_SUCCESS if supported, error code indicating why if not.
|
---|
| 1655 | * @param pfCaps Pointer to capability dword (out).
|
---|
[32358] | 1656 | * @todo Intended for main, which means we need to relax the privilege requires
|
---|
| 1657 | * when accessing certain vboxdrv functions.
|
---|
[23699] | 1658 | */
|
---|
[23725] | 1659 | SUPR3DECL(int) SUPR3QueryVTCaps(uint32_t *pfCaps);
|
---|
[23699] | 1660 |
|
---|
[40820] | 1661 | /**
|
---|
[72326] | 1662 | * Check if NEM is supported when no VT-x/AMD-V is indicated by the CPU.
|
---|
| 1663 | *
|
---|
| 1664 | * This is really only for the windows case where we're running in a root
|
---|
| 1665 | * partition and isn't allowed to use the hardware directly.
|
---|
| 1666 | *
|
---|
| 1667 | * @returns True if NEM API support, false if not.
|
---|
| 1668 | */
|
---|
| 1669 | SUPR3DECL(bool) SUPR3IsNemSupportedWhenNoVtxOrAmdV(void);
|
---|
| 1670 |
|
---|
| 1671 | /**
|
---|
[40820] | 1672 | * Open the tracer.
|
---|
| 1673 | *
|
---|
| 1674 | * @returns VBox status code.
|
---|
| 1675 | * @param uCookie Cookie identifying the tracer we expect to talk to.
|
---|
| 1676 | * @param uArg Tracer specific open argument.
|
---|
| 1677 | */
|
---|
| 1678 | SUPR3DECL(int) SUPR3TracerOpen(uint32_t uCookie, uintptr_t uArg);
|
---|
| 1679 |
|
---|
| 1680 | /**
|
---|
| 1681 | * Closes the tracer.
|
---|
| 1682 | *
|
---|
| 1683 | * @returns VBox status code.
|
---|
| 1684 | */
|
---|
| 1685 | SUPR3DECL(int) SUPR3TracerClose(void);
|
---|
| 1686 |
|
---|
| 1687 | /**
|
---|
| 1688 | * Perform an I/O request on the tracer.
|
---|
| 1689 | *
|
---|
| 1690 | * @returns VBox status.
|
---|
| 1691 | * @param uCmd The tracer command.
|
---|
| 1692 | * @param uArg The argument.
|
---|
| 1693 | * @param piRetVal Where to store the tracer return value.
|
---|
| 1694 | */
|
---|
| 1695 | SUPR3DECL(int) SUPR3TracerIoCtl(uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal);
|
---|
| 1696 |
|
---|
[40981] | 1697 | /**
|
---|
| 1698 | * Registers the user module with the tracer.
|
---|
| 1699 | *
|
---|
| 1700 | * @returns VBox status code.
|
---|
| 1701 | * @param hModNative Native module handle. Pass ~(uintptr_t)0 if not
|
---|
| 1702 | * at hand.
|
---|
| 1703 | * @param pszModule The module name.
|
---|
| 1704 | * @param pVtgHdr The VTG header.
|
---|
[41117] | 1705 | * @param uVtgHdrAddr The address to which the VTG header is loaded
|
---|
| 1706 | * in the relevant execution context.
|
---|
[40981] | 1707 | * @param fFlags See SUP_TRACER_UMOD_FLAGS_XXX
|
---|
| 1708 | */
|
---|
[41117] | 1709 | SUPR3DECL(int) SUPR3TracerRegisterModule(uintptr_t hModNative, const char *pszModule, struct VTGOBJHDR *pVtgHdr,
|
---|
| 1710 | RTUINTPTR uVtgHdrAddr, uint32_t fFlags);
|
---|
[40981] | 1711 |
|
---|
| 1712 | /**
|
---|
| 1713 | * Deregisters the user module.
|
---|
| 1714 | *
|
---|
| 1715 | * @returns VBox status code.
|
---|
| 1716 | * @param pVtgHdr The VTG header.
|
---|
| 1717 | */
|
---|
| 1718 | SUPR3DECL(int) SUPR3TracerDeregisterModule(struct VTGOBJHDR *pVtgHdr);
|
---|
| 1719 |
|
---|
| 1720 | /**
|
---|
| 1721 | * Fire the probe.
|
---|
| 1722 | *
|
---|
| 1723 | * @param pVtgProbeLoc The probe location record.
|
---|
| 1724 | * @param uArg0 Raw probe argument 0.
|
---|
| 1725 | * @param uArg1 Raw probe argument 1.
|
---|
| 1726 | * @param uArg2 Raw probe argument 2.
|
---|
| 1727 | * @param uArg3 Raw probe argument 3.
|
---|
| 1728 | * @param uArg4 Raw probe argument 4.
|
---|
| 1729 | */
|
---|
| 1730 | SUPDECL(void) SUPTracerFireProbe(struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
|
---|
| 1731 | uintptr_t uArg3, uintptr_t uArg4);
|
---|
[49634] | 1732 |
|
---|
| 1733 | /**
|
---|
| 1734 | * Attempts to read the value of an MSR.
|
---|
| 1735 | *
|
---|
| 1736 | * @returns VBox status code.
|
---|
| 1737 | * @param uMsr The MSR to read.
|
---|
| 1738 | * @param idCpu The CPU to read it on, NIL_RTCPUID if it doesn't
|
---|
| 1739 | * matter which CPU.
|
---|
| 1740 | * @param puValue Where to return the value.
|
---|
| 1741 | * @param pfGp Where to store the \#GP indicator for the read
|
---|
| 1742 | * operation.
|
---|
| 1743 | */
|
---|
| 1744 | SUPR3DECL(int) SUPR3MsrProberRead(uint32_t uMsr, RTCPUID idCpu, uint64_t *puValue, bool *pfGp);
|
---|
| 1745 |
|
---|
| 1746 | /**
|
---|
| 1747 | * Attempts to write to an MSR.
|
---|
| 1748 | *
|
---|
| 1749 | * @returns VBox status code.
|
---|
| 1750 | * @param uMsr The MSR to write to.
|
---|
| 1751 | * @param idCpu The CPU to wrtie it on, NIL_RTCPUID if it
|
---|
| 1752 | * doesn't matter which CPU.
|
---|
| 1753 | * @param uValue The value to write.
|
---|
| 1754 | * @param pfGp Where to store the \#GP indicator for the write
|
---|
| 1755 | * operation.
|
---|
| 1756 | */
|
---|
| 1757 | SUPR3DECL(int) SUPR3MsrProberWrite(uint32_t uMsr, RTCPUID idCpu, uint64_t uValue, bool *pfGp);
|
---|
| 1758 |
|
---|
| 1759 | /**
|
---|
| 1760 | * Attempts to modify the value of an MSR.
|
---|
| 1761 | *
|
---|
| 1762 | * @returns VBox status code.
|
---|
| 1763 | * @param uMsr The MSR to modify.
|
---|
| 1764 | * @param idCpu The CPU to modify it on, NIL_RTCPUID if it
|
---|
| 1765 | * doesn't matter which CPU.
|
---|
| 1766 | * @param fAndMask The bits to keep in the current MSR value.
|
---|
| 1767 | * @param fOrMask The bits to set before writing.
|
---|
| 1768 | * @param pResult The result buffer.
|
---|
| 1769 | */
|
---|
| 1770 | SUPR3DECL(int) SUPR3MsrProberModify(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask,
|
---|
| 1771 | PSUPMSRPROBERMODIFYRESULT pResult);
|
---|
| 1772 |
|
---|
| 1773 | /**
|
---|
| 1774 | * Attempts to modify the value of an MSR, extended version.
|
---|
| 1775 | *
|
---|
| 1776 | * @returns VBox status code.
|
---|
| 1777 | * @param uMsr The MSR to modify.
|
---|
| 1778 | * @param idCpu The CPU to modify it on, NIL_RTCPUID if it
|
---|
| 1779 | * doesn't matter which CPU.
|
---|
| 1780 | * @param fAndMask The bits to keep in the current MSR value.
|
---|
| 1781 | * @param fOrMask The bits to set before writing.
|
---|
| 1782 | * @param fFaster If set to @c true some cache/tlb invalidation is
|
---|
| 1783 | * skipped, otherwise behave like
|
---|
| 1784 | * SUPR3MsrProberModify.
|
---|
| 1785 | * @param pResult The result buffer.
|
---|
| 1786 | */
|
---|
| 1787 | SUPR3DECL(int) SUPR3MsrProberModifyEx(uint32_t uMsr, RTCPUID idCpu, uint64_t fAndMask, uint64_t fOrMask, bool fFaster,
|
---|
| 1788 | PSUPMSRPROBERMODIFYRESULT pResult);
|
---|
| 1789 |
|
---|
[49787] | 1790 | /**
|
---|
| 1791 | * Resume built-in keyboard on MacBook Air and Pro hosts.
|
---|
| 1792 | *
|
---|
| 1793 | * @returns VBox status code.
|
---|
| 1794 | */
|
---|
[49965] | 1795 | SUPR3DECL(int) SUPR3ResumeSuspendedKeyboards(void);
|
---|
[49787] | 1796 |
|
---|
[53063] | 1797 | /**
|
---|
| 1798 | * Measure the TSC-delta for the specified CPU.
|
---|
| 1799 | *
|
---|
| 1800 | * @returns VBox status code.
|
---|
| 1801 | * @param idCpu The CPU to measure the TSC-delta for.
|
---|
| 1802 | * @param fAsync Whether the measurement is asynchronous, returns
|
---|
| 1803 | * immediately after signalling a measurement
|
---|
| 1804 | * request.
|
---|
| 1805 | * @param fForce Whether to perform a measurement even if the
|
---|
| 1806 | * specified CPU has a (possibly) valid TSC delta.
|
---|
| 1807 | * @param cRetries Number of times to retry failed delta
|
---|
| 1808 | * measurements.
|
---|
[54286] | 1809 | * @param cMsWaitRetry Number of milliseconds to wait between retries.
|
---|
[53063] | 1810 | */
|
---|
[54286] | 1811 | SUPR3DECL(int) SUPR3TscDeltaMeasure(RTCPUID idCpu, bool fAsync, bool fForce, uint8_t cRetries, uint8_t cMsWaitRetry);
|
---|
[53063] | 1812 |
|
---|
[53212] | 1813 | /**
|
---|
| 1814 | * Reads the delta-adjust TSC value.
|
---|
| 1815 | *
|
---|
| 1816 | * @returns VBox status code.
|
---|
| 1817 | * @param puTsc Where to store the read TSC value.
|
---|
| 1818 | * @param pidApic Where to store the APIC ID of the CPU where the TSC
|
---|
| 1819 | * was read (optional, can be NULL).
|
---|
| 1820 | */
|
---|
| 1821 | SUPR3DECL(int) SUPR3ReadTsc(uint64_t *puTsc, uint16_t *pidApic);
|
---|
| 1822 |
|
---|
[57218] | 1823 | /**
|
---|
[57222] | 1824 | * Modifies the GIP flags.
|
---|
[57218] | 1825 | *
|
---|
| 1826 | * @returns VBox status code.
|
---|
| 1827 | * @param fOrMask The OR mask of the GIP flags, see SUPGIP_FLAGS_XXX.
|
---|
| 1828 | * @param fAndMask The AND mask of the GIP flags, see SUPGIP_FLAGS_XXX.
|
---|
| 1829 | */
|
---|
| 1830 | SUPR3DECL(int) SUPR3GipSetFlags(uint32_t fOrMask, uint32_t fAndMask);
|
---|
[57222] | 1831 |
|
---|
[67821] | 1832 | /**
|
---|
| 1833 | * Return processor microcode revision, if applicable.
|
---|
| 1834 | *
|
---|
| 1835 | * @returns VINF_SUCCESS if supported, error code indicating why if not.
|
---|
| 1836 | * @param puMicrocodeRev Pointer to microcode revision dword (out).
|
---|
| 1837 | */
|
---|
| 1838 | SUPR3DECL(int) SUPR3QueryMicrocodeRev(uint32_t *puMicrocodeRev);
|
---|
| 1839 |
|
---|
[1] | 1840 | /** @} */
|
---|
| 1841 | #endif /* IN_RING3 */
|
---|
| 1842 |
|
---|
[53212] | 1843 |
|
---|
[40981] | 1844 | /** @name User mode module flags (SUPR3TracerRegisterModule & SUP_IOCTL_TRACER_UMOD_REG).
|
---|
| 1845 | * @{ */
|
---|
| 1846 | /** Executable image. */
|
---|
| 1847 | #define SUP_TRACER_UMOD_FLAGS_EXE UINT32_C(1)
|
---|
| 1848 | /** Shared library (DLL, DYLIB, SO, etc). */
|
---|
| 1849 | #define SUP_TRACER_UMOD_FLAGS_SHARED UINT32_C(2)
|
---|
| 1850 | /** Image type mask. */
|
---|
| 1851 | #define SUP_TRACER_UMOD_FLAGS_TYPE_MASK UINT32_C(3)
|
---|
| 1852 | /** @} */
|
---|
[1] | 1853 |
|
---|
[40981] | 1854 |
|
---|
[1] | 1855 | #ifdef IN_RING0
|
---|
[26227] | 1856 | /** @defgroup grp_sup_r0 SUP Host Context Ring-0 API
|
---|
[1] | 1857 | * @{
|
---|
| 1858 | */
|
---|
| 1859 |
|
---|
| 1860 | /**
|
---|
| 1861 | * Security objectype.
|
---|
| 1862 | */
|
---|
| 1863 | typedef enum SUPDRVOBJTYPE
|
---|
| 1864 | {
|
---|
| 1865 | /** The usual invalid object. */
|
---|
| 1866 | SUPDRVOBJTYPE_INVALID = 0,
|
---|
[4971] | 1867 | /** A Virtual Machine instance. */
|
---|
| 1868 | SUPDRVOBJTYPE_VM,
|
---|
[1] | 1869 | /** Internal network. */
|
---|
| 1870 | SUPDRVOBJTYPE_INTERNAL_NETWORK,
|
---|
| 1871 | /** Internal network interface. */
|
---|
| 1872 | SUPDRVOBJTYPE_INTERNAL_NETWORK_INTERFACE,
|
---|
[19866] | 1873 | /** Single release event semaphore. */
|
---|
| 1874 | SUPDRVOBJTYPE_SEM_EVENT,
|
---|
| 1875 | /** Multiple release event semaphore. */
|
---|
| 1876 | SUPDRVOBJTYPE_SEM_EVENT_MULTI,
|
---|
[35855] | 1877 | /** Raw PCI device. */
|
---|
| 1878 | SUPDRVOBJTYPE_RAW_PCI_DEVICE,
|
---|
[1] | 1879 | /** The first invalid object type in this end. */
|
---|
| 1880 | SUPDRVOBJTYPE_END,
|
---|
| 1881 | /** The usual 32-bit type size hack. */
|
---|
| 1882 | SUPDRVOBJTYPE_32_BIT_HACK = 0x7ffffff
|
---|
| 1883 | } SUPDRVOBJTYPE;
|
---|
| 1884 |
|
---|
| 1885 | /**
|
---|
| 1886 | * Object destructor callback.
|
---|
| 1887 | * This is called for reference counted objectes when the count reaches 0.
|
---|
| 1888 | *
|
---|
| 1889 | * @param pvObj The object pointer.
|
---|
| 1890 | * @param pvUser1 The first user argument.
|
---|
| 1891 | * @param pvUser2 The second user argument.
|
---|
| 1892 | */
|
---|
| 1893 | typedef DECLCALLBACK(void) FNSUPDRVDESTRUCTOR(void *pvObj, void *pvUser1, void *pvUser2);
|
---|
| 1894 | /** Pointer to a FNSUPDRVDESTRUCTOR(). */
|
---|
| 1895 | typedef FNSUPDRVDESTRUCTOR *PFNSUPDRVDESTRUCTOR;
|
---|
| 1896 |
|
---|
| 1897 | SUPR0DECL(void *) SUPR0ObjRegister(PSUPDRVSESSION pSession, SUPDRVOBJTYPE enmType, PFNSUPDRVDESTRUCTOR pfnDestructor, void *pvUser1, void *pvUser2);
|
---|
| 1898 | SUPR0DECL(int) SUPR0ObjAddRef(void *pvObj, PSUPDRVSESSION pSession);
|
---|
[15505] | 1899 | SUPR0DECL(int) SUPR0ObjAddRefEx(void *pvObj, PSUPDRVSESSION pSession, bool fNoBlocking);
|
---|
[1] | 1900 | SUPR0DECL(int) SUPR0ObjRelease(void *pvObj, PSUPDRVSESSION pSession);
|
---|
| 1901 | SUPR0DECL(int) SUPR0ObjVerifyAccess(void *pvObj, PSUPDRVSESSION pSession, const char *pszObjName);
|
---|
| 1902 |
|
---|
[67955] | 1903 | SUPR0DECL(PVM) SUPR0GetSessionVM(PSUPDRVSESSION pSession);
|
---|
| 1904 | SUPR0DECL(PGVM) SUPR0GetSessionGVM(PSUPDRVSESSION pSession);
|
---|
| 1905 | SUPR0DECL(int) SUPR0SetSessionVM(PSUPDRVSESSION pSession, PGVM pGVM, PVM pVM);
|
---|
| 1906 |
|
---|
[4800] | 1907 | SUPR0DECL(int) SUPR0LockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t cPages, PRTHCPHYS paPages);
|
---|
[1480] | 1908 | SUPR0DECL(int) SUPR0UnlockMem(PSUPDRVSESSION pSession, RTR3PTR pvR3);
|
---|
[1890] | 1909 | SUPR0DECL(int) SUPR0ContAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS pHCPhys);
|
---|
[1480] | 1910 | SUPR0DECL(int) SUPR0ContFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr);
|
---|
[4800] | 1911 | SUPR0DECL(int) SUPR0LowAlloc(PSUPDRVSESSION pSession, uint32_t cPages, PRTR0PTR ppvR0, PRTR3PTR ppvR3, PRTHCPHYS paPages);
|
---|
[1480] | 1912 | SUPR0DECL(int) SUPR0LowFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr);
|
---|
| 1913 | SUPR0DECL(int) SUPR0MemAlloc(PSUPDRVSESSION pSession, uint32_t cb, PRTR0PTR ppvR0, PRTR3PTR ppvR3);
|
---|
| 1914 | SUPR0DECL(int) SUPR0MemGetPhys(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr, PSUPPAGE paPages);
|
---|
| 1915 | SUPR0DECL(int) SUPR0MemFree(PSUPDRVSESSION pSession, RTHCUINTPTR uPtr);
|
---|
[14575] | 1916 | SUPR0DECL(int) SUPR0PageAllocEx(PSUPDRVSESSION pSession, uint32_t cPages, uint32_t fFlags, PRTR3PTR ppvR3, PRTR0PTR ppvR0, PRTHCPHYS paPages);
|
---|
[14825] | 1917 | SUPR0DECL(int) SUPR0PageMapKernel(PSUPDRVSESSION pSession, RTR3PTR pvR3, uint32_t offSub, uint32_t cbSub, uint32_t fFlags, PRTR0PTR ppvR0);
|
---|
[20528] | 1918 | SUPR0DECL(int) SUPR0PageProtect(PSUPDRVSESSION pSession, RTR3PTR pvR3, RTR0PTR pvR0, uint32_t offSub, uint32_t cbSub, uint32_t fProt);
|
---|
[4800] | 1919 | SUPR0DECL(int) SUPR0PageFree(PSUPDRVSESSION pSession, RTR3PTR pvR3);
|
---|
| 1920 | SUPR0DECL(int) SUPR0GipMap(PSUPDRVSESSION pSession, PRTR3PTR ppGipR3, PRTHCPHYS pHCPhysGip);
|
---|
[54201] | 1921 | SUPR0DECL(int) SUPR0GetSvmUsability(bool fInitSvm);
|
---|
| 1922 | SUPR0DECL(int) SUPR0GetVmxUsability(bool *pfIsSmxModeAmbiguous);
|
---|
[70917] | 1923 | SUPR0DECL(int) SUPR0GetRawModeUsability(void);
|
---|
[67136] | 1924 | SUPR0DECL(int) SUPR0GetCurrentGdtRw(RTHCUINTPTR *pGdtRw);
|
---|
[23725] | 1925 | SUPR0DECL(int) SUPR0QueryVTCaps(PSUPDRVSESSION pSession, uint32_t *pfCaps);
|
---|
[1] | 1926 | SUPR0DECL(int) SUPR0GipUnmap(PSUPDRVSESSION pSession);
|
---|
[67821] | 1927 | SUPR0DECL(int) SUPR0QueryUcodeRev(PSUPDRVSESSION pSession, uint32_t *puMicrocodeRev);
|
---|
[14373] | 1928 | SUPR0DECL(SUPPAGINGMODE) SUPR0GetPagingMode(void);
|
---|
[54650] | 1929 | SUPR0DECL(RTCCUINTREG) SUPR0ChangeCR4(RTCCUINTREG fOrMask, RTCCUINTREG fAndMask);
|
---|
[14901] | 1930 | SUPR0DECL(int) SUPR0EnableVTx(bool fEnable);
|
---|
[43379] | 1931 | SUPR0DECL(bool) SUPR0SuspendVTxOnCpu(void);
|
---|
| 1932 | SUPR0DECL(void) SUPR0ResumeVTxOnCpu(bool fSuspended);
|
---|
[54339] | 1933 | #define SUP_TSCDELTA_MEASURE_F_FORCE RT_BIT_32(0)
|
---|
| 1934 | #define SUP_TSCDELTA_MEASURE_F_ASYNC RT_BIT_32(1)
|
---|
| 1935 | #define SUP_TSCDELTA_MEASURE_F_VALID_MASK UINT32_C(0x00000003)
|
---|
| 1936 | SUPR0DECL(int) SUPR0TscDeltaMeasureBySetIndex(PSUPDRVSESSION pSession, uint32_t iCpuSet, uint32_t fFlags,
|
---|
| 1937 | RTMSINTERVAL cMsWaitRetry, RTMSINTERVAL cMsWaitThread, uint32_t cTries);
|
---|
[1] | 1938 |
|
---|
[57229] | 1939 | SUPR0DECL(void) SUPR0BadContext(PSUPDRVSESSION pSession, const char *pszFile, uint32_t uLine, const char *pszExpr);
|
---|
| 1940 |
|
---|
[71136] | 1941 | /** Context structure returned by SUPR0IoCtlSetup for use with
|
---|
| 1942 | * SUPR0IoCtlPerform and cleaned up by SUPR0IoCtlCleanup. */
|
---|
| 1943 | typedef struct SUPR0IOCTLCTX *PSUPR0IOCTLCTX;
|
---|
| 1944 |
|
---|
[57108] | 1945 | /**
|
---|
[71136] | 1946 | * Sets up a I/O control context for the given handle.
|
---|
| 1947 | *
|
---|
| 1948 | * @returns VBox status code.
|
---|
| 1949 | * @param pSession The support driver session.
|
---|
| 1950 | * @param hHandle The handle.
|
---|
| 1951 | * @param fFlags Flag, MBZ.
|
---|
| 1952 | * @param ppCtx Where the context is returned.
|
---|
| 1953 | */
|
---|
| 1954 | SUPR0DECL(int) SUPR0IoCtlSetupForHandle(PSUPDRVSESSION pSession, intptr_t hHandle, uint32_t fFlags, PSUPR0IOCTLCTX *ppCtx);
|
---|
| 1955 |
|
---|
| 1956 | /**
|
---|
| 1957 | * Cleans up the I/O control context when done.
|
---|
| 1958 | *
|
---|
| 1959 | * This won't close the handle passed to SUPR0IoCtlSetupForHandle.
|
---|
| 1960 | *
|
---|
| 1961 | * @returns VBox status code.
|
---|
| 1962 | * @param pCtx The I/O control context to cleanup.
|
---|
| 1963 | */
|
---|
| 1964 | SUPR0DECL(int) SUPR0IoCtlCleanup(PSUPR0IOCTLCTX pCtx);
|
---|
| 1965 |
|
---|
| 1966 | /**
|
---|
| 1967 | * Performs an I/O control operation.
|
---|
| 1968 | *
|
---|
| 1969 | * @returns VBox status code.
|
---|
| 1970 | * @param pCtx The I/O control context returned by
|
---|
| 1971 | * SUPR0IoCtlSetupForHandle.
|
---|
| 1972 | * @param uFunction The I/O control function to perform.
|
---|
| 1973 | * @param pvInput Pointer to input buffer (ring-0).
|
---|
| 1974 | * @param pvInputUser Ring-3 pointer corresponding to @a pvInput.
|
---|
| 1975 | * @param cbInput The amount of input. If zero, both input pointers
|
---|
| 1976 | * are expected to be NULL.
|
---|
| 1977 | * @param pvOutput Pointer to output buffer (ring-0).
|
---|
| 1978 | * @param pvOutputUser Ring-3 pointer corresponding to @a pvInput.
|
---|
| 1979 | * @param cbOutput The amount of input. If zero, both input pointers
|
---|
| 1980 | * are expected to be NULL.
|
---|
| 1981 | * @param piNativeRc Where to return the native return code. When
|
---|
| 1982 | * specified the VBox status code will typically be
|
---|
| 1983 | * VINF_SUCCESS and the caller have to consult this for
|
---|
| 1984 | * the actual result of the operation. (This saves
|
---|
| 1985 | * pointless status code conversion.) Optional.
|
---|
| 1986 | *
|
---|
| 1987 | * @note On unix systems where there is only one set of buffers possible,
|
---|
| 1988 | * pass the same pointers as input and output.
|
---|
| 1989 | */
|
---|
| 1990 | SUPR0DECL(int) SUPR0IoCtlPerform(PSUPR0IOCTLCTX pCtx, uintptr_t uFunction,
|
---|
| 1991 | void *pvInput, RTR3PTR pvInputUser, size_t cbInput,
|
---|
| 1992 | void *pvOutput, RTR3PTR pvOutputUser, size_t cbOutput,
|
---|
| 1993 | int32_t *piNativeRc);
|
---|
| 1994 |
|
---|
| 1995 | /**
|
---|
[57229] | 1996 | * Writes to the debugger and/or kernel log.
|
---|
| 1997 | *
|
---|
| 1998 | * The length of the formatted message is somewhat limited, so keep things short
|
---|
| 1999 | * and to the point.
|
---|
| 2000 | *
|
---|
| 2001 | * @returns Number of bytes written, mabye.
|
---|
| 2002 | * @param pszFormat IPRT format string.
|
---|
| 2003 | * @param ... Arguments referenced by the format string.
|
---|
| 2004 | */
|
---|
| 2005 | SUPR0DECL(int) SUPR0Printf(const char *pszFormat, ...) RT_IPRT_FORMAT_ATTR(1, 2);
|
---|
| 2006 |
|
---|
| 2007 | /**
|
---|
[57108] | 2008 | * Returns configuration flags of the host kernel.
|
---|
| 2009 | *
|
---|
| 2010 | * @returns Combination of SUPKERNELFEATURES_XXX flags.
|
---|
| 2011 | */
|
---|
| 2012 | SUPR0DECL(uint32_t) SUPR0GetKernelFeatures(void);
|
---|
| 2013 |
|
---|
[72693] | 2014 | /** @copydoc RTLogGetDefaultInstanceEx
|
---|
| 2015 | * @remarks To allow overriding RTLogGetDefaultInstanceEx locally. */
|
---|
[72778] | 2016 | SUPR0DECL(struct RTLOGGER *) SUPR0GetDefaultLogInstanceEx(uint32_t fFlagsAndGroup);
|
---|
[72693] | 2017 | /** @copydoc RTLogRelGetDefaultInstanceEx
|
---|
| 2018 | * @remarks To allow overriding RTLogRelGetDefaultInstanceEx locally. */
|
---|
[72778] | 2019 | SUPR0DECL(struct RTLOGGER *) SUPR0GetDefaultLogRelInstanceEx(uint32_t fFlagsAndGroup);
|
---|
[57108] | 2020 |
|
---|
[72693] | 2021 |
|
---|
[14805] | 2022 | /** @name Absolute symbols
|
---|
| 2023 | * Take the address of these, don't try call them.
|
---|
| 2024 | * @{ */
|
---|
| 2025 | SUPR0DECL(void) SUPR0AbsIs64bit(void);
|
---|
| 2026 | SUPR0DECL(void) SUPR0Abs64bitKernelCS(void);
|
---|
| 2027 | SUPR0DECL(void) SUPR0Abs64bitKernelSS(void);
|
---|
| 2028 | SUPR0DECL(void) SUPR0Abs64bitKernelDS(void);
|
---|
| 2029 | SUPR0DECL(void) SUPR0AbsKernelCS(void);
|
---|
| 2030 | SUPR0DECL(void) SUPR0AbsKernelSS(void);
|
---|
| 2031 | SUPR0DECL(void) SUPR0AbsKernelDS(void);
|
---|
| 2032 | SUPR0DECL(void) SUPR0AbsKernelES(void);
|
---|
| 2033 | SUPR0DECL(void) SUPR0AbsKernelFS(void);
|
---|
| 2034 | SUPR0DECL(void) SUPR0AbsKernelGS(void);
|
---|
| 2035 | /** @} */
|
---|
[10259] | 2036 |
|
---|
[9695] | 2037 | /**
|
---|
| 2038 | * Support driver component factory.
|
---|
| 2039 | *
|
---|
| 2040 | * Component factories are registered by drivers that provides services
|
---|
| 2041 | * such as the host network interface filtering and access to the host
|
---|
| 2042 | * TCP/IP stack.
|
---|
| 2043 | *
|
---|
| 2044 | * @remark Module dependencies and making sure that a component doesn't
|
---|
| 2045 | * get unloaded while in use, is the sole responsibility of the
|
---|
| 2046 | * driver/kext/whatever implementing the component.
|
---|
| 2047 | */
|
---|
| 2048 | typedef struct SUPDRVFACTORY
|
---|
| 2049 | {
|
---|
| 2050 | /** The (unique) name of the component factory. */
|
---|
| 2051 | char szName[56];
|
---|
| 2052 | /**
|
---|
| 2053 | * Queries a factory interface.
|
---|
| 2054 | *
|
---|
| 2055 | * The factory interface is specific to each component and will be be
|
---|
| 2056 | * found in the header(s) for the component alongside its UUID.
|
---|
| 2057 | *
|
---|
| 2058 | * @returns Pointer to the factory interfaces on success, NULL on failure.
|
---|
| 2059 | *
|
---|
[10377] | 2060 | * @param pSupDrvFactory Pointer to this structure.
|
---|
[9695] | 2061 | * @param pSession The SUPDRV session making the query.
|
---|
[9736] | 2062 | * @param pszInterfaceUuid The UUID of the factory interface.
|
---|
[9695] | 2063 | */
|
---|
[10377] | 2064 | DECLR0CALLBACKMEMBER(void *, pfnQueryFactoryInterface,(struct SUPDRVFACTORY const *pSupDrvFactory, PSUPDRVSESSION pSession, const char *pszInterfaceUuid));
|
---|
[9695] | 2065 | } SUPDRVFACTORY;
|
---|
| 2066 | /** Pointer to a support driver factory. */
|
---|
| 2067 | typedef SUPDRVFACTORY *PSUPDRVFACTORY;
|
---|
[10259] | 2068 | /** Pointer to a const support driver factory. */
|
---|
| 2069 | typedef SUPDRVFACTORY const *PCSUPDRVFACTORY;
|
---|
[9695] | 2070 |
|
---|
[10377] | 2071 | SUPR0DECL(int) SUPR0ComponentRegisterFactory(PSUPDRVSESSION pSession, PCSUPDRVFACTORY pFactory);
|
---|
| 2072 | SUPR0DECL(int) SUPR0ComponentDeregisterFactory(PSUPDRVSESSION pSession, PCSUPDRVFACTORY pFactory);
|
---|
| 2073 | SUPR0DECL(int) SUPR0ComponentQueryFactory(PSUPDRVSESSION pSession, const char *pszName, const char *pszInterfaceUuid, void **ppvFactoryIf);
|
---|
[9695] | 2074 |
|
---|
| 2075 |
|
---|
[40756] | 2076 | /** @name Tracing
|
---|
| 2077 | * @{ */
|
---|
| 2078 |
|
---|
| 2079 | /**
|
---|
| 2080 | * Tracer data associated with a provider.
|
---|
| 2081 | */
|
---|
| 2082 | typedef union SUPDRVTRACERDATA
|
---|
| 2083 | {
|
---|
| 2084 | /** Generic */
|
---|
| 2085 | uint64_t au64[2];
|
---|
| 2086 |
|
---|
| 2087 | /** DTrace data. */
|
---|
| 2088 | struct
|
---|
| 2089 | {
|
---|
| 2090 | /** Provider ID. */
|
---|
| 2091 | uintptr_t idProvider;
|
---|
[40763] | 2092 | /** The number of trace points provided. */
|
---|
| 2093 | uint32_t volatile cProvidedProbes;
|
---|
| 2094 | /** Whether we've invalidated this bugger. */
|
---|
| 2095 | bool fZombie;
|
---|
[40756] | 2096 | } DTrace;
|
---|
| 2097 | } SUPDRVTRACERDATA;
|
---|
| 2098 | /** Pointer to the tracer data associated with a provider. */
|
---|
| 2099 | typedef SUPDRVTRACERDATA *PSUPDRVTRACERDATA;
|
---|
| 2100 |
|
---|
| 2101 | /**
|
---|
[41117] | 2102 | * Probe location info for ring-0.
|
---|
| 2103 | *
|
---|
| 2104 | * Since we cannot trust user tracepoint modules, we need to duplicate the probe
|
---|
| 2105 | * ID and enabled flag in ring-0.
|
---|
| 2106 | */
|
---|
| 2107 | typedef struct SUPDRVPROBELOC
|
---|
| 2108 | {
|
---|
| 2109 | /** The probe ID. */
|
---|
| 2110 | uint32_t idProbe;
|
---|
| 2111 | /** Whether it's enabled or not. */
|
---|
| 2112 | bool fEnabled;
|
---|
| 2113 | } SUPDRVPROBELOC;
|
---|
| 2114 | /** Pointer to a ring-0 probe location record. */
|
---|
| 2115 | typedef SUPDRVPROBELOC *PSUPDRVPROBELOC;
|
---|
| 2116 |
|
---|
| 2117 | /**
|
---|
| 2118 | * Probe info for ring-0.
|
---|
| 2119 | *
|
---|
| 2120 | * Since we cannot trust user tracepoint modules, we need to duplicate the
|
---|
| 2121 | * probe enable count.
|
---|
| 2122 | */
|
---|
| 2123 | typedef struct SUPDRVPROBEINFO
|
---|
| 2124 | {
|
---|
| 2125 | /** The number of times this probe has been enabled. */
|
---|
| 2126 | uint32_t volatile cEnabled;
|
---|
| 2127 | } SUPDRVPROBEINFO;
|
---|
| 2128 | /** Pointer to a ring-0 probe info record. */
|
---|
| 2129 | typedef SUPDRVPROBEINFO *PSUPDRVPROBEINFO;
|
---|
| 2130 |
|
---|
| 2131 | /**
|
---|
[40756] | 2132 | * Support driver tracepoint provider core.
|
---|
| 2133 | */
|
---|
| 2134 | typedef struct SUPDRVVDTPROVIDERCORE
|
---|
| 2135 | {
|
---|
| 2136 | /** The tracer data member. */
|
---|
| 2137 | SUPDRVTRACERDATA TracerData;
|
---|
[41117] | 2138 | /** Pointer to the provider name (a copy that's always available). */
|
---|
| 2139 | const char *pszName;
|
---|
| 2140 | /** Pointer to the module name (a copy that's always available). */
|
---|
| 2141 | const char *pszModName;
|
---|
| 2142 |
|
---|
[40756] | 2143 | /** The provider descriptor. */
|
---|
| 2144 | struct VTGDESCPROVIDER *pDesc;
|
---|
| 2145 | /** The VTG header. */
|
---|
| 2146 | struct VTGOBJHDR *pHdr;
|
---|
| 2147 |
|
---|
[41117] | 2148 | /** The size of the entries in the pvProbeLocsEn table. */
|
---|
| 2149 | uint8_t cbProbeLocsEn;
|
---|
| 2150 | /** The actual module bit count (corresponds to cbProbeLocsEn). */
|
---|
| 2151 | uint8_t cBits;
|
---|
[58106] | 2152 | /** Set if this is a Umod, otherwise clear. */
|
---|
[41117] | 2153 | bool fUmod;
|
---|
| 2154 | /** Explicit alignment padding (paranoia). */
|
---|
| 2155 | uint8_t abAlignment[ARCH_BITS == 32 ? 1 : 5];
|
---|
[40756] | 2156 |
|
---|
[41117] | 2157 | /** The probe locations used for descriptive purposes. */
|
---|
| 2158 | struct VTGPROBELOC const *paProbeLocsRO;
|
---|
| 2159 | /** Pointer to the probe location array where the enable flag needs
|
---|
| 2160 | * flipping. For kernel providers, this will always be SUPDRVPROBELOC,
|
---|
| 2161 | * while user providers can either be 32-bit or 64-bit. Use
|
---|
| 2162 | * cbProbeLocsEn to calculate the address of an entry. */
|
---|
| 2163 | void *pvProbeLocsEn;
|
---|
| 2164 | /** Pointer to the probe array containing the enabled counts. */
|
---|
| 2165 | uint32_t *pacProbeEnabled;
|
---|
[40761] | 2166 |
|
---|
[41117] | 2167 | /** The ring-0 probe location info for user tracepoint modules.
|
---|
| 2168 | * This is NULL if fUmod is false. */
|
---|
| 2169 | PSUPDRVPROBELOC paR0ProbeLocs;
|
---|
| 2170 | /** The ring-0 probe info for user tracepoint modules.
|
---|
| 2171 | * This is NULL if fUmod is false. */
|
---|
| 2172 | PSUPDRVPROBEINFO paR0Probes;
|
---|
[40761] | 2173 |
|
---|
[41117] | 2174 | } SUPDRVVDTPROVIDERCORE;
|
---|
| 2175 | /** Pointer to a tracepoint provider core structure. */
|
---|
| 2176 | typedef SUPDRVVDTPROVIDERCORE *PSUPDRVVDTPROVIDERCORE;
|
---|
[40761] | 2177 |
|
---|
[40756] | 2178 | /** Pointer to a tracer registration record. */
|
---|
| 2179 | typedef struct SUPDRVTRACERREG const *PCSUPDRVTRACERREG;
|
---|
| 2180 | /**
|
---|
| 2181 | * Support driver tracer registration record.
|
---|
| 2182 | */
|
---|
| 2183 | typedef struct SUPDRVTRACERREG
|
---|
| 2184 | {
|
---|
| 2185 | /** Magic value (SUPDRVTRACERREG_MAGIC). */
|
---|
| 2186 | uint32_t u32Magic;
|
---|
| 2187 | /** Version (SUPDRVTRACERREG_VERSION). */
|
---|
| 2188 | uint32_t u32Version;
|
---|
| 2189 |
|
---|
[40759] | 2190 | /**
|
---|
[40761] | 2191 | * Fire off a kernel probe.
|
---|
[40759] | 2192 | *
|
---|
[40761] | 2193 | * @param pVtgProbeLoc The probe location record.
|
---|
| 2194 | * @param uArg0 The first raw probe argument.
|
---|
| 2195 | * @param uArg1 The second raw probe argument.
|
---|
| 2196 | * @param uArg2 The third raw probe argument.
|
---|
| 2197 | * @param uArg3 The fourth raw probe argument.
|
---|
| 2198 | * @param uArg4 The fifth raw probe argument.
|
---|
[40759] | 2199 | *
|
---|
[40763] | 2200 | * @remarks SUPR0TracerFireProbe will do a tail jump thru this member, so
|
---|
| 2201 | * no extra stack frames will be added.
|
---|
[40759] | 2202 | * @remarks This does not take a 'this' pointer argument because it doesn't map
|
---|
| 2203 | * well onto VTG or DTrace.
|
---|
| 2204 | *
|
---|
| 2205 | */
|
---|
[40763] | 2206 | DECLR0CALLBACKMEMBER(void, pfnProbeFireKernel, (struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
|
---|
[40761] | 2207 | uintptr_t uArg3, uintptr_t uArg4));
|
---|
[40756] | 2208 |
|
---|
| 2209 | /**
|
---|
[40761] | 2210 | * Fire off a user-mode probe.
|
---|
| 2211 | *
|
---|
| 2212 | * @param pThis Pointer to the registration record.
|
---|
| 2213 | *
|
---|
| 2214 | * @param pVtgProbeLoc The probe location record.
|
---|
[40763] | 2215 | * @param pSession The user session.
|
---|
[40761] | 2216 | * @param pCtx The usermode context info.
|
---|
[41130] | 2217 | * @param pVtgHdr The VTG header (read-only).
|
---|
| 2218 | * @param pProbeLocRO The read-only probe location record .
|
---|
[40761] | 2219 | */
|
---|
[41130] | 2220 | DECLR0CALLBACKMEMBER(void, pfnProbeFireUser, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, PCSUPDRVTRACERUSRCTX pCtx,
|
---|
| 2221 | struct VTGOBJHDR const *pVtgHdr, struct VTGPROBELOC const *pProbeLocRO));
|
---|
[40761] | 2222 |
|
---|
| 2223 | /**
|
---|
[40759] | 2224 | * Opens up the tracer.
|
---|
| 2225 | *
|
---|
| 2226 | * @returns VBox status code.
|
---|
| 2227 | * @param pThis Pointer to the registration record.
|
---|
| 2228 | * @param pSession The session doing the opening.
|
---|
| 2229 | * @param uCookie A cookie (magic) unique to the tracer, so it can
|
---|
| 2230 | * fend off incompatible clients.
|
---|
| 2231 | * @param uArg Tracer specific argument.
|
---|
| 2232 | * @param puSessionData Pointer to the session data variable. This must be
|
---|
| 2233 | * set to a non-zero value on success.
|
---|
| 2234 | */
|
---|
[40763] | 2235 | DECLR0CALLBACKMEMBER(int, pfnTracerOpen, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uint32_t uCookie, uintptr_t uArg,
|
---|
[40759] | 2236 | uintptr_t *puSessionData));
|
---|
| 2237 |
|
---|
| 2238 | /**
|
---|
| 2239 | * I/O control style tracer communication method.
|
---|
| 2240 | *
|
---|
| 2241 | *
|
---|
| 2242 | * @returns VBox status code.
|
---|
| 2243 | * @param pThis Pointer to the registration record.
|
---|
| 2244 | * @param pSession The session.
|
---|
| 2245 | * @param uSessionData The session data value.
|
---|
| 2246 | * @param uCmd The tracer specific command.
|
---|
| 2247 | * @param uArg The tracer command specific argument.
|
---|
| 2248 | * @param piRetVal The tracer specific return value.
|
---|
| 2249 | */
|
---|
[40763] | 2250 | DECLR0CALLBACKMEMBER(int, pfnTracerIoCtl, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData,
|
---|
| 2251 | uintptr_t uCmd, uintptr_t uArg, int32_t *piRetVal));
|
---|
[40759] | 2252 |
|
---|
| 2253 | /**
|
---|
| 2254 | * Cleans up data the tracer has associated with a session.
|
---|
| 2255 | *
|
---|
| 2256 | * @param pThis Pointer to the registration record.
|
---|
| 2257 | * @param pSession The session handle.
|
---|
| 2258 | * @param uSessionData The data assoicated with the session.
|
---|
| 2259 | */
|
---|
[40763] | 2260 | DECLR0CALLBACKMEMBER(void, pfnTracerClose, (PCSUPDRVTRACERREG pThis, PSUPDRVSESSION pSession, uintptr_t uSessionData));
|
---|
[40759] | 2261 |
|
---|
| 2262 | /**
|
---|
[40756] | 2263 | * Registers a provider.
|
---|
| 2264 | *
|
---|
| 2265 | * @returns VBox status code.
|
---|
| 2266 | * @param pThis Pointer to the registration record.
|
---|
| 2267 | * @param pCore The provider core data.
|
---|
[40763] | 2268 | *
|
---|
| 2269 | * @todo Kernel vs. Userland providers.
|
---|
[40756] | 2270 | */
|
---|
[40763] | 2271 | DECLR0CALLBACKMEMBER(int, pfnProviderRegister, (PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore));
|
---|
[40756] | 2272 |
|
---|
| 2273 | /**
|
---|
| 2274 | * Attempts to deregisters a provider.
|
---|
| 2275 | *
|
---|
| 2276 | * @returns VINF_SUCCESS or VERR_TRY_AGAIN. If the latter, the provider
|
---|
| 2277 | * should be made as harmless as possible before returning as the
|
---|
| 2278 | * VTG object and associated code will be unloaded upon return.
|
---|
| 2279 | *
|
---|
| 2280 | * @param pThis Pointer to the registration record.
|
---|
| 2281 | * @param pCore The provider core data.
|
---|
| 2282 | */
|
---|
[40763] | 2283 | DECLR0CALLBACKMEMBER(int, pfnProviderDeregister, (PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore));
|
---|
[40756] | 2284 |
|
---|
| 2285 | /**
|
---|
| 2286 | * Make another attempt at unregister a busy provider.
|
---|
| 2287 | *
|
---|
| 2288 | * @returns VINF_SUCCESS or VERR_TRY_AGAIN.
|
---|
| 2289 | * @param pThis Pointer to the registration record.
|
---|
| 2290 | * @param pCore The provider core data.
|
---|
| 2291 | */
|
---|
[40763] | 2292 | DECLR0CALLBACKMEMBER(int, pfnProviderDeregisterZombie, (PCSUPDRVTRACERREG pThis, PSUPDRVVDTPROVIDERCORE pCore));
|
---|
[40756] | 2293 |
|
---|
| 2294 | /** End marker (SUPDRVTRACERREG_MAGIC). */
|
---|
| 2295 | uintptr_t uEndMagic;
|
---|
| 2296 | } SUPDRVTRACERREG;
|
---|
| 2297 |
|
---|
| 2298 | /** Tracer magic (Kenny Garrett). */
|
---|
| 2299 | #define SUPDRVTRACERREG_MAGIC UINT32_C(0x19601009)
|
---|
| 2300 | /** Tracer registration structure version. */
|
---|
| 2301 | #define SUPDRVTRACERREG_VERSION RT_MAKE_U32(0, 1)
|
---|
| 2302 |
|
---|
| 2303 | /** Pointer to a trace helper structure. */
|
---|
| 2304 | typedef struct SUPDRVTRACERHLP const *PCSUPDRVTRACERHLP;
|
---|
| 2305 | /**
|
---|
| 2306 | * Helper structure.
|
---|
| 2307 | */
|
---|
| 2308 | typedef struct SUPDRVTRACERHLP
|
---|
| 2309 | {
|
---|
| 2310 | /** The structure version (SUPDRVTRACERHLP_VERSION). */
|
---|
| 2311 | uintptr_t uVersion;
|
---|
| 2312 |
|
---|
| 2313 | /** @todo ... */
|
---|
| 2314 |
|
---|
| 2315 | /** End marker (SUPDRVTRACERHLP_VERSION) */
|
---|
| 2316 | uintptr_t uEndVersion;
|
---|
| 2317 | } SUPDRVTRACERHLP;
|
---|
| 2318 | /** Tracer helper structure version. */
|
---|
| 2319 | #define SUPDRVTRACERHLP_VERSION RT_MAKE_U32(0, 1)
|
---|
| 2320 |
|
---|
[40763] | 2321 | SUPR0DECL(int) SUPR0TracerRegisterImpl(void *hMod, PSUPDRVSESSION pSession, PCSUPDRVTRACERREG pReg, PCSUPDRVTRACERHLP *ppHlp);
|
---|
[40777] | 2322 | SUPR0DECL(int) SUPR0TracerDeregisterImpl(void *hMod, PSUPDRVSESSION pSession);
|
---|
[40763] | 2323 | SUPR0DECL(int) SUPR0TracerRegisterDrv(PSUPDRVSESSION pSession, struct VTGOBJHDR *pVtgHdr, const char *pszName);
|
---|
| 2324 | SUPR0DECL(void) SUPR0TracerDeregisterDrv(PSUPDRVSESSION pSession);
|
---|
| 2325 | SUPR0DECL(int) SUPR0TracerRegisterModule(void *hMod, struct VTGOBJHDR *pVtgHdr);
|
---|
[40981] | 2326 | SUPR0DECL(void) SUPR0TracerFireProbe(struct VTGPROBELOC *pVtgProbeLoc, uintptr_t uArg0, uintptr_t uArg1, uintptr_t uArg2,
|
---|
[40763] | 2327 | uintptr_t uArg3, uintptr_t uArg4);
|
---|
[41147] | 2328 | SUPR0DECL(void) SUPR0TracerUmodProbeFire(PSUPDRVSESSION pSession, PSUPDRVTRACERUSRCTX pCtx);
|
---|
[40756] | 2329 | /** @} */
|
---|
[40636] | 2330 |
|
---|
[40756] | 2331 |
|
---|
[14332] | 2332 | /**
|
---|
| 2333 | * Service request callback function.
|
---|
| 2334 | *
|
---|
| 2335 | * @returns VBox status code.
|
---|
| 2336 | * @param pSession The caller's session.
|
---|
[64364] | 2337 | * @param uOperation The operation identifier.
|
---|
[14332] | 2338 | * @param u64Arg 64-bit integer argument.
|
---|
| 2339 | * @param pReqHdr The request header. Input / Output. Optional.
|
---|
| 2340 | */
|
---|
| 2341 | typedef DECLCALLBACK(int) FNSUPR0SERVICEREQHANDLER(PSUPDRVSESSION pSession, uint32_t uOperation,
|
---|
| 2342 | uint64_t u64Arg, PSUPR0SERVICEREQHDR pReqHdr);
|
---|
| 2343 | /** Pointer to a FNR0SERVICEREQHANDLER(). */
|
---|
| 2344 | typedef R0PTRTYPE(FNSUPR0SERVICEREQHANDLER *) PFNSUPR0SERVICEREQHANDLER;
|
---|
| 2345 |
|
---|
| 2346 |
|
---|
[9695] | 2347 | /** @defgroup grp_sup_r0_idc The IDC Interface
|
---|
| 2348 | * @{
|
---|
| 2349 | */
|
---|
| 2350 |
|
---|
| 2351 | /** The current SUPDRV IDC version.
|
---|
| 2352 | * This follows the usual high word / low word rules, i.e. high word is the
|
---|
| 2353 | * major number and it signifies incompatible interface changes. */
|
---|
[10259] | 2354 | #define SUPDRV_IDC_VERSION UINT32_C(0x00010000)
|
---|
[9695] | 2355 |
|
---|
| 2356 | /**
|
---|
[33540] | 2357 | * Inter-Driver Communication Handle.
|
---|
[9695] | 2358 | */
|
---|
[10259] | 2359 | typedef union SUPDRVIDCHANDLE
|
---|
[9695] | 2360 | {
|
---|
[10259] | 2361 | /** Padding for opaque usage.
|
---|
| 2362 | * Must be greater or equal in size than the private struct. */
|
---|
| 2363 | void *apvPadding[4];
|
---|
| 2364 | #ifdef SUPDRVIDCHANDLEPRIVATE_DECLARED
|
---|
| 2365 | /** The private view. */
|
---|
| 2366 | struct SUPDRVIDCHANDLEPRIVATE s;
|
---|
| 2367 | #endif
|
---|
| 2368 | } SUPDRVIDCHANDLE;
|
---|
| 2369 | /** Pointer to a handle. */
|
---|
| 2370 | typedef SUPDRVIDCHANDLE *PSUPDRVIDCHANDLE;
|
---|
[9695] | 2371 |
|
---|
[10377] | 2372 | SUPR0DECL(int) SUPR0IdcOpen(PSUPDRVIDCHANDLE pHandle, uint32_t uReqVersion, uint32_t uMinVersion,
|
---|
| 2373 | uint32_t *puSessionVersion, uint32_t *puDriverVersion, uint32_t *puDriverRevision);
|
---|
[10259] | 2374 | SUPR0DECL(int) SUPR0IdcCall(PSUPDRVIDCHANDLE pHandle, uint32_t iReq, void *pvReq, uint32_t cbReq);
|
---|
| 2375 | SUPR0DECL(int) SUPR0IdcClose(PSUPDRVIDCHANDLE pHandle);
|
---|
| 2376 | SUPR0DECL(PSUPDRVSESSION) SUPR0IdcGetSession(PSUPDRVIDCHANDLE pHandle);
|
---|
| 2377 | SUPR0DECL(int) SUPR0IdcComponentRegisterFactory(PSUPDRVIDCHANDLE pHandle, PCSUPDRVFACTORY pFactory);
|
---|
| 2378 | SUPR0DECL(int) SUPR0IdcComponentDeregisterFactory(PSUPDRVIDCHANDLE pHandle, PCSUPDRVFACTORY pFactory);
|
---|
[9695] | 2379 |
|
---|
[1] | 2380 | /** @} */
|
---|
[9695] | 2381 |
|
---|
[40644] | 2382 | /** @name Ring-0 module entry points.
|
---|
[40667] | 2383 | *
|
---|
[40644] | 2384 | * These can be exported by ring-0 modules SUP are told to load.
|
---|
[40667] | 2385 | *
|
---|
[40644] | 2386 | * @{ */
|
---|
| 2387 | DECLEXPORT(int) ModuleInit(void *hMod);
|
---|
| 2388 | DECLEXPORT(void) ModuleTerm(void *hMod);
|
---|
| 2389 | /** @} */
|
---|
| 2390 |
|
---|
| 2391 |
|
---|
[9695] | 2392 | /** @} */
|
---|
[1] | 2393 | #endif
|
---|
| 2394 |
|
---|
[40644] | 2395 |
|
---|
[51770] | 2396 | /** @name Trust Anchors and Certificates
|
---|
| 2397 | * @{ */
|
---|
| 2398 |
|
---|
| 2399 | /**
|
---|
| 2400 | * Trust anchor table entry (in generated Certificates.cpp).
|
---|
| 2401 | */
|
---|
| 2402 | typedef struct SUPTAENTRY
|
---|
| 2403 | {
|
---|
| 2404 | /** Pointer to the raw bytes. */
|
---|
| 2405 | const unsigned char *pch;
|
---|
| 2406 | /** Number of bytes. */
|
---|
| 2407 | unsigned cb;
|
---|
| 2408 | } SUPTAENTRY;
|
---|
| 2409 | /** Pointer to a trust anchor table entry. */
|
---|
| 2410 | typedef SUPTAENTRY const *PCSUPTAENTRY;
|
---|
| 2411 |
|
---|
| 2412 | /** Macro for simplifying generating the trust anchor tables. */
|
---|
| 2413 | #define SUPTAENTRY_GEN(a_abTA) { &a_abTA[0], sizeof(a_abTA) }
|
---|
| 2414 |
|
---|
| 2415 | /** All certificates we know. */
|
---|
| 2416 | extern SUPTAENTRY const g_aSUPAllTAs[];
|
---|
| 2417 | /** Number of entries in g_aSUPAllTAs. */
|
---|
| 2418 | extern unsigned const g_cSUPAllTAs;
|
---|
| 2419 |
|
---|
| 2420 | /** Software publisher certificate roots (Authenticode). */
|
---|
| 2421 | extern SUPTAENTRY const g_aSUPSpcRootTAs[];
|
---|
| 2422 | /** Number of entries in g_aSUPSpcRootTAs. */
|
---|
| 2423 | extern unsigned const g_cSUPSpcRootTAs;
|
---|
| 2424 |
|
---|
| 2425 | /** Kernel root certificates used by Windows. */
|
---|
| 2426 | extern SUPTAENTRY const g_aSUPNtKernelRootTAs[];
|
---|
| 2427 | /** Number of entries in g_aSUPNtKernelRootTAs. */
|
---|
| 2428 | extern unsigned const g_cSUPNtKernelRootTAs;
|
---|
| 2429 |
|
---|
| 2430 | /** Timestamp root certificates trusted by Windows. */
|
---|
| 2431 | extern SUPTAENTRY const g_aSUPTimestampTAs[];
|
---|
| 2432 | /** Number of entries in g_aSUPTimestampTAs. */
|
---|
| 2433 | extern unsigned const g_cSUPTimestampTAs;
|
---|
| 2434 |
|
---|
| 2435 | /** TAs we trust (the build certificate, Oracle VirtualBox). */
|
---|
| 2436 | extern SUPTAENTRY const g_aSUPTrustedTAs[];
|
---|
| 2437 | /** Number of entries in g_aSUPTrustedTAs. */
|
---|
| 2438 | extern unsigned const g_cSUPTrustedTAs;
|
---|
| 2439 |
|
---|
| 2440 | /** Supplemental certificates, like cross signing certificates. */
|
---|
| 2441 | extern SUPTAENTRY const g_aSUPSupplementalTAs[];
|
---|
| 2442 | /** Number of entries in g_aSUPTrustedTAs. */
|
---|
| 2443 | extern unsigned const g_cSUPSupplementalTAs;
|
---|
| 2444 |
|
---|
| 2445 | /** The build certificate. */
|
---|
| 2446 | extern const unsigned char g_abSUPBuildCert[];
|
---|
| 2447 | /** The size of the build certificate. */
|
---|
| 2448 | extern const unsigned g_cbSUPBuildCert;
|
---|
| 2449 |
|
---|
[1] | 2450 | /** @} */
|
---|
| 2451 |
|
---|
[51770] | 2452 |
|
---|
| 2453 | /** @} */
|
---|
| 2454 |
|
---|
[20374] | 2455 | RT_C_DECLS_END
|
---|
[1] | 2456 |
|
---|
| 2457 | #endif
|
---|
| 2458 |
|
---|