VirtualBox

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

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

Automated rebranding to Oracle copyright/license strings via filemuncher

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