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