VirtualBox

source: vbox/trunk/include/VBox/sup.h@ 91688

Last change on this file since 91688 was 91037, checked in by vboxsync, 3 years ago

VMM: Nested VMX: bugref:10092 Added support for tertiary processor based VM-execution controls and updated the virtual VMCS.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette