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