VirtualBox

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

Last change on this file since 32766 was 31636, checked in by vboxsync, 14 years ago

EM: Addressed VBOXSTRICTRC todo from r64673. Decided to only use VBOXSTRICTRC on the methods that would actually return VINF_EM_* stuff.

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