VirtualBox

source: vbox/trunk/src/recompiler/VBoxREMWrapper.cpp@ 28317

Last change on this file since 28317 was 28317, checked in by vboxsync, 15 years ago

RTMemPageFree + all users: Added size parameter to RTMemPageFree so we can avoid tracking structures when using mmap/munmap.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 125.7 KB
Line 
1/* $Id: VBoxREMWrapper.cpp 28317 2010-04-14 18:06:05Z vboxsync $ */
2/** @file
3 *
4 * VBoxREM Win64 DLL Wrapper.
5 */
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/** @page pg_vboxrem_amd64 VBoxREM Hacks on AMD64
24 *
25 * There are problems with building BoxREM both on WIN64 and 64-bit linux.
26 *
27 * On linux binutils refuses to link shared objects without -fPIC compiled code
28 * (bitches about some fixup types). But when trying to build with -fPIC dyngen
29 * doesn't like the code anymore. Sweet. The current solution is to build the
30 * VBoxREM code as a relocatable module and use our ELF loader to load it.
31 *
32 * On WIN64 we're not aware of any GCC port which can emit code using the MSC
33 * calling convention. So, we're in for some real fun here. The choice is between
34 * porting GCC to AMD64 WIN64 and comming up with some kind of wrapper around
35 * either the win32 build or the 64-bit linux build.
36 *
37 * -# Porting GCC will be a lot of work. For one thing the calling convention differs
38 * and messing with such stuff can easily create ugly bugs. We would also have to
39 * do some binutils changes, but I think those are rather small compared to GCC.
40 * (That said, the MSC calling convention is far simpler than the linux one, it
41 * reminds me of _Optlink which we have working already.)
42 * -# Wrapping win32 code will work, but addresses outside the first 4GB are
43 * inaccessible and we will have to create 32-64 thunks for all imported functions.
44 * (To switch between 32-bit and 64-bit is load the right CS using far jmps (32->64)
45 * or far returns (both).)
46 * -# Wrapping 64-bit linux code might be the easier solution. The requirements here
47 * are:
48 * - Remove all CRT references we possibly, either by using intrinsics or using
49 * IPRT. Part of IPRT will be linked into VBoxREM2.rel, this will be yet another
50 * IPRT mode which I've dubbed 'no-crt'. The no-crt mode provide basic non-system
51 * dependent stuff.
52 * - Compile and link it into a relocatable object (include the gcc intrinsics
53 * in libgcc). Call this VBoxREM2.rel.
54 * - Write a wrapper dll, VBoxREM.dll, for which during REMR3Init() will load
55 * VBoxREM2.rel (using IPRT) and generate calling convention wrappers
56 * for all IPRT functions and VBoxVMM functions that it uses. All exports
57 * will be wrapped vice versa.
58 * - For building on windows hosts, we will use a mingw32 hosted cross compiler.
59 * and add a 'no-crt' mode to IPRT where it provides the necessary CRT headers
60 * and function implementations.
61 *
62 * The 3rd solution will be tried out first since it requires the least effort and
63 * will let us make use of the full 64-bit register set.
64 *
65 *
66 *
67 * @section sec_vboxrem_amd64_compare Comparing the GCC and MSC calling conventions
68 *
69 * GCC expects the following (cut & past from page 20 in the ABI draft 0.96):
70 *
71 * @verbatim
72 %rax temporary register; with variable arguments passes information about the
73 number of SSE registers used; 1st return register.
74 [Not preserved]
75 %rbx callee-saved register; optionally used as base pointer.
76 [Preserved]
77 %rcx used to pass 4th integer argument to functions.
78 [Not preserved]
79 %rdx used to pass 3rd argument to functions; 2nd return register
80 [Not preserved]
81 %rsp stack pointer
82 [Preserved]
83 %rbp callee-saved register; optionally used as frame pointer
84 [Preserved]
85 %rsi used to pass 2nd argument to functions
86 [Not preserved]
87 %rdi used to pass 1st argument to functions
88 [Not preserved]
89 %r8 used to pass 5th argument to functions
90 [Not preserved]
91 %r9 used to pass 6th argument to functions
92 [Not preserved]
93 %r10 temporary register, used for passing a function's static chain
94 pointer [Not preserved]
95 %r11 temporary register
96 [Not preserved]
97 %r12-r15 callee-saved registers
98 [Preserved]
99 %xmm0-%xmm1 used to pass and return floating point arguments
100 [Not preserved]
101 %xmm2-%xmm7 used to pass floating point arguments
102 [Not preserved]
103 %xmm8-%xmm15 temporary registers
104 [Not preserved]
105 %mmx0-%mmx7 temporary registers
106 [Not preserved]
107 %st0 temporary register; used to return long double arguments
108 [Not preserved]
109 %st1 temporary registers; used to return long double arguments
110 [Not preserved]
111 %st2-%st7 temporary registers
112 [Not preserved]
113 %fs Reserved for system use (as thread specific data register)
114 [Not preserved]
115 @endverbatim
116 *
117 * Direction flag is preserved as cleared.
118 * The stack must be aligned on a 16-byte boundrary before the 'call/jmp' instruction.
119 *
120 *
121 *
122 * MSC expects the following:
123 * @verbatim
124 rax return value, not preserved.
125 rbx preserved.
126 rcx 1st argument, integer, not preserved.
127 rdx 2nd argument, integer, not preserved.
128 rbp preserved.
129 rsp preserved.
130 rsi preserved.
131 rdi preserved.
132 r8 3rd argument, integer, not preserved.
133 r9 4th argument, integer, not preserved.
134 r10 scratch register, not preserved.
135 r11 scratch register, not preserved.
136 r12-r15 preserved.
137 xmm0 1st argument, fp, return value, not preserved.
138 xmm1 2st argument, fp, not preserved.
139 xmm2 3st argument, fp, not preserved.
140 xmm3 4st argument, fp, not preserved.
141 xmm4-xmm5 scratch, not preserved.
142 xmm6-xmm15 preserved.
143 @endverbatim
144 *
145 * Dunno what the direction flag is...
146 * The stack must be aligned on a 16-byte boundrary before the 'call/jmp' instruction.
147 *
148 *
149 * Thus, When GCC code is calling MSC code we don't really have to preserve
150 * anything. But but MSC code is calling GCC code, we'll have to save esi and edi.
151 *
152 */
153
154
155/*******************************************************************************
156* Defined Constants And Macros *
157*******************************************************************************/
158/** @def USE_REM_STUBS
159 * Define USE_REM_STUBS to stub the entire REM stuff. This is useful during
160 * early porting (before we start running stuff).
161 */
162#if defined(DOXYGEN_RUNNING)
163# define USE_REM_STUBS
164#endif
165
166/** @def USE_REM_CALLING_CONVENTION_GLUE
167 * Define USE_REM_CALLING_CONVENTION_GLUE for platforms where it's necessary to
168 * use calling convention wrappers.
169 */
170#if (defined(RT_ARCH_AMD64) && defined(RT_OS_WINDOWS)) || defined(DOXYGEN_RUNNING)
171# define USE_REM_CALLING_CONVENTION_GLUE
172#endif
173
174/** @def USE_REM_IMPORT_JUMP_GLUE
175 * Define USE_REM_IMPORT_JUMP_GLUE for platforms where we need to
176 * emit some jump glue to deal with big addresses.
177 */
178#if (defined(RT_ARCH_AMD64) && !defined(USE_REM_CALLING_CONVENTION_GLUE) && !defined(RT_OS_DARWIN)) || defined(DOXYGEN_RUNNING)
179# define USE_REM_IMPORT_JUMP_GLUE
180#endif
181
182/** @def VBOX_USE_BITNESS_SELECTOR
183 * Define VBOX_USE_BITNESS_SELECTOR to build this module as a bitness selector
184 * between VBoxREM32 and VBoxREM64.
185 */
186#if defined(DOXYGEN_RUNNING)
187# define VBOX_USE_BITNESS_SELECTOR
188#endif
189
190/** @def VBOX_WITHOUT_REM_LDR_CYCLE
191 * Define VBOX_WITHOUT_REM_LDR_CYCLE dynamically resolve any dependencies on
192 * VBoxVMM and thus avoid the cyclic dependency between VBoxREM and VBoxVMM.
193 */
194#if defined(DOXYGEN_RUNNING)
195# define VBOX_WITHOUT_REM_LDR_CYCLE
196#endif
197
198
199/*******************************************************************************
200* Header Files *
201*******************************************************************************/
202#define LOG_GROUP LOG_GROUP_REM
203#include <VBox/rem.h>
204#include <VBox/vmm.h>
205#include <VBox/dbgf.h>
206#include <VBox/dbg.h>
207#include <VBox/csam.h>
208#include <VBox/mm.h>
209#include <VBox/em.h>
210#include <VBox/ssm.h>
211#include <VBox/hwaccm.h>
212#include <VBox/patm.h>
213#ifdef VBOX_WITH_VMI
214# include <VBox/parav.h>
215#endif
216#include <VBox/pdm.h>
217#include <VBox/pdmcritsect.h>
218#include <VBox/pgm.h>
219#include <VBox/iom.h>
220#include <VBox/vm.h>
221#include <VBox/err.h>
222#include <VBox/log.h>
223#include <VBox/dis.h>
224
225#include <iprt/alloc.h>
226#include <iprt/assert.h>
227#include <iprt/ldr.h>
228#include <iprt/lockvalidator.h>
229#include <iprt/param.h>
230#include <iprt/path.h>
231#include <iprt/string.h>
232#include <iprt/stream.h>
233
234
235/*******************************************************************************
236* Structures and Typedefs *
237*******************************************************************************/
238/**
239 * Parameter descriptor.
240 */
241typedef struct REMPARMDESC
242{
243 /** Parameter flags (REMPARMDESC_FLAGS_*). */
244 uint8_t fFlags;
245 /** The parameter size if REMPARMDESC_FLAGS_SIZE is set. */
246 uint8_t cb;
247 /** Pointer to additional data.
248 * For REMPARMDESC_FLAGS_PFN this is a PREMFNDESC. */
249 void *pvExtra;
250
251} REMPARMDESC, *PREMPARMDESC;
252/** Pointer to a constant parameter descriptor. */
253typedef const REMPARMDESC *PCREMPARMDESC;
254
255/** @name Parameter descriptor flags.
256 * @{ */
257/** The parameter type is a kind of integer which could fit in a register. This includes pointers. */
258#define REMPARMDESC_FLAGS_INT 0
259/** The parameter is a GC pointer. */
260#define REMPARMDESC_FLAGS_GCPTR 1
261/** The parameter is a GC physical address. */
262#define REMPARMDESC_FLAGS_GCPHYS 2
263/** The parameter is a HC physical address. */
264#define REMPARMDESC_FLAGS_HCPHYS 3
265/** The parameter type is a kind of floating point. */
266#define REMPARMDESC_FLAGS_FLOAT 4
267/** The parameter value is a struct. This type takes a size. */
268#define REMPARMDESC_FLAGS_STRUCT 5
269/** The parameter is an elipsis. */
270#define REMPARMDESC_FLAGS_ELLIPSIS 6
271/** The parameter is a va_list. */
272#define REMPARMDESC_FLAGS_VALIST 7
273/** The parameter is a function pointer. pvExtra is a PREMFNDESC. */
274#define REMPARMDESC_FLAGS_PFN 8
275/** The parameter type mask. */
276#define REMPARMDESC_FLAGS_TYPE_MASK 15
277/** The parameter size field is valid. */
278#define REMPARMDESC_FLAGS_SIZE RT_BIT(7)
279/** @} */
280
281/**
282 * Function descriptor.
283 */
284typedef struct REMFNDESC
285{
286 /** The function name. */
287 const char *pszName;
288 /** Exports: Pointer to the function pointer.
289 * Imports: Pointer to the function. */
290 void *pv;
291 /** Array of parameter descriptors. */
292 PCREMPARMDESC paParams;
293 /** The number of parameter descriptors pointed to by paParams. */
294 uint8_t cParams;
295 /** Function flags (REMFNDESC_FLAGS_*). */
296 uint8_t fFlags;
297 /** The size of the return value. */
298 uint8_t cbReturn;
299 /** Pointer to the wrapper code for imports. */
300 void *pvWrapper;
301} REMFNDESC, *PREMFNDESC;
302/** Pointer to a constant function descriptor. */
303typedef const REMFNDESC *PCREMFNDESC;
304
305/** @name Function descriptor flags.
306 * @{ */
307/** The return type is void. */
308#define REMFNDESC_FLAGS_RET_VOID 0
309/** The return type is a kind of integer passed in rax/eax. This includes pointers. */
310#define REMFNDESC_FLAGS_RET_INT 1
311/** The return type is a kind of floating point. */
312#define REMFNDESC_FLAGS_RET_FLOAT 2
313/** The return value is a struct. This type take a size. */
314#define REMFNDESC_FLAGS_RET_STRUCT 3
315/** The return type mask. */
316#define REMFNDESC_FLAGS_RET_TYPE_MASK 7
317/** The argument list contains one or more va_list arguments (i.e. problems). */
318#define REMFNDESC_FLAGS_VALIST RT_BIT(6)
319/** The function has an ellipsis (i.e. a problem). */
320#define REMFNDESC_FLAGS_ELLIPSIS RT_BIT(7)
321/** @} */
322
323/**
324 * Chunk of read-write-executable memory.
325 */
326typedef struct REMEXECMEM
327{
328 /** The number of bytes left. */
329 struct REMEXECMEM *pNext;
330 /** The size of this chunk. */
331 uint32_t cb;
332 /** The offset of the next code block. */
333 uint32_t off;
334#if ARCH_BITS == 32
335 uint32_t padding;
336#endif
337} REMEXECMEM, *PREMEXECMEM;
338
339
340/*******************************************************************************
341* Global Variables *
342*******************************************************************************/
343#ifndef USE_REM_STUBS
344/** Loader handle of the REM object/DLL. */
345static RTLDRMOD g_ModREM2 = NIL_RTLDRMOD;
346/** Pointer to the memory containing the loaded REM2 object/DLL. */
347static void *g_pvREM2 = NULL;
348# ifdef VBOX_WITHOUT_REM_LDR_CYCLE
349/** Loader handle of the VBoxVMM DLL. */
350static RTLDRMOD g_ModVMM = NIL_RTLDRMOD;
351# endif
352
353/** Linux object export addresses.
354 * These are references from the assembly wrapper code.
355 * @{ */
356static DECLCALLBACKPTR(int, pfnREMR3Init)(PVM);
357static DECLCALLBACKPTR(int, pfnREMR3InitFinalize)(PVM);
358static DECLCALLBACKPTR(int, pfnREMR3Term)(PVM);
359static DECLCALLBACKPTR(void, pfnREMR3Reset)(PVM);
360static DECLCALLBACKPTR(int, pfnREMR3Step)(PVM, PVMCPU);
361static DECLCALLBACKPTR(int, pfnREMR3BreakpointSet)(PVM, RTGCUINTPTR);
362static DECLCALLBACKPTR(int, pfnREMR3BreakpointClear)(PVM, RTGCUINTPTR);
363static DECLCALLBACKPTR(int, pfnREMR3EmulateInstruction)(PVM, PVMCPU);
364static DECLCALLBACKPTR(int, pfnREMR3Run)(PVM, PVMCPU);
365static DECLCALLBACKPTR(int, pfnREMR3State)(PVM, PVMCPU);
366static DECLCALLBACKPTR(int, pfnREMR3StateBack)(PVM, PVMCPU);
367static DECLCALLBACKPTR(void, pfnREMR3StateUpdate)(PVM, PVMCPU);
368static DECLCALLBACKPTR(void, pfnREMR3A20Set)(PVM, PVMCPU, bool);
369static DECLCALLBACKPTR(void, pfnREMR3ReplayHandlerNotifications)(PVM pVM);
370static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamRegister)(PVM, RTGCPHYS, RTGCPHYS, unsigned);
371static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRamDeregister)(PVM, RTGCPHYS, RTUINT);
372static DECLCALLBACKPTR(void, pfnREMR3NotifyPhysRomRegister)(PVM, RTGCPHYS, RTUINT, void *, bool);
373static DECLCALLBACKPTR(void, pfnREMR3NotifyHandlerPhysicalModify)(PVM, PGMPHYSHANDLERTYPE, RTGCPHYS, RTGCPHYS, RTGCPHYS, bool, bool);
374static DECLCALLBACKPTR(void, pfnREMR3NotifyHandlerPhysicalRegister)(PVM, PGMPHYSHANDLERTYPE, RTGCPHYS, RTGCPHYS, bool);
375static DECLCALLBACKPTR(void, pfnREMR3NotifyHandlerPhysicalDeregister)(PVM, PGMPHYSHANDLERTYPE, RTGCPHYS, RTGCPHYS, bool, bool);
376static DECLCALLBACKPTR(void, pfnREMR3NotifyInterruptSet)(PVM, PVMCPU);
377static DECLCALLBACKPTR(void, pfnREMR3NotifyInterruptClear)(PVM, PVMCPU);
378static DECLCALLBACKPTR(void, pfnREMR3NotifyTimerPending)(PVM, PVMCPU);
379static DECLCALLBACKPTR(void, pfnREMR3NotifyDmaPending)(PVM);
380static DECLCALLBACKPTR(void, pfnREMR3NotifyQueuePending)(PVM);
381static DECLCALLBACKPTR(void, pfnREMR3NotifyFF)(PVM);
382static DECLCALLBACKPTR(int, pfnREMR3NotifyCodePageChanged)(PVM, PVMCPU, RTGCPTR);
383static DECLCALLBACKPTR(void, pfnREMR3NotifyPendingInterrupt)(PVM, PVMCPU, uint8_t);
384static DECLCALLBACKPTR(uint32_t, pfnREMR3QueryPendingInterrupt)(PVM, PVMCPU);
385static DECLCALLBACKPTR(int, pfnREMR3DisasEnableStepping)(PVM, bool);
386static DECLCALLBACKPTR(bool, pfnREMR3IsPageAccessHandled)(PVM, RTGCPHYS);
387/** @} */
388
389/** Export and import parameter descriptors.
390 * @{
391 */
392/* Common args. */
393static const REMPARMDESC g_aArgsSIZE_T[] =
394{
395 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
396};
397static const REMPARMDESC g_aArgsPTR[] =
398{
399 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL }
400};
401static const REMPARMDESC g_aArgsVM[] =
402{
403 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL }
404};
405static const REMPARMDESC g_aArgsVMCPU[] =
406{
407 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL }
408};
409
410static const REMPARMDESC g_aArgsVMandVMCPU[] =
411{
412 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
413 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL }
414};
415
416/* REM args */
417static const REMPARMDESC g_aArgsBreakpoint[] =
418{
419 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
420 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCUINTPTR), NULL }
421};
422static const REMPARMDESC g_aArgsA20Set[] =
423{
424 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
425 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
426 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
427};
428static const REMPARMDESC g_aArgsNotifyPhysRamRegister[] =
429{
430 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
431 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
432 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
433 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
434 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL }
435};
436static const REMPARMDESC g_aArgsNotifyPhysRamChunkRegister[] =
437{
438 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
439 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
440 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL },
441 { REMPARMDESC_FLAGS_INT, sizeof(RTHCUINTPTR), NULL },
442 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL }
443};
444static const REMPARMDESC g_aArgsNotifyPhysRamDeregister[] =
445{
446 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
447 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
448 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL }
449};
450static const REMPARMDESC g_aArgsNotifyPhysRomRegister[] =
451{
452 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
453 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
454 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL },
455 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
456 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
457};
458static const REMPARMDESC g_aArgsNotifyHandlerPhysicalModify[] =
459{
460 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
461 { REMPARMDESC_FLAGS_INT, sizeof(PGMPHYSHANDLERTYPE), NULL },
462 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
463 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
464 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
465 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL },
466 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
467};
468static const REMPARMDESC g_aArgsNotifyHandlerPhysicalRegister[] =
469{
470 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
471 { REMPARMDESC_FLAGS_INT, sizeof(PGMPHYSHANDLERTYPE), NULL },
472 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
473 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
474 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
475};
476static const REMPARMDESC g_aArgsNotifyHandlerPhysicalDeregister[] =
477{
478 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
479 { REMPARMDESC_FLAGS_INT, sizeof(PGMPHYSHANDLERTYPE), NULL },
480 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
481 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
482 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL },
483 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
484};
485static const REMPARMDESC g_aArgsNotifyCodePageChanged[] =
486{
487 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
488 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
489 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCUINTPTR), NULL }
490};
491static const REMPARMDESC g_aArgsNotifyPendingInterrupt[] =
492{
493 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
494 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
495 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL }
496};
497static const REMPARMDESC g_aArgsDisasEnableStepping[] =
498{
499 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
500 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
501};
502static const REMPARMDESC g_aArgsIsPageAccessHandled[] =
503{
504 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
505 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }
506};
507
508# ifndef VBOX_USE_BITNESS_SELECTOR
509
510/* VMM args */
511static const REMPARMDESC g_aArgsCPUMGetGuestCpl[] =
512{
513 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
514 { REMPARMDESC_FLAGS_INT, sizeof(PCPUMCTXCORE), NULL },
515};
516
517/* EMInterpretInstructionCPUEx args */
518static const REMPARMDESC g_aArgsEMInterpretInstructionCPUEx[] =
519{
520 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
521 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
522 { REMPARMDESC_FLAGS_INT, sizeof(PDISCPUSTATE), NULL },
523 { REMPARMDESC_FLAGS_INT, sizeof(PCPUMCTXCORE), NULL },
524 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL },
525 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
526 { REMPARMDESC_FLAGS_INT, sizeof(EMCODETYPE), NULL }
527};
528
529/* CPUMGetGuestMsr args */
530static const REMPARMDESC g_aArgsCPUMGetGuestMsr[] =
531{
532 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
533 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
534};
535
536/* CPUMGetGuestMsr args */
537static const REMPARMDESC g_aArgsCPUMSetGuestMsr[] =
538{
539 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
540 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
541 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },
542};
543
544static const REMPARMDESC g_aArgsCPUMGetGuestCpuId[] =
545{
546 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
547 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
548 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
549 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
550 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
551 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL }
552};
553
554static const REMPARMDESC g_aArgsCPUMSetChangedFlags[] =
555{
556 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
557 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
558};
559
560static const REMPARMDESC g_aArgsCPUMQueryGuestCtxPtr[] =
561{
562 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL }
563};
564static const REMPARMDESC g_aArgsCSAMR3MonitorPage[] =
565{
566 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
567 { REMPARMDESC_FLAGS_INT, sizeof(RTRCPTR), NULL },
568 { REMPARMDESC_FLAGS_INT, sizeof(CSAMTAG), NULL }
569};
570static const REMPARMDESC g_aArgsCSAMR3UnmonitorPage[] =
571{
572 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
573 { REMPARMDESC_FLAGS_INT, sizeof(RTRCPTR), NULL },
574 { REMPARMDESC_FLAGS_INT, sizeof(CSAMTAG), NULL }
575};
576
577static const REMPARMDESC g_aArgsCSAMR3RecordCallAddress[] =
578{
579 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
580 { REMPARMDESC_FLAGS_INT, sizeof(RTRCPTR), NULL }
581};
582
583# if defined(VBOX_WITH_DEBUGGER) && !(defined(RT_OS_WINDOWS) && defined(RT_ARCH_AMD64)) /* the callbacks are problematic */
584static const REMPARMDESC g_aArgsDBGCRegisterCommands[] =
585{
586 { REMPARMDESC_FLAGS_INT, sizeof(PCDBGCCMD), NULL },
587 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL }
588};
589# endif
590static const REMPARMDESC g_aArgsDBGFR3DisasInstrEx[] =
591{
592 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
593 { REMPARMDESC_FLAGS_INT, sizeof(VMCPUID), NULL },
594 { REMPARMDESC_FLAGS_INT, sizeof(RTSEL), NULL },
595 { REMPARMDESC_FLAGS_INT, sizeof(RTGCPTR), NULL },
596 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
597 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL },
598 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
599 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL }
600};
601static const REMPARMDESC g_aArgsDBGFR3DisasInstrCurrentLogInternal[] =
602{
603 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
604 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL }
605};
606static const REMPARMDESC g_aArgsDBGFR3Info[] =
607{
608 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
609 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
610 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
611 { REMPARMDESC_FLAGS_INT, sizeof(PCDBGFINFOHLP), NULL }
612};
613static const REMPARMDESC g_aArgsDBGFR3AsSymbolByAddr[] =
614{
615 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
616 { REMPARMDESC_FLAGS_INT, sizeof(RTDBGAS), NULL },
617 { REMPARMDESC_FLAGS_INT, sizeof(PCDBGFADDRESS), NULL },
618 { REMPARMDESC_FLAGS_GCPTR, sizeof(PRTGCINTPTR), NULL },
619 { REMPARMDESC_FLAGS_INT, sizeof(PRTDBGSYMBOL), NULL },
620 { REMPARMDESC_FLAGS_INT, sizeof(PRTDBGMOD), NULL }
621};
622static const REMPARMDESC g_aArgsDBGFR3AddrFromFlat[] =
623{
624 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
625 { REMPARMDESC_FLAGS_INT, sizeof(PDBGFADDRESS), NULL },
626 { REMPARMDESC_FLAGS_INT, sizeof(RTGCUINTPTR), NULL }
627};
628static const REMPARMDESC g_aArgsDISInstr[] =
629{
630 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
631 { REMPARMDESC_FLAGS_INT, sizeof(RTUINTPTR), NULL },
632 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
633 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
634 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL }
635};
636static const REMPARMDESC g_aArgsEMR3FatalError[] =
637{
638 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
639 { REMPARMDESC_FLAGS_INT, sizeof(int), NULL }
640};
641static const REMPARMDESC g_aArgsHWACCMR3CanExecuteGuest[] =
642{
643 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
644 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
645 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
646 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
647};
648static const REMPARMDESC g_aArgsIOMIOPortRead[] =
649{
650 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
651 { REMPARMDESC_FLAGS_INT, sizeof(RTIOPORT), NULL },
652 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
653 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
654};
655static const REMPARMDESC g_aArgsIOMIOPortWrite[] =
656{
657 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
658 { REMPARMDESC_FLAGS_INT, sizeof(RTIOPORT), NULL },
659 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
660 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
661};
662static const REMPARMDESC g_aArgsIOMMMIORead[] =
663{
664 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
665 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
666 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL },
667 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
668};
669static const REMPARMDESC g_aArgsIOMMMIOWrite[] =
670{
671 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
672 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
673 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
674 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
675};
676static const REMPARMDESC g_aArgsMMR3HeapAlloc[] =
677{
678 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
679 { REMPARMDESC_FLAGS_INT, sizeof(MMTAG), NULL },
680 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
681};
682static const REMPARMDESC g_aArgsMMR3HeapAllocZ[] =
683{
684 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
685 { REMPARMDESC_FLAGS_INT, sizeof(MMTAG), NULL },
686 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
687};
688static const REMPARMDESC g_aArgsPATMIsPatchGCAddr[] =
689{
690 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
691 { REMPARMDESC_FLAGS_INT, sizeof(RTRCUINTPTR), NULL }
692};
693static const REMPARMDESC g_aArgsPATMR3QueryOpcode[] =
694{
695 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
696 { REMPARMDESC_FLAGS_INT, sizeof(RTRCPTR), NULL },
697 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL }
698};
699static const REMPARMDESC g_aArgsPATMR3QueryPatchMem[] =
700{
701 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
702 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL }
703};
704# ifdef VBOX_WITH_VMI
705static const REMPARMDESC g_aArgsPARAVIsBiosCall[] =
706{
707 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
708 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL },
709 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
710};
711# endif
712static const REMPARMDESC g_aArgsPDMApicGetBase[] =
713{
714 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
715 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t *), NULL }
716};
717static const REMPARMDESC g_aArgsPDMApicGetTPR[] =
718{
719 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
720 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL },
721 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL }
722};
723static const REMPARMDESC g_aArgsPDMApicSetBase[] =
724{
725 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
726 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL }
727};
728static const REMPARMDESC g_aArgsPDMApicSetTPR[] =
729{
730 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
731 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL }
732};
733static const REMPARMDESC g_aArgsPDMApicWriteMSR[] =
734{
735 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
736 { REMPARMDESC_FLAGS_INT, sizeof(VMCPUID), NULL },
737 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
738 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL }
739};
740static const REMPARMDESC g_aArgsPDMApicReadMSR[] =
741{
742 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
743 { REMPARMDESC_FLAGS_INT, sizeof(VMCPUID), NULL },
744 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
745 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t *), NULL }
746};
747static const REMPARMDESC g_aArgsPDMGetInterrupt[] =
748{
749 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
750 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL }
751};
752static const REMPARMDESC g_aArgsPDMIsaSetIrq[] =
753{
754 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
755 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL },
756 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL }
757};
758static const REMPARMDESC g_aArgsPDMR3CritSectInit[] =
759{
760 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
761 { REMPARMDESC_FLAGS_INT, sizeof(PPDMCRITSECT), NULL },
762 /* RT_SRC_POS_DECL */
763 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
764 { REMPARMDESC_FLAGS_INT, sizeof(unsigned int), NULL },
765 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
766 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL },
767 { REMPARMDESC_FLAGS_ELLIPSIS, 0 }
768};
769static const REMPARMDESC g_aArgsPDMCritSectEnter[] =
770{
771 { REMPARMDESC_FLAGS_INT, sizeof(PPDMCRITSECT), NULL },
772 { REMPARMDESC_FLAGS_INT, sizeof(int), NULL }
773};
774static const REMPARMDESC g_aArgsPDMCritSectEnterDebug[] =
775{
776 { REMPARMDESC_FLAGS_INT, sizeof(PPDMCRITSECT), NULL },
777 { REMPARMDESC_FLAGS_INT, sizeof(int), NULL },
778 { REMPARMDESC_FLAGS_INT, sizeof(RTHCUINTPTR), NULL },
779 /* RT_SRC_POS_DECL */
780 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
781 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
782 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL }
783};
784static const REMPARMDESC g_aArgsPGMGetGuestMode[] =
785{
786 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
787};
788static const REMPARMDESC g_aArgsPGMGstGetPage[] =
789{
790 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
791 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL },
792 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t *), NULL },
793 { REMPARMDESC_FLAGS_INT, sizeof(PRTGCPHYS), NULL }
794};
795static const REMPARMDESC g_aArgsPGMInvalidatePage[] =
796{
797 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
798 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL }
799};
800static const REMPARMDESC g_aArgsPGMR3PhysTlbGCPhys2Ptr[] =
801{
802 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
803 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
804 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL },
805 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL }
806};
807static const REMPARMDESC g_aArgsPGM3PhysGrowRange[] =
808{
809 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
810 { REMPARMDESC_FLAGS_INT, sizeof(PCRTGCPHYS), NULL }
811};
812static const REMPARMDESC g_aArgsPGMPhysIsGCPhysValid[] =
813{
814 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
815 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }
816};
817static const REMPARMDESC g_aArgsPGMPhysRead[] =
818{
819 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
820 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
821 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
822 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
823};
824static const REMPARMDESC g_aArgsPGMPhysSimpleReadGCPtr[] =
825{
826 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
827 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
828 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL },
829 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
830};
831static const REMPARMDESC g_aArgsPGMPhysWrite[] =
832{
833 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
834 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
835 { REMPARMDESC_FLAGS_INT, sizeof(const void *), NULL },
836 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
837};
838static const REMPARMDESC g_aArgsPGMChangeMode[] =
839{
840 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
841 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },
842 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },
843 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL }
844};
845static const REMPARMDESC g_aArgsPGMFlushTLB[] =
846{
847 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
848 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL },
849 { REMPARMDESC_FLAGS_INT, sizeof(bool), NULL }
850};
851static const REMPARMDESC g_aArgsPGMR3PhysReadUxx[] =
852{
853 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
854 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL }
855};
856static const REMPARMDESC g_aArgsPGMR3PhysWriteU8[] =
857{
858 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
859 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
860 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL }
861};
862static const REMPARMDESC g_aArgsPGMR3PhysWriteU16[] =
863{
864 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
865 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
866 { REMPARMDESC_FLAGS_INT, sizeof(uint16_t), NULL }
867};
868static const REMPARMDESC g_aArgsPGMR3PhysWriteU32[] =
869{
870 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
871 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
872 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL }
873};
874static const REMPARMDESC g_aArgsPGMR3PhysWriteU64[] =
875{
876 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
877 { REMPARMDESC_FLAGS_GCPHYS, sizeof(RTGCPHYS), NULL },
878 { REMPARMDESC_FLAGS_INT, sizeof(uint64_t), NULL }
879};
880static const REMPARMDESC g_aArgsRTMemRealloc[] =
881{
882 { REMPARMDESC_FLAGS_INT, sizeof(void*), NULL },
883 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
884};
885static const REMPARMDESC g_aArgsSSMR3GetGCPtr[] =
886{
887 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
888 { REMPARMDESC_FLAGS_INT, sizeof(PRTGCPTR), NULL }
889};
890static const REMPARMDESC g_aArgsSSMR3GetMem[] =
891{
892 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
893 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
894 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
895};
896static const REMPARMDESC g_aArgsSSMR3GetU32[] =
897{
898 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
899 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t *), NULL }
900};
901static const REMPARMDESC g_aArgsSSMR3GetUInt[] =
902{
903 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
904 { REMPARMDESC_FLAGS_INT, sizeof(PRTUINT), NULL }
905};
906static const REMPARMDESC g_aArgsSSMR3PutGCPtr[] =
907{
908 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
909 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCPTR), NULL }
910};
911static const REMPARMDESC g_aArgsSSMR3PutMem[] =
912{
913 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
914 { REMPARMDESC_FLAGS_INT, sizeof(const void *), NULL },
915 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
916};
917static const REMPARMDESC g_aArgsSSMR3PutU32[] =
918{
919 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
920 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
921};
922static const REMPARMDESC g_aArgsSSMR3PutUInt[] =
923{
924 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
925 { REMPARMDESC_FLAGS_INT, sizeof(RTUINT), NULL },
926};
927
928static const REMPARMDESC g_aArgsSSMIntLiveExecCallback[] =
929{
930 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
931 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
932 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
933};
934static REMFNDESC g_SSMIntLiveExecCallback =
935{
936 "SSMIntLiveExecCallback", NULL, &g_aArgsSSMIntLiveExecCallback[0], RT_ELEMENTS(g_aArgsSSMIntLiveExecCallback), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL
937};
938
939static const REMPARMDESC g_aArgsSSMIntLiveVoteCallback[] =
940{
941 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
942 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
943};
944static REMFNDESC g_SSMIntLiveVoteCallback =
945{
946 "SSMIntLiveVoteCallback", NULL, &g_aArgsSSMIntLiveVoteCallback[0], RT_ELEMENTS(g_aArgsSSMIntLiveVoteCallback), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL
947};
948
949static const REMPARMDESC g_aArgsSSMIntCallback[] =
950{
951 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
952 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
953};
954static REMFNDESC g_SSMIntCallback =
955{
956 "SSMIntCallback", NULL, &g_aArgsSSMIntCallback[0], RT_ELEMENTS(g_aArgsSSMIntCallback), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL
957};
958
959static const REMPARMDESC g_aArgsSSMIntLoadExecCallback[] =
960{
961 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
962 { REMPARMDESC_FLAGS_INT, sizeof(PSSMHANDLE), NULL },
963 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
964 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
965};
966static REMFNDESC g_SSMIntLoadExecCallback =
967{
968 "SSMIntLoadExecCallback", NULL, &g_aArgsSSMIntLoadExecCallback[0], RT_ELEMENTS(g_aArgsSSMIntLoadExecCallback), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL
969};
970/* Note: don't forget about the handwritten assembly wrapper when changing this! */
971static const REMPARMDESC g_aArgsSSMR3RegisterInternal[] =
972{
973 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
974 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
975 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
976 { REMPARMDESC_FLAGS_INT, sizeof(uint32_t), NULL },
977 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL },
978 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTLIVEPREP), &g_SSMIntCallback },
979 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTLIVEEXEC), &g_SSMIntLiveExecCallback },
980 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTLIVEVOTE), &g_SSMIntLiveVoteCallback },
981 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTSAVEPREP), &g_SSMIntCallback },
982 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTSAVEEXEC), &g_SSMIntCallback },
983 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTSAVEDONE), &g_SSMIntCallback },
984 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTLOADPREP), &g_SSMIntCallback },
985 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTLOADEXEC), &g_SSMIntLoadExecCallback },
986 { REMPARMDESC_FLAGS_PFN, sizeof(PFNSSMINTLOADDONE), &g_SSMIntCallback },
987};
988
989static const REMPARMDESC g_aArgsSTAMR3Register[] =
990{
991 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
992 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
993 { REMPARMDESC_FLAGS_INT, sizeof(STAMTYPE), NULL },
994 { REMPARMDESC_FLAGS_INT, sizeof(STAMVISIBILITY), NULL },
995 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
996 { REMPARMDESC_FLAGS_INT, sizeof(STAMUNIT), NULL },
997 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL }
998};
999static const REMPARMDESC g_aArgsSTAMR3Deregister[] =
1000{
1001 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
1002 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
1003};
1004static const REMPARMDESC g_aArgsTRPMAssertTrap[] =
1005{
1006 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
1007 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t), NULL },
1008 { REMPARMDESC_FLAGS_INT, sizeof(TRPMEVENT), NULL }
1009};
1010static const REMPARMDESC g_aArgsTRPMQueryTrap[] =
1011{
1012 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
1013 { REMPARMDESC_FLAGS_INT, sizeof(uint8_t *), NULL },
1014 { REMPARMDESC_FLAGS_INT, sizeof(TRPMEVENT *), NULL }
1015};
1016static const REMPARMDESC g_aArgsTRPMSetErrorCode[] =
1017{
1018 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
1019 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCUINT), NULL }
1020};
1021static const REMPARMDESC g_aArgsTRPMSetFaultAddress[] =
1022{
1023 { REMPARMDESC_FLAGS_INT, sizeof(PVMCPU), NULL },
1024 { REMPARMDESC_FLAGS_GCPTR, sizeof(RTGCUINT), NULL }
1025};
1026static const REMPARMDESC g_aArgsVMR3ReqCallWait[] =
1027{
1028 { REMPARMDESC_FLAGS_INT, sizeof(PVM), NULL },
1029 { REMPARMDESC_FLAGS_INT, sizeof(VMCPUID), NULL },
1030 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
1031 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
1032 { REMPARMDESC_FLAGS_ELLIPSIS, 0, NULL }
1033};
1034static const REMPARMDESC g_aArgsVMR3ReqFree[] =
1035{
1036 { REMPARMDESC_FLAGS_INT, sizeof(PVMREQ), NULL }
1037};
1038
1039/* IPRT args */
1040static const REMPARMDESC g_aArgsRTAssertMsg1[] =
1041{
1042 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1043 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
1044 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1045 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL }
1046};
1047static const REMPARMDESC g_aArgsRTAssertMsg2[] =
1048{
1049 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1050 { REMPARMDESC_FLAGS_ELLIPSIS, 0, NULL }
1051};
1052static const REMPARMDESC g_aArgsRTAssertMsg2V[] =
1053{
1054 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1055 { REMPARMDESC_FLAGS_VALIST, 0, NULL }
1056};
1057static const REMPARMDESC g_aArgsRTLogFlags[] =
1058{
1059 { REMPARMDESC_FLAGS_INT, sizeof(PRTLOGGER), NULL },
1060 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL }
1061};
1062static const REMPARMDESC g_aArgsRTLogFlush[] =
1063{
1064 { REMPARMDESC_FLAGS_INT, sizeof(PRTLOGGER), NULL }
1065};
1066static const REMPARMDESC g_aArgsRTLogLoggerEx[] =
1067{
1068 { REMPARMDESC_FLAGS_INT, sizeof(PRTLOGGER), NULL },
1069 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
1070 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
1071 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1072 { REMPARMDESC_FLAGS_ELLIPSIS, 0, NULL }
1073};
1074static const REMPARMDESC g_aArgsRTLogLoggerExV[] =
1075{
1076 { REMPARMDESC_FLAGS_INT, sizeof(PRTLOGGER), NULL },
1077 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
1078 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL },
1079 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1080 { REMPARMDESC_FLAGS_VALIST, 0, NULL }
1081};
1082static const REMPARMDESC g_aArgsRTLogPrintf[] =
1083{
1084 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1085 { REMPARMDESC_FLAGS_ELLIPSIS, 0, NULL }
1086};
1087static const REMPARMDESC g_aArgsRTMemProtect[] =
1088{
1089 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
1090 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL },
1091 { REMPARMDESC_FLAGS_INT, sizeof(unsigned), NULL }
1092};
1093static const REMPARMDESC g_aArgsRTMemFree[] =
1094{
1095 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
1096 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
1097};
1098static const REMPARMDESC g_aArgsRTStrPrintf[] =
1099{
1100 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL },
1101 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL },
1102 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1103 { REMPARMDESC_FLAGS_ELLIPSIS, 0, NULL }
1104};
1105static const REMPARMDESC g_aArgsRTStrPrintfV[] =
1106{
1107 { REMPARMDESC_FLAGS_INT, sizeof(char *), NULL },
1108 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL },
1109 { REMPARMDESC_FLAGS_INT, sizeof(const char *), NULL },
1110 { REMPARMDESC_FLAGS_VALIST, 0, NULL }
1111};
1112static const REMPARMDESC g_aArgsThread[] =
1113{
1114 { REMPARMDESC_FLAGS_INT, sizeof(RTTHREAD), NULL }
1115};
1116
1117
1118/* CRT args */
1119static const REMPARMDESC g_aArgsmemcpy[] =
1120{
1121 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
1122 { REMPARMDESC_FLAGS_INT, sizeof(const void *), NULL },
1123 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
1124};
1125static const REMPARMDESC g_aArgsmemset[] =
1126{
1127 { REMPARMDESC_FLAGS_INT, sizeof(void *), NULL },
1128 { REMPARMDESC_FLAGS_INT, sizeof(int), NULL },
1129 { REMPARMDESC_FLAGS_INT, sizeof(size_t), NULL }
1130};
1131
1132# endif /* !VBOX_USE_BITNESS_SELECTOR */
1133
1134/** @} */
1135
1136/**
1137 * Descriptors for the exported functions.
1138 */
1139static const REMFNDESC g_aExports[] =
1140{ /* pszName, (void *)pv, pParams, cParams, fFlags, cb, pvWrapper. */
1141 { "REMR3Init", (void *)&pfnREMR3Init, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1142 { "REMR3InitFinalize", (void *)&pfnREMR3InitFinalize, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1143 { "REMR3Term", (void *)&pfnREMR3Term, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1144 { "REMR3Reset", (void *)&pfnREMR3Reset, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1145 { "REMR3Step", (void *)&pfnREMR3Step, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1146 { "REMR3BreakpointSet", (void *)&pfnREMR3BreakpointSet, &g_aArgsBreakpoint[0], RT_ELEMENTS(g_aArgsBreakpoint), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1147 { "REMR3BreakpointClear", (void *)&pfnREMR3BreakpointClear, &g_aArgsBreakpoint[0], RT_ELEMENTS(g_aArgsBreakpoint), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1148 { "REMR3EmulateInstruction", (void *)&pfnREMR3EmulateInstruction, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1149 { "REMR3Run", (void *)&pfnREMR3Run, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1150 { "REMR3State", (void *)&pfnREMR3State, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1151 { "REMR3StateBack", (void *)&pfnREMR3StateBack, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1152 { "REMR3StateUpdate", (void *)&pfnREMR3StateUpdate, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1153 { "REMR3A20Set", (void *)&pfnREMR3A20Set, &g_aArgsA20Set[0], RT_ELEMENTS(g_aArgsA20Set), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1154 { "REMR3ReplayHandlerNotifications", (void *)&pfnREMR3ReplayHandlerNotifications, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1155 { "REMR3NotifyPhysRamRegister", (void *)&pfnREMR3NotifyPhysRamRegister, &g_aArgsNotifyPhysRamRegister[0], RT_ELEMENTS(g_aArgsNotifyPhysRamRegister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1156 { "REMR3NotifyPhysRamDeregister", (void *)&pfnREMR3NotifyPhysRamDeregister, &g_aArgsNotifyPhysRamDeregister[0], RT_ELEMENTS(g_aArgsNotifyPhysRamDeregister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1157 { "REMR3NotifyPhysRomRegister", (void *)&pfnREMR3NotifyPhysRomRegister, &g_aArgsNotifyPhysRomRegister[0], RT_ELEMENTS(g_aArgsNotifyPhysRomRegister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1158 { "REMR3NotifyHandlerPhysicalModify", (void *)&pfnREMR3NotifyHandlerPhysicalModify, &g_aArgsNotifyHandlerPhysicalModify[0], RT_ELEMENTS(g_aArgsNotifyHandlerPhysicalModify), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1159 { "REMR3NotifyHandlerPhysicalRegister", (void *)&pfnREMR3NotifyHandlerPhysicalRegister, &g_aArgsNotifyHandlerPhysicalRegister[0], RT_ELEMENTS(g_aArgsNotifyHandlerPhysicalRegister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1160 { "REMR3NotifyHandlerPhysicalDeregister", (void *)&pfnREMR3NotifyHandlerPhysicalDeregister, &g_aArgsNotifyHandlerPhysicalDeregister[0], RT_ELEMENTS(g_aArgsNotifyHandlerPhysicalDeregister), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1161 { "REMR3NotifyInterruptSet", (void *)&pfnREMR3NotifyInterruptSet, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1162 { "REMR3NotifyInterruptClear", (void *)&pfnREMR3NotifyInterruptClear, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1163 { "REMR3NotifyTimerPending", (void *)&pfnREMR3NotifyTimerPending, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1164 { "REMR3NotifyDmaPending", (void *)&pfnREMR3NotifyDmaPending, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1165 { "REMR3NotifyQueuePending", (void *)&pfnREMR3NotifyQueuePending, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1166 { "REMR3NotifyFF", (void *)&pfnREMR3NotifyFF, &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1167 { "REMR3NotifyCodePageChanged", (void *)&pfnREMR3NotifyCodePageChanged, &g_aArgsNotifyCodePageChanged[0], RT_ELEMENTS(g_aArgsNotifyCodePageChanged), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1168 { "REMR3NotifyPendingInterrupt", (void *)&pfnREMR3NotifyPendingInterrupt, &g_aArgsNotifyPendingInterrupt[0], RT_ELEMENTS(g_aArgsNotifyPendingInterrupt), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1169 { "REMR3QueryPendingInterrupt", (void *)&pfnREMR3QueryPendingInterrupt, &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1170 { "REMR3DisasEnableStepping", (void *)&pfnREMR3DisasEnableStepping, &g_aArgsDisasEnableStepping[0], RT_ELEMENTS(g_aArgsDisasEnableStepping), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1171 { "REMR3IsPageAccessHandled", (void *)&pfnREMR3IsPageAccessHandled, &g_aArgsIsPageAccessHandled[0], RT_ELEMENTS(g_aArgsIsPageAccessHandled), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL }
1172};
1173
1174# ifndef VBOX_USE_BITNESS_SELECTOR
1175
1176# ifdef VBOX_WITHOUT_REM_LDR_CYCLE
1177# define VMM_FN(name) NULL
1178# else
1179# define VMM_FN(name) (void *)(uintptr_t)& name
1180# endif
1181
1182/**
1183 * Descriptors for the functions imported from VBoxVMM.
1184 */
1185static REMFNDESC g_aVMMImports[] =
1186{
1187 { "CPUMAreHiddenSelRegsValid", VMM_FN(CPUMAreHiddenSelRegsValid), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1188 { "CPUMGetAndClearChangedFlagsREM", VMM_FN(CPUMGetAndClearChangedFlagsREM), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(unsigned), NULL },
1189 { "CPUMSetChangedFlags", VMM_FN(CPUMSetChangedFlags), &g_aArgsCPUMSetChangedFlags[0], RT_ELEMENTS(g_aArgsCPUMSetChangedFlags), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1190 { "CPUMGetGuestCPL", VMM_FN(CPUMGetGuestCPL), &g_aArgsCPUMGetGuestCpl[0], RT_ELEMENTS(g_aArgsCPUMGetGuestCpl), REMFNDESC_FLAGS_RET_INT, sizeof(unsigned), NULL },
1191 { "CPUMGetGuestMsr", VMM_FN(CPUMGetGuestMsr), &g_aArgsCPUMGetGuestMsr[0], RT_ELEMENTS(g_aArgsCPUMGetGuestMsr), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },
1192 { "CPUMSetGuestMsr", VMM_FN(CPUMSetGuestMsr), &g_aArgsCPUMSetGuestMsr[0], RT_ELEMENTS(g_aArgsCPUMSetGuestMsr), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1193 { "CPUMGetGuestCpuId", VMM_FN(CPUMGetGuestCpuId), &g_aArgsCPUMGetGuestCpuId[0], RT_ELEMENTS(g_aArgsCPUMGetGuestCpuId), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1194 { "CPUMGetGuestEAX", VMM_FN(CPUMGetGuestEAX), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1195 { "CPUMGetGuestEBP", VMM_FN(CPUMGetGuestEBP), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1196 { "CPUMGetGuestEBX", VMM_FN(CPUMGetGuestEBX), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1197 { "CPUMGetGuestECX", VMM_FN(CPUMGetGuestECX), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1198 { "CPUMGetGuestEDI", VMM_FN(CPUMGetGuestEDI), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1199 { "CPUMGetGuestEDX", VMM_FN(CPUMGetGuestEDX), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1200 { "CPUMGetGuestEIP", VMM_FN(CPUMGetGuestEIP), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1201 { "CPUMGetGuestESI", VMM_FN(CPUMGetGuestESI), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1202 { "CPUMGetGuestESP", VMM_FN(CPUMGetGuestESP), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1203 { "CPUMGetGuestCS", VMM_FN(CPUMGetGuestCS), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(RTSEL), NULL },
1204 { "CPUMGetGuestSS", VMM_FN(CPUMGetGuestSS), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(RTSEL), NULL },
1205 { "CPUMQueryGuestCtxPtr", VMM_FN(CPUMQueryGuestCtxPtr), &g_aArgsCPUMQueryGuestCtxPtr[0], RT_ELEMENTS(g_aArgsCPUMQueryGuestCtxPtr), REMFNDESC_FLAGS_RET_INT, sizeof(PCPUMCTX), NULL },
1206 { "CSAMR3MonitorPage", VMM_FN(CSAMR3MonitorPage), &g_aArgsCSAMR3MonitorPage[0], RT_ELEMENTS(g_aArgsCSAMR3MonitorPage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1207 { "CSAMR3UnmonitorPage", VMM_FN(CSAMR3UnmonitorPage), &g_aArgsCSAMR3UnmonitorPage[0], RT_ELEMENTS(g_aArgsCSAMR3UnmonitorPage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1208 { "CSAMR3RecordCallAddress", VMM_FN(CSAMR3RecordCallAddress), &g_aArgsCSAMR3RecordCallAddress[0], RT_ELEMENTS(g_aArgsCSAMR3RecordCallAddress), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1209# if defined(VBOX_WITH_DEBUGGER) && !(defined(RT_OS_WINDOWS) && defined(RT_ARCH_AMD64)) /* the callbacks are problematic */
1210 { "DBGCRegisterCommands", VMM_FN(DBGCRegisterCommands), &g_aArgsDBGCRegisterCommands[0], RT_ELEMENTS(g_aArgsDBGCRegisterCommands), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1211# endif
1212 { "DBGFR3DisasInstrEx", VMM_FN(DBGFR3DisasInstrEx), &g_aArgsDBGFR3DisasInstrEx[0], RT_ELEMENTS(g_aArgsDBGFR3DisasInstrEx), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1213 { "DBGFR3DisasInstrCurrentLogInternal", VMM_FN(DBGFR3DisasInstrCurrentLogInternal), &g_aArgsDBGFR3DisasInstrCurrentLogInternal[0], RT_ELEMENTS(g_aArgsDBGFR3DisasInstrCurrentLogInternal),REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1214 { "DBGFR3Info", VMM_FN(DBGFR3Info), &g_aArgsDBGFR3Info[0], RT_ELEMENTS(g_aArgsDBGFR3Info), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1215 { "DBGFR3InfoLogRelHlp", VMM_FN(DBGFR3InfoLogRelHlp), NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1216 { "DBGFR3AsSymbolByAddr", VMM_FN(DBGFR3AsSymbolByAddr), &g_aArgsDBGFR3AsSymbolByAddr[0], RT_ELEMENTS(g_aArgsDBGFR3AsSymbolByAddr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1217 { "DBGFR3AddrFromFlat", VMM_FN(DBGFR3AddrFromFlat), &g_aArgsDBGFR3AddrFromFlat[0], RT_ELEMENTS(g_aArgsDBGFR3AddrFromFlat), REMFNDESC_FLAGS_RET_INT, sizeof(PDBGFADDRESS), NULL },
1218 { "DISInstr", VMM_FN(DISInstr), &g_aArgsDISInstr[0], RT_ELEMENTS(g_aArgsDISInstr), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1219 { "EMR3FatalError", VMM_FN(EMR3FatalError), &g_aArgsEMR3FatalError[0], RT_ELEMENTS(g_aArgsEMR3FatalError), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1220 { "EMRemLock", VMM_FN(EMRemLock), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1221 { "EMRemUnlock", VMM_FN(EMRemUnlock), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1222 { "EMRemIsLockOwner", VMM_FN(EMRemIsLockOwner), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, sizeof(bool), NULL },
1223 { "HWACCMR3CanExecuteGuest", VMM_FN(HWACCMR3CanExecuteGuest), &g_aArgsHWACCMR3CanExecuteGuest[0], RT_ELEMENTS(g_aArgsHWACCMR3CanExecuteGuest), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1224 { "IOMIOPortRead", VMM_FN(IOMIOPortRead), &g_aArgsIOMIOPortRead[0], RT_ELEMENTS(g_aArgsIOMIOPortRead), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1225 { "IOMIOPortWrite", VMM_FN(IOMIOPortWrite), &g_aArgsIOMIOPortWrite[0], RT_ELEMENTS(g_aArgsIOMIOPortWrite), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1226 { "IOMMMIORead", VMM_FN(IOMMMIORead), &g_aArgsIOMMMIORead[0], RT_ELEMENTS(g_aArgsIOMMMIORead), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1227 { "IOMMMIOWrite", VMM_FN(IOMMMIOWrite), &g_aArgsIOMMMIOWrite[0], RT_ELEMENTS(g_aArgsIOMMMIOWrite), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1228 { "MMR3HeapAlloc", VMM_FN(MMR3HeapAlloc), &g_aArgsMMR3HeapAlloc[0], RT_ELEMENTS(g_aArgsMMR3HeapAlloc), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1229 { "MMR3HeapAllocZ", VMM_FN(MMR3HeapAllocZ), &g_aArgsMMR3HeapAllocZ[0], RT_ELEMENTS(g_aArgsMMR3HeapAllocZ), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1230 { "MMR3PhysGetRamSize", VMM_FN(MMR3PhysGetRamSize), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },
1231 { "PATMIsPatchGCAddr", VMM_FN(PATMIsPatchGCAddr), &g_aArgsPATMIsPatchGCAddr[0], RT_ELEMENTS(g_aArgsPATMIsPatchGCAddr), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1232 { "PATMR3QueryOpcode", VMM_FN(PATMR3QueryOpcode), &g_aArgsPATMR3QueryOpcode[0], RT_ELEMENTS(g_aArgsPATMR3QueryOpcode), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1233 { "PATMR3QueryPatchMemGC", VMM_FN(PATMR3QueryPatchMemGC), &g_aArgsPATMR3QueryPatchMem[0], RT_ELEMENTS(g_aArgsPATMR3QueryPatchMem), REMFNDESC_FLAGS_RET_INT, sizeof(RTGCPTR), NULL },
1234 { "PATMR3QueryPatchMemHC", VMM_FN(PATMR3QueryPatchMemHC), &g_aArgsPATMR3QueryPatchMem[0], RT_ELEMENTS(g_aArgsPATMR3QueryPatchMem), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1235# ifdef VBOX_WITH_VMI
1236 { "PARAVIsBiosCall", VMM_FN(PARAVIsBiosCall), &g_aArgsPARAVIsBiosCall[0], RT_ELEMENTS(g_aArgsPARAVIsBiosCall), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1237# endif
1238 { "PDMApicGetBase", VMM_FN(PDMApicGetBase), &g_aArgsPDMApicGetBase[0], RT_ELEMENTS(g_aArgsPDMApicGetBase), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1239 { "PDMApicGetTPR", VMM_FN(PDMApicGetTPR), &g_aArgsPDMApicGetTPR[0], RT_ELEMENTS(g_aArgsPDMApicGetTPR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1240 { "PDMApicSetBase", VMM_FN(PDMApicSetBase), &g_aArgsPDMApicSetBase[0], RT_ELEMENTS(g_aArgsPDMApicSetBase), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1241 { "PDMApicSetTPR", VMM_FN(PDMApicSetTPR), &g_aArgsPDMApicSetTPR[0], RT_ELEMENTS(g_aArgsPDMApicSetTPR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1242 { "PDMApicWriteMSR", VMM_FN(PDMApicWriteMSR), &g_aArgsPDMApicWriteMSR[0], RT_ELEMENTS(g_aArgsPDMApicWriteMSR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1243 { "PDMApicReadMSR", VMM_FN(PDMApicReadMSR), &g_aArgsPDMApicReadMSR[0], RT_ELEMENTS(g_aArgsPDMApicReadMSR), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1244 { "PDMR3DmaRun", VMM_FN(PDMR3DmaRun), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1245 { "PDMR3CritSectInit", VMM_FN(PDMR3CritSectInit), &g_aArgsPDMR3CritSectInit[0], RT_ELEMENTS(g_aArgsPDMR3CritSectInit), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1246 { "PDMCritSectEnter", VMM_FN(PDMCritSectEnter), &g_aArgsPDMCritSectEnter[0], RT_ELEMENTS(g_aArgsPDMCritSectEnter), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1247 { "PDMCritSectLeave", VMM_FN(PDMCritSectLeave), &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1248# ifdef VBOX_STRICT
1249 { "PDMCritSectEnterDebug", VMM_FN(PDMCritSectEnterDebug), &g_aArgsPDMCritSectEnterDebug[0], RT_ELEMENTS(g_aArgsPDMCritSectEnterDebug), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1250# endif
1251 { "PDMGetInterrupt", VMM_FN(PDMGetInterrupt), &g_aArgsPDMGetInterrupt[0], RT_ELEMENTS(g_aArgsPDMGetInterrupt), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1252 { "PDMIsaSetIrq", VMM_FN(PDMIsaSetIrq), &g_aArgsPDMIsaSetIrq[0], RT_ELEMENTS(g_aArgsPDMIsaSetIrq), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1253 { "PGMGetGuestMode", VMM_FN(PGMGetGuestMode), &g_aArgsPGMGetGuestMode[0], RT_ELEMENTS(g_aArgsPGMGetGuestMode), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1254 { "PGMGstGetPage", VMM_FN(PGMGstGetPage), &g_aArgsPGMGstGetPage[0], RT_ELEMENTS(g_aArgsPGMGstGetPage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1255 { "PGMInvalidatePage", VMM_FN(PGMInvalidatePage), &g_aArgsPGMInvalidatePage[0], RT_ELEMENTS(g_aArgsPGMInvalidatePage), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1256 { "PGMPhysIsGCPhysValid", VMM_FN(PGMPhysIsGCPhysValid), &g_aArgsPGMPhysIsGCPhysValid[0], RT_ELEMENTS(g_aArgsPGMPhysIsGCPhysValid), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1257 { "PGMPhysIsA20Enabled", VMM_FN(PGMPhysIsA20Enabled), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1258 { "PGMPhysRead", VMM_FN(PGMPhysRead), &g_aArgsPGMPhysRead[0], RT_ELEMENTS(g_aArgsPGMPhysRead), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1259 { "PGMPhysSimpleReadGCPtr", VMM_FN(PGMPhysSimpleReadGCPtr), &g_aArgsPGMPhysSimpleReadGCPtr[0], RT_ELEMENTS(g_aArgsPGMPhysSimpleReadGCPtr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1260 { "PGMPhysWrite", VMM_FN(PGMPhysWrite), &g_aArgsPGMPhysWrite[0], RT_ELEMENTS(g_aArgsPGMPhysWrite), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1261 { "PGMChangeMode", VMM_FN(PGMChangeMode), &g_aArgsPGMChangeMode[0], RT_ELEMENTS(g_aArgsPGMChangeMode), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1262 { "PGMFlushTLB", VMM_FN(PGMFlushTLB), &g_aArgsPGMFlushTLB[0], RT_ELEMENTS(g_aArgsPGMFlushTLB), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1263 { "PGMR3PhysReadU8", VMM_FN(PGMR3PhysReadU8), &g_aArgsPGMR3PhysReadUxx[0], RT_ELEMENTS(g_aArgsPGMR3PhysReadUxx), REMFNDESC_FLAGS_RET_INT, sizeof(uint8_t), NULL },
1264 { "PGMR3PhysReadU16", VMM_FN(PGMR3PhysReadU16), &g_aArgsPGMR3PhysReadUxx[0], RT_ELEMENTS(g_aArgsPGMR3PhysReadUxx), REMFNDESC_FLAGS_RET_INT, sizeof(uint16_t), NULL },
1265 { "PGMR3PhysReadU32", VMM_FN(PGMR3PhysReadU32), &g_aArgsPGMR3PhysReadUxx[0], RT_ELEMENTS(g_aArgsPGMR3PhysReadUxx), REMFNDESC_FLAGS_RET_INT, sizeof(uint32_t), NULL },
1266 { "PGMR3PhysReadU64", VMM_FN(PGMR3PhysReadU64), &g_aArgsPGMR3PhysReadUxx[0], RT_ELEMENTS(g_aArgsPGMR3PhysReadUxx), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },
1267 { "PGMR3PhysWriteU8", VMM_FN(PGMR3PhysWriteU8), &g_aArgsPGMR3PhysWriteU8[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU8), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1268 { "PGMR3PhysWriteU16", VMM_FN(PGMR3PhysWriteU16), &g_aArgsPGMR3PhysWriteU16[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU16), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1269 { "PGMR3PhysWriteU32", VMM_FN(PGMR3PhysWriteU32), &g_aArgsPGMR3PhysWriteU32[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1270 { "PGMR3PhysWriteU64", VMM_FN(PGMR3PhysWriteU64), &g_aArgsPGMR3PhysWriteU64[0], RT_ELEMENTS(g_aArgsPGMR3PhysWriteU32), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1271 { "PGMR3PhysTlbGCPhys2Ptr", VMM_FN(PGMR3PhysTlbGCPhys2Ptr), &g_aArgsPGMR3PhysTlbGCPhys2Ptr[0], RT_ELEMENTS(g_aArgsPGMR3PhysTlbGCPhys2Ptr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1272 { "PGMIsLockOwner", VMM_FN(PGMIsLockOwner), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1273 { "SSMR3GetGCPtr", VMM_FN(SSMR3GetGCPtr), &g_aArgsSSMR3GetGCPtr[0], RT_ELEMENTS(g_aArgsSSMR3GetGCPtr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1274 { "SSMR3GetMem", VMM_FN(SSMR3GetMem), &g_aArgsSSMR3GetMem[0], RT_ELEMENTS(g_aArgsSSMR3GetMem), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1275 { "SSMR3GetU32", VMM_FN(SSMR3GetU32), &g_aArgsSSMR3GetU32[0], RT_ELEMENTS(g_aArgsSSMR3GetU32), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1276 { "SSMR3GetUInt", VMM_FN(SSMR3GetUInt), &g_aArgsSSMR3GetUInt[0], RT_ELEMENTS(g_aArgsSSMR3GetUInt), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1277 { "SSMR3PutGCPtr", VMM_FN(SSMR3PutGCPtr), &g_aArgsSSMR3PutGCPtr[0], RT_ELEMENTS(g_aArgsSSMR3PutGCPtr), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1278 { "SSMR3PutMem", VMM_FN(SSMR3PutMem), &g_aArgsSSMR3PutMem[0], RT_ELEMENTS(g_aArgsSSMR3PutMem), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1279 { "SSMR3PutU32", VMM_FN(SSMR3PutU32), &g_aArgsSSMR3PutU32[0], RT_ELEMENTS(g_aArgsSSMR3PutU32), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1280 { "SSMR3PutUInt", VMM_FN(SSMR3PutUInt), &g_aArgsSSMR3PutUInt[0], RT_ELEMENTS(g_aArgsSSMR3PutUInt), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1281 { "SSMR3RegisterInternal", VMM_FN(SSMR3RegisterInternal), &g_aArgsSSMR3RegisterInternal[0], RT_ELEMENTS(g_aArgsSSMR3RegisterInternal), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1282 { "STAMR3Register", VMM_FN(STAMR3Register), &g_aArgsSTAMR3Register[0], RT_ELEMENTS(g_aArgsSTAMR3Register), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1283 { "STAMR3Deregister", VMM_FN(STAMR3Deregister), &g_aArgsSTAMR3Deregister[0], RT_ELEMENTS(g_aArgsSTAMR3Deregister), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1284 { "TMCpuTickGet", VMM_FN(TMCpuTickGet), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(uint64_t), NULL },
1285 { "TMR3NotifySuspend", VMM_FN(TMR3NotifySuspend), &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1286 { "TMR3NotifyResume", VMM_FN(TMR3NotifyResume), &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1287 { "TMNotifyEndOfExecution", VMM_FN(TMNotifyEndOfExecution), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1288 { "TMNotifyStartOfExecution", VMM_FN(TMNotifyStartOfExecution), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1289 { "TMTimerPollBool", VMM_FN(TMTimerPollBool), &g_aArgsVMandVMCPU[0], RT_ELEMENTS(g_aArgsVMandVMCPU), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1290 { "TMR3TimerQueuesDo", VMM_FN(TMR3TimerQueuesDo), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1291 { "TRPMAssertTrap", VMM_FN(TRPMAssertTrap), &g_aArgsTRPMAssertTrap[0], RT_ELEMENTS(g_aArgsTRPMAssertTrap), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1292 { "TRPMGetErrorCode", VMM_FN(TRPMGetErrorCode), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(RTGCUINT), NULL },
1293 { "TRPMGetFaultAddress", VMM_FN(TRPMGetFaultAddress), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(RTGCUINTPTR),NULL },
1294 { "TRPMQueryTrap", VMM_FN(TRPMQueryTrap), &g_aArgsTRPMQueryTrap[0], RT_ELEMENTS(g_aArgsTRPMQueryTrap), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1295 { "TRPMResetTrap", VMM_FN(TRPMResetTrap), &g_aArgsVMCPU[0], RT_ELEMENTS(g_aArgsVMCPU), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1296 { "TRPMSetErrorCode", VMM_FN(TRPMSetErrorCode), &g_aArgsTRPMSetErrorCode[0], RT_ELEMENTS(g_aArgsTRPMSetErrorCode), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1297 { "TRPMSetFaultAddress", VMM_FN(TRPMSetFaultAddress), &g_aArgsTRPMSetFaultAddress[0], RT_ELEMENTS(g_aArgsTRPMSetFaultAddress), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1298 { "VMMGetCpu", VMM_FN(VMMGetCpu), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(PVMCPU), NULL },
1299 { "VMR3ReqCallWait", VMM_FN(VMR3ReqCallWait), &g_aArgsVMR3ReqCallWait[0], RT_ELEMENTS(g_aArgsVMR3ReqCallWait), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1300 { "VMR3ReqFree", VMM_FN(VMR3ReqFree), &g_aArgsVMR3ReqFree[0], RT_ELEMENTS(g_aArgsVMR3ReqFree), REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_ELLIPSIS, sizeof(int), NULL },
1301 { "VMR3GetVMCPUId", VMM_FN(VMR3GetVMCPUId), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1302 { "VMR3GetVMCPUNativeThread", VMM_FN(VMR3GetVMCPUNativeThread), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1303 { "EMInterpretInstructionCPUEx", VMM_FN(EMInterpretInstructionCPUEx), &g_aArgsEMInterpretInstructionCPUEx[0], RT_ELEMENTS(g_aArgsEMInterpretInstructionCPUEx), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1304// { "", VMM_FN(), &g_aArgsVM[0], RT_ELEMENTS(g_aArgsVM), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1305};
1306
1307
1308/**
1309 * Descriptors for the functions imported from VBoxRT.
1310 */
1311static REMFNDESC g_aRTImports[] =
1312{
1313 { "RTAssertMsg1", (void *)(uintptr_t)&RTAssertMsg1, &g_aArgsRTAssertMsg1[0], RT_ELEMENTS(g_aArgsRTAssertMsg1), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1314 { "RTAssertMsg1Weak", (void *)(uintptr_t)&RTAssertMsg1Weak, &g_aArgsRTAssertMsg1[0], RT_ELEMENTS(g_aArgsRTAssertMsg1), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1315 { "RTAssertMsg2", (void *)(uintptr_t)&RTAssertMsg2, &g_aArgsRTAssertMsg2[0], RT_ELEMENTS(g_aArgsRTAssertMsg2), REMFNDESC_FLAGS_RET_VOID | REMFNDESC_FLAGS_ELLIPSIS, 0, NULL },
1316 { "RTAssertMsg2V", (void *)(uintptr_t)&RTAssertMsg2V, &g_aArgsRTAssertMsg2V[0], RT_ELEMENTS(g_aArgsRTAssertMsg2V), REMFNDESC_FLAGS_RET_VOID | REMFNDESC_FLAGS_VALIST, 0, NULL },
1317 { "RTAssertMsg2Weak", (void *)(uintptr_t)&RTAssertMsg2Weak, &g_aArgsRTAssertMsg2[0], RT_ELEMENTS(g_aArgsRTAssertMsg2), REMFNDESC_FLAGS_RET_VOID | REMFNDESC_FLAGS_ELLIPSIS, 0, NULL },
1318 { "RTAssertShouldPanic", (void *)(uintptr_t)&RTAssertShouldPanic, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(bool), NULL },
1319 { "RTLogDefaultInstance", (void *)(uintptr_t)&RTLogDefaultInstance, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(PRTLOGGER), NULL },
1320 { "RTLogRelDefaultInstance", (void *)(uintptr_t)&RTLogRelDefaultInstance, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(PRTLOGGER), NULL },
1321 { "RTLogFlags", (void *)(uintptr_t)&RTLogFlags, &g_aArgsRTLogFlags[0], RT_ELEMENTS(g_aArgsRTLogFlags), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1322 { "RTLogFlush", (void *)(uintptr_t)&RTLogFlush, &g_aArgsRTLogFlush[0], RT_ELEMENTS(g_aArgsRTLogFlush), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1323 { "RTLogLoggerEx", (void *)(uintptr_t)&RTLogLoggerEx, &g_aArgsRTLogLoggerEx[0], RT_ELEMENTS(g_aArgsRTLogLoggerEx), REMFNDESC_FLAGS_RET_VOID | REMFNDESC_FLAGS_ELLIPSIS, 0, NULL },
1324 { "RTLogLoggerExV", (void *)(uintptr_t)&RTLogLoggerExV, &g_aArgsRTLogLoggerExV[0], RT_ELEMENTS(g_aArgsRTLogLoggerExV), REMFNDESC_FLAGS_RET_VOID | REMFNDESC_FLAGS_VALIST, 0, NULL },
1325 { "RTLogPrintf", (void *)(uintptr_t)&RTLogPrintf, &g_aArgsRTLogPrintf[0], RT_ELEMENTS(g_aArgsRTLogPrintf), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1326 { "RTLogRelPrintf", (void *)(uintptr_t)&RTLogRelPrintf, &g_aArgsRTLogPrintf[0], RT_ELEMENTS(g_aArgsRTLogPrintf), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1327 { "RTMemAlloc", (void *)(uintptr_t)&RTMemAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1328 { "RTMemAllocZ", (void *)(uintptr_t)&RTMemAllocZ, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1329 { "RTMemRealloc", (void *)(uintptr_t)&RTMemRealloc, &g_aArgsRTMemRealloc[0], RT_ELEMENTS(g_aArgsRTMemRealloc), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1330 { "RTMemExecAlloc", (void *)(uintptr_t)&RTMemExecAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1331 { "RTMemExecFree", (void *)(uintptr_t)&RTMemExecFree, &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1332 { "RTMemFree", (void *)(uintptr_t)&RTMemFree, &g_aArgsPTR[0], RT_ELEMENTS(g_aArgsPTR), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1333 { "RTMemPageAlloc", (void *)(uintptr_t)&RTMemPageAlloc, &g_aArgsSIZE_T[0], RT_ELEMENTS(g_aArgsSIZE_T), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1334 { "RTMemPageFree", (void *)(uintptr_t)&RTMemPageFree, &g_aArgsRTMemProtect[0], RT_ELEMENTS(g_aArgsRTMemProtect), REMFNDESC_FLAGS_RET_VOID, 0, NULL },
1335 { "RTMemProtect", (void *)(uintptr_t)&RTMemProtect, &g_aArgsRTMemProtect[0], RT_ELEMENTS(g_aArgsRTMemProtect), REMFNDESC_FLAGS_RET_INT, sizeof(int), NULL },
1336 { "RTStrPrintf", (void *)(uintptr_t)&RTStrPrintf, &g_aArgsRTStrPrintf[0], RT_ELEMENTS(g_aArgsRTStrPrintf), REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_ELLIPSIS, sizeof(size_t), NULL },
1337 { "RTStrPrintfV", (void *)(uintptr_t)&RTStrPrintfV, &g_aArgsRTStrPrintfV[0], RT_ELEMENTS(g_aArgsRTStrPrintfV), REMFNDESC_FLAGS_RET_INT | REMFNDESC_FLAGS_VALIST, sizeof(size_t), NULL },
1338 { "RTThreadSelf", (void *)(uintptr_t)&RTThreadSelf, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(RTTHREAD), NULL },
1339 { "RTThreadNativeSelf", (void *)(uintptr_t)&RTThreadNativeSelf, NULL, 0, REMFNDESC_FLAGS_RET_INT, sizeof(RTNATIVETHREAD), NULL },
1340 { "RTLockValidatorWriteLockGetCount", (void *)(uintptr_t)&RTLockValidatorWriteLockGetCount, &g_aArgsThread[0], 0, REMFNDESC_FLAGS_RET_INT, sizeof(int32_t), NULL },
1341};
1342
1343
1344/**
1345 * Descriptors for the functions imported from VBoxRT.
1346 */
1347static REMFNDESC g_aCRTImports[] =
1348{
1349 { "memcpy", (void *)(uintptr_t)&memcpy, &g_aArgsmemcpy[0], RT_ELEMENTS(g_aArgsmemcpy), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL },
1350 { "memset", (void *)(uintptr_t)&memset, &g_aArgsmemset[0], RT_ELEMENTS(g_aArgsmemset), REMFNDESC_FLAGS_RET_INT, sizeof(void *), NULL }
1351/*
1352floor floor
1353memcpy memcpy
1354sqrt sqrt
1355sqrtf sqrtf
1356*/
1357};
1358
1359
1360# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE)
1361/** LIFO of read-write-executable memory chunks used for wrappers. */
1362static PREMEXECMEM g_pExecMemHead;
1363# endif
1364# endif /* !VBOX_USE_BITNESS_SELECTOR */
1365
1366
1367
1368/*******************************************************************************
1369* Internal Functions *
1370*******************************************************************************/
1371# ifndef VBOX_USE_BITNESS_SELECTOR
1372static int remGenerateExportGlue(PRTUINTPTR pValue, PCREMFNDESC pDesc);
1373
1374# ifdef USE_REM_CALLING_CONVENTION_GLUE
1375DECLASM(int) WrapGCC2MSC0Int(void); DECLASM(int) WrapGCC2MSC0Int_EndProc(void);
1376DECLASM(int) WrapGCC2MSC1Int(void); DECLASM(int) WrapGCC2MSC1Int_EndProc(void);
1377DECLASM(int) WrapGCC2MSC2Int(void); DECLASM(int) WrapGCC2MSC2Int_EndProc(void);
1378DECLASM(int) WrapGCC2MSC3Int(void); DECLASM(int) WrapGCC2MSC3Int_EndProc(void);
1379DECLASM(int) WrapGCC2MSC4Int(void); DECLASM(int) WrapGCC2MSC4Int_EndProc(void);
1380DECLASM(int) WrapGCC2MSC5Int(void); DECLASM(int) WrapGCC2MSC5Int_EndProc(void);
1381DECLASM(int) WrapGCC2MSC6Int(void); DECLASM(int) WrapGCC2MSC6Int_EndProc(void);
1382DECLASM(int) WrapGCC2MSC7Int(void); DECLASM(int) WrapGCC2MSC7Int_EndProc(void);
1383DECLASM(int) WrapGCC2MSC8Int(void); DECLASM(int) WrapGCC2MSC8Int_EndProc(void);
1384DECLASM(int) WrapGCC2MSC9Int(void); DECLASM(int) WrapGCC2MSC9Int_EndProc(void);
1385DECLASM(int) WrapGCC2MSC10Int(void); DECLASM(int) WrapGCC2MSC10Int_EndProc(void);
1386DECLASM(int) WrapGCC2MSC11Int(void); DECLASM(int) WrapGCC2MSC11Int_EndProc(void);
1387DECLASM(int) WrapGCC2MSC12Int(void); DECLASM(int) WrapGCC2MSC12Int_EndProc(void);
1388DECLASM(int) WrapGCC2MSCVariadictInt(void); DECLASM(int) WrapGCC2MSCVariadictInt_EndProc(void);
1389DECLASM(int) WrapGCC2MSC_SSMR3RegisterInternal(void); DECLASM(int) WrapGCC2MSC_SSMR3RegisterInternal_EndProc(void);
1390
1391DECLASM(int) WrapMSC2GCC0Int(void); DECLASM(int) WrapMSC2GCC0Int_EndProc(void);
1392DECLASM(int) WrapMSC2GCC1Int(void); DECLASM(int) WrapMSC2GCC1Int_EndProc(void);
1393DECLASM(int) WrapMSC2GCC2Int(void); DECLASM(int) WrapMSC2GCC2Int_EndProc(void);
1394DECLASM(int) WrapMSC2GCC3Int(void); DECLASM(int) WrapMSC2GCC3Int_EndProc(void);
1395DECLASM(int) WrapMSC2GCC4Int(void); DECLASM(int) WrapMSC2GCC4Int_EndProc(void);
1396DECLASM(int) WrapMSC2GCC5Int(void); DECLASM(int) WrapMSC2GCC5Int_EndProc(void);
1397DECLASM(int) WrapMSC2GCC6Int(void); DECLASM(int) WrapMSC2GCC6Int_EndProc(void);
1398DECLASM(int) WrapMSC2GCC7Int(void); DECLASM(int) WrapMSC2GCC7Int_EndProc(void);
1399DECLASM(int) WrapMSC2GCC8Int(void); DECLASM(int) WrapMSC2GCC8Int_EndProc(void);
1400DECLASM(int) WrapMSC2GCC9Int(void); DECLASM(int) WrapMSC2GCC9Int_EndProc(void);
1401# endif
1402
1403
1404# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE)
1405/**
1406 * Allocates a block of memory for glue code.
1407 *
1408 * The returned memory is padded with INT3s.
1409 *
1410 * @returns Pointer to the allocated memory.
1411 * @param The amount of memory to allocate.
1412 */
1413static void *remAllocGlue(size_t cb)
1414{
1415 PREMEXECMEM pCur = g_pExecMemHead;
1416 uint32_t cbAligned = (uint32_t)RT_ALIGN_32(cb, 32);
1417 while (pCur)
1418 {
1419 if (pCur->cb - pCur->off >= cbAligned)
1420 {
1421 void *pv = (uint8_t *)pCur + pCur->off;
1422 pCur->off += cbAligned;
1423 return memset(pv, 0xcc, cbAligned);
1424 }
1425 pCur = pCur->pNext;
1426 }
1427
1428 /* add a new chunk */
1429 AssertReturn(_64K - RT_ALIGN_Z(sizeof(*pCur), 32) > cbAligned, NULL);
1430 pCur = (PREMEXECMEM)RTMemExecAlloc(_64K);
1431 AssertReturn(pCur, NULL);
1432 pCur->cb = _64K;
1433 pCur->off = RT_ALIGN_32(sizeof(*pCur), 32) + cbAligned;
1434 pCur->pNext = g_pExecMemHead;
1435 g_pExecMemHead = pCur;
1436 return memset((uint8_t *)pCur + RT_ALIGN_Z(sizeof(*pCur), 32), 0xcc, cbAligned);
1437}
1438# endif /* USE_REM_CALLING_CONVENTION_GLUE || USE_REM_IMPORT_JUMP_GLUE */
1439
1440
1441# ifdef USE_REM_CALLING_CONVENTION_GLUE
1442/**
1443 * Checks if a function is all straight forward integers.
1444 *
1445 * @returns True if it's simple, false if it's bothersome.
1446 * @param pDesc The function descriptor.
1447 */
1448static bool remIsFunctionAllInts(PCREMFNDESC pDesc)
1449{
1450 if ( ( (pDesc->fFlags & REMFNDESC_FLAGS_RET_TYPE_MASK) != REMFNDESC_FLAGS_RET_INT
1451 || pDesc->cbReturn > sizeof(uint64_t))
1452 && (pDesc->fFlags & REMFNDESC_FLAGS_RET_TYPE_MASK) != REMFNDESC_FLAGS_RET_VOID)
1453 return false;
1454 unsigned i = pDesc->cParams;
1455 while (i-- > 0)
1456 switch (pDesc->paParams[i].fFlags & REMPARMDESC_FLAGS_TYPE_MASK)
1457 {
1458 case REMPARMDESC_FLAGS_INT:
1459 case REMPARMDESC_FLAGS_GCPTR:
1460 case REMPARMDESC_FLAGS_GCPHYS:
1461 case REMPARMDESC_FLAGS_HCPHYS:
1462 break;
1463
1464 default:
1465 AssertReleaseMsgFailed(("Invalid param flags %#x for #%d of %s!\n", pDesc->paParams[i].fFlags, i, pDesc->pszName));
1466 case REMPARMDESC_FLAGS_VALIST:
1467 case REMPARMDESC_FLAGS_ELLIPSIS:
1468 case REMPARMDESC_FLAGS_FLOAT:
1469 case REMPARMDESC_FLAGS_STRUCT:
1470 case REMPARMDESC_FLAGS_PFN:
1471 return false;
1472 }
1473 return true;
1474}
1475
1476
1477/**
1478 * Checks if the function has an ellipsis (...) argument.
1479 *
1480 * @returns true if it has an ellipsis, otherwise false.
1481 * @param pDesc The function descriptor.
1482 */
1483static bool remHasFunctionEllipsis(PCREMFNDESC pDesc)
1484{
1485 unsigned i = pDesc->cParams;
1486 while (i-- > 0)
1487 if ((pDesc->paParams[i].fFlags & REMPARMDESC_FLAGS_TYPE_MASK) == REMPARMDESC_FLAGS_ELLIPSIS)
1488 return true;
1489 return false;
1490}
1491
1492
1493/**
1494 * Checks if the function uses floating point (FP) arguments or return value.
1495 *
1496 * @returns true if it uses floating point, otherwise false.
1497 * @param pDesc The function descriptor.
1498 */
1499static bool remIsFunctionUsingFP(PCREMFNDESC pDesc)
1500{
1501 if ((pDesc->fFlags & REMFNDESC_FLAGS_RET_TYPE_MASK) == REMFNDESC_FLAGS_RET_FLOAT)
1502 return true;
1503 unsigned i = pDesc->cParams;
1504 while (i-- > 0)
1505 if ((pDesc->paParams[i].fFlags & REMPARMDESC_FLAGS_TYPE_MASK) == REMPARMDESC_FLAGS_FLOAT)
1506 return true;
1507 return false;
1508}
1509
1510
1511/** @name The export and import fixups.
1512 * @{ */
1513# define REM_FIXUP_32_REAL_STUFF UINT32_C(0xdeadbeef)
1514# define REM_FIXUP_64_REAL_STUFF UINT64_C(0xdeadf00df00ddead)
1515# define REM_FIXUP_64_DESC UINT64_C(0xdead00010001dead)
1516# define REM_FIXUP_64_LOG_ENTRY UINT64_C(0xdead00020002dead)
1517# define REM_FIXUP_64_LOG_EXIT UINT64_C(0xdead00030003dead)
1518# define REM_FIXUP_64_WRAP_GCC_CB UINT64_C(0xdead00040004dead)
1519/** @} */
1520
1521
1522/**
1523 * Entry logger function.
1524 *
1525 * @param pDesc The description.
1526 */
1527DECLASM(void) remLogEntry(PCREMFNDESC pDesc)
1528{
1529 RTPrintf("calling %s\n", pDesc->pszName);
1530}
1531
1532
1533/**
1534 * Exit logger function.
1535 *
1536 * @param pDesc The description.
1537 * @param pvRet The return code.
1538 */
1539DECLASM(void) remLogExit(PCREMFNDESC pDesc, void *pvRet)
1540{
1541 RTPrintf("returning %p from %s\n", pvRet, pDesc->pszName);
1542}
1543
1544
1545/**
1546 * Creates a wrapper for the specified callback function at run time.
1547 *
1548 * @param pDesc The function descriptor.
1549 * @param pValue Upon entry *pValue contains the address of the function to be wrapped.
1550 * Upon return *pValue contains the address of the wrapper glue function.
1551 * @param iParam The parameter index in the function descriptor (0 based).
1552 * If UINT32_MAX pDesc is the descriptor for *pValue.
1553 */
1554DECLASM(void) remWrapGCCCallback(PCREMFNDESC pDesc, PRTUINTPTR pValue, uint32_t iParam)
1555{
1556 AssertPtr(pDesc);
1557 AssertPtr(pValue);
1558
1559 /*
1560 * Simple?
1561 */
1562 if (!*pValue)
1563 return;
1564
1565 /*
1566 * Locate the right function descriptor.
1567 */
1568 if (iParam != UINT32_MAX)
1569 {
1570 AssertRelease(iParam < pDesc->cParams);
1571 pDesc = (PCREMFNDESC)pDesc->paParams[iParam].pvExtra;
1572 AssertPtr(pDesc);
1573 }
1574
1575 /*
1576 * When we get serious, here is where to insert the hash table lookup.
1577 */
1578
1579 /*
1580 * Create a new glue patch.
1581 */
1582# ifdef RT_OS_WINDOWS
1583 int rc = remGenerateExportGlue(pValue, pDesc);
1584# else
1585# error "port me"
1586# endif
1587 AssertReleaseRC(rc);
1588
1589 /*
1590 * Add it to the hash (later)
1591 */
1592}
1593
1594
1595/**
1596 * Fixes export glue.
1597 *
1598 * @param pvGlue The glue code.
1599 * @param cb The size of the glue code.
1600 * @param pvExport The address of the export we're wrapping.
1601 * @param pDesc The export descriptor.
1602 */
1603static void remGenerateExportGlueFixup(void *pvGlue, size_t cb, uintptr_t uExport, PCREMFNDESC pDesc)
1604{
1605 union
1606 {
1607 uint8_t *pu8;
1608 int32_t *pi32;
1609 uint32_t *pu32;
1610 uint64_t *pu64;
1611 void *pv;
1612 } u;
1613 u.pv = pvGlue;
1614
1615 while (cb >= 4)
1616 {
1617 /** @todo add defines for the fixup constants... */
1618 if (*u.pu32 == REM_FIXUP_32_REAL_STUFF)
1619 {
1620 /* 32-bit rel jmp/call to real export. */
1621 *u.pi32 = uExport - (uintptr_t)(u.pi32 + 1);
1622 Assert((uintptr_t)(u.pi32 + 1) + *u.pi32 == uExport);
1623 u.pi32++;
1624 cb -= 4;
1625 continue;
1626 }
1627 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_REAL_STUFF)
1628 {
1629 /* 64-bit address to the real export. */
1630 *u.pu64++ = uExport;
1631 cb -= 8;
1632 continue;
1633 }
1634 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_DESC)
1635 {
1636 /* 64-bit address to the descriptor. */
1637 *u.pu64++ = (uintptr_t)pDesc;
1638 cb -= 8;
1639 continue;
1640 }
1641 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_WRAP_GCC_CB)
1642 {
1643 /* 64-bit address to the entry logger function. */
1644 *u.pu64++ = (uintptr_t)remWrapGCCCallback;
1645 cb -= 8;
1646 continue;
1647 }
1648 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_LOG_ENTRY)
1649 {
1650 /* 64-bit address to the entry logger function. */
1651 *u.pu64++ = (uintptr_t)remLogEntry;
1652 cb -= 8;
1653 continue;
1654 }
1655 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_LOG_EXIT)
1656 {
1657 /* 64-bit address to the entry logger function. */
1658 *u.pu64++ = (uintptr_t)remLogExit;
1659 cb -= 8;
1660 continue;
1661 }
1662
1663 /* move on. */
1664 u.pu8++;
1665 cb--;
1666 }
1667}
1668
1669
1670/**
1671 * Fixes import glue.
1672 *
1673 * @param pvGlue The glue code.
1674 * @param cb The size of the glue code.
1675 * @param pDesc The import descriptor.
1676 */
1677static void remGenerateImportGlueFixup(void *pvGlue, size_t cb, PCREMFNDESC pDesc)
1678{
1679 union
1680 {
1681 uint8_t *pu8;
1682 int32_t *pi32;
1683 uint32_t *pu32;
1684 uint64_t *pu64;
1685 void *pv;
1686 } u;
1687 u.pv = pvGlue;
1688
1689 while (cb >= 4)
1690 {
1691 if (*u.pu32 == REM_FIXUP_32_REAL_STUFF)
1692 {
1693 /* 32-bit rel jmp/call to real function. */
1694 *u.pi32 = (uintptr_t)pDesc->pv - (uintptr_t)(u.pi32 + 1);
1695 Assert((uintptr_t)(u.pi32 + 1) + *u.pi32 == (uintptr_t)pDesc->pv);
1696 u.pi32++;
1697 cb -= 4;
1698 continue;
1699 }
1700 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_REAL_STUFF)
1701 {
1702 /* 64-bit address to the real function. */
1703 *u.pu64++ = (uintptr_t)pDesc->pv;
1704 cb -= 8;
1705 continue;
1706 }
1707 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_DESC)
1708 {
1709 /* 64-bit address to the descriptor. */
1710 *u.pu64++ = (uintptr_t)pDesc;
1711 cb -= 8;
1712 continue;
1713 }
1714 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_WRAP_GCC_CB)
1715 {
1716 /* 64-bit address to the entry logger function. */
1717 *u.pu64++ = (uintptr_t)remWrapGCCCallback;
1718 cb -= 8;
1719 continue;
1720 }
1721 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_LOG_ENTRY)
1722 {
1723 /* 64-bit address to the entry logger function. */
1724 *u.pu64++ = (uintptr_t)remLogEntry;
1725 cb -= 8;
1726 continue;
1727 }
1728 if (cb >= 8 && *u.pu64 == REM_FIXUP_64_LOG_EXIT)
1729 {
1730 /* 64-bit address to the entry logger function. */
1731 *u.pu64++ = (uintptr_t)remLogExit;
1732 cb -= 8;
1733 continue;
1734 }
1735
1736 /* move on. */
1737 u.pu8++;
1738 cb--;
1739 }
1740}
1741
1742# endif /* USE_REM_CALLING_CONVENTION_GLUE */
1743
1744
1745/**
1746 * Generate wrapper glue code for an export.
1747 *
1748 * This is only used on win64 when loading a 64-bit linux module. So, on other
1749 * platforms it will not do anything.
1750 *
1751 * @returns VBox status code.
1752 * @param pValue IN: Where to get the address of the function to wrap.
1753 * OUT: Where to store the glue address.
1754 * @param pDesc The export descriptor.
1755 */
1756static int remGenerateExportGlue(PRTUINTPTR pValue, PCREMFNDESC pDesc)
1757{
1758# ifdef USE_REM_CALLING_CONVENTION_GLUE
1759 uintptr_t *ppfn = (uintptr_t *)pDesc->pv;
1760
1761 uintptr_t pfn = 0; /* a little hack for the callback glue */
1762 if (!ppfn)
1763 ppfn = &pfn;
1764
1765 if (!*ppfn)
1766 {
1767 if (remIsFunctionAllInts(pDesc))
1768 {
1769 static const struct { void *pvStart, *pvEnd; } s_aTemplates[] =
1770 {
1771 { (void *)&WrapMSC2GCC0Int, (void *)&WrapMSC2GCC0Int_EndProc },
1772 { (void *)&WrapMSC2GCC1Int, (void *)&WrapMSC2GCC1Int_EndProc },
1773 { (void *)&WrapMSC2GCC2Int, (void *)&WrapMSC2GCC2Int_EndProc },
1774 { (void *)&WrapMSC2GCC3Int, (void *)&WrapMSC2GCC3Int_EndProc },
1775 { (void *)&WrapMSC2GCC4Int, (void *)&WrapMSC2GCC4Int_EndProc },
1776 { (void *)&WrapMSC2GCC5Int, (void *)&WrapMSC2GCC5Int_EndProc },
1777 { (void *)&WrapMSC2GCC6Int, (void *)&WrapMSC2GCC6Int_EndProc },
1778 { (void *)&WrapMSC2GCC7Int, (void *)&WrapMSC2GCC7Int_EndProc },
1779 { (void *)&WrapMSC2GCC8Int, (void *)&WrapMSC2GCC8Int_EndProc },
1780 { (void *)&WrapMSC2GCC9Int, (void *)&WrapMSC2GCC9Int_EndProc },
1781 };
1782 const unsigned i = pDesc->cParams;
1783 AssertReleaseMsg(i < RT_ELEMENTS(s_aTemplates), ("%d (%s)\n", i, pDesc->pszName));
1784
1785 /* duplicate the patch. */
1786 const size_t cb = (uintptr_t)s_aTemplates[i].pvEnd - (uintptr_t)s_aTemplates[i].pvStart;
1787 uint8_t *pb = (uint8_t *)remAllocGlue(cb);
1788 AssertReturn(pb, VERR_NO_MEMORY);
1789 memcpy(pb, s_aTemplates[i].pvStart, cb);
1790
1791 /* fix it up. */
1792 remGenerateExportGlueFixup(pb, cb, *pValue, pDesc);
1793 *ppfn = (uintptr_t)pb;
1794 }
1795 else
1796 {
1797 /* custom hacks - it's simpler to make assembly templates than writing a more generic code generator... */
1798 static const struct { const char *pszName; PFNRT pvStart, pvEnd; } s_aTemplates[] =
1799 {
1800 { "somefunction", (PFNRT)&WrapMSC2GCC9Int, (PFNRT)&WrapMSC2GCC9Int_EndProc },
1801 };
1802 unsigned i;
1803 for (i = 0; i < RT_ELEMENTS(s_aTemplates); i++)
1804 if (!strcmp(pDesc->pszName, s_aTemplates[i].pszName))
1805 break;
1806 AssertReleaseMsgReturn(i < RT_ELEMENTS(s_aTemplates), ("Not implemented! %s\n", pDesc->pszName), VERR_NOT_IMPLEMENTED);
1807
1808 /* duplicate the patch. */
1809 const size_t cb = (uintptr_t)s_aTemplates[i].pvEnd - (uintptr_t)s_aTemplates[i].pvStart;
1810 uint8_t *pb = (uint8_t *)remAllocGlue(cb);
1811 AssertReturn(pb, VERR_NO_MEMORY);
1812 memcpy(pb, s_aTemplates[i].pvStart, cb);
1813
1814 /* fix it up. */
1815 remGenerateExportGlueFixup(pb, cb, *pValue, pDesc);
1816 *ppfn = (uintptr_t)pb;
1817 }
1818 }
1819 *pValue = *ppfn;
1820 return VINF_SUCCESS;
1821# else /* !USE_REM_CALLING_CONVENTION_GLUE */
1822 return VINF_SUCCESS;
1823# endif /* !USE_REM_CALLING_CONVENTION_GLUE */
1824}
1825
1826
1827/**
1828 * Generate wrapper glue code for an import.
1829 *
1830 * This is only used on win64 when loading a 64-bit linux module. So, on other
1831 * platforms it will simply return the address of the imported function
1832 * without generating any glue code.
1833 *
1834 * @returns VBox status code.
1835 * @param pValue Where to store the glue address.
1836 * @param pDesc The export descriptor.
1837 */
1838static int remGenerateImportGlue(PRTUINTPTR pValue, PREMFNDESC pDesc)
1839{
1840# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE)
1841 if (!pDesc->pvWrapper)
1842 {
1843# ifdef USE_REM_CALLING_CONVENTION_GLUE
1844 if (remIsFunctionAllInts(pDesc))
1845 {
1846 static const struct { void *pvStart, *pvEnd; } s_aTemplates[] =
1847 {
1848 { (void *)&WrapGCC2MSC0Int, (void *)&WrapGCC2MSC0Int_EndProc },
1849 { (void *)&WrapGCC2MSC1Int, (void *)&WrapGCC2MSC1Int_EndProc },
1850 { (void *)&WrapGCC2MSC2Int, (void *)&WrapGCC2MSC2Int_EndProc },
1851 { (void *)&WrapGCC2MSC3Int, (void *)&WrapGCC2MSC3Int_EndProc },
1852 { (void *)&WrapGCC2MSC4Int, (void *)&WrapGCC2MSC4Int_EndProc },
1853 { (void *)&WrapGCC2MSC5Int, (void *)&WrapGCC2MSC5Int_EndProc },
1854 { (void *)&WrapGCC2MSC6Int, (void *)&WrapGCC2MSC6Int_EndProc },
1855 { (void *)&WrapGCC2MSC7Int, (void *)&WrapGCC2MSC7Int_EndProc },
1856 { (void *)&WrapGCC2MSC8Int, (void *)&WrapGCC2MSC8Int_EndProc },
1857 { (void *)&WrapGCC2MSC9Int, (void *)&WrapGCC2MSC9Int_EndProc },
1858 { (void *)&WrapGCC2MSC10Int, (void *)&WrapGCC2MSC10Int_EndProc },
1859 { (void *)&WrapGCC2MSC11Int, (void *)&WrapGCC2MSC11Int_EndProc },
1860 { (void *)&WrapGCC2MSC12Int, (void *)&WrapGCC2MSC12Int_EndProc }
1861 };
1862 const unsigned i = pDesc->cParams;
1863 AssertReleaseMsg(i < RT_ELEMENTS(s_aTemplates), ("%d (%s)\n", i, pDesc->pszName));
1864
1865 /* duplicate the patch. */
1866 const size_t cb = (uintptr_t)s_aTemplates[i].pvEnd - (uintptr_t)s_aTemplates[i].pvStart;
1867 pDesc->pvWrapper = remAllocGlue(cb);
1868 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1869 memcpy(pDesc->pvWrapper, s_aTemplates[i].pvStart, cb);
1870
1871 /* fix it up. */
1872 remGenerateImportGlueFixup((uint8_t *)pDesc->pvWrapper, cb, pDesc);
1873 }
1874 else if ( remHasFunctionEllipsis(pDesc)
1875 && !remIsFunctionUsingFP(pDesc))
1876 {
1877 /* duplicate the patch. */
1878 const size_t cb = (uintptr_t)&WrapGCC2MSCVariadictInt_EndProc - (uintptr_t)&WrapGCC2MSCVariadictInt;
1879 pDesc->pvWrapper = remAllocGlue(cb);
1880 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1881 memcpy(pDesc->pvWrapper, (void *)&WrapGCC2MSCVariadictInt, cb);
1882
1883 /* fix it up. */
1884 remGenerateImportGlueFixup((uint8_t *)pDesc->pvWrapper, cb, pDesc);
1885 }
1886 else
1887 {
1888 /* custom hacks - it's simpler to make assembly templates than writing a more generic code generator... */
1889 static const struct { const char *pszName; PFNRT pvStart, pvEnd; } s_aTemplates[] =
1890 {
1891 { "SSMR3RegisterInternal", (PFNRT)&WrapGCC2MSC_SSMR3RegisterInternal, (PFNRT)&WrapGCC2MSC_SSMR3RegisterInternal_EndProc },
1892 };
1893 unsigned i;
1894 for (i = 0; i < RT_ELEMENTS(s_aTemplates); i++)
1895 if (!strcmp(pDesc->pszName, s_aTemplates[i].pszName))
1896 break;
1897 AssertReleaseMsgReturn(i < RT_ELEMENTS(s_aTemplates), ("Not implemented! %s\n", pDesc->pszName), VERR_NOT_IMPLEMENTED);
1898
1899 /* duplicate the patch. */
1900 const size_t cb = (uintptr_t)s_aTemplates[i].pvEnd - (uintptr_t)s_aTemplates[i].pvStart;
1901 pDesc->pvWrapper = remAllocGlue(cb);
1902 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1903 memcpy(pDesc->pvWrapper, s_aTemplates[i].pvStart, cb);
1904
1905 /* fix it up. */
1906 remGenerateImportGlueFixup((uint8_t *)pDesc->pvWrapper, cb, pDesc);
1907 }
1908# else /* !USE_REM_CALLING_CONVENTION_GLUE */
1909
1910 /*
1911 * Generate a jump patch.
1912 */
1913 uint8_t *pb;
1914# ifdef RT_ARCH_AMD64
1915 pDesc->pvWrapper = pb = (uint8_t *)remAllocGlue(32);
1916 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1917 /**pb++ = 0xcc;*/
1918 *pb++ = 0xff;
1919 *pb++ = 0x24;
1920 *pb++ = 0x25;
1921 *(uint32_t *)pb = (uintptr_t)pb + 5;
1922 pb += 5;
1923 *(uint64_t *)pb = (uint64_t)pDesc->pv;
1924# else
1925 pDesc->pvWrapper = pb = (uint8_t *)remAllocGlue(8);
1926 AssertReturn(pDesc->pvWrapper, VERR_NO_MEMORY);
1927 *pb++ = 0xea;
1928 *(uint32_t *)pb = (uint32_t)pDesc->pv;
1929# endif
1930# endif /* !USE_REM_CALLING_CONVENTION_GLUE */
1931 }
1932 *pValue = (uintptr_t)pDesc->pvWrapper;
1933# else /* !USE_REM_CALLING_CONVENTION_GLUE */
1934 *pValue = (uintptr_t)pDesc->pv;
1935# endif /* !USE_REM_CALLING_CONVENTION_GLUE */
1936 return VINF_SUCCESS;
1937}
1938
1939
1940/**
1941 * Resolve an external symbol during RTLdrGetBits().
1942 *
1943 * @returns iprt status code.
1944 * @param hLdrMod The loader module handle.
1945 * @param pszModule Module name.
1946 * @param pszSymbol Symbol name, NULL if uSymbol should be used.
1947 * @param uSymbol Symbol ordinal, ~0 if pszSymbol should be used.
1948 * @param pValue Where to store the symbol value (address).
1949 * @param pvUser User argument.
1950 */
1951static DECLCALLBACK(int) remGetImport(RTLDRMOD hLdrMod, const char *pszModule, const char *pszSymbol, unsigned uSymbol, RTUINTPTR *pValue, void *pvUser)
1952{
1953 unsigned i;
1954 for (i = 0; i < RT_ELEMENTS(g_aVMMImports); i++)
1955 if (!strcmp(g_aVMMImports[i].pszName, pszSymbol))
1956 return remGenerateImportGlue(pValue, &g_aVMMImports[i]);
1957 for (i = 0; i < RT_ELEMENTS(g_aRTImports); i++)
1958 if (!strcmp(g_aRTImports[i].pszName, pszSymbol))
1959 return remGenerateImportGlue(pValue, &g_aRTImports[i]);
1960 for (i = 0; i < RT_ELEMENTS(g_aCRTImports); i++)
1961 if (!strcmp(g_aCRTImports[i].pszName, pszSymbol))
1962 return remGenerateImportGlue(pValue, &g_aCRTImports[i]);
1963 LogRel(("Missing REM Import: %s\n", pszSymbol));
1964# if 1
1965 *pValue = 0;
1966 AssertMsgFailed(("%s.%s\n", pszModule, pszSymbol));
1967 return VERR_SYMBOL_NOT_FOUND;
1968# else
1969 return remGenerateImportGlue(pValue, &g_aCRTImports[0]);
1970# endif
1971}
1972
1973/**
1974 * Loads the linux object, resolves all imports and exports.
1975 *
1976 * @returns VBox status code.
1977 */
1978static int remLoadLinuxObj(void)
1979{
1980 size_t offFilename;
1981 char szPath[RTPATH_MAX];
1982 int rc = RTPathAppPrivateArch(szPath, sizeof(szPath) - 32);
1983 AssertRCReturn(rc, rc);
1984 offFilename = strlen(szPath);
1985
1986# ifdef VBOX_WITHOUT_REM_LDR_CYCLE
1987 /*
1988 * Resolve all the VBoxVMM references.
1989 */
1990 if (g_ModVMM != NIL_RTLDRMOD)
1991 {
1992 rc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &g_ModVMM);
1993 AssertRCReturn(rc, rc);
1994 for (size_t i = 0; i < RT_ELEMENTS(g_aVMMImports); i++)
1995 {
1996 rc = RTLdrGetSymbol(g_ModVMM, g_aVMMImports[i].pszName, &g_aVMMImports[i].pv);
1997 AssertLogRelMsgRCReturn(rc, ("RTLdrGetSymbol(VBoxVMM,%s,) -> %Rrc\n", g_aVMMImports[i].pszName, rc), rc);
1998 }
1999 }
2000# endif
2001
2002 /*
2003 * Load the VBoxREM2.rel object/DLL.
2004 */
2005 strcpy(&szPath[offFilename], "/VBoxREM2.rel");
2006 rc = RTLdrOpen(szPath, 0, RTLDRARCH_HOST, &g_ModREM2);
2007 if (RT_SUCCESS(rc))
2008 {
2009 g_pvREM2 = RTMemExecAlloc(RTLdrSize(g_ModREM2));
2010 if (g_pvREM2)
2011 {
2012# ifdef DEBUG /* How to load the VBoxREM2.rel symbols into the GNU debugger. */
2013 RTPrintf("VBoxREMWrapper: (gdb) add-symbol-file %s 0x%p\n", szPath, g_pvREM2);
2014# endif
2015 LogRel(("REM: Loading %s at 0x%p (%d bytes)\n"
2016 "REM: (gdb) add-symbol-file %s 0x%p\n",
2017 szPath, g_pvREM2, RTLdrSize(g_ModREM2), szPath, g_pvREM2));
2018 rc = RTLdrGetBits(g_ModREM2, g_pvREM2, (RTUINTPTR)g_pvREM2, remGetImport, NULL);
2019 if (RT_SUCCESS(rc))
2020 {
2021 /*
2022 * Resolve exports.
2023 */
2024 unsigned i;
2025 for (i = 0; i < RT_ELEMENTS(g_aExports); i++)
2026 {
2027 RTUINTPTR Value;
2028 rc = RTLdrGetSymbolEx(g_ModREM2, g_pvREM2, (RTUINTPTR)g_pvREM2, g_aExports[i].pszName, &Value);
2029 AssertMsgRC(rc, ("%s rc=%Rrc\n", g_aExports[i].pszName, rc));
2030 if (RT_FAILURE(rc))
2031 break;
2032 rc = remGenerateExportGlue(&Value, &g_aExports[i]);
2033 if (RT_FAILURE(rc))
2034 break;
2035 *(void **)g_aExports[i].pv = (void *)(uintptr_t)Value;
2036 }
2037 return rc;
2038 }
2039 RTMemExecFree(g_pvREM2);
2040 }
2041 RTLdrClose(g_ModREM2);
2042 g_ModREM2 = NIL_RTLDRMOD;
2043 }
2044 LogRel(("REM: failed loading '%s', rc=%Rrc\n", szPath, rc));
2045 return rc;
2046}
2047
2048
2049/**
2050 * Unloads the linux object, freeing up all resources (dlls and
2051 * import glue) we allocated during remLoadLinuxObj().
2052 */
2053static void remUnloadLinuxObj(void)
2054{
2055 unsigned i;
2056
2057 /* close modules. */
2058 RTLdrClose(g_ModREM2);
2059 g_ModREM2 = NIL_RTLDRMOD;
2060 RTMemExecFree(g_pvREM2);
2061 g_pvREM2 = NULL;
2062
2063 /* clear the pointers. */
2064 for (i = 0; i < RT_ELEMENTS(g_aExports); i++)
2065 *(void **)g_aExports[i].pv = NULL;
2066# if defined(USE_REM_CALLING_CONVENTION_GLUE) || defined(USE_REM_IMPORT_JUMP_GLUE)
2067 for (i = 0; i < RT_ELEMENTS(g_aVMMImports); i++)
2068 g_aVMMImports[i].pvWrapper = NULL;
2069 for (i = 0; i < RT_ELEMENTS(g_aRTImports); i++)
2070 g_aRTImports[i].pvWrapper = NULL;
2071 for (i = 0; i < RT_ELEMENTS(g_aCRTImports); i++)
2072 g_aCRTImports[i].pvWrapper = NULL;
2073
2074 /* free wrapper memory. */
2075 while (g_pExecMemHead)
2076 {
2077 PREMEXECMEM pCur = g_pExecMemHead;
2078 g_pExecMemHead = pCur->pNext;
2079 memset(pCur, 0xcc, pCur->cb);
2080 RTMemExecFree(pCur);
2081 }
2082# endif
2083}
2084
2085# else /* VBOX_USE_BITNESS_SELECTOR */
2086
2087/**
2088 * Checks if 64-bit support is enabled.
2089 *
2090 * @returns true / false.
2091 * @param pVM Pointer to the shared VM structure.
2092 */
2093static bool remIs64bitEnabled(PVM pVM)
2094{
2095 bool f;
2096 int rc;
2097
2098# ifdef VBOX_WITHOUT_REM_LDR_CYCLE
2099 if (g_ModVMM == NIL_RTLDRMOD)
2100 {
2101 rc = SUPR3HardenedLdrLoadAppPriv("VBoxVMM", &g_ModVMM);
2102 AssertRCReturn(rc, false);
2103 }
2104
2105 DECLCALLBACKMEMBER(PCFGMNODE, pfnCFGMR3GetRoot)(PVM);
2106 rc = RTLdrGetSymbol(g_ModVMM, "CFGMR3GetRoot", (void **)&pfnCFGMR3GetRoot);
2107 AssertRCReturn(rc, false);
2108
2109 DECLCALLBACKMEMBER(PCFGMNODE, pfnCFGMR3GetChild)(PCFGMNODE, const char *);
2110 rc = RTLdrGetSymbol(g_ModVMM, "CFGMR3GetChild", (void **)&pfnCFGMR3GetChild);
2111 AssertRCReturn(rc, false);
2112
2113 DECLCALLBACKMEMBER(int, pfnCFGMR3QueryBoolDef)(PCFGMNODE, const char *, bool *, bool);
2114 rc = RTLdrGetSymbol(g_ModVMM, "CFGMR3QueryBoolDef", (void **)&pfnCFGMR3QueryBoolDef);
2115 AssertRCReturn(rc, false);
2116
2117 rc = pfnCFGMR3QueryBoolDef(pfnCFGMR3GetChild(pfnCFGMR3GetRoot(pVM), "REM"), "64bitEnabled", &f, false);
2118# else
2119 rc = CFGMR3QueryBoolDef(CFGMR3GetChild(CFGMR3GetRoot(pVM), "REM"), "64bitEnabled", &f, false);
2120# endif
2121 AssertRCReturn(rc, false);
2122 return f;
2123}
2124
2125
2126/**
2127 * Loads real REM object, resolves all exports (imports are done by native loader).
2128 *
2129 * @returns VBox status code.
2130 */
2131static int remLoadProperObj(PVM pVM)
2132{
2133 /*
2134 * Load the VBoxREM32/64 object/DLL.
2135 */
2136 const char *pszModule = remIs64bitEnabled(pVM) ? "VBoxREM64" : "VBoxREM32";
2137 int rc = SUPR3HardenedLdrLoadAppPriv(pszModule, &g_ModREM2);
2138 if (RT_SUCCESS(rc))
2139 {
2140 LogRel(("REM: %s\n", pszModule));
2141
2142 /*
2143 * Resolve exports.
2144 */
2145 unsigned i;
2146 for (i = 0; i < RT_ELEMENTS(g_aExports); i++)
2147 {
2148 void *pvValue;
2149 rc = RTLdrGetSymbol(g_ModREM2, g_aExports[i].pszName, &pvValue);
2150 AssertLogRelMsgRCBreak(rc, ("%s rc=%Rrc\n", g_aExports[i].pszName, rc));
2151 *(void **)g_aExports[i].pv = pvValue;
2152 }
2153 }
2154
2155 return rc;
2156}
2157
2158
2159/**
2160 * Unloads the real REM object.
2161 */
2162static void remUnloadProperObj(void)
2163{
2164 /* close module. */
2165 RTLdrClose(g_ModREM2);
2166 g_ModREM2 = NIL_RTLDRMOD;
2167}
2168
2169# endif /* VBOX_USE_BITNESS_SELECTOR */
2170#endif /* USE_REM_STUBS */
2171
2172REMR3DECL(int) REMR3Init(PVM pVM)
2173{
2174#ifdef USE_REM_STUBS
2175 return VINF_SUCCESS;
2176
2177#elif defined(VBOX_USE_BITNESS_SELECTOR)
2178 if (!pfnREMR3Init)
2179 {
2180 int rc = remLoadProperObj(pVM);
2181 if (RT_FAILURE(rc))
2182 return rc;
2183 }
2184 return pfnREMR3Init(pVM);
2185
2186#else
2187 if (!pfnREMR3Init)
2188 {
2189 int rc = remLoadLinuxObj();
2190 if (RT_FAILURE(rc))
2191 return rc;
2192 }
2193 return pfnREMR3Init(pVM);
2194#endif
2195}
2196
2197REMR3DECL(int) REMR3InitFinalize(PVM pVM)
2198{
2199#ifndef USE_REM_STUBS
2200 Assert(VALID_PTR(pfnREMR3InitFinalize));
2201 return pfnREMR3InitFinalize(pVM);
2202#endif
2203}
2204
2205REMR3DECL(int) REMR3Term(PVM pVM)
2206{
2207#ifdef USE_REM_STUBS
2208 return VINF_SUCCESS;
2209
2210#elif defined(VBOX_USE_BITNESS_SELECTOR)
2211 int rc;
2212 Assert(VALID_PTR(pfnREMR3Term));
2213 rc = pfnREMR3Term(pVM);
2214 remUnloadProperObj();
2215 return rc;
2216
2217#else
2218 int rc;
2219 Assert(VALID_PTR(pfnREMR3Term));
2220 rc = pfnREMR3Term(pVM);
2221 remUnloadLinuxObj();
2222 return rc;
2223#endif
2224}
2225
2226REMR3DECL(void) REMR3Reset(PVM pVM)
2227{
2228#ifndef USE_REM_STUBS
2229 Assert(VALID_PTR(pfnREMR3Reset));
2230 pfnREMR3Reset(pVM);
2231#endif
2232}
2233
2234REMR3DECL(int) REMR3Step(PVM pVM, PVMCPU pVCpu)
2235{
2236#ifdef USE_REM_STUBS
2237 return VERR_NOT_IMPLEMENTED;
2238#else
2239 Assert(VALID_PTR(pfnREMR3Step));
2240 return pfnREMR3Step(pVM, pVCpu);
2241#endif
2242}
2243
2244REMR3DECL(int) REMR3BreakpointSet(PVM pVM, RTGCUINTPTR Address)
2245{
2246#ifdef USE_REM_STUBS
2247 return VERR_REM_NO_MORE_BP_SLOTS;
2248#else
2249 Assert(VALID_PTR(pfnREMR3BreakpointSet));
2250 return pfnREMR3BreakpointSet(pVM, Address);
2251#endif
2252}
2253
2254REMR3DECL(int) REMR3BreakpointClear(PVM pVM, RTGCUINTPTR Address)
2255{
2256#ifdef USE_REM_STUBS
2257 return VERR_NOT_IMPLEMENTED;
2258#else
2259 Assert(VALID_PTR(pfnREMR3BreakpointClear));
2260 return pfnREMR3BreakpointClear(pVM, Address);
2261#endif
2262}
2263
2264REMR3DECL(int) REMR3EmulateInstruction(PVM pVM, PVMCPU pVCpu)
2265{
2266#ifdef USE_REM_STUBS
2267 return VERR_NOT_IMPLEMENTED;
2268#else
2269 Assert(VALID_PTR(pfnREMR3EmulateInstruction));
2270 return pfnREMR3EmulateInstruction(pVM, pVCpu);
2271#endif
2272}
2273
2274REMR3DECL(int) REMR3Run(PVM pVM, PVMCPU pVCpu)
2275{
2276#ifdef USE_REM_STUBS
2277 return VERR_NOT_IMPLEMENTED;
2278#else
2279 Assert(VALID_PTR(pfnREMR3Run));
2280 return pfnREMR3Run(pVM, pVCpu);
2281#endif
2282}
2283
2284REMR3DECL(int) REMR3State(PVM pVM, PVMCPU pVCpu)
2285{
2286#ifdef USE_REM_STUBS
2287 return VERR_NOT_IMPLEMENTED;
2288#else
2289 Assert(VALID_PTR(pfnREMR3State));
2290 return pfnREMR3State(pVM, pVCpu);
2291#endif
2292}
2293
2294REMR3DECL(int) REMR3StateBack(PVM pVM, PVMCPU pVCpu)
2295{
2296#ifdef USE_REM_STUBS
2297 return VERR_NOT_IMPLEMENTED;
2298#else
2299 Assert(VALID_PTR(pfnREMR3StateBack));
2300 return pfnREMR3StateBack(pVM, pVCpu);
2301#endif
2302}
2303
2304REMR3DECL(void) REMR3StateUpdate(PVM pVM, PVMCPU pVCpu)
2305{
2306#ifndef USE_REM_STUBS
2307 Assert(VALID_PTR(pfnREMR3StateUpdate));
2308 pfnREMR3StateUpdate(pVM, pVCpu);
2309#endif
2310}
2311
2312REMR3DECL(void) REMR3A20Set(PVM pVM, PVMCPU pVCpu, bool fEnable)
2313{
2314#ifndef USE_REM_STUBS
2315 Assert(VALID_PTR(pfnREMR3A20Set));
2316 pfnREMR3A20Set(pVM, pVCpu, fEnable);
2317#endif
2318}
2319
2320REMR3DECL(void) REMR3ReplayHandlerNotifications(PVM pVM)
2321{
2322#ifndef USE_REM_STUBS
2323 Assert(VALID_PTR(pfnREMR3ReplayHandlerNotifications));
2324 pfnREMR3ReplayHandlerNotifications(pVM);
2325#endif
2326}
2327
2328REMR3DECL(int) REMR3NotifyCodePageChanged(PVM pVM, PVMCPU pVCpu, RTGCPTR pvCodePage)
2329{
2330#ifdef USE_REM_STUBS
2331 return VINF_SUCCESS;
2332#else
2333 Assert(VALID_PTR(pfnREMR3NotifyCodePageChanged));
2334 return pfnREMR3NotifyCodePageChanged(pVM, pVCpu, pvCodePage);
2335#endif
2336}
2337
2338REMR3DECL(void) REMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, unsigned fFlags)
2339{
2340#ifndef USE_REM_STUBS
2341 Assert(VALID_PTR(pfnREMR3NotifyPhysRamRegister));
2342 pfnREMR3NotifyPhysRamRegister(pVM, GCPhys, cb, fFlags);
2343#endif
2344}
2345
2346REMR3DECL(void) REMR3NotifyPhysRomRegister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb, void *pvCopy, bool fShadow)
2347{
2348#ifndef USE_REM_STUBS
2349 Assert(VALID_PTR(pfnREMR3NotifyPhysRomRegister));
2350 pfnREMR3NotifyPhysRomRegister(pVM, GCPhys, cb, pvCopy, fShadow);
2351#endif
2352}
2353
2354REMR3DECL(void) REMR3NotifyPhysRamDeregister(PVM pVM, RTGCPHYS GCPhys, RTUINT cb)
2355{
2356#ifndef USE_REM_STUBS
2357 Assert(VALID_PTR(pfnREMR3NotifyPhysRamDeregister));
2358 pfnREMR3NotifyPhysRamDeregister(pVM, GCPhys, cb);
2359#endif
2360}
2361
2362REMR3DECL(void) REMR3NotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler)
2363{
2364#ifndef USE_REM_STUBS
2365 Assert(VALID_PTR(pfnREMR3NotifyHandlerPhysicalRegister));
2366 pfnREMR3NotifyHandlerPhysicalRegister(pVM, enmType, GCPhys, cb, fHasHCHandler);
2367#endif
2368}
2369
2370REMR3DECL(void) REMR3NotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
2371{
2372#ifndef USE_REM_STUBS
2373 Assert(VALID_PTR(pfnREMR3NotifyHandlerPhysicalDeregister));
2374 pfnREMR3NotifyHandlerPhysicalDeregister(pVM, enmType, GCPhys, cb, fHasHCHandler, fRestoreAsRAM);
2375#endif
2376}
2377
2378REMR3DECL(void) REMR3NotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
2379{
2380#ifndef USE_REM_STUBS
2381 Assert(VALID_PTR(pfnREMR3NotifyHandlerPhysicalModify));
2382 pfnREMR3NotifyHandlerPhysicalModify(pVM, enmType, GCPhysOld, GCPhysNew, cb, fHasHCHandler, fRestoreAsRAM);
2383#endif
2384}
2385
2386REMR3DECL(bool) REMR3IsPageAccessHandled(PVM pVM, RTGCPHYS GCPhys)
2387{
2388#ifdef USE_REM_STUBS
2389 return false;
2390#else
2391 Assert(VALID_PTR(pfnREMR3IsPageAccessHandled));
2392 return pfnREMR3IsPageAccessHandled(pVM, GCPhys);
2393#endif
2394}
2395
2396REMR3DECL(int) REMR3DisasEnableStepping(PVM pVM, bool fEnable)
2397{
2398#ifdef USE_REM_STUBS
2399 return VERR_NOT_IMPLEMENTED;
2400#else
2401 Assert(VALID_PTR(pfnREMR3DisasEnableStepping));
2402 return pfnREMR3DisasEnableStepping(pVM, fEnable);
2403#endif
2404}
2405
2406REMR3DECL(void) REMR3NotifyPendingInterrupt(PVM pVM, PVMCPU pVCpu, uint8_t u8Interrupt)
2407{
2408#ifndef USE_REM_STUBS
2409 Assert(VALID_PTR(pfnREMR3NotifyPendingInterrupt));
2410 pfnREMR3NotifyPendingInterrupt(pVM, pVCpu, u8Interrupt);
2411#endif
2412}
2413
2414REMR3DECL(uint32_t) REMR3QueryPendingInterrupt(PVM pVM, PVMCPU pVCpu)
2415{
2416#ifdef USE_REM_STUBS
2417 return REM_NO_PENDING_IRQ;
2418#else
2419 Assert(VALID_PTR(pfnREMR3QueryPendingInterrupt));
2420 return pfnREMR3QueryPendingInterrupt(pVM, pVCpu);
2421#endif
2422}
2423
2424REMR3DECL(void) REMR3NotifyInterruptSet(PVM pVM, PVMCPU pVCpu)
2425{
2426#ifndef USE_REM_STUBS
2427 Assert(VALID_PTR(pfnREMR3NotifyInterruptSet));
2428 pfnREMR3NotifyInterruptSet(pVM, pVCpu);
2429#endif
2430}
2431
2432REMR3DECL(void) REMR3NotifyInterruptClear(PVM pVM, PVMCPU pVCpu)
2433{
2434#ifndef USE_REM_STUBS
2435 Assert(VALID_PTR(pfnREMR3NotifyInterruptClear));
2436 pfnREMR3NotifyInterruptClear(pVM, pVCpu);
2437#endif
2438}
2439
2440REMR3DECL(void) REMR3NotifyTimerPending(PVM pVM, PVMCPU pVCpuDst)
2441{
2442#ifndef USE_REM_STUBS
2443 Assert(VALID_PTR(pfnREMR3NotifyTimerPending));
2444 pfnREMR3NotifyTimerPending(pVM, pVCpuDst);
2445#endif
2446}
2447
2448REMR3DECL(void) REMR3NotifyDmaPending(PVM pVM)
2449{
2450#ifndef USE_REM_STUBS
2451 Assert(VALID_PTR(pfnREMR3NotifyDmaPending));
2452 pfnREMR3NotifyDmaPending(pVM);
2453#endif
2454}
2455
2456REMR3DECL(void) REMR3NotifyQueuePending(PVM pVM)
2457{
2458#ifndef USE_REM_STUBS
2459 Assert(VALID_PTR(pfnREMR3NotifyQueuePending));
2460 pfnREMR3NotifyQueuePending(pVM);
2461#endif
2462}
2463
2464REMR3DECL(void) REMR3NotifyFF(PVM pVM)
2465{
2466#ifndef USE_REM_STUBS
2467 /* the timer can call this early on, so don't be picky. */
2468 if (pfnREMR3NotifyFF)
2469 pfnREMR3NotifyFF(pVM);
2470#endif
2471}
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