VirtualBox

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

Last change on this file since 55879 was 55863, checked in by vboxsync, 10 years ago

IPRT,SUPDrv,VMM: Revised the context switching hook interface. Do less work when enabling the hook (formerly 'registration'). Drop the reference counting (kept internally for solaris) as it complicates restrictions wrt destroying enabled hooks. Bumped support driver version.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 53.0 KB
Line 
1/* $Id: SUPDrvIOC.h 55863 2015-05-14 18:29:34Z vboxsync $ */
2/** @file
3 * VirtualBox Support Driver - IOCtl definitions.
4 */
5
6/*
7 * Copyright (C) 2006-2015 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 <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#define SUPDRV_IOC_VERSION 0x00220000
218
219/** SUP_IOCTL_COOKIE. */
220typedef struct SUPCOOKIE
221{
222 /** The header.
223 * u32Cookie must be set to SUPCOOKIE_INITIAL_COOKIE.
224 * u32SessionCookie should be set to some random value. */
225 SUPREQHDR Hdr;
226 union
227 {
228 struct
229 {
230 /** Magic word. */
231 char szMagic[16];
232 /** The requested interface version number. */
233 uint32_t u32ReqVersion;
234 /** The minimum interface version number. */
235 uint32_t u32MinVersion;
236 } In;
237 struct
238 {
239 /** Cookie. */
240 uint32_t u32Cookie;
241 /** Session cookie. */
242 uint32_t u32SessionCookie;
243 /** Interface version for this session. */
244 uint32_t u32SessionVersion;
245 /** The actual interface version in the driver. */
246 uint32_t u32DriverVersion;
247 /** Number of functions available for the SUP_IOCTL_QUERY_FUNCS request. */
248 uint32_t cFunctions;
249 /** Session handle. */
250 R0PTRTYPE(PSUPDRVSESSION) pSession;
251 } Out;
252 } u;
253} SUPCOOKIE, *PSUPCOOKIE;
254/** @} */
255
256
257/** @name SUP_IOCTL_QUERY_FUNCS
258 * Query SUPR0 functions.
259 * @{
260 */
261#define SUP_IOCTL_QUERY_FUNCS(cFuncs) SUP_CTL_CODE_BIG(2)
262#define SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs) RT_UOFFSETOF(SUPQUERYFUNCS, u.Out.aFunctions[(cFuncs)])
263#define SUP_IOCTL_QUERY_FUNCS_SIZE_IN sizeof(SUPREQHDR)
264#define SUP_IOCTL_QUERY_FUNCS_SIZE_OUT(cFuncs) SUP_IOCTL_QUERY_FUNCS_SIZE(cFuncs)
265
266/** A function. */
267typedef struct SUPFUNC
268{
269 /** Name - mangled. */
270 char szName[32];
271 /** Address. */
272 RTR0PTR pfn;
273} SUPFUNC, *PSUPFUNC;
274
275typedef struct SUPQUERYFUNCS
276{
277 /** The header. */
278 SUPREQHDR Hdr;
279 union
280 {
281 struct
282 {
283 /** Number of functions returned. */
284 uint32_t cFunctions;
285 /** Array of functions. */
286 SUPFUNC aFunctions[1];
287 } Out;
288 } u;
289} SUPQUERYFUNCS, *PSUPQUERYFUNCS;
290/** @} */
291
292
293/** @name SUP_IOCTL_LDR_OPEN
294 * Open an image.
295 * @{
296 */
297#define SUP_IOCTL_LDR_OPEN SUP_CTL_CODE_SIZE(3, SUP_IOCTL_LDR_OPEN_SIZE)
298#define SUP_IOCTL_LDR_OPEN_SIZE sizeof(SUPLDROPEN)
299#define SUP_IOCTL_LDR_OPEN_SIZE_IN sizeof(SUPLDROPEN)
300#define SUP_IOCTL_LDR_OPEN_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDROPEN, u.Out))
301typedef struct SUPLDROPEN
302{
303 /** The header. */
304 SUPREQHDR Hdr;
305 union
306 {
307 struct
308 {
309 /** Size of the image we'll be loading (including tables). */
310 uint32_t cbImageWithTabs;
311 /** The size of the image bits. (Less or equal to cbImageWithTabs.) */
312 uint32_t cbImageBits;
313 /** Image name.
314 * This is the NAME of the image, not the file name. It is used
315 * to share code with other processes. (Max len is 32 chars!) */
316 char szName[32];
317 /** Image file name.
318 * This can be used to load the image using a native loader. */
319 char szFilename[260];
320 } In;
321 struct
322 {
323 /** The base address of the image. */
324 RTR0PTR pvImageBase;
325 /** Indicate whether or not the image requires loading. */
326 bool fNeedsLoading;
327 /** Indicates that we're using the native ring-0 loader. */
328 bool fNativeLoader;
329 } Out;
330 } u;
331} SUPLDROPEN, *PSUPLDROPEN;
332/** @} */
333
334
335/** @name SUP_IOCTL_LDR_LOAD
336 * Upload the image bits.
337 * @{
338 */
339#define SUP_IOCTL_LDR_LOAD SUP_CTL_CODE_BIG(4)
340#define SUP_IOCTL_LDR_LOAD_SIZE(cbImage) RT_UOFFSETOF(SUPLDRLOAD, u.In.abImage[cbImage])
341#define SUP_IOCTL_LDR_LOAD_SIZE_IN(cbImage) RT_UOFFSETOF(SUPLDRLOAD, u.In.abImage[cbImage])
342#define SUP_IOCTL_LDR_LOAD_SIZE_OUT sizeof(SUPREQHDR)
343
344/**
345 * Module initialization callback function.
346 * This is called once after the module has been loaded.
347 *
348 * @returns 0 on success.
349 * @returns Appropriate error code on failure.
350 * @param hMod Image handle for use in APIs.
351 */
352typedef DECLCALLBACK(int) FNR0MODULEINIT(void *hMod);
353/** Pointer to a FNR0MODULEINIT(). */
354typedef R0PTRTYPE(FNR0MODULEINIT *) PFNR0MODULEINIT;
355
356/**
357 * Module termination callback function.
358 * This is called once right before the module is being unloaded.
359 *
360 * @param hMod Image handle for use in APIs.
361 */
362typedef DECLCALLBACK(void) FNR0MODULETERM(void *hMod);
363/** Pointer to a FNR0MODULETERM(). */
364typedef R0PTRTYPE(FNR0MODULETERM *) PFNR0MODULETERM;
365
366/**
367 * Symbol table entry.
368 */
369typedef struct SUPLDRSYM
370{
371 /** Offset into of the string table. */
372 uint32_t offName;
373 /** Offset of the symbol relative to the image load address.
374 * @remarks When used inside the SUPDrv to calculate real addresses, it
375 * must be cast to int32_t for the sake of native loader support
376 * on Solaris. (The loader puts the and data in different
377 * memory areans, and the text one is generally higher.) */
378 uint32_t offSymbol;
379} SUPLDRSYM;
380/** Pointer to a symbol table entry. */
381typedef SUPLDRSYM *PSUPLDRSYM;
382/** Pointer to a const symbol table entry. */
383typedef SUPLDRSYM const *PCSUPLDRSYM;
384
385/**
386 * SUPLDRLOAD::u::In::EP type.
387 */
388typedef enum SUPLDRLOADEP
389{
390 SUPLDRLOADEP_NOTHING = 0,
391 SUPLDRLOADEP_VMMR0,
392 SUPLDRLOADEP_SERVICE,
393 SUPLDRLOADEP_32BIT_HACK = 0x7fffffff
394} SUPLDRLOADEP;
395
396typedef struct SUPLDRLOAD
397{
398 /** The header. */
399 SUPREQHDR Hdr;
400 union
401 {
402 struct
403 {
404 /** The address of module initialization function. Similar to _DLL_InitTerm(hmod, 0). */
405 RTR0PTR pfnModuleInit;
406 /** The address of module termination function. Similar to _DLL_InitTerm(hmod, 1). */
407 RTR0PTR pfnModuleTerm;
408 /** Special entry points. */
409 union
410 {
411 /** SUPLDRLOADEP_VMMR0. */
412 struct
413 {
414 /** The module handle (i.e. address). */
415 RTR0PTR pvVMMR0;
416 /** Address of VMMR0EntryInt function. */
417 RTR0PTR pvVMMR0EntryInt;
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 } u;
454} SUPLDRLOAD, *PSUPLDRLOAD;
455/** @} */
456
457
458/** @name SUP_IOCTL_LDR_FREE
459 * Free an image.
460 * @{
461 */
462#define SUP_IOCTL_LDR_FREE SUP_CTL_CODE_SIZE(5, SUP_IOCTL_LDR_FREE_SIZE)
463#define SUP_IOCTL_LDR_FREE_SIZE sizeof(SUPLDRFREE)
464#define SUP_IOCTL_LDR_FREE_SIZE_IN sizeof(SUPLDRFREE)
465#define SUP_IOCTL_LDR_FREE_SIZE_OUT sizeof(SUPREQHDR)
466typedef struct SUPLDRFREE
467{
468 /** The header. */
469 SUPREQHDR Hdr;
470 union
471 {
472 struct
473 {
474 /** Address. */
475 RTR0PTR pvImageBase;
476 } In;
477 } u;
478} SUPLDRFREE, *PSUPLDRFREE;
479/** @} */
480
481
482/** @name SUP_IOCTL_LDR_LOCK_DOWN
483 * Lock down the image loader interface.
484 * @{
485 */
486#define SUP_IOCTL_LDR_LOCK_DOWN SUP_CTL_CODE_SIZE(38, SUP_IOCTL_LDR_LOCK_DOWN_SIZE)
487#define SUP_IOCTL_LDR_LOCK_DOWN_SIZE sizeof(SUPREQHDR)
488#define SUP_IOCTL_LDR_LOCK_DOWN_SIZE_IN sizeof(SUPREQHDR)
489#define SUP_IOCTL_LDR_LOCK_DOWN_SIZE_OUT sizeof(SUPREQHDR)
490/** @} */
491
492
493/** @name SUP_IOCTL_LDR_GET_SYMBOL
494 * Get address of a symbol within an image.
495 * @{
496 */
497#define SUP_IOCTL_LDR_GET_SYMBOL SUP_CTL_CODE_SIZE(6, SUP_IOCTL_LDR_GET_SYMBOL_SIZE)
498#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE sizeof(SUPLDRGETSYMBOL)
499#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_IN sizeof(SUPLDRGETSYMBOL)
500#define SUP_IOCTL_LDR_GET_SYMBOL_SIZE_OUT (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLDRGETSYMBOL, u.Out))
501typedef struct SUPLDRGETSYMBOL
502{
503 /** The header. */
504 SUPREQHDR Hdr;
505 union
506 {
507 struct
508 {
509 /** Address. */
510 RTR0PTR pvImageBase;
511 /** The symbol name. */
512 char szSymbol[64];
513 } In;
514 struct
515 {
516 /** The symbol address. */
517 RTR0PTR pvSymbol;
518 } Out;
519 } u;
520} SUPLDRGETSYMBOL, *PSUPLDRGETSYMBOL;
521/** @} */
522
523
524/** @name SUP_IOCTL_CALL_VMMR0
525 * Call the R0 VMM Entry point.
526 * @{
527 */
528#define SUP_IOCTL_CALL_VMMR0(cbReq) SUP_CTL_CODE_SIZE(7, SUP_IOCTL_CALL_VMMR0_SIZE(cbReq))
529#define SUP_IOCTL_CALL_VMMR0_NO_SIZE() SUP_CTL_CODE_SIZE(7, 0)
530#define SUP_IOCTL_CALL_VMMR0_SIZE(cbReq) RT_UOFFSETOF(SUPCALLVMMR0, abReqPkt[cbReq])
531#define SUP_IOCTL_CALL_VMMR0_SIZE_IN(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
532#define SUP_IOCTL_CALL_VMMR0_SIZE_OUT(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
533typedef struct SUPCALLVMMR0
534{
535 /** The header. */
536 SUPREQHDR Hdr;
537 union
538 {
539 struct
540 {
541 /** The VM handle. */
542 PVMR0 pVMR0;
543 /** VCPU id. */
544 uint32_t idCpu;
545 /** Which operation to execute. */
546 uint32_t uOperation;
547 /** Argument to use when no request packet is supplied. */
548 uint64_t u64Arg;
549 } In;
550 } u;
551 /** The VMMR0Entry request packet. */
552 uint8_t abReqPkt[1];
553} SUPCALLVMMR0, *PSUPCALLVMMR0;
554/** @} */
555
556
557/** @name SUP_IOCTL_CALL_VMMR0_BIG
558 * Version of SUP_IOCTL_CALL_VMMR0 for dealing with large requests.
559 * @{
560 */
561#define SUP_IOCTL_CALL_VMMR0_BIG SUP_CTL_CODE_BIG(27)
562#define SUP_IOCTL_CALL_VMMR0_BIG_SIZE(cbReq) RT_UOFFSETOF(SUPCALLVMMR0, abReqPkt[cbReq])
563#define SUP_IOCTL_CALL_VMMR0_BIG_SIZE_IN(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
564#define SUP_IOCTL_CALL_VMMR0_BIG_SIZE_OUT(cbReq) SUP_IOCTL_CALL_VMMR0_SIZE(cbReq)
565/** @} */
566
567
568/** @name SUP_IOCTL_LOW_ALLOC
569 * Allocate memory below 4GB (physically).
570 * @{
571 */
572#define SUP_IOCTL_LOW_ALLOC SUP_CTL_CODE_BIG(8)
573#define SUP_IOCTL_LOW_ALLOC_SIZE(cPages) ((uint32_t)RT_UOFFSETOF(SUPLOWALLOC, u.Out.aPages[cPages]))
574#define SUP_IOCTL_LOW_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPLOWALLOC, u.In))
575#define SUP_IOCTL_LOW_ALLOC_SIZE_OUT(cPages) SUP_IOCTL_LOW_ALLOC_SIZE(cPages)
576typedef struct SUPLOWALLOC
577{
578 /** The header. */
579 SUPREQHDR Hdr;
580 union
581 {
582 struct
583 {
584 /** Number of pages to allocate. */
585 uint32_t cPages;
586 } In;
587 struct
588 {
589 /** The ring-3 address of the allocated memory. */
590 RTR3PTR pvR3;
591 /** The ring-0 address of the allocated memory. */
592 RTR0PTR pvR0;
593 /** Array of pages. */
594 RTHCPHYS aPages[1];
595 } Out;
596 } u;
597} SUPLOWALLOC, *PSUPLOWALLOC;
598/** @} */
599
600
601/** @name SUP_IOCTL_LOW_FREE
602 * Free low memory.
603 * @{
604 */
605#define SUP_IOCTL_LOW_FREE SUP_CTL_CODE_SIZE(9, SUP_IOCTL_LOW_FREE_SIZE)
606#define SUP_IOCTL_LOW_FREE_SIZE sizeof(SUPLOWFREE)
607#define SUP_IOCTL_LOW_FREE_SIZE_IN sizeof(SUPLOWFREE)
608#define SUP_IOCTL_LOW_FREE_SIZE_OUT sizeof(SUPREQHDR)
609typedef struct SUPLOWFREE
610{
611 /** The header. */
612 SUPREQHDR Hdr;
613 union
614 {
615 struct
616 {
617 /** The ring-3 address of the memory to free. */
618 RTR3PTR pvR3;
619 } In;
620 } u;
621} SUPLOWFREE, *PSUPLOWFREE;
622/** @} */
623
624
625/** @name SUP_IOCTL_PAGE_ALLOC_EX
626 * Allocate memory and map it into kernel and/or user space. The memory is of
627 * course locked. The result should be freed using SUP_IOCTL_PAGE_FREE.
628 *
629 * @remarks Allocations without a kernel mapping may fail with
630 * VERR_NOT_SUPPORTED on some platforms.
631 *
632 * @{
633 */
634#define SUP_IOCTL_PAGE_ALLOC_EX SUP_CTL_CODE_BIG(10)
635#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages) RT_UOFFSETOF(SUPPAGEALLOCEX, u.Out.aPages[cPages])
636#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGEALLOCEX, u.In))
637#define SUP_IOCTL_PAGE_ALLOC_EX_SIZE_OUT(cPages) SUP_IOCTL_PAGE_ALLOC_EX_SIZE(cPages)
638typedef struct SUPPAGEALLOCEX
639{
640 /** The header. */
641 SUPREQHDR Hdr;
642 union
643 {
644 struct
645 {
646 /** Number of pages to allocate */
647 uint32_t cPages;
648 /** Whether it should have kernel mapping. */
649 bool fKernelMapping;
650 /** Whether it should have a user mapping. */
651 bool fUserMapping;
652 /** Reserved. Must be false. */
653 bool fReserved0;
654 /** Reserved. Must be false. */
655 bool fReserved1;
656 } In;
657 struct
658 {
659 /** Returned ring-3 address. */
660 RTR3PTR pvR3;
661 /** Returned ring-0 address. */
662 RTR0PTR pvR0;
663 /** The physical addresses of the allocated pages. */
664 RTHCPHYS aPages[1];
665 } Out;
666 } u;
667} SUPPAGEALLOCEX, *PSUPPAGEALLOCEX;
668/** @} */
669
670
671/** @name SUP_IOCTL_PAGE_MAP_KERNEL
672 * Maps a portion of memory allocated by SUP_IOCTL_PAGE_ALLOC_EX /
673 * SUPR0PageAllocEx into kernel space for use by a device or similar.
674 *
675 * The mapping will be freed together with the ring-3 mapping when
676 * SUP_IOCTL_PAGE_FREE or SUPR0PageFree is called.
677 *
678 * @remarks Not necessarily supported on all platforms.
679 *
680 * @{
681 */
682#define SUP_IOCTL_PAGE_MAP_KERNEL SUP_CTL_CODE_SIZE(11, SUP_IOCTL_PAGE_MAP_KERNEL_SIZE)
683#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE sizeof(SUPPAGEMAPKERNEL)
684#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_IN sizeof(SUPPAGEMAPKERNEL)
685#define SUP_IOCTL_PAGE_MAP_KERNEL_SIZE_OUT sizeof(SUPPAGEMAPKERNEL)
686typedef struct SUPPAGEMAPKERNEL
687{
688 /** The header. */
689 SUPREQHDR Hdr;
690 union
691 {
692 struct
693 {
694 /** The pointer of to the previously allocated memory. */
695 RTR3PTR pvR3;
696 /** The offset to start mapping from. */
697 uint32_t offSub;
698 /** Size of the section to map. */
699 uint32_t cbSub;
700 /** Flags reserved for future fun. */
701 uint32_t fFlags;
702 } In;
703 struct
704 {
705 /** The ring-0 address corresponding to pvR3 + offSub. */
706 RTR0PTR pvR0;
707 } Out;
708 } u;
709} SUPPAGEMAPKERNEL, *PSUPPAGEMAPKERNEL;
710/** @} */
711
712
713/** @name SUP_IOCTL_PAGE_PROTECT
714 * Changes the page level protection of the user and/or kernel mappings of
715 * memory previously allocated by SUPR0PageAllocEx.
716 *
717 * @remarks Not necessarily supported on all platforms.
718 *
719 * @{
720 */
721#define SUP_IOCTL_PAGE_PROTECT SUP_CTL_CODE_SIZE(12, SUP_IOCTL_PAGE_PROTECT_SIZE)
722#define SUP_IOCTL_PAGE_PROTECT_SIZE sizeof(SUPPAGEPROTECT)
723#define SUP_IOCTL_PAGE_PROTECT_SIZE_IN sizeof(SUPPAGEPROTECT)
724#define SUP_IOCTL_PAGE_PROTECT_SIZE_OUT sizeof(SUPPAGEPROTECT)
725typedef struct SUPPAGEPROTECT
726{
727 /** The header. */
728 SUPREQHDR Hdr;
729 union
730 {
731 struct
732 {
733 /** The pointer of to the previously allocated memory.
734 * Pass NIL_RTR3PTR if the ring-0 mapping should remain unaffected. */
735 RTR3PTR pvR3;
736 /** The pointer of to the previously allocated memory.
737 * Pass NIL_RTR0PTR if the ring-0 mapping should remain unaffected. */
738 RTR0PTR pvR0;
739 /** The offset to start changing protection at. */
740 uint32_t offSub;
741 /** Size of the portion that should be changed. */
742 uint32_t cbSub;
743 /** Protection flags, RTMEM_PROT_*. */
744 uint32_t fProt;
745 } In;
746 } u;
747} SUPPAGEPROTECT, *PSUPPAGEPROTECT;
748/** @} */
749
750
751/** @name SUP_IOCTL_PAGE_FREE
752 * Free memory allocated with SUP_IOCTL_PAGE_ALLOC_EX.
753 * @{
754 */
755#define SUP_IOCTL_PAGE_FREE SUP_CTL_CODE_SIZE(13, SUP_IOCTL_PAGE_FREE_SIZE_IN)
756#define SUP_IOCTL_PAGE_FREE_SIZE sizeof(SUPPAGEFREE)
757#define SUP_IOCTL_PAGE_FREE_SIZE_IN sizeof(SUPPAGEFREE)
758#define SUP_IOCTL_PAGE_FREE_SIZE_OUT sizeof(SUPREQHDR)
759typedef struct SUPPAGEFREE
760{
761 /** The header. */
762 SUPREQHDR Hdr;
763 union
764 {
765 struct
766 {
767 /** Address of memory range to free. */
768 RTR3PTR pvR3;
769 } In;
770 } u;
771} SUPPAGEFREE, *PSUPPAGEFREE;
772/** @} */
773
774
775
776
777/** @name SUP_IOCTL_PAGE_LOCK
778 * Pin down physical pages.
779 * @{
780 */
781#define SUP_IOCTL_PAGE_LOCK SUP_CTL_CODE_BIG(14)
782#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)))
783#define SUP_IOCTL_PAGE_LOCK_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPPAGELOCK, u.In))
784#define SUP_IOCTL_PAGE_LOCK_SIZE_OUT(cPages) RT_UOFFSETOF(SUPPAGELOCK, u.Out.aPages[cPages])
785typedef struct SUPPAGELOCK
786{
787 /** The header. */
788 SUPREQHDR Hdr;
789 union
790 {
791 struct
792 {
793 /** Start of page range. Must be PAGE aligned. */
794 RTR3PTR pvR3;
795 /** The range size given as a page count. */
796 uint32_t cPages;
797 } In;
798
799 struct
800 {
801 /** Array of pages. */
802 RTHCPHYS aPages[1];
803 } Out;
804 } u;
805} SUPPAGELOCK, *PSUPPAGELOCK;
806/** @} */
807
808
809/** @name SUP_IOCTL_PAGE_UNLOCK
810 * Unpin physical pages.
811 * @{ */
812#define SUP_IOCTL_PAGE_UNLOCK SUP_CTL_CODE_SIZE(15, SUP_IOCTL_PAGE_UNLOCK_SIZE)
813#define SUP_IOCTL_PAGE_UNLOCK_SIZE sizeof(SUPPAGEUNLOCK)
814#define SUP_IOCTL_PAGE_UNLOCK_SIZE_IN sizeof(SUPPAGEUNLOCK)
815#define SUP_IOCTL_PAGE_UNLOCK_SIZE_OUT sizeof(SUPREQHDR)
816typedef struct SUPPAGEUNLOCK
817{
818 /** The header. */
819 SUPREQHDR Hdr;
820 union
821 {
822 struct
823 {
824 /** Start of page range of a range previously pinned. */
825 RTR3PTR pvR3;
826 } In;
827 } u;
828} SUPPAGEUNLOCK, *PSUPPAGEUNLOCK;
829/** @} */
830
831
832/** @name SUP_IOCTL_CONT_ALLOC
833 * Allocate continuous memory.
834 * @{
835 */
836#define SUP_IOCTL_CONT_ALLOC SUP_CTL_CODE_SIZE(16, SUP_IOCTL_CONT_ALLOC_SIZE)
837#define SUP_IOCTL_CONT_ALLOC_SIZE sizeof(SUPCONTALLOC)
838#define SUP_IOCTL_CONT_ALLOC_SIZE_IN (sizeof(SUPREQHDR) + RT_SIZEOFMEMB(SUPCONTALLOC, u.In))
839#define SUP_IOCTL_CONT_ALLOC_SIZE_OUT sizeof(SUPCONTALLOC)
840typedef struct SUPCONTALLOC
841{
842 /** The header. */
843 SUPREQHDR Hdr;
844 union
845 {
846 struct
847 {
848 /** The allocation size given as a page count. */
849 uint32_t cPages;
850 } In;
851
852 struct
853 {
854 /** The address of the ring-0 mapping of the allocated memory. */
855 RTR0PTR pvR0;
856 /** The address of the ring-3 mapping of the allocated memory. */
857 RTR3PTR pvR3;
858 /** The physical address of the allocation. */
859 RTHCPHYS HCPhys;
860 } Out;
861 } u;
862} SUPCONTALLOC, *PSUPCONTALLOC;
863/** @} */
864
865
866/** @name SUP_IOCTL_CONT_FREE Input.
867 * @{
868 */
869/** Free continuous memory. */
870#define SUP_IOCTL_CONT_FREE SUP_CTL_CODE_SIZE(17, SUP_IOCTL_CONT_FREE_SIZE)
871#define SUP_IOCTL_CONT_FREE_SIZE sizeof(SUPCONTFREE)
872#define SUP_IOCTL_CONT_FREE_SIZE_IN sizeof(SUPCONTFREE)
873#define SUP_IOCTL_CONT_FREE_SIZE_OUT sizeof(SUPREQHDR)
874typedef struct SUPCONTFREE
875{
876 /** The header. */
877 SUPREQHDR Hdr;
878 union
879 {
880 struct
881 {
882 /** The ring-3 address of the memory to free. */
883 RTR3PTR pvR3;
884 } In;
885 } u;
886} SUPCONTFREE, *PSUPCONTFREE;
887/** @} */
888
889
890/** @name SUP_IOCTL_GET_PAGING_MODE
891 * Get the host paging mode.
892 * @{
893 */
894#define SUP_IOCTL_GET_PAGING_MODE SUP_CTL_CODE_SIZE(18, SUP_IOCTL_GET_PAGING_MODE_SIZE)
895#define SUP_IOCTL_GET_PAGING_MODE_SIZE sizeof(SUPGETPAGINGMODE)
896#define SUP_IOCTL_GET_PAGING_MODE_SIZE_IN sizeof(SUPREQHDR)
897#define SUP_IOCTL_GET_PAGING_MODE_SIZE_OUT sizeof(SUPGETPAGINGMODE)
898typedef struct SUPGETPAGINGMODE
899{
900 /** The header. */
901 SUPREQHDR Hdr;
902 union
903 {
904 struct
905 {
906 /** The paging mode. */
907 SUPPAGINGMODE enmMode;
908 } Out;
909 } u;
910} SUPGETPAGINGMODE, *PSUPGETPAGINGMODE;
911/** @} */
912
913
914/** @name SUP_IOCTL_SET_VM_FOR_FAST
915 * Set the VM handle for doing fast call ioctl calls.
916 * @{
917 */
918#define SUP_IOCTL_SET_VM_FOR_FAST SUP_CTL_CODE_SIZE(19, SUP_IOCTL_SET_VM_FOR_FAST_SIZE)
919#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE sizeof(SUPSETVMFORFAST)
920#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_IN sizeof(SUPSETVMFORFAST)
921#define SUP_IOCTL_SET_VM_FOR_FAST_SIZE_OUT sizeof(SUPREQHDR)
922typedef struct SUPSETVMFORFAST
923{
924 /** The header. */
925 SUPREQHDR Hdr;
926 union
927 {
928 struct
929 {
930 /** The ring-0 VM handle (pointer). */
931 PVMR0 pVMR0;
932 } In;
933 } u;
934} SUPSETVMFORFAST, *PSUPSETVMFORFAST;
935/** @} */
936
937
938/** @name SUP_IOCTL_GIP_MAP
939 * Map the GIP into user space.
940 * @{
941 */
942#define SUP_IOCTL_GIP_MAP SUP_CTL_CODE_SIZE(20, SUP_IOCTL_GIP_MAP_SIZE)
943#define SUP_IOCTL_GIP_MAP_SIZE sizeof(SUPGIPMAP)
944#define SUP_IOCTL_GIP_MAP_SIZE_IN sizeof(SUPREQHDR)
945#define SUP_IOCTL_GIP_MAP_SIZE_OUT sizeof(SUPGIPMAP)
946typedef struct SUPGIPMAP
947{
948 /** The header. */
949 SUPREQHDR Hdr;
950 union
951 {
952 struct
953 {
954 /** The physical address of the GIP. */
955 RTHCPHYS HCPhysGip;
956 /** Pointer to the read-only usermode GIP mapping for this session. */
957 R3PTRTYPE(PSUPGLOBALINFOPAGE) pGipR3;
958 /** Pointer to the supervisor mode GIP mapping. */
959 R0PTRTYPE(PSUPGLOBALINFOPAGE) pGipR0;
960 } Out;
961 } u;
962} SUPGIPMAP, *PSUPGIPMAP;
963/** @} */
964
965
966/** @name SUP_IOCTL_GIP_UNMAP
967 * Unmap the GIP.
968 * @{
969 */
970#define SUP_IOCTL_GIP_UNMAP SUP_CTL_CODE_SIZE(21, SUP_IOCTL_GIP_UNMAP_SIZE)
971#define SUP_IOCTL_GIP_UNMAP_SIZE sizeof(SUPGIPUNMAP)
972#define SUP_IOCTL_GIP_UNMAP_SIZE_IN sizeof(SUPGIPUNMAP)
973#define SUP_IOCTL_GIP_UNMAP_SIZE_OUT sizeof(SUPGIPUNMAP)
974typedef struct SUPGIPUNMAP
975{
976 /** The header. */
977 SUPREQHDR Hdr;
978} SUPGIPUNMAP, *PSUPGIPUNMAP;
979/** @} */
980
981
982/** @name SUP_IOCTL_CALL_SERVICE
983 * Call the a ring-0 service.
984 *
985 * @todo Might have to convert this to a big request, just like
986 * SUP_IOCTL_CALL_VMMR0
987 * @{
988 */
989#define SUP_IOCTL_CALL_SERVICE(cbReq) SUP_CTL_CODE_SIZE(22, SUP_IOCTL_CALL_SERVICE_SIZE(cbReq))
990#define SUP_IOCTL_CALL_SERVICE_NO_SIZE() SUP_CTL_CODE_SIZE(22, 0)
991#define SUP_IOCTL_CALL_SERVICE_SIZE(cbReq) RT_UOFFSETOF(SUPCALLSERVICE, abReqPkt[cbReq])
992#define SUP_IOCTL_CALL_SERVICE_SIZE_IN(cbReq) SUP_IOCTL_CALL_SERVICE_SIZE(cbReq)
993#define SUP_IOCTL_CALL_SERVICE_SIZE_OUT(cbReq) SUP_IOCTL_CALL_SERVICE_SIZE(cbReq)
994typedef struct SUPCALLSERVICE
995{
996 /** The header. */
997 SUPREQHDR Hdr;
998 union
999 {
1000 struct
1001 {
1002 /** The service name. */
1003 char szName[28];
1004 /** Which operation to execute. */
1005 uint32_t uOperation;
1006 /** Argument to use when no request packet is supplied. */
1007 uint64_t u64Arg;
1008 } In;
1009 } u;
1010 /** The request packet passed to SUP. */
1011 uint8_t abReqPkt[1];
1012} SUPCALLSERVICE, *PSUPCALLSERVICE;
1013/** @} */
1014
1015
1016/** @name SUP_IOCTL_LOGGER_SETTINGS
1017 * Changes the ring-0 release or debug logger settings.
1018 * @{
1019 */
1020#define SUP_IOCTL_LOGGER_SETTINGS(cbStrTab) SUP_CTL_CODE_SIZE(23, SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab))
1021#define SUP_IOCTL_LOGGER_SETTINGS_NO_SIZE() SUP_CTL_CODE_SIZE(23, 0)
1022#define SUP_IOCTL_LOGGER_SETTINGS_SIZE(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab])
1023#define SUP_IOCTL_LOGGER_SETTINGS_SIZE_IN(cbStrTab) RT_UOFFSETOF(SUPLOGGERSETTINGS, u.In.szStrings[cbStrTab])
1024#define SUP_IOCTL_LOGGER_SETTINGS_SIZE_OUT sizeof(SUPREQHDR)
1025typedef struct SUPLOGGERSETTINGS
1026{
1027 /** The header. */
1028 SUPREQHDR Hdr;
1029 union
1030 {
1031 struct
1032 {
1033 /** Which logger. */
1034 uint32_t fWhich;
1035 /** What to do with it. */
1036 uint32_t fWhat;
1037 /** Offset of the flags setting string. */
1038 uint32_t offFlags;
1039 /** Offset of the groups setting string. */
1040 uint32_t offGroups;
1041 /** Offset of the destination setting string. */
1042 uint32_t offDestination;
1043 /** The string table. */
1044 char szStrings[1];
1045 } In;
1046 } u;
1047} SUPLOGGERSETTINGS, *PSUPLOGGERSETTINGS;
1048
1049/** Debug logger. */
1050#define SUPLOGGERSETTINGS_WHICH_DEBUG 0
1051/** Release logger. */
1052#define SUPLOGGERSETTINGS_WHICH_RELEASE 1
1053
1054/** Change the settings. */
1055#define SUPLOGGERSETTINGS_WHAT_SETTINGS 0
1056/** Create the logger instance. */
1057#define SUPLOGGERSETTINGS_WHAT_CREATE 1
1058/** Destroy the logger instance. */
1059#define SUPLOGGERSETTINGS_WHAT_DESTROY 2
1060
1061/** @} */
1062
1063
1064/** @name Semaphore Types
1065 * @{ */
1066#define SUP_SEM_TYPE_EVENT 0
1067#define SUP_SEM_TYPE_EVENT_MULTI 1
1068/** @} */
1069
1070
1071/** @name SUP_IOCTL_SEM_OP2
1072 * Semaphore operations.
1073 * @remarks This replaces the old SUP_IOCTL_SEM_OP interface.
1074 * @{
1075 */
1076#define SUP_IOCTL_SEM_OP2 SUP_CTL_CODE_SIZE(24, SUP_IOCTL_SEM_OP2_SIZE)
1077#define SUP_IOCTL_SEM_OP2_SIZE sizeof(SUPSEMOP2)
1078#define SUP_IOCTL_SEM_OP2_SIZE_IN sizeof(SUPSEMOP2)
1079#define SUP_IOCTL_SEM_OP2_SIZE_OUT sizeof(SUPREQHDR)
1080typedef struct SUPSEMOP2
1081{
1082 /** The header. */
1083 SUPREQHDR Hdr;
1084 union
1085 {
1086 struct
1087 {
1088 /** The semaphore type. */
1089 uint32_t uType;
1090 /** The semaphore handle. */
1091 uint32_t hSem;
1092 /** The operation. */
1093 uint32_t uOp;
1094 /** Reserved, must be zero. */
1095 uint32_t uReserved;
1096 /** The number of milliseconds to wait if it's a wait operation. */
1097 union
1098 {
1099 /** Absolute timeout (RTTime[System]NanoTS).
1100 * Used by SUPSEMOP2_WAIT_NS_ABS. */
1101 uint64_t uAbsNsTimeout;
1102 /** Relative nanosecond timeout.
1103 * Used by SUPSEMOP2_WAIT_NS_REL. */
1104 uint64_t cRelNsTimeout;
1105 /** Relative millisecond timeout.
1106 * Used by SUPSEMOP2_WAIT_MS_REL. */
1107 uint32_t cRelMsTimeout;
1108 /** Generic 64-bit accessor.
1109 * ASSUMES little endian! */
1110 uint64_t u64;
1111 } uArg;
1112 } In;
1113 } u;
1114} SUPSEMOP2, *PSUPSEMOP2;
1115
1116/** Wait for a number of milliseconds. */
1117#define SUPSEMOP2_WAIT_MS_REL 0
1118/** Wait until the specified deadline is reached. */
1119#define SUPSEMOP2_WAIT_NS_ABS 1
1120/** Wait for a number of nanoseconds. */
1121#define SUPSEMOP2_WAIT_NS_REL 2
1122/** Signal the semaphore. */
1123#define SUPSEMOP2_SIGNAL 3
1124/** Reset the semaphore (only applicable to SUP_SEM_TYPE_EVENT_MULTI). */
1125#define SUPSEMOP2_RESET 4
1126/** Close the semaphore handle. */
1127#define SUPSEMOP2_CLOSE 5
1128/** @} */
1129
1130
1131/** @name SUP_IOCTL_SEM_OP3
1132 * Semaphore operations.
1133 * @{
1134 */
1135#define SUP_IOCTL_SEM_OP3 SUP_CTL_CODE_SIZE(25, SUP_IOCTL_SEM_OP3_SIZE)
1136#define SUP_IOCTL_SEM_OP3_SIZE sizeof(SUPSEMOP3)
1137#define SUP_IOCTL_SEM_OP3_SIZE_IN sizeof(SUPSEMOP3)
1138#define SUP_IOCTL_SEM_OP3_SIZE_OUT sizeof(SUPSEMOP3)
1139typedef struct SUPSEMOP3
1140{
1141 /** The header. */
1142 SUPREQHDR Hdr;
1143 union
1144 {
1145 struct
1146 {
1147 /** The semaphore type. */
1148 uint32_t uType;
1149 /** The semaphore handle. */
1150 uint32_t hSem;
1151 /** The operation. */
1152 uint32_t uOp;
1153 /** Reserved, must be zero. */
1154 uint32_t u32Reserved;
1155 /** Reserved for future use. */
1156 uint64_t u64Reserved;
1157 } In;
1158 union
1159 {
1160 /** The handle of the created semaphore.
1161 * Used by SUPSEMOP3_CREATE. */
1162 uint32_t hSem;
1163 /** The semaphore resolution in nano seconds.
1164 * Used by SUPSEMOP3_GET_RESOLUTION. */
1165 uint32_t cNsResolution;
1166 /** The 32-bit view. */
1167 uint32_t u32;
1168 /** Reserved some space for later expansion. */
1169 uint64_t u64Reserved;
1170 } Out;
1171 } u;
1172} SUPSEMOP3, *PSUPSEMOP3;
1173
1174/** Get the wait resolution. */
1175#define SUPSEMOP3_CREATE 0
1176/** Get the wait resolution. */
1177#define SUPSEMOP3_GET_RESOLUTION 1
1178/** @} */
1179
1180
1181/** @name SUP_IOCTL_VT_CAPS
1182 * Get the VT-x/AMD-V capabilities.
1183 *
1184 * @todo Intended for main, which means we need to relax the privilege requires
1185 * when accessing certain vboxdrv functions.
1186 *
1187 * @{
1188 */
1189#define SUP_IOCTL_VT_CAPS SUP_CTL_CODE_SIZE(26, SUP_IOCTL_VT_CAPS_SIZE)
1190#define SUP_IOCTL_VT_CAPS_SIZE sizeof(SUPVTCAPS)
1191#define SUP_IOCTL_VT_CAPS_SIZE_IN sizeof(SUPREQHDR)
1192#define SUP_IOCTL_VT_CAPS_SIZE_OUT sizeof(SUPVTCAPS)
1193typedef struct SUPVTCAPS
1194{
1195 /** The header. */
1196 SUPREQHDR Hdr;
1197 union
1198 {
1199 struct
1200 {
1201 /** The VT capability dword. */
1202 uint32_t Caps;
1203 } Out;
1204 } u;
1205} SUPVTCAPS, *PSUPVTCAPS;
1206/** @} */
1207
1208
1209/** @name SUP_IOCTL_TRACER_OPEN
1210 * Open the tracer.
1211 *
1212 * Should be matched by an SUP_IOCTL_TRACER_CLOSE call.
1213 *
1214 * @{
1215 */
1216#define SUP_IOCTL_TRACER_OPEN SUP_CTL_CODE_SIZE(28, SUP_IOCTL_TRACER_OPEN_SIZE)
1217#define SUP_IOCTL_TRACER_OPEN_SIZE sizeof(SUPTRACEROPEN)
1218#define SUP_IOCTL_TRACER_OPEN_SIZE_IN sizeof(SUPTRACEROPEN)
1219#define SUP_IOCTL_TRACER_OPEN_SIZE_OUT sizeof(SUPREQHDR)
1220typedef struct SUPTRACEROPEN
1221{
1222 /** The header. */
1223 SUPREQHDR Hdr;
1224 union
1225 {
1226 struct
1227 {
1228 /** Tracer cookie. Used to make sure we only open a matching tracer. */
1229 uint32_t uCookie;
1230 /** Tracer specific argument. */
1231 RTHCUINTPTR uArg;
1232 } In;
1233 } u;
1234} SUPTRACEROPEN, *PSUPTRACEROPEN;
1235/** @} */
1236
1237
1238/** @name SUP_IOCTL_TRACER_CLOSE
1239 * Close the tracer.
1240 *
1241 * Must match a SUP_IOCTL_TRACER_OPEN call.
1242 *
1243 * @{
1244 */
1245#define SUP_IOCTL_TRACER_CLOSE SUP_CTL_CODE_SIZE(29, SUP_IOCTL_TRACER_CLOSE_SIZE)
1246#define SUP_IOCTL_TRACER_CLOSE_SIZE sizeof(SUPREQHDR)
1247#define SUP_IOCTL_TRACER_CLOSE_SIZE_IN sizeof(SUPREQHDR)
1248#define SUP_IOCTL_TRACER_CLOSE_SIZE_OUT sizeof(SUPREQHDR)
1249/** @} */
1250
1251
1252/** @name SUP_IOCTL_TRACER_IOCTL
1253 * Speak UNIX ioctl() with the tracer.
1254 *
1255 * The session must have opened the tracer prior to issuing this request.
1256 *
1257 * @{
1258 */
1259#define SUP_IOCTL_TRACER_IOCTL SUP_CTL_CODE_SIZE(30, SUP_IOCTL_TRACER_IOCTL_SIZE)
1260#define SUP_IOCTL_TRACER_IOCTL_SIZE sizeof(SUPTRACERIOCTL)
1261#define SUP_IOCTL_TRACER_IOCTL_SIZE_IN sizeof(SUPTRACERIOCTL)
1262#define SUP_IOCTL_TRACER_IOCTL_SIZE_OUT (RT_UOFFSETOF(SUPTRACERIOCTL, u.Out.iRetVal) + sizeof(int32_t))
1263typedef struct SUPTRACERIOCTL
1264{
1265 /** The header. */
1266 SUPREQHDR Hdr;
1267 union
1268 {
1269 struct
1270 {
1271 /** The command. */
1272 RTHCUINTPTR uCmd;
1273 /** Argument to the command. */
1274 RTHCUINTPTR uArg;
1275 } In;
1276
1277 struct
1278 {
1279 /** The return value. */
1280 int32_t iRetVal;
1281 } Out;
1282 } u;
1283} SUPTRACERIOCTL, *PSUPTRACERIOCTL;
1284/** @} */
1285
1286
1287/** @name SUP_IOCTL_TRACER_UMOD_REG
1288 * Registers tracepoints in a user mode module.
1289 *
1290 * @{
1291 */
1292#define SUP_IOCTL_TRACER_UMOD_REG SUP_CTL_CODE_SIZE(31, SUP_IOCTL_TRACER_UMOD_REG_SIZE)
1293#define SUP_IOCTL_TRACER_UMOD_REG_SIZE sizeof(SUPTRACERUMODREG)
1294#define SUP_IOCTL_TRACER_UMOD_REG_SIZE_IN sizeof(SUPTRACERUMODREG)
1295#define SUP_IOCTL_TRACER_UMOD_REG_SIZE_OUT sizeof(SUPREQHDR)
1296typedef struct SUPTRACERUMODREG
1297{
1298 /** The header. */
1299 SUPREQHDR Hdr;
1300 union
1301 {
1302 struct
1303 {
1304 /** The address at which the VTG header actually resides.
1305 * This will differ from R3PtrVtgHdr for raw-mode context
1306 * modules. */
1307 RTUINTPTR uVtgHdrAddr;
1308 /** The ring-3 pointer of the VTG header. */
1309 RTR3PTR R3PtrVtgHdr;
1310 /** The ring-3 pointer of the probe location string table. */
1311 RTR3PTR R3PtrStrTab;
1312 /** The size of the string table. */
1313 uint32_t cbStrTab;
1314 /** Future flags, MBZ. */
1315 uint32_t fFlags;
1316 /** The module name. */
1317 char szName[64];
1318 } In;
1319 } u;
1320} SUPTRACERUMODREG, *PSUPTRACERUMODREG;
1321/** @} */
1322
1323
1324/** @name SUP_IOCTL_TRACER_UMOD_DEREG
1325 * Deregisters tracepoints in a user mode module.
1326 *
1327 * @{
1328 */
1329#define SUP_IOCTL_TRACER_UMOD_DEREG SUP_CTL_CODE_SIZE(32, SUP_IOCTL_TRACER_UMOD_DEREG_SIZE)
1330#define SUP_IOCTL_TRACER_UMOD_DEREG_SIZE sizeof(SUPTRACERUMODDEREG)
1331#define SUP_IOCTL_TRACER_UMOD_DEREG_SIZE_IN sizeof(SUPTRACERUMODDEREG)
1332#define SUP_IOCTL_TRACER_UMOD_DEREG_SIZE_OUT sizeof(SUPREQHDR)
1333typedef struct SUPTRACERUMODDEREG
1334{
1335 /** The header. */
1336 SUPREQHDR Hdr;
1337 union
1338 {
1339 struct
1340 {
1341 /** Pointer to the VTG header. */
1342 RTR3PTR pVtgHdr;
1343 } In;
1344 } u;
1345} SUPTRACERUMODDEREG, *PSUPTRACERUMODDEREG;
1346/** @} */
1347
1348
1349/** @name SUP_IOCTL_TRACER_UMOD_FIRE_PROBE
1350 * Fire a probe in a user tracepoint module.
1351 *
1352 * @{
1353 */
1354#define SUP_IOCTL_TRACER_UMOD_FIRE_PROBE SUP_CTL_CODE_SIZE(33, SUP_IOCTL_TRACER_UMOD_FIRE_PROBE_SIZE)
1355#define SUP_IOCTL_TRACER_UMOD_FIRE_PROBE_SIZE sizeof(SUPTRACERUMODFIREPROBE)
1356#define SUP_IOCTL_TRACER_UMOD_FIRE_PROBE_SIZE_IN sizeof(SUPTRACERUMODFIREPROBE)
1357#define SUP_IOCTL_TRACER_UMOD_FIRE_PROBE_SIZE_OUT sizeof(SUPREQHDR)
1358typedef struct SUPTRACERUMODFIREPROBE
1359{
1360 /** The header. */
1361 SUPREQHDR Hdr;
1362 union
1363 {
1364 SUPDRVTRACERUSRCTX In;
1365 } u;
1366} SUPTRACERUMODFIREPROBE, *PSUPTRACERUMODFIREPROBE;
1367/** @} */
1368
1369
1370/** @name SUP_IOCTL_MSR_PROBER
1371 * MSR probing interface, not available in normal builds.
1372 *
1373 * @{
1374 */
1375#define SUP_IOCTL_MSR_PROBER SUP_CTL_CODE_SIZE(34, SUP_IOCTL_MSR_PROBER_SIZE)
1376#define SUP_IOCTL_MSR_PROBER_SIZE sizeof(SUPMSRPROBER)
1377#define SUP_IOCTL_MSR_PROBER_SIZE_IN sizeof(SUPMSRPROBER)
1378#define SUP_IOCTL_MSR_PROBER_SIZE_OUT sizeof(SUPMSRPROBER)
1379
1380typedef enum SUPMSRPROBEROP
1381{
1382 SUPMSRPROBEROP_INVALID = 0, /**< The customary invalid zero value. */
1383 SUPMSRPROBEROP_READ, /**< Read an MSR. */
1384 SUPMSRPROBEROP_WRITE, /**< Write a value to an MSR (use with care!). */
1385 SUPMSRPROBEROP_MODIFY, /**< Read-modify-restore-flushall. */
1386 SUPMSRPROBEROP_MODIFY_FASTER, /**< Read-modify-restore, skip the flushing. */
1387 SUPMSRPROBEROP_END, /**< End of valid values. */
1388 SUPMSRPROBEROP_32BIT_HACK = 0x7fffffff /**< The customary 32-bit type hack. */
1389} SUPMSRPROBEROP;
1390
1391typedef struct SUPMSRPROBER
1392{
1393 /** The header. */
1394 SUPREQHDR Hdr;
1395
1396 /** Input/output union. */
1397 union
1398 {
1399 /** Inputs. */
1400 struct
1401 {
1402 /** The operation. */
1403 SUPMSRPROBEROP enmOp;
1404 /** The MSR to test. */
1405 uint32_t uMsr;
1406 /** The CPU to perform the operation on.
1407 * Use UINT32_MAX to indicate that any CPU will do. */
1408 uint32_t idCpu;
1409 /** Alignment padding. */
1410 uint32_t u32Padding;
1411 /** Operation specific arguments. */
1412 union
1413 {
1414 /* SUPMSRPROBEROP_READ takes no extra arguments. */
1415
1416 /** For SUPMSRPROBEROP_WRITE. */
1417 struct
1418 {
1419 /** The value to write. */
1420 uint64_t uToWrite;
1421 } Write;
1422
1423 /** For SUPMSRPROBEROP_MODIFY and SUPMSRPROBEROP_MODIFY_FASTER. */
1424 struct
1425 {
1426 /** The value to AND the current MSR value with to construct the value to
1427 * write. This applied first. */
1428 uint64_t fAndMask;
1429 /** The value to OR the result of the above mentioned AND operation with
1430 * attempting to modify the MSR. */
1431 uint64_t fOrMask;
1432 } Modify;
1433
1434 /** Reserve space for the future.. */
1435 uint64_t auPadding[3];
1436 } uArgs;
1437 } In;
1438
1439 /** Outputs. */
1440 struct
1441 {
1442 /** Operation specific results. */
1443 union
1444 {
1445 /** For SUPMSRPROBEROP_READ. */
1446 struct
1447 {
1448 /** The value we've read. */
1449 uint64_t uValue;
1450 /** Set if we GPed while reading it. */
1451 bool fGp;
1452 } Read;
1453
1454 /** For SUPMSRPROBEROP_WRITE. */
1455 struct
1456 {
1457 /** Set if we GPed while writing it. */
1458 bool fGp;
1459 } Write;
1460
1461 /** For SUPMSRPROBEROP_MODIFY and SUPMSRPROBEROP_MODIFY_FASTER. */
1462 SUPMSRPROBERMODIFYRESULT Modify;
1463
1464 /** Size padding/aligning. */
1465 uint64_t auPadding[5];
1466 } uResults;
1467 } Out;
1468 } u;
1469} SUPMSRPROBER, *PSUPMSRPROBER;
1470AssertCompileMemberAlignment(SUPMSRPROBER, u, 8);
1471AssertCompileMemberAlignment(SUPMSRPROBER, u.In.uArgs, 8);
1472AssertCompileMembersSameSizeAndOffset(SUPMSRPROBER, u.In, SUPMSRPROBER, u.Out);
1473/** @} */
1474
1475/** @name SUP_IOCTL_RESUME_SUSPENDED_KBDS
1476 * Resume suspended keyboard devices if any found in the system.
1477 *
1478 * @{
1479 */
1480#define SUP_IOCTL_RESUME_SUSPENDED_KBDS SUP_CTL_CODE_SIZE(35, SUP_IOCTL_RESUME_SUSPENDED_KBDS_SIZE)
1481#define SUP_IOCTL_RESUME_SUSPENDED_KBDS_SIZE sizeof(SUPREQHDR)
1482#define SUP_IOCTL_RESUME_SUSPENDED_KBDS_SIZE_IN sizeof(SUPREQHDR)
1483#define SUP_IOCTL_RESUME_SUSPENDED_KBDS_SIZE_OUT sizeof(SUPREQHDR)
1484/** @} */
1485
1486
1487/** @name SUP_IOCTL_TSC_DELTA_MEASURE
1488 * Measure the TSC-delta between the specified CPU and the master TSC.
1489 *
1490 * To call this I/O control, the client must first have mapped the GIP.
1491 *
1492 * @{
1493 */
1494#define SUP_IOCTL_TSC_DELTA_MEASURE SUP_CTL_CODE_SIZE(36, SUP_IOCTL_TSC_DELTA_MEASURE_SIZE)
1495#define SUP_IOCTL_TSC_DELTA_MEASURE_SIZE sizeof(SUPTSCDELTAMEASURE)
1496#define SUP_IOCTL_TSC_DELTA_MEASURE_SIZE_IN sizeof(SUPTSCDELTAMEASURE)
1497#define SUP_IOCTL_TSC_DELTA_MEASURE_SIZE_OUT sizeof(SUPREQHDR)
1498typedef struct SUPTSCDELTAMEASURE
1499{
1500 /** The header. */
1501 SUPREQHDR Hdr;
1502
1503 /** Input/output union. */
1504 union
1505 {
1506 struct
1507 {
1508 /** Which CPU to take the TSC-delta measurement for. */
1509 RTCPUID idCpu;
1510 /** Number of times to retry on failure (specify 0 for default). */
1511 uint8_t cRetries;
1512 /** Number of milliseconds to wait before each retry. */
1513 uint8_t cMsWaitRetry;
1514 /** Whether to force taking a measurement if one exists already. */
1515 bool fForce;
1516 /** Whether to do the measurement asynchronously (if possible). */
1517 bool fAsync;
1518 } In;
1519 } u;
1520} SUPTSCDELTAMEASURE, *PSUPTSCDELTAMEASURE;
1521AssertCompileMemberAlignment(SUPTSCDELTAMEASURE, u, 8);
1522AssertCompileSize(SUPTSCDELTAMEASURE, 6*4 + 4+1+1+1+1);
1523/** @} */
1524
1525/** @name SUP_IOCTL_TSC_READ
1526 * Reads the TSC and apply TSC-delta if applicable, determining the delta if
1527 * necessary (i64TSCDelta = INT64_MAX).
1528 *
1529 * This latter function is the primary use case of this I/O control. To call
1530 * this I/O control, the client must first have mapped the GIP.
1531 *
1532 * @{
1533 */
1534#define SUP_IOCTL_TSC_READ SUP_CTL_CODE_SIZE(37, SUP_IOCTL_TSC_READ_SIZE)
1535#define SUP_IOCTL_TSC_READ_SIZE sizeof(SUPTSCREAD)
1536#define SUP_IOCTL_TSC_READ_SIZE_IN sizeof(SUPREQHDR)
1537#define SUP_IOCTL_TSC_READ_SIZE_OUT sizeof(SUPTSCREAD)
1538typedef struct SUPTSCREAD
1539{
1540 /** The header. */
1541 SUPREQHDR Hdr;
1542
1543 /** Input/output union. */
1544 union
1545 {
1546 struct
1547 {
1548 /** The TSC after applying the relevant delta. */
1549 uint64_t u64AdjustedTsc;
1550 /** The APIC Id of the CPU where the TSC was read. */
1551 uint16_t idApic;
1552 /** Explicit alignment padding. */
1553 uint16_t auPadding[3];
1554 } Out;
1555 } u;
1556} SUPTSCREAD, *PSUPTSCREAD;
1557AssertCompileMemberAlignment(SUPTSCREAD, u, 8);
1558AssertCompileSize(SUPTSCREAD, 6*4 + 2*8);
1559/** @} */
1560
1561#pragma pack() /* paranoia */
1562
1563#endif
1564
Note: See TracBrowser for help on using the repository browser.

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