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