VirtualBox

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

Last change on this file since 87728 was 87728, checked in by vboxsync, 4 years ago

SUPDrv,VMMR0,VBoxDDR0,++: More work on wrapper kmods. bugref:9937

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