VirtualBox

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

Last change on this file since 72549 was 71198, checked in by vboxsync, 7 years ago

SUPDrv,VMMR0: Prepped for extending the fast I/O control interface a bit for NEM; SUPDRV version increment. bugref:9044

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