VirtualBox

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

Last change on this file since 45331 was 45305, checked in by vboxsync, 12 years ago

IOM: Adding pVCpu to a lot of calls and moving the lookup caches from VM to VMCPU.

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