VirtualBox

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

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

REM: missing export

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