VirtualBox

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

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

removed VBOX_WITH_VMI

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