VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/Support/SUPDrvIOC.h@ 68033

Last change on this file since 68033 was 67982, checked in by vboxsync, 7 years ago

SUPDrvIOC.h: Documented need to skip a version because 5.1 is using it.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 55.1 KB
Line 
1/* $Id: SUPDrvIOC.h 67982 2017-07-16 12:45:53Z vboxsync $ */
2/** @file
3 * VirtualBox Support Driver - IOCtl definitions.
4 */
5
6/*
7 * Copyright (C) 2006-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * The contents of this file may alternatively be used under the terms
18 * of the Common Development and Distribution License Version 1.0
19 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
20 * VirtualBox OSE distribution, in which case the provisions of the
21 * CDDL are applicable instead of those of the GPL.
22 *
23 * You may elect to license modified versions of this file under the
24 * terms and conditions of either the GPL or the CDDL or both.
25 */
26
27#ifndef ___SUPDrvIOC_h___
28#define ___SUPDrvIOC_h___
29
30/*
31 * Basic types.
32 */
33#include <iprt/types.h>
34#include <VBox/sup.h>
35
36/*
37 * IOCtl numbers.
38 * We're using the Win32 type of numbers here, thus the macros below.
39 * The SUP_IOCTL_FLAG macro is used to separate requests from 32-bit
40 * and 64-bit processes.
41 */
42#if defined(RT_ARCH_AMD64) || defined(RT_ARCH_SPARC64)
43# define SUP_IOCTL_FLAG 128
44#elif defined(RT_ARCH_X86) || defined(RT_ARCH_SPARC)
45# define SUP_IOCTL_FLAG 0
46#else
47# error "dunno which arch this is!"
48#endif
49
50#ifdef RT_OS_WINDOWS
51# ifndef CTL_CODE
52# include <iprt/win/windows.h>
53# endif
54 /* Automatic buffering, size not encoded. */
55# define SUP_CTL_CODE_SIZE(Function, Size) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_BUFFERED, FILE_WRITE_ACCESS)
56# define SUP_CTL_CODE_BIG(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_BUFFERED, FILE_WRITE_ACCESS)
57# define SUP_CTL_CODE_FAST(Function) CTL_CODE(FILE_DEVICE_UNKNOWN, (Function) | SUP_IOCTL_FLAG, METHOD_NEITHER, FILE_WRITE_ACCESS)
58# define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
59
60# define SUP_NT_STATUS_BASE UINT32_C(0xe9860000) /**< STATUS_SEVERITY_ERROR + C-bit + facility 0x986. */
61# define SUP_NT_STATUS_IS_VBOX(a_rcNt) ( ((uint32_t)(a_rcNt) & 0xffff0000) == SUP_NT_STATUS_BASE )
62# define SUP_NT_STATUS_TO_VBOX(a_rcNt) ( (int)((uint32_t)(a_rcNt) | UINT32_C(0xffff0000)) )
63
64/** NT device name for system access. */
65# define SUPDRV_NT_DEVICE_NAME_SYS L"\\Device\\VBoxDrv"
66/** NT device name for user access. */
67# define SUPDRV_NT_DEVICE_NAME_USR L"\\Device\\VBoxDrvU"
68# ifdef VBOX_WITH_HARDENING
69/** NT device name for hardened stub access. */
70# define SUPDRV_NT_DEVICE_NAME_STUB L"\\Device\\VBoxDrvStub"
71/** NT device name for getting error information for failed VBoxDrv or
72 * VBoxDrvStub open. */
73# define SUPDRV_NT_DEVICE_NAME_ERROR_INFO L"\\Device\\VBoxDrvErrorInfo"
74# endif
75
76
77#elif defined(RT_OS_SOLARIS)
78 /* No automatic buffering, size limited to 255 bytes. */
79# include <sys/ioccom.h>
80# define SUP_CTL_CODE_SIZE(Function, Size) _IOWRN('V', (Function) | SUP_IOCTL_FLAG, sizeof(SUPREQHDR))
81# define SUP_CTL_CODE_BIG(Function) _IOWRN('V', (Function) | SUP_IOCTL_FLAG, sizeof(SUPREQHDR))
82# define SUP_CTL_CODE_FAST(Function) _IO( 'V', (Function) | SUP_IOCTL_FLAG)
83# define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
84
85#elif defined(RT_OS_OS2)
86 /* No automatic buffering, size not encoded. */
87# define SUP_CTL_CATEGORY 0xc0
88# define SUP_CTL_CODE_SIZE(Function, Size) ((unsigned char)(Function))
89# define SUP_CTL_CODE_BIG(Function) ((unsigned char)(Function))
90# define SUP_CTL_CATEGORY_FAST 0xc1
91# define SUP_CTL_CODE_FAST(Function) ((unsigned char)(Function))
92# define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
93
94#elif defined(RT_OS_LINUX)
95 /* No automatic buffering, size limited to 16KB. */
96# include <linux/ioctl.h>
97# define SUP_CTL_CODE_SIZE(Function, Size) _IOC(_IOC_READ | _IOC_WRITE, 'V', (Function) | SUP_IOCTL_FLAG, (Size))
98# define SUP_CTL_CODE_BIG(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
99# define SUP_CTL_CODE_FAST(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
100# define SUP_CTL_CODE_NO_SIZE(uIOCtl) ((uIOCtl) & ~IOCSIZE_MASK)
101
102#elif defined(RT_OS_L4)
103 /* Implemented in suplib, no worries. */
104# define SUP_CTL_CODE_SIZE(Function, Size) (Function)
105# define SUP_CTL_CODE_BIG(Function) (Function)
106# define SUP_CTL_CODE_FAST(Function) (Function)
107# define SUP_CTL_CODE_NO_SIZE(uIOCtl) (uIOCtl)
108
109#else /* BSD Like */
110 /* Automatic buffering, size limited to 4KB on *BSD and 8KB on Darwin - commands the limit, 4KB. */
111# include <sys/ioccom.h>
112# define SUP_CTL_CODE_SIZE(Function, Size) _IOC(IOC_INOUT, 'V', (Function) | SUP_IOCTL_FLAG, (Size))
113# define SUP_CTL_CODE_BIG(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
114# define SUP_CTL_CODE_FAST(Function) _IO('V', (Function) | SUP_IOCTL_FLAG)
115# define SUP_CTL_CODE_NO_SIZE(uIOCtl) ( (uIOCtl) & ~_IOC(0,0,0,IOCPARM_MASK) )
116#endif
117
118/** Fast path IOCtl: VMMR0_DO_RAW_RUN */
119#define SUP_IOCTL_FAST_DO_RAW_RUN SUP_CTL_CODE_FAST(64)
120/** Fast path IOCtl: VMMR0_DO_HM_RUN */
121#define SUP_IOCTL_FAST_DO_HM_RUN SUP_CTL_CODE_FAST(65)
122/** Just a NOP call for profiling the latency of a fast ioctl call to VMMR0. */
123#define SUP_IOCTL_FAST_DO_NOP SUP_CTL_CODE_FAST(66)
124
125#ifdef RT_OS_DARWIN
126/** Cookie used to fend off some unwanted clients to the IOService. */
127# define SUP_DARWIN_IOSERVICE_COOKIE 0x64726962 /* 'bird' */
128#endif
129
130
131/*******************************************************************************
132* Structures and Typedefs *
133*******************************************************************************/
134#ifdef RT_ARCH_AMD64
135# pragma pack(8) /* paranoia. */
136#else
137# pragma pack(4) /* paranoia. */
138#endif
139
140
141/**
142 * Common In/Out header.
143 */
144typedef struct SUPREQHDR
145{
146 /** Cookie. */
147 uint32_t u32Cookie;
148 /** Session cookie. */
149 uint32_t u32SessionCookie;
150 /** The size of the input. */
151 uint32_t cbIn;
152 /** The size of the output. */
153 uint32_t cbOut;
154 /** Flags. See SUPREQHDR_FLAGS_* for details and values. */
155 uint32_t fFlags;
156 /** The VBox status code of the operation, out direction only. */
157 int32_t rc;
158} SUPREQHDR;
159/** Pointer to a IOC header. */
160typedef SUPREQHDR *PSUPREQHDR;
161
162/** @name SUPREQHDR::fFlags values
163 * @{ */
164/** Masks out the magic value. */
165#define SUPREQHDR_FLAGS_MAGIC_MASK UINT32_C(0xff0000ff)
166/** The generic mask. */
167#define SUPREQHDR_FLAGS_GEN_MASK UINT32_C(0x0000ff00)
168/** The request specific mask. */
169#define SUPREQHDR_FLAGS_REQ_MASK UINT32_C(0x00ff0000)
170
171/** There is extra input that needs copying on some platforms. */
172#define SUPREQHDR_FLAGS_EXTRA_IN UINT32_C(0x00000100)
173/** There is extra output that needs copying on some platforms. */
174#define SUPREQHDR_FLAGS_EXTRA_OUT UINT32_C(0x00000200)
175
176/** The magic value. */
177#define SUPREQHDR_FLAGS_MAGIC UINT32_C(0x42000042)
178/** The default value. Use this when no special stuff is requested. */
179#define SUPREQHDR_FLAGS_DEFAULT SUPREQHDR_FLAGS_MAGIC
180/** @} */
181
182
183/** @name SUP_IOCTL_COOKIE
184 * @{
185 */
186/** Negotiate cookie. */
187#define SUP_IOCTL_COOKIE SUP_CTL_CODE_SIZE(1, SUP_IOCTL_COOKIE_SIZE)
188/** The request size. */
189#define SUP_IOCTL_COOKIE_SIZE sizeof(SUPCOOKIE)
190/** The SUPREQHDR::cbIn value. */
191#define SUP_IOCTL_COOKIE_SIZE_IN sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCOOKIE, u.In)
192/** The SUPREQHDR::cbOut value. */
193#define SUP_IOCTL_COOKIE_SIZE_OUT sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCOOKIE, u.Out)
194/** SUPCOOKIE_IN magic word. */
195#define SUPCOOKIE_MAGIC "The Magic Word!"
196/** The initial cookie. */
197#define SUPCOOKIE_INITIAL_COOKIE 0x69726f74 /* 'tori' */
198
199/** Current interface version.
200 * The upper 16-bit is the major version, the lower the minor version.
201 * When incompatible changes are made, the upper major number has to be changed.
202 *
203 * Update rules:
204 * -# Only update the major number when incompatible changes have been made to
205 * the IOC interface or the ABI provided via the functions returned by
206 * SUPQUERYFUNCS.
207 * -# When adding new features (new IOC number, new flags, new exports, ++)
208 * only update the minor number and change SUPLib.cpp to require the
209 * new IOC version.
210 * -# When incrementing the major number, clear the minor part and reset
211 * any IOC version requirements in SUPLib.cpp.
212 * -# When increment the major number, execute all pending work.
213 *
214 * @todo Pending work on next major version change:
215 * - nothing.
216 *
217 * @remarks 0x002a0000 is used by 5.1. The next version number must be 0x002b0000.
218 */
219#define SUPDRV_IOC_VERSION 0x00290000
220
221/** SUP_IOCTL_COOKIE. */
222typedef struct SUPCOOKIE
223{
224 /** The header.
225 * u32Cookie must be set to SUPCOOKIE_INITIAL_COOKIE.
226 * u32SessionCookie should be set to some random value. */
227 SUPREQHDR Hdr;
228 union
229 {
230 struct
231 {
232 /** Magic word. */
233 char szMagic[16];
234 /** The requested interface version number. */
235 uint32_t u32ReqVersion;
236 /** The minimum interface version number. */
237 uint32_t u32MinVersion;
238 } In;
239 struct
240 {
241 /** Cookie. */
242 uint32_t u32Cookie;
243 /** Session cookie. */
244 uint32_t u32SessionCookie;
245 /** Interface version for this session. */
246 uint32_t u32SessionVersion;
247 /** The actual interface version in the driver. */
248 uint32_t u32DriverVersion;
249 /** Number of functions available for the SUP_IOCTL_QUERY_FUNCS request. */
250 uint32_t cFunctions;
251 /** Session handle. */
252 R0PTRTYPE(PSUPDRVSESSION) pSession;
253 } Out;
254 } u;
255} SUPCOOKIE, *PSUPCOOKIE;
256/** @} */
257
258
259/** @name SUP_IOCTL_QUERY_FUNCS
260 * Query SUPR0 functions.
261 * @{
262 */
263#define SUP_IOCTL_QUERY_FUNCS(cFuncs) SUP_CTL_CODE_BIG(2)
264#define SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs) RT_UOFFSETOF(SUPQUERYFUNCS, u.Out.aFunctions[(cFuncs)])
265#define SUP_IOCTL_QUERY_FUNCS_SIZE_IN sizeof(SUPREQHDR)
266#define SUP_IOCTL_QUERY_FUNCS_SIZE_OUT(cFuncs) SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs)
267
268/** A function. */
269typedef struct SUPFUNC
270{
271 /** Name - mangled. */
272 char szName[32];
273 /** Address. */
274 RTR0PTR pfn;
275} SUPFUNC, *PSUPFUNC;
276
277typedef struct SUPQUERYFUNCS
278{
279 /** The header. */
280 SUPREQHDR Hdr;
281 union
282 {
283 struct
284 {
285 /** Number of functions returned. */
286 uint32_t cFunctions;
287 /** Array of functions. */
288 SUPFUNC aFunctions[1];
289 } Out;
290 } u;
291} SUPQUERYFUNCS, *PSUPQUERYFUNCS;
292/** @} */
293
294
295/** @name SUP_IOCTL_LDR_OPEN
296 * Open an image.
297 * @{
298 */
299#define SUP_IOCTL_LDR_OPEN SUP_CTL_CODE_SIZE(3, SUP_IOCTL_LDR_OPEN_SIZE)
300#define SUP_IOCTL_LDR_OPEN_SIZE sizeof(SUPLDROPEN)
301#define SUP_IOCTL_LDR_OPEN_SIZE_IN sizeof(SUPLDROPEN)
302#define SUP_IOCTL_LDR_OPEN_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDROPEN, u.Out))
303typedef struct SUPLDROPEN
304{
305 /** The header. */
306 SUPREQHDR Hdr;
307 union
308 {
309 struct
310 {
311 /** Size of the image we'll be loading (including tables). */
312 uint32_t cbImageWithTabs;
313 /** The size of the image bits. (Less or equal to cbImageWithTabs.) */
314 uint32_t cbImageBits;
315 /** Image name.
316 * This is the NAME of the image, not the file name. It is used
317 * to share code with other processes. (Max len is 32 chars!) */
318 char szName[32];
319 /** Image file name.
320 * This can be used to load the image using a native loader. */
321 char szFilename[260];
322 } In;
323 struct
324 {
325 /** The base address of the image. */
326 RTR0PTR pvImageBase;
327 /** Indicate whether or not the image requires loading. */
328 bool fNeedsLoading;
329 /** Indicates that we're using the native ring-0 loader. */
330 bool fNativeLoader;
331 } Out;
332 } u;
333} SUPLDROPEN, *PSUPLDROPEN;
334/** @} */
335
336
337/** @name SUP_IOCTL_LDR_LOAD
338 * Upload the image bits.
339 * @{
340 */
341#define SUP_IOCTL_LDR_LOAD SUP_CTL_CODE_BIG(4)
342#define SUP_IOCTL_LDR_LOAD_SIZE(cbImage) RT_MAX(RT_UOFFSETOF(SUPLDRLOAD, u.In.abImage[cbImage]), SUP_IOCTL_LDR_LOAD_SIZE_OUT)
343#define SUP_IOCTL_LDR_LOAD_SIZE_IN(cbImage) RT_UOFFSETOF(SUPLDRLOAD, u.In.abImage[cbImage])
344#define SUP_IOCTL_LDR_LOAD_SIZE_OUT (RT_UOFFSETOF(SUPLDRLOAD, u.Out.szError) + RT_SIZEOFMEMB(SUPLDRLOAD, u.Out.szError))
345
346/**
347 * Module initialization callback function.
348 * This is called once after the module has been loaded.
349 *
350 * @returns 0 on success.
351 * @returns Appropriate error code on failure.
352 * @param hMod Image handle for use in APIs.
353 */
354typedef DECLCALLBACK(int) FNR0MODULEINIT(void *hMod);
355/** Pointer to a FNR0MODULEINIT(). */
356typedef R0PTRTYPE(FNR0MODULEINIT *) PFNR0MODULEINIT;
357
358/**
359 * Module termination callback function.
360 * This is called once right before the module is being unloaded.
361 *
362 * @param hMod Image handle for use in APIs.
363 */
364typedef DECLCALLBACK(void) FNR0MODULETERM(void *hMod);
365/** Pointer to a FNR0MODULETERM(). */
366typedef R0PTRTYPE(FNR0MODULETERM *) PFNR0MODULETERM;
367
368/**
369 * Symbol table entry.
370 */
371typedef struct SUPLDRSYM
372{
373 /** Offset into of the string table. */
374 uint32_t offName;
375 /** Offset of the symbol relative to the image load address.
376 * @remarks When used inside the SUPDrv to calculate real addresses, it
377 * must be cast to int32_t for the sake of native loader support
378 * on Solaris. (The loader puts the and data in different
379 * memory areans, and the text one is generally higher.) */
380 uint32_t offSymbol;
381} SUPLDRSYM;
382/** Pointer to a symbol table entry. */
383typedef SUPLDRSYM *PSUPLDRSYM;
384/** Pointer to a const symbol table entry. */
385typedef SUPLDRSYM const *PCSUPLDRSYM;
386
387/**
388 * SUPLDRLOAD::u::In::EP type.
389 */
390typedef enum SUPLDRLOADEP
391{
392 SUPLDRLOADEP_NOTHING = 0,
393 SUPLDRLOADEP_VMMR0,
394 SUPLDRLOADEP_SERVICE,
395 SUPLDRLOADEP_32BIT_HACK = 0x7fffffff
396} SUPLDRLOADEP;
397
398typedef struct SUPLDRLOAD
399{
400 /** The header. */
401 SUPREQHDR Hdr;
402 union
403 {
404 struct
405 {
406 /** The address of module initialization function. Similar to _DLL_InitTerm(hmod, 0). */
407 RTR0PTR pfnModuleInit;
408 /** The address of module termination function. Similar to _DLL_InitTerm(hmod, 1). */
409 RTR0PTR pfnModuleTerm;
410 /** Special entry points. */
411 union
412 {
413 /** SUPLDRLOADEP_VMMR0. */
414 struct
415 {
416 /** The module handle (i.e. address). */
417 RTR0PTR pvVMMR0;
418 /** Address of VMMR0EntryFast function. */
419 RTR0PTR pvVMMR0EntryFast;
420 /** Address of VMMR0EntryEx function. */
421 RTR0PTR pvVMMR0EntryEx;
422 } VMMR0;
423 /** SUPLDRLOADEP_SERVICE. */
424 struct
425 {
426 /** The service request handler.
427 * (PFNR0SERVICEREQHANDLER isn't defined yet.) */
428 RTR0PTR pfnServiceReq;
429 /** Reserved, must be NIL. */
430 RTR0PTR apvReserved[3];
431 } Service;
432 } EP;
433 /** Address. */
434 RTR0PTR pvImageBase;
435 /** Entry point type. */
436 SUPLDRLOADEP eEPType;
437 /** The size of the image bits (starting at offset 0 and
438 * approaching offSymbols). */
439 uint32_t cbImageBits;
440 /** The offset of the symbol table. */
441 uint32_t offSymbols;
442 /** The number of entries in the symbol table. */
443 uint32_t cSymbols;
444 /** The offset of the string table. */
445 uint32_t offStrTab;
446 /** Size of the string table. */
447 uint32_t cbStrTab;
448 /** Size of image data in achImage. */
449 uint32_t cbImageWithTabs;
450 /** The image data. */
451 uint8_t abImage[1];
452 } In;
453 struct
454 {
455 /** Magic value indicating whether extended error information is
456 * present or not (SUPLDRLOAD_ERROR_MAGIC). */
457 uint64_t uErrorMagic;
458 /** Extended error information. */
459 char szError[2048];
460 } Out;
461 } u;
462} SUPLDRLOAD, *PSUPLDRLOAD;
463/** Magic value that indicates that there is a valid error information string
464 * present on SUP_IOCTL_LDR_LOAD failure.
465 * @remarks The value is choosen to be an unlikely init and term address. */
466#define SUPLDRLOAD_ERROR_MAGIC UINT64_C(0xabcdefef0feddcb9)
467/** @} */
468
469
470/** @name SUP_IOCTL_LDR_FREE
471 * Free an image.
472 * @{
473 */
474#define SUP_IOCTL_LDR_FREE SUP_CTL_CODE_SIZE(5, SUP_IOCTL_LDR_FREE_SIZE)
475#define SUP_IOCTL_LDR_FREE_SIZE sizeof(SUPLDRFREE)
476#define SUP_IOCTL_LDR_FREE_SIZE_IN sizeof(SUPLDRFREE)
477#define SUP_IOCTL_LDR_FREE_SIZE_OUT sizeof(SUPREQHDR)
478typedef struct SUPLDRFREE
479{
480 /** The header. */
481 SUPREQHDR Hdr;
482 union
483 {
484 struct
485 {
486 /** Address. */
487 RTR0PTR pvImageBase;
488 } In;
489 } u;
490} SUPLDRFREE, *PSUPLDRFREE;
491/** @} */
492
493
494/** @name SUP_IOCTL_LDR_LOCK_DOWN
495 * Lock down the image loader interface.
496 * @{
497 */
498#define SUP_IOCTL_LDR_LOCK_DOWN SUP_CTL_CODE_SIZE(38, SUP_IOCTL_LDR_LOCK_DOWN_SIZE)
499#define SUP_IOCTL_LDR_LOCK_DOWN_SIZE sizeof(SUPREQHDR)
500#define SUP_IOCTL_LDR_LOCK_DOWN_SIZE_IN sizeof(SUPREQHDR)
501#define SUP_IOCTL_LDR_LOCK_DOWN_SIZE_OUT sizeof(SUPREQHDR)
502/** @} */
503
504
505/** @name SUP_IOCTL_LDR_GET_SYMBOL
506 * Get address of a symbol within an image.
507 * @{
508 */
509#define SUP_IOCTL_LDR_GET_SYMBOL SUP_CTL_CODE_SIZE(6, SUP_IOCTL_LDR_GET_SYMBOL_SIZE)
510#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE sizeof(SUPLDRGETSYMBOL)
511#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_IN sizeof(SUPLDRGETSYMBOL)
512#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDRGETSYMBOL, u.Out))
513typedef struct SUPLDRGETSYMBOL
514{
515 /** The header. */
516 SUPREQHDR Hdr;
517 union
518 {
519 struct
520 {
521 /** Address. */
522 RTR0PTR pvImageBase;
523 /** The symbol name. */
524 char szSymbol[64];
525 } In;
526 struct
527 {
528 /** The symbol address. */
529 RTR0PTR pvSymbol;
530 } Out;
531 } u;
532} SUPLDRGETSYMBOL, *PSUPLDRGETSYMBOL;
533/** @} */
534
535
536/** @name SUP_IOCTL_CALL_VMMR0
537 * Call the R0 VMM Entry point.
538 * @{
539 */
540#define SUP_IOCTL_CALL_VMMR0(cbReq) SUP_CTL_CODE_SIZE(7, SUP_IOCTL_CALL_VMMR0_SIZE(cbReq))
541#define SUP_IOCTL_CALL_VMMR0_NO_SIZE() SUP_CTL_CODE_SIZE(7, 0)
542#define SUP_IOCTL_CALL_VMMR0_SIZE(cbReq) RT_UOFFSETOF(SUPCALLVMMR0, abReqPkt[cbReq])
543#define SUP_IOCTL_CALL_VMMR0_SIZE_IN(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
544#define SUP_IOCTL_CALL_VMMR0_SIZE_OUT(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
545typedef struct SUPCALLVMMR0
546{
547 /** The header. */
548 SUPREQHDR Hdr;
549 union
550 {
551 struct
552 {
553 /** The VM handle. */
554 PVMR0 pVMR0;
555 /** VCPU id. */
556 uint32_t idCpu;
557 /** Which operation to execute. */
558 uint32_t uOperation;
559 /** Argument to use when no request packet is supplied. */
560 uint64_t u64Arg;
561 } In;
562 } u;
563 /** The VMMR0Entry request packet. */
564 uint8_t abReqPkt[1];
565} SUPCALLVMMR0, *PSUPCALLVMMR0;
566/** @} */
567
568
569/** @name SUP_IOCTL_CALL_VMMR0_BIG
570 * Version of SUP_IOCTL_CALL_VMMR0 for dealing with large requests.
571 * @{
572 */
573#define SUP_IOCTL_CALL_VMMR0_BIG SUP_CTL_CODE_BIG(27)
574#define SUP_IOCTL_CALL_VMMR0_BIG_SIZE(cbReq) RT_UOFFSETOF(SUPCALLVMMR0, abReqPkt[cbReq])
575#define SUP_IOCTL_CALL_VMMR0_BIG_SIZE_IN(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
576#define SUP_IOCTL_CALL_VMMR0_BIG_SIZE_OUT(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
577/** @} */
578
579
580/** @name SUP_IOCTL_LOW_ALLOC
581 * Allocate memory below 4GB (physically).
582 * @{
583 */
584#define SUP_IOCTL_LOW_ALLOC SUP_CTL_CODE_BIG(8)
585#define SUP_IOCTL_LOW_ALLOC_SIZE(cPages) ((uint32_t)RT_UOFFSETOF(SUPLOWALLOC, u.Out.aPages[cPages]))
586#define SUP_IOCTL_LOW_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLOWALLOC, u.In))
587#define SUP_IOCTL_LOW_ALLOC_SIZE_OUT(cPages) SUP_IOCTL_LOW_ALLOC_SIZE(cPages)
588typedef struct SUPLOWALLOC
589{
590 /** The header. */
591 SUPREQHDR Hdr;
592 union
593 {
594 struct
595 {
596 /** Number of pages to allocate. */
597 uint32_t cPages;
598 } In;
599 struct
600 {
601 /** The ring-3 address of the allocated memory. */
602 RTR3PTR pvR3;
603 /** The ring-0 address of the allocated memory. */
604 RTR0PTR pvR0;
605 /** Array of pages. */
606 RTHCPHYS aPages[1];
607 } Out;
608 } u;
609} SUPLOWALLOC, *PSUPLOWALLOC;
610/** @} */
611
612
613/** @name SUP_IOCTL_LOW_FREE
614 * Free low memory.
615 * @{
616 */
617#define SUP_IOCTL_LOW_FREE SUP_CTL_CODE_SIZE(9, SUP_IOCTL_LOW_FREE_SIZE)
618#define SUP_IOCTL_LOW_FREE_SIZE sizeof(SUPLOWFREE)
619#define SUP_IOCTL_LOW_FREE_SIZE_IN sizeof(SUPLOWFREE)
620#define SUP_IOCTL_LOW_FREE_SIZE_OUT sizeof(SUPREQHDR)
621typedef struct SUPLOWFREE
622{
623 /** The header. */
624 SUPREQHDR Hdr;
625 union
626 {
627 struct
628 {
629 /** The ring-3 address of the memory to free. */
630 RTR3PTR pvR3;
631 } In;
632 } u;
633} SUPLOWFREE, *PSUPLOWFREE;
634/** @} */
635
636
637/** @name SUP_IOCTL_PAGE_ALLOC_EX
638 * Allocate memory and map it into kernel and/or user space. The memory is of
639 * course locked. The result should be freed using SUP_IOCTL_PAGE_FREE.
640 *
641 * @remarks Allocations without a kernel mapping may fail with
642 * VERR_NOT_SUPPORTED on some platforms.
643 *
644 * @{
645 */
646#define SUP_IOCTL_PAGE_ALLOC_EX SUP_CTL_CODE_BIG(10)
647#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages) RT_UOFFSETOF(SUPPAGEALLOCEX, u.Out.aPages[cPages])
648#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGEALLOCEX, u.In))
649#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_OUT(cPages) SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages)
650typedef struct SUPPAGEALLOCEX
651{
652 /** The header. */
653 SUPREQHDR Hdr;
654 union
655 {
656 struct
657 {
658 /** Number of pages to allocate */
659 uint32_t cPages;
660 /** Whether it should have kernel mapping. */
661 bool fKernelMapping;
662 /** Whether it should have a user mapping. */
663 bool fUserMapping;
664 /** Reserved. Must be false. */
665 bool fReserved0;
666 /** Reserved. Must be false. */
667 bool fReserved1;
668 } In;
669 struct
670 {
671 /** Returned ring-3 address. */
672 RTR3PTR pvR3;
673 /** Returned ring-0 address. */
674 RTR0PTR pvR0;
675 /** The physical addresses of the allocated pages. */
676 RTHCPHYS aPages[1];
677 } Out;
678 } u;
679} SUPPAGEALLOCEX, *PSUPPAGEALLOCEX;
680/** @} */
681
682
683/** @name SUP_IOCTL_PAGE_MAP_KERNEL
684 * Maps a portion of memory allocated by SUP_IOCTL_PAGE_ALLOC_EX /
685 * SUPR0PageAllocEx into kernel space for use by a device or similar.
686 *
687 * The mapping will be freed together with the ring-3 mapping when
688 * SUP_IOCTL_PAGE_FREE or SUPR0PageFree is called.
689 *
690 * @remarks Not necessarily supported on all platforms.
691 *
692 * @{
693 */
694#define SUP_IOCTL_PAGE_MAP_KERNEL SUP_CTL_CODE_SIZE(11, SUP_IOCTL_PAGE_MAP_KERNEL_SIZE)
695#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE sizeof(SUPPAGEMAPKERNEL)
696#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_IN sizeof(SUPPAGEMAPKERNEL)
697#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_OUT sizeof(SUPPAGEMAPKERNEL)
698typedef struct SUPPAGEMAPKERNEL
699{
700 /** The header. */
701 SUPREQHDR Hdr;
702 union
703 {
704 struct
705 {
706 /** The pointer of to the previously allocated memory. */
707 RTR3PTR pvR3;
708 /** The offset to start mapping from. */
709 uint32_t offSub;
710 /** Size of the section to map. */
711 uint32_t cbSub;
712 /** Flags reserved for future fun. */
713 uint32_t fFlags;
714 } In;
715 struct
716 {
717 /** The ring-0 address corresponding to pvR3 + offSub. */
718 RTR0PTR pvR0;
719 } Out;
720 } u;
721} SUPPAGEMAPKERNEL, *PSUPPAGEMAPKERNEL;
722/** @} */
723
724
725/** @name SUP_IOCTL_PAGE_PROTECT
726 * Changes the page level protection of the user and/or kernel mappings of
727 * memory previously allocated by SUPR0PageAllocEx.
728 *
729 * @remarks Not necessarily supported on all platforms.
730 *
731 * @{
732 */
733#define SUP_IOCTL_PAGE_PROTECT SUP_CTL_CODE_SIZE(12, SUP_IOCTL_PAGE_PROTECT_SIZE)
734#define SUP_IOCTL_PAGE_PROTECT_SIZE sizeof(SUPPAGEPROTECT)
735#define SUP_IOCTL_PAGE_PROTECT_SIZE_IN sizeof(SUPPAGEPROTECT)
736#define SUP_IOCTL_PAGE_PROTECT_SIZE_OUT sizeof(SUPPAGEPROTECT)
737typedef struct SUPPAGEPROTECT
738{
739 /** The header. */
740 SUPREQHDR Hdr;
741 union
742 {
743 struct
744 {
745 /** The pointer of to the previously allocated memory.
746 * Pass NIL_RTR3PTR if the ring-0 mapping should remain unaffected. */
747 RTR3PTR pvR3;
748 /** The pointer of to the previously allocated memory.
749 * Pass NIL_RTR0PTR if the ring-0 mapping should remain unaffected. */
750 RTR0PTR pvR0;
751 /** The offset to start changing protection at. */
752 uint32_t offSub;
753 /** Size of the portion that should be changed. */
754 uint32_t cbSub;
755 /** Protection flags, RTMEM_PROT_*. */
756 uint32_t fProt;
757 } In;
758 } u;
759} SUPPAGEPROTECT, *PSUPPAGEPROTECT;
760/** @} */
761
762
763/** @name SUP_IOCTL_PAGE_FREE
764 * Free memory allocated with SUP_IOCTL_PAGE_ALLOC_EX.
765 * @{
766 */
767#define SUP_IOCTL_PAGE_FREE SUP_CTL_CODE_SIZE(13, SUP_IOCTL_PAGE_FREE_SIZE_IN)
768#define SUP_IOCTL_PAGE_FREE_SIZE sizeof(SUPPAGEFREE)
769#define SUP_IOCTL_PAGE_FREE_SIZE_IN sizeof(SUPPAGEFREE)
770#define SUP_IOCTL_PAGE_FREE_SIZE_OUT sizeof(SUPREQHDR)
771typedef struct SUPPAGEFREE
772{
773 /** The header. */
774 SUPREQHDR Hdr;
775 union
776 {
777 struct
778 {
779 /** Address of memory range to free. */
780 RTR3PTR pvR3;
781 } In;
782 } u;
783} SUPPAGEFREE, *PSUPPAGEFREE;
784/** @} */
785
786
787
788
789/** @name SUP_IOCTL_PAGE_LOCK
790 * Pin down physical pages.
791 * @{
792 */
793#define SUP_IOCTL_PAGE_LOCK SUP_CTL_CODE_BIG(14)
794#define SUP_IOCTL_PAGE_LOCK_SIZE(cPages) (RT_MAX((size_t)SUP_IOCTL_PAGE_LOCK_SIZE_IN, (size_t)SUP_IOCTL_PAGE_LOCK_SIZE_OUT(cPages)))
795#define SUP_IOCTL_PAGE_LOCK_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGELOCK, u.In))
796#define SUP_IOCTL_PAGE_LOCK_SIZE_OUT(cPages) RT_UOFFSETOF(SUPPAGELOCK, u.Out.aPages[cPages])
797typedef struct SUPPAGELOCK
798{
799 /** The header. */
800 SUPREQHDR Hdr;
801 union
802 {
803 struct
804 {
805 /** Start of page range. Must be PAGE aligned. */
806 RTR3PTR pvR3;
807 /** The range size given as a page count. */
808 uint32_t cPages;
809 } In;
810
811 struct
812 {
813 /** Array of pages. */
814 RTHCPHYS aPages[1];
815 } Out;
816 } u;
817} SUPPAGELOCK, *PSUPPAGELOCK;
818/** @} */
819
820
821/** @name SUP_IOCTL_PAGE_UNLOCK
822 * Unpin physical pages.
823 * @{ */
824#define SUP_IOCTL_PAGE_UNLOCK SUP_CTL_CODE_SIZE(15, SUP_IOCTL_PAGE_UNLOCK_SIZE)
825#define SUP_IOCTL_PAGE_UNLOCK_SIZE sizeof(SUPPAGEUNLOCK)
826#define SUP_IOCTL_PAGE_UNLOCK_SIZE_IN sizeof(SUPPAGEUNLOCK)
827#define SUP_IOCTL_PAGE_UNLOCK_SIZE_OUT sizeof(SUPREQHDR)
828typedef struct SUPPAGEUNLOCK
829{
830 /** The header. */
831 SUPREQHDR Hdr;
832 union
833 {
834 struct
835 {
836 /** Start of page range of a range previously pinned. */
837 RTR3PTR pvR3;
838 } In;
839 } u;
840} SUPPAGEUNLOCK, *PSUPPAGEUNLOCK;
841/** @} */
842
843
844/** @name SUP_IOCTL_CONT_ALLOC
845 * Allocate continuous memory.
846 * @{
847 */
848#define SUP_IOCTL_CONT_ALLOC SUP_CTL_CODE_SIZE(16, SUP_IOCTL_CONT_ALLOC_SIZE)
849#define SUP_IOCTL_CONT_ALLOC_SIZE sizeof(SUPCONTALLOC)
850#define SUP_IOCTL_CONT_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCONTALLOC, u.In))
851#define SUP_IOCTL_CONT_ALLOC_SIZE_OUT sizeof(SUPCONTALLOC)
852typedef struct SUPCONTALLOC
853{
854 /** The header. */
855 SUPREQHDR Hdr;
856 union
857 {
858 struct
859 {
860 /** The allocation size given as a page count. */
861 uint32_t cPages;
862 } In;
863
864 struct
865 {
866 /** The address of the ring-0 mapping of the allocated memory. */
867 RTR0PTR pvR0;
868 /** The address of the ring-3 mapping of the allocated memory. */
869 RTR3PTR pvR3;
870 /** The physical address of the allocation. */
871 RTHCPHYS HCPhys;
872 } Out;
873 } u;
874} SUPCONTALLOC, *PSUPCONTALLOC;
875/** @} */
876
877
878/** @name SUP_IOCTL_CONT_FREE Input.
879 * @{
880 */
881/** Free continuous memory. */
882#define SUP_IOCTL_CONT_FREE SUP_CTL_CODE_SIZE(17, SUP_IOCTL_CONT_FREE_SIZE)
883#define SUP_IOCTL_CONT_FREE_SIZE sizeof(SUPCONTFREE)
884#define SUP_IOCTL_CONT_FREE_SIZE_IN sizeof(SUPCONTFREE)
885#define SUP_IOCTL_CONT_FREE_SIZE_OUT sizeof(SUPREQHDR)
886typedef struct SUPCONTFREE
887{
888 /** The header. */
889 SUPREQHDR Hdr;
890 union
891 {
892 struct
893 {
894 /** The ring-3 address of the memory to free. */
895 RTR3PTR pvR3;
896 } In;
897 } u;
898} SUPCONTFREE, *PSUPCONTFREE;
899/** @} */
900
901
902/** @name SUP_IOCTL_GET_PAGING_MODE
903 * Get the host paging mode.
904 * @{
905 */
906#define SUP_IOCTL_GET_PAGING_MODE SUP_CTL_CODE_SIZE(18, SUP_IOCTL_GET_PAGING_MODE_SIZE)
907#define SUP_IOCTL_GET_PAGING_MODE_SIZE sizeof(SUPGETPAGINGMODE)
908#define SUP_IOCTL_GET_PAGING_MODE_SIZE_IN sizeof(SUPREQHDR)
909#define SUP_IOCTL_GET_PAGING_MODE_SIZE_OUT sizeof(SUPGETPAGINGMODE)
910typedef struct SUPGETPAGINGMODE
911{
912 /** The header. */
913 SUPREQHDR Hdr;
914 union
915 {
916 struct
917 {
918 /** The paging mode. */
919 SUPPAGINGMODE enmMode;
920 } Out;
921 } u;
922} SUPGETPAGINGMODE, *PSUPGETPAGINGMODE;
923/** @} */
924
925
926/** @name SUP_IOCTL_SET_VM_FOR_FAST
927 * Set the VM handle for doing fast call ioctl calls.
928 * @{
929 */
930#define SUP_IOCTL_SET_VM_FOR_FAST SUP_CTL_CODE_SIZE(19, SUP_IOCTL_SET_VM_FOR_FAST_SIZE)
931#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE sizeof(SUPSETVMFORFAST)
932#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_IN sizeof(SUPSETVMFORFAST)
933#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_OUT sizeof(SUPREQHDR)
934typedef struct SUPSETVMFORFAST
935{
936 /** The header. */
937 SUPREQHDR Hdr;
938 union
939 {
940 struct
941 {
942 /** The ring-0 VM handle (pointer). */
943 PVMR0 pVMR0;
944 } In;
945 } u;
946} SUPSETVMFORFAST, *PSUPSETVMFORFAST;
947/** @} */
948
949
950/** @name SUP_IOCTL_GIP_MAP
951 * Map the GIP into user space.
952 * @{
953 */
954#define SUP_IOCTL_GIP_MAP SUP_CTL_CODE_SIZE(20, SUP_IOCTL_GIP_MAP_SIZE)
955#define SUP_IOCTL_GIP_MAP_SIZE sizeof(SUPGIPMAP)
956#define SUP_IOCTL_GIP_MAP_SIZE_IN sizeof(SUPREQHDR)
957#define SUP_IOCTL_GIP_MAP_SIZE_OUT sizeof(SUPGIPMAP)
958typedef struct SUPGIPMAP
959{
960 /** The header. */
961 SUPREQHDR Hdr;
962 union
963 {
964 struct
965 {
966 /** The physical address of the GIP. */
967 RTHCPHYS HCPhysGip;
968 /** Pointer to the read-only usermode GIP mapping for this session. */
969 R3PTRTYPE(PSUPGLOBALINFOPAGE) pGipR3;
970 /** Pointer to the supervisor mode GIP mapping. */
971 R0PTRTYPE(PSUPGLOBALINFOPAGE) pGipR0;
972 } Out;
973 } u;
974} SUPGIPMAP, *PSUPGIPMAP;
975/** @} */
976
977
978/** @name SUP_IOCTL_GIP_UNMAP
979 * Unmap the GIP.
980 * @{
981 */
982#define SUP_IOCTL_GIP_UNMAP SUP_CTL_CODE_SIZE(21, SUP_IOCTL_GIP_UNMAP_SIZE)
983#define SUP_IOCTL_GIP_UNMAP_SIZE sizeof(SUPGIPUNMAP)
984#define SUP_IOCTL_GIP_UNMAP_SIZE_IN sizeof(SUPGIPUNMAP)
985#define SUP_IOCTL_GIP_UNMAP_SIZE_OUT sizeof(SUPGIPUNMAP)
986typedef struct SUPGIPUNMAP
987{
988 /** The header. */
989 SUPREQHDR Hdr;
990} SUPGIPUNMAP, *PSUPGIPUNMAP;
991/** @} */
992
993
994/** @name SUP_IOCTL_CALL_SERVICE
995 * Call the a ring-0 service.
996 *
997 * @todo Might have to convert this to a big request, just like
998 * SUP_IOCTL_CALL_VMMR0
999 * @{
1000 */
1001#define SUP_IOCTL_CALL_SERVICE(cbReq) SUP_CTL_CODE_SIZE(22, SUP_IOCTL_CALL_SERVICE_SIZE(cbReq))
1002#define SUP_IOCTL_CALL_SERVICE_NO_SIZE() SUP_CTL_CODE_SIZE(22, 0)
1003#define SUP_IOCTL_CALL_SERVICE_SIZE(cbReq) RT_UOFFSETOF(SUPCALLSERVICE, abReqPkt[cbReq])
1004#define SUP_IOCTL_CALL_SERVICE_SIZE_IN(cbReq) SUP_IOCTL_CALL_SERVICE_SIZE(cbReq)
1005#define SUP_IOCTL_CALL_SERVICE_SIZE_OUT(cbReq) SUP_IOCTL_CALL_SERVICE_SIZE(cbReq)
1006typedef struct SUPCALLSERVICE
1007{
1008 /** The header. */
1009 SUPREQHDR Hdr;
1010 union
1011 {
1012 struct
1013 {
1014 /** The service name. */
1015 char szName[28];
1016 /** Which operation to execute. */
1017 uint32_t uOperation;
1018 /** Argument to use when no request packet is supplied. */
1019 uint64_t u64Arg;
1020 } In;
1021 } u;
1022 /** The request packet passed to SUP. */
1023 uint8_t abReqPkt[1];
1024} SUPCALLSERVICE, *PSUPCALLSERVICE;
1025/** @} */
1026
1027
1028/** @name SUP_IOCTL_LOGGER_SETTINGS
1029 * Changes the ring-0 release or debug logger settings.
1030 * @{
1031 */
1032#define SUP_IOCTL_LOGGER_SETTINGS(cbStrTab) SUP_CTL_CODE_SIZE(23, SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab))
1033#define SUP_IOCTL_LOGGER_SETTINGS_NO_SIZE() SUP_CTL_CODE_SIZE(23, 0)
1034#define SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab])
1035#define SUP_IOCTL_LOGGER_SETTINGS_SIZE_IN(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab])
1036#define SUP_IOCTL_LOGGER_SETTINGS_SIZE_OUT sizeof(SUPREQHDR)
1037typedef struct SUPLOGGERSETTINGS
1038{
1039 /** The header. */
1040 SUPREQHDR Hdr;
1041 union
1042 {
1043 struct
1044 {
1045 /** Which logger. */
1046 uint32_t fWhich;
1047 /** What to do with it. */
1048 uint32_t fWhat;
1049 /** Offset of the flags setting string. */
1050 uint32_t offFlags;
1051 /** Offset of the groups setting string. */
1052 uint32_t offGroups;
1053 /** Offset of the destination setting string. */
1054 uint32_t offDestination;
1055 /** The string table. */
1056 char szStrings[1];
1057 } In;
1058 } u;
1059} SUPLOGGERSETTINGS, *PSUPLOGGERSETTINGS;
1060
1061/** Debug logger. */
1062#define SUPLOGGERSETTINGS_WHICH_DEBUG 0
1063/** Release logger. */
1064#define SUPLOGGERSETTINGS_WHICH_RELEASE 1
1065
1066/** Change the settings. */
1067#define SUPLOGGERSETTINGS_WHAT_SETTINGS 0
1068/** Create the logger instance. */
1069#define SUPLOGGERSETTINGS_WHAT_CREATE 1
1070/** Destroy the logger instance. */
1071#define SUPLOGGERSETTINGS_WHAT_DESTROY 2
1072
1073/** @} */
1074
1075
1076/** @name Semaphore Types
1077 * @{ */
1078#define SUP_SEM_TYPE_EVENT 0
1079#define SUP_SEM_TYPE_EVENT_MULTI 1
1080/** @} */
1081
1082
1083/** @name SUP_IOCTL_SEM_OP2
1084 * Semaphore operations.
1085 * @remarks This replaces the old SUP_IOCTL_SEM_OP interface.
1086 * @{
1087 */
1088#define SUP_IOCTL_SEM_OP2 SUP_CTL_CODE_SIZE(24, SUP_IOCTL_SEM_OP2_SIZE)
1089#define SUP_IOCTL_SEM_OP2_SIZE sizeof(SUPSEMOP2)
1090#define SUP_IOCTL_SEM_OP2_SIZE_IN sizeof(SUPSEMOP2)
1091#define SUP_IOCTL_SEM_OP2_SIZE_OUT sizeof(SUPREQHDR)
1092typedef struct SUPSEMOP2
1093{
1094 /** The header. */
1095 SUPREQHDR Hdr;
1096 union
1097 {
1098 struct
1099 {
1100 /** The semaphore type. */
1101 uint32_t uType;
1102 /** The semaphore handle. */
1103 uint32_t hSem;
1104 /** The operation. */
1105 uint32_t uOp;
1106 /** Reserved, must be zero. */
1107 uint32_t uReserved;
1108 /** The number of milliseconds to wait if it's a wait operation. */
1109 union
1110 {
1111 /** Absolute timeout (RTTime[System]NanoTS).
1112 * Used by SUPSEMOP2_WAIT_NS_ABS. */
1113 uint64_t uAbsNsTimeout;
1114 /** Relative nanosecond timeout.
1115 * Used by SUPSEMOP2_WAIT_NS_REL. */
1116 uint64_t cRelNsTimeout;
1117 /** Relative millisecond timeout.
1118 * Used by SUPSEMOP2_WAIT_MS_REL. */
1119 uint32_t cRelMsTimeout;
1120 /** Generic 64-bit accessor.
1121 * ASSUMES little endian! */
1122 uint64_t u64;
1123 } uArg;
1124 } In;
1125 } u;
1126} SUPSEMOP2, *PSUPSEMOP2;
1127
1128/** Wait for a number of milliseconds. */
1129#define SUPSEMOP2_WAIT_MS_REL 0
1130/** Wait until the specified deadline is reached. */
1131#define SUPSEMOP2_WAIT_NS_ABS 1
1132/** Wait for a number of nanoseconds. */
1133#define SUPSEMOP2_WAIT_NS_REL 2
1134/** Signal the semaphore. */
1135#define SUPSEMOP2_SIGNAL 3
1136/** Reset the semaphore (only applicable to SUP_SEM_TYPE_EVENT_MULTI). */
1137#define SUPSEMOP2_RESET 4
1138/** Close the semaphore handle. */
1139#define SUPSEMOP2_CLOSE 5
1140/** @} */
1141
1142
1143/** @name SUP_IOCTL_SEM_OP3
1144 * Semaphore operations.
1145 * @{
1146 */
1147#define SUP_IOCTL_SEM_OP3 SUP_CTL_CODE_SIZE(25, SUP_IOCTL_SEM_OP3_SIZE)
1148#define SUP_IOCTL_SEM_OP3_SIZE sizeof(SUPSEMOP3)
1149#define SUP_IOCTL_SEM_OP3_SIZE_IN sizeof(SUPSEMOP3)
1150#define SUP_IOCTL_SEM_OP3_SIZE_OUT sizeof(SUPSEMOP3)
1151typedef struct SUPSEMOP3
1152{
1153 /** The header. */
1154 SUPREQHDR Hdr;
1155 union
1156 {
1157 struct
1158 {
1159 /** The semaphore type. */
1160 uint32_t uType;
1161 /** The semaphore handle. */
1162 uint32_t hSem;
1163 /** The operation. */
1164 uint32_t uOp;
1165 /** Reserved, must be zero. */
1166 uint32_t u32Reserved;
1167 /** Reserved for future use. */
1168 uint64_t u64Reserved;
1169 } In;
1170 union
1171 {
1172 /** The handle of the created semaphore.
1173 * Used by SUPSEMOP3_CREATE. */
1174 uint32_t hSem;
1175 /** The semaphore resolution in nano seconds.
1176 * Used by SUPSEMOP3_GET_RESOLUTION. */
1177 uint32_t cNsResolution;
1178 /** The 32-bit view. */
1179 uint32_t u32;
1180 /** Reserved some space for later expansion. */
1181 uint64_t u64Reserved;
1182 } Out;
1183 } u;
1184} SUPSEMOP3, *PSUPSEMOP3;
1185
1186/** Get the wait resolution. */
1187#define SUPSEMOP3_CREATE 0
1188/** Get the wait resolution. */
1189#define SUPSEMOP3_GET_RESOLUTION 1
1190/** @} */
1191
1192
1193/** @name SUP_IOCTL_VT_CAPS
1194 * Get the VT-x/AMD-V capabilities.
1195 *
1196 * @todo Intended for main, which means we need to relax the privilege requires
1197 * when accessing certain vboxdrv functions.
1198 *
1199 * @{
1200 */
1201#define SUP_IOCTL_VT_CAPS SUP_CTL_CODE_SIZE(26, SUP_IOCTL_VT_CAPS_SIZE)
1202#define SUP_IOCTL_VT_CAPS_SIZE sizeof(SUPVTCAPS)
1203#define SUP_IOCTL_VT_CAPS_SIZE_IN sizeof(SUPREQHDR)
1204#define SUP_IOCTL_VT_CAPS_SIZE_OUT sizeof(SUPVTCAPS)
1205typedef struct SUPVTCAPS
1206{
1207 /** The header. */
1208 SUPREQHDR Hdr;
1209 union
1210 {
1211 struct
1212 {
1213 /** The VT capability dword. */
1214 uint32_t Caps;
1215 } Out;
1216 } u;
1217} SUPVTCAPS, *PSUPVTCAPS;
1218/** @} */
1219
1220
1221/** @name SUP_IOCTL_TRACER_OPEN
1222 * Open the tracer.
1223 *
1224 * Should be matched by an SUP_IOCTL_TRACER_CLOSE call.
1225 *
1226 * @{
1227 */
1228#define SUP_IOCTL_TRACER_OPEN SUP_CTL_CODE_SIZE(28, SUP_IOCTL_TRACER_OPEN_SIZE)
1229#define SUP_IOCTL_TRACER_OPEN_SIZE sizeof(SUPTRACEROPEN)
1230#define SUP_IOCTL_TRACER_OPEN_SIZE_IN sizeof(SUPTRACEROPEN)
1231#define SUP_IOCTL_TRACER_OPEN_SIZE_OUT sizeof(SUPREQHDR)
1232typedef struct SUPTRACEROPEN
1233{
1234 /** The header. */
1235 SUPREQHDR Hdr;
1236 union
1237 {
1238 struct
1239 {
1240 /** Tracer cookie. Used to make sure we only open a matching tracer. */
1241 uint32_t uCookie;
1242 /** Tracer specific argument. */
1243 RTHCUINTPTR uArg;
1244 } In;
1245 } u;
1246} SUPTRACEROPEN, *PSUPTRACEROPEN;
1247/** @} */
1248
1249
1250/** @name SUP_IOCTL_TRACER_CLOSE
1251 * Close the tracer.
1252 *
1253 * Must match a SUP_IOCTL_TRACER_OPEN call.
1254 *
1255 * @{
1256 */
1257#define SUP_IOCTL_TRACER_CLOSE SUP_CTL_CODE_SIZE(29, SUP_IOCTL_TRACER_CLOSE_SIZE)
1258#define SUP_IOCTL_TRACER_CLOSE_SIZE sizeof(SUPREQHDR)
1259#define SUP_IOCTL_TRACER_CLOSE_SIZE_IN sizeof(SUPREQHDR)
1260#define SUP_IOCTL_TRACER_CLOSE_SIZE_OUT sizeof(SUPREQHDR)
1261/** @} */
1262
1263
1264/** @name SUP_IOCTL_TRACER_IOCTL
1265 * Speak UNIX ioctl() with the tracer.
1266 *
1267 * The session must have opened the tracer prior to issuing this request.
1268 *
1269 * @{
1270 */
1271#define SUP_IOCTL_TRACER_IOCTL SUP_CTL_CODE_SIZE(30, SUP_IOCTL_TRACER_IOCTL_SIZE)
1272#define SUP_IOCTL_TRACER_IOCTL_SIZE sizeof(SUPTRACERIOCTL)
1273#define SUP_IOCTL_TRACER_IOCTL_SIZE_IN sizeof(SUPTRACERIOCTL)
1274#define SUP_IOCTL_TRACER_IOCTL_SIZE_OUT (RT_UOFFSETOF(SUPTRACERIOCTL, u.Out.iRetVal) + sizeof(int32_t))
1275typedef struct SUPTRACERIOCTL
1276{
1277 /** The header. */
1278 SUPREQHDR Hdr;
1279 union
1280 {
1281 struct
1282 {
1283 /** The command. */
1284 RTHCUINTPTR uCmd;
1285 /** Argument to the command. */
1286 RTHCUINTPTR uArg;
1287 } In;
1288
1289 struct
1290 {
1291 /** The return value. */
1292 int32_t iRetVal;
1293 } Out;
1294 } u;
1295} SUPTRACERIOCTL, *PSUPTRACERIOCTL;
1296/** @} */
1297
1298
1299/** @name SUP_IOCTL_TRACER_UMOD_REG
1300 * Registers tracepoints in a user mode module.
1301 *
1302 * @{
1303 */
1304#define SUP_IOCTL_TRACER_UMOD_REG SUP_CTL_CODE_SIZE(31, SUP_IOCTL_TRACER_UMOD_REG_SIZE)
1305#define SUP_IOCTL_TRACER_UMOD_REG_SIZE sizeof(SUPTRACERUMODREG)
1306#define SUP_IOCTL_TRACER_UMOD_REG_SIZE_IN sizeof(SUPTRACERUMODREG)
1307#define SUP_IOCTL_TRACER_UMOD_REG_SIZE_OUT sizeof(SUPREQHDR)
1308typedef struct SUPTRACERUMODREG
1309{
1310 /** The header. */
1311 SUPREQHDR Hdr;
1312 union
1313 {
1314 struct
1315 {
1316 /** The address at which the VTG header actually resides.
1317 * This will differ from R3PtrVtgHdr for raw-mode context
1318 * modules. */
1319 RTUINTPTR uVtgHdrAddr;
1320 /** The ring-3 pointer of the VTG header. */
1321 RTR3PTR R3PtrVtgHdr;
1322 /** The ring-3 pointer of the probe location string table. */
1323 RTR3PTR R3PtrStrTab;
1324 /** The size of the string table. */
1325 uint32_t cbStrTab;
1326 /** Future flags, MBZ. */
1327 uint32_t fFlags;
1328 /** The module name. */
1329 char szName[64];
1330 } In;
1331 } u;
1332} SUPTRACERUMODREG, *PSUPTRACERUMODREG;
1333/** @} */
1334
1335
1336/** @name SUP_IOCTL_TRACER_UMOD_DEREG
1337 * Deregisters tracepoints in a user mode module.
1338 *
1339 * @{
1340 */
1341#define SUP_IOCTL_TRACER_UMOD_DEREG SUP_CTL_CODE_SIZE(32, SUP_IOCTL_TRACER_UMOD_DEREG_SIZE)
1342#define SUP_IOCTL_TRACER_UMOD_DEREG_SIZE sizeof(SUPTRACERUMODDEREG)
1343#define SUP_IOCTL_TRACER_UMOD_DEREG_SIZE_IN sizeof(SUPTRACERUMODDEREG)
1344#define SUP_IOCTL_TRACER_UMOD_DEREG_SIZE_OUT sizeof(SUPREQHDR)
1345typedef struct SUPTRACERUMODDEREG
1346{
1347 /** The header. */
1348 SUPREQHDR Hdr;
1349 union
1350 {
1351 struct
1352 {
1353 /** Pointer to the VTG header. */
1354 RTR3PTR pVtgHdr;
1355 } In;
1356 } u;
1357} SUPTRACERUMODDEREG, *PSUPTRACERUMODDEREG;
1358/** @} */
1359
1360
1361/** @name SUP_IOCTL_TRACER_UMOD_FIRE_PROBE
1362 * Fire a probe in a user tracepoint module.
1363 *
1364 * @{
1365 */
1366#define SUP_IOCTL_TRACER_UMOD_FIRE_PROBE SUP_CTL_CODE_SIZE(33, SUP_IOCTL_TRACER_UMOD_FIRE_PROBE_SIZE)
1367#define SUP_IOCTL_TRACER_UMOD_FIRE_PROBE_SIZE sizeof(SUPTRACERUMODFIREPROBE)
1368#define SUP_IOCTL_TRACER_UMOD_FIRE_PROBE_SIZE_IN sizeof(SUPTRACERUMODFIREPROBE)
1369#define SUP_IOCTL_TRACER_UMOD_FIRE_PROBE_SIZE_OUT sizeof(SUPREQHDR)
1370typedef struct SUPTRACERUMODFIREPROBE
1371{
1372 /** The header. */
1373 SUPREQHDR Hdr;
1374 union
1375 {
1376 SUPDRVTRACERUSRCTX In;
1377 } u;
1378} SUPTRACERUMODFIREPROBE, *PSUPTRACERUMODFIREPROBE;
1379/** @} */
1380
1381
1382/** @name SUP_IOCTL_MSR_PROBER
1383 * MSR probing interface, not available in normal builds.
1384 *
1385 * @{
1386 */
1387#define SUP_IOCTL_MSR_PROBER SUP_CTL_CODE_SIZE(34, SUP_IOCTL_MSR_PROBER_SIZE)
1388#define SUP_IOCTL_MSR_PROBER_SIZE sizeof(SUPMSRPROBER)
1389#define SUP_IOCTL_MSR_PROBER_SIZE_IN sizeof(SUPMSRPROBER)
1390#define SUP_IOCTL_MSR_PROBER_SIZE_OUT sizeof(SUPMSRPROBER)
1391
1392typedef enum SUPMSRPROBEROP
1393{
1394 SUPMSRPROBEROP_INVALID = 0, /**< The customary invalid zero value. */
1395 SUPMSRPROBEROP_READ, /**< Read an MSR. */
1396 SUPMSRPROBEROP_WRITE, /**< Write a value to an MSR (use with care!). */
1397 SUPMSRPROBEROP_MODIFY, /**< Read-modify-restore-flushall. */
1398 SUPMSRPROBEROP_MODIFY_FASTER, /**< Read-modify-restore, skip the flushing. */
1399 SUPMSRPROBEROP_END, /**< End of valid values. */
1400 SUPMSRPROBEROP_32BIT_HACK = 0x7fffffff /**< The customary 32-bit type hack. */
1401} SUPMSRPROBEROP;
1402
1403typedef struct SUPMSRPROBER
1404{
1405 /** The header. */
1406 SUPREQHDR Hdr;
1407
1408 /** Input/output union. */
1409 union
1410 {
1411 /** Inputs. */
1412 struct
1413 {
1414 /** The operation. */
1415 SUPMSRPROBEROP enmOp;
1416 /** The MSR to test. */
1417 uint32_t uMsr;
1418 /** The CPU to perform the operation on.
1419 * Use UINT32_MAX to indicate that any CPU will do. */
1420 uint32_t idCpu;
1421 /** Alignment padding. */
1422 uint32_t u32Padding;
1423 /** Operation specific arguments. */
1424 union
1425 {
1426 /* SUPMSRPROBEROP_READ takes no extra arguments. */
1427
1428 /** For SUPMSRPROBEROP_WRITE. */
1429 struct
1430 {
1431 /** The value to write. */
1432 uint64_t uToWrite;
1433 } Write;
1434
1435 /** For SUPMSRPROBEROP_MODIFY and SUPMSRPROBEROP_MODIFY_FASTER. */
1436 struct
1437 {
1438 /** The value to AND the current MSR value with to construct the value to
1439 * write. This applied first. */
1440 uint64_t fAndMask;
1441 /** The value to OR the result of the above mentioned AND operation with
1442 * attempting to modify the MSR. */
1443 uint64_t fOrMask;
1444 } Modify;
1445
1446 /** Reserve space for the future. */
1447 uint64_t auPadding[3];
1448 } uArgs;
1449 } In;
1450
1451 /** Outputs. */
1452 struct
1453 {
1454 /** Operation specific results. */
1455 union
1456 {
1457 /** For SUPMSRPROBEROP_READ. */
1458 struct
1459 {
1460 /** The value we've read. */
1461 uint64_t uValue;
1462 /** Set if we GPed while reading it. */
1463 bool fGp;
1464 } Read;
1465
1466 /** For SUPMSRPROBEROP_WRITE. */
1467 struct
1468 {
1469 /** Set if we GPed while writing it. */
1470 bool fGp;
1471 } Write;
1472
1473 /** For SUPMSRPROBEROP_MODIFY and SUPMSRPROBEROP_MODIFY_FASTER. */
1474 SUPMSRPROBERMODIFYRESULT Modify;
1475
1476 /** Size padding/aligning. */
1477 uint64_t auPadding[5];
1478 } uResults;
1479 } Out;
1480 } u;
1481} SUPMSRPROBER, *PSUPMSRPROBER;
1482AssertCompileMemberAlignment(SUPMSRPROBER, u, 8);
1483AssertCompileMemberAlignment(SUPMSRPROBER, u.In.uArgs, 8);
1484AssertCompileMembersSameSizeAndOffset(SUPMSRPROBER, u.In, SUPMSRPROBER, u.Out);
1485/** @} */
1486
1487/** @name SUP_IOCTL_RESUME_SUSPENDED_KBDS
1488 * Resume suspended keyboard devices if any found in the system.
1489 *
1490 * @{
1491 */
1492#define SUP_IOCTL_RESUME_SUSPENDED_KBDS SUP_CTL_CODE_SIZE(35, SUP_IOCTL_RESUME_SUSPENDED_KBDS_SIZE)
1493#define SUP_IOCTL_RESUME_SUSPENDED_KBDS_SIZE sizeof(SUPREQHDR)
1494#define SUP_IOCTL_RESUME_SUSPENDED_KBDS_SIZE_IN sizeof(SUPREQHDR)
1495#define SUP_IOCTL_RESUME_SUSPENDED_KBDS_SIZE_OUT sizeof(SUPREQHDR)
1496/** @} */
1497
1498
1499/** @name SUP_IOCTL_TSC_DELTA_MEASURE
1500 * Measure the TSC-delta between the specified CPU and the master TSC.
1501 *
1502 * To call this I/O control, the client must first have mapped the GIP.
1503 *
1504 * @{
1505 */
1506#define SUP_IOCTL_TSC_DELTA_MEASURE SUP_CTL_CODE_SIZE(36, SUP_IOCTL_TSC_DELTA_MEASURE_SIZE)
1507#define SUP_IOCTL_TSC_DELTA_MEASURE_SIZE sizeof(SUPTSCDELTAMEASURE)
1508#define SUP_IOCTL_TSC_DELTA_MEASURE_SIZE_IN sizeof(SUPTSCDELTAMEASURE)
1509#define SUP_IOCTL_TSC_DELTA_MEASURE_SIZE_OUT sizeof(SUPREQHDR)
1510typedef struct SUPTSCDELTAMEASURE
1511{
1512 /** The header. */
1513 SUPREQHDR Hdr;
1514
1515 /** Input/output union. */
1516 union
1517 {
1518 struct
1519 {
1520 /** Which CPU to take the TSC-delta measurement for. */
1521 RTCPUID idCpu;
1522 /** Number of times to retry on failure (specify 0 for default). */
1523 uint8_t cRetries;
1524 /** Number of milliseconds to wait before each retry. */
1525 uint8_t cMsWaitRetry;
1526 /** Whether to force taking a measurement if one exists already. */
1527 bool fForce;
1528 /** Whether to do the measurement asynchronously (if possible). */
1529 bool fAsync;
1530 } In;
1531 } u;
1532} SUPTSCDELTAMEASURE, *PSUPTSCDELTAMEASURE;
1533AssertCompileMemberAlignment(SUPTSCDELTAMEASURE, u, 8);
1534AssertCompileSize(SUPTSCDELTAMEASURE, 6*4 + 4+1+1+1+1);
1535/** @} */
1536
1537
1538/** @name SUP_IOCTL_TSC_READ
1539 * Reads the TSC and apply TSC-delta if applicable, determining the delta if
1540 * necessary (i64TSCDelta = INT64_MAX).
1541 *
1542 * This latter function is the primary use case of this I/O control. To call
1543 * this I/O control, the client must first have mapped the GIP.
1544 *
1545 * @{
1546 */
1547#define SUP_IOCTL_TSC_READ SUP_CTL_CODE_SIZE(37, SUP_IOCTL_TSC_READ_SIZE)
1548#define SUP_IOCTL_TSC_READ_SIZE sizeof(SUPTSCREAD)
1549#define SUP_IOCTL_TSC_READ_SIZE_IN sizeof(SUPREQHDR)
1550#define SUP_IOCTL_TSC_READ_SIZE_OUT sizeof(SUPTSCREAD)
1551typedef struct SUPTSCREAD
1552{
1553 /** The header. */
1554 SUPREQHDR Hdr;
1555
1556 /** Input/output union. */
1557 union
1558 {
1559 struct
1560 {
1561 /** The TSC after applying the relevant delta. */
1562 uint64_t u64AdjustedTsc;
1563 /** The APIC Id of the CPU where the TSC was read. */
1564 uint16_t idApic;
1565 /** Explicit alignment padding. */
1566 uint16_t auPadding[3];
1567 } Out;
1568 } u;
1569} SUPTSCREAD, *PSUPTSCREAD;
1570AssertCompileMemberAlignment(SUPTSCREAD, u, 8);
1571AssertCompileSize(SUPTSCREAD, 6*4 + 2*8);
1572/** @} */
1573
1574
1575/** @name SUP_IOCTL_GIP_SET_FLAGS
1576 * Set GIP flags.
1577 *
1578 * @{
1579 */
1580#define SUP_IOCTL_GIP_SET_FLAGS SUP_CTL_CODE_SIZE(39, SUP_IOCTL_GIP_SET_FLAGS_SIZE)
1581#define SUP_IOCTL_GIP_SET_FLAGS_SIZE sizeof(SUPGIPSETFLAGS)
1582#define SUP_IOCTL_GIP_SET_FLAGS_SIZE_IN sizeof(SUPGIPSETFLAGS)
1583#define SUP_IOCTL_GIP_SET_FLAGS_SIZE_OUT sizeof(SUPREQHDR)
1584typedef struct SUPGIPSETFLAGS
1585{
1586 /** The header. */
1587 SUPREQHDR Hdr;
1588 union
1589 {
1590 struct
1591 {
1592 /** The AND flags mask, see SUPGIP_FLAGS_XXX. */
1593 uint32_t fAndMask;
1594 /** The OR flags mask, see SUPGIP_FLAGS_XXX. */
1595 uint32_t fOrMask;
1596 } In;
1597 } u;
1598} SUPGIPSETFLAGS, *PSUPGIPSETFLAGS;
1599/** @} */
1600
1601
1602/** @name SUP_IOCTL_UCODE_REV
1603 * Get the CPU microcode revision.
1604 *
1605 * @{
1606 */
1607#define SUP_IOCTL_UCODE_REV SUP_CTL_CODE_SIZE(40, SUP_IOCTL_VT_CAPS_SIZE)
1608#define SUP_IOCTL_UCODE_REV_SIZE sizeof(SUPUCODEREV)
1609#define SUP_IOCTL_UCODE_REV_SIZE_IN sizeof(SUPREQHDR)
1610#define SUP_IOCTL_UCODE_REV_SIZE_OUT sizeof(SUPUCODEREV)
1611typedef struct SUPUCODEREV
1612{
1613 /** The header. */
1614 SUPREQHDR Hdr;
1615 union
1616 {
1617 struct
1618 {
1619 /** The microcode revision dword. */
1620 uint32_t MicrocodeRev;
1621 } Out;
1622 } u;
1623} SUPUCODEREV, *PSUPUCODEREV;
1624/** @} */
1625
1626
1627#pragma pack() /* paranoia */
1628
1629#endif
1630
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