1 | /* $Id: MMAll.cpp 15174 2008-12-09 14:11:35Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * MM - Memory Manager - Any Context.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
10 | * available from http://www.virtualbox.org. This file is free software;
|
---|
11 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
12 | * General Public License (GPL) as published by the Free Software
|
---|
13 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
14 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
15 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
16 | *
|
---|
17 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
18 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
19 | * additional information or have any questions.
|
---|
20 | */
|
---|
21 |
|
---|
22 |
|
---|
23 | /*******************************************************************************
|
---|
24 | * Header Files *
|
---|
25 | *******************************************************************************/
|
---|
26 | #define LOG_GROUP LOG_GROUP_MM_HYPER
|
---|
27 | #include <VBox/mm.h>
|
---|
28 | #include <VBox/vmm.h>
|
---|
29 | #include "MMInternal.h"
|
---|
30 | #include <VBox/vm.h>
|
---|
31 | #include <VBox/log.h>
|
---|
32 | #include <iprt/assert.h>
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * Lookup a host context ring-3 address.
|
---|
38 | *
|
---|
39 | * @returns Pointer to the corresponding lookup record.
|
---|
40 | * @returns NULL on failure.
|
---|
41 | * @param pVM The VM handle.
|
---|
42 | * @param R3Ptr The host context ring-3 address to lookup.
|
---|
43 | * @param poff Where to store the offset into the HMA memory chunk.
|
---|
44 | */
|
---|
45 | DECLINLINE(PMMLOOKUPHYPER) mmHyperLookupR3(PVM pVM, RTR3PTR R3Ptr, uint32_t *poff)
|
---|
46 | {
|
---|
47 | /** @todo cache last lookup, this stuff ain't cheap! */
|
---|
48 | PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap) + pVM->mm.s.offLookupHyper);
|
---|
49 | for (;;)
|
---|
50 | {
|
---|
51 | switch (pLookup->enmType)
|
---|
52 | {
|
---|
53 | case MMLOOKUPHYPERTYPE_LOCKED:
|
---|
54 | {
|
---|
55 | const RTR3UINTPTR off = (RTR3UINTPTR)R3Ptr - (RTR3UINTPTR)pLookup->u.Locked.pvR3;
|
---|
56 | if (off < pLookup->cb)
|
---|
57 | {
|
---|
58 | *poff = off;
|
---|
59 | return pLookup;
|
---|
60 | }
|
---|
61 | break;
|
---|
62 | }
|
---|
63 |
|
---|
64 | case MMLOOKUPHYPERTYPE_HCPHYS:
|
---|
65 | {
|
---|
66 | const RTR3UINTPTR off = (RTR3UINTPTR)R3Ptr - (RTR3UINTPTR)pLookup->u.HCPhys.pvR3;
|
---|
67 | if (off < pLookup->cb)
|
---|
68 | {
|
---|
69 | *poff = off;
|
---|
70 | return pLookup;
|
---|
71 | }
|
---|
72 | break;
|
---|
73 | }
|
---|
74 |
|
---|
75 | case MMLOOKUPHYPERTYPE_GCPHYS: /* (for now we'll not allow these kind of conversions) */
|
---|
76 | case MMLOOKUPHYPERTYPE_MMIO2:
|
---|
77 | case MMLOOKUPHYPERTYPE_DYNAMIC:
|
---|
78 | break;
|
---|
79 |
|
---|
80 | default:
|
---|
81 | AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
|
---|
82 | break;
|
---|
83 | }
|
---|
84 |
|
---|
85 | /* next */
|
---|
86 | if (pLookup->offNext == (int32_t)NIL_OFFSET)
|
---|
87 | break;
|
---|
88 | pLookup = (PMMLOOKUPHYPER)((uint8_t *)pLookup + pLookup->offNext);
|
---|
89 | }
|
---|
90 |
|
---|
91 | AssertMsgFailed(("R3Ptr=%RHv is not inside the hypervisor memory area!\n", R3Ptr));
|
---|
92 | return NULL;
|
---|
93 | }
|
---|
94 |
|
---|
95 |
|
---|
96 | /**
|
---|
97 | * Lookup a host context ring-0 address.
|
---|
98 | *
|
---|
99 | * @returns Pointer to the corresponding lookup record.
|
---|
100 | * @returns NULL on failure.
|
---|
101 | * @param pVM The VM handle.
|
---|
102 | * @param R0Ptr The host context ring-0 address to lookup.
|
---|
103 | * @param poff Where to store the offset into the HMA memory chunk.
|
---|
104 | */
|
---|
105 | DECLINLINE(PMMLOOKUPHYPER) mmHyperLookupR0(PVM pVM, RTR0PTR R0Ptr, uint32_t *poff)
|
---|
106 | {
|
---|
107 | AssertCompile(sizeof(RTR0PTR) == sizeof(RTR3PTR));
|
---|
108 |
|
---|
109 | /** @todo cache last lookup, this stuff ain't cheap! */
|
---|
110 | PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap) + pVM->mm.s.offLookupHyper);
|
---|
111 | for (;;)
|
---|
112 | {
|
---|
113 | switch (pLookup->enmType)
|
---|
114 | {
|
---|
115 | case MMLOOKUPHYPERTYPE_LOCKED:
|
---|
116 | {
|
---|
117 | const RTR0UINTPTR off = (RTR0UINTPTR)R0Ptr - (RTR0UINTPTR)pLookup->u.Locked.pvR0;
|
---|
118 | if (off < pLookup->cb && pLookup->u.Locked.pvR0)
|
---|
119 | {
|
---|
120 | *poff = off;
|
---|
121 | return pLookup;
|
---|
122 | }
|
---|
123 | break;
|
---|
124 | }
|
---|
125 |
|
---|
126 | case MMLOOKUPHYPERTYPE_HCPHYS:
|
---|
127 | {
|
---|
128 | const RTR0UINTPTR off = (RTR0UINTPTR)R0Ptr - (RTR0UINTPTR)pLookup->u.HCPhys.pvR0;
|
---|
129 | if (off < pLookup->cb && pLookup->u.HCPhys.pvR0)
|
---|
130 | {
|
---|
131 | *poff = off;
|
---|
132 | return pLookup;
|
---|
133 | }
|
---|
134 | break;
|
---|
135 | }
|
---|
136 |
|
---|
137 | case MMLOOKUPHYPERTYPE_GCPHYS: /* (for now we'll not allow these kind of conversions) */
|
---|
138 | case MMLOOKUPHYPERTYPE_MMIO2:
|
---|
139 | case MMLOOKUPHYPERTYPE_DYNAMIC:
|
---|
140 | break;
|
---|
141 |
|
---|
142 | default:
|
---|
143 | AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
|
---|
144 | break;
|
---|
145 | }
|
---|
146 |
|
---|
147 | /* next */
|
---|
148 | if (pLookup->offNext == (int32_t)NIL_OFFSET)
|
---|
149 | break;
|
---|
150 | pLookup = (PMMLOOKUPHYPER)((uint8_t *)pLookup + pLookup->offNext);
|
---|
151 | }
|
---|
152 |
|
---|
153 | AssertMsgFailed(("R0Ptr=%RHv is not inside the hypervisor memory area!\n", R0Ptr));
|
---|
154 | return NULL;
|
---|
155 | }
|
---|
156 |
|
---|
157 |
|
---|
158 | /**
|
---|
159 | * Lookup a raw-mode context address.
|
---|
160 | *
|
---|
161 | * @returns Pointer to the corresponding lookup record.
|
---|
162 | * @returns NULL on failure.
|
---|
163 | * @param pVM The VM handle.
|
---|
164 | * @param RCPtr The raw-mode context address to lookup.
|
---|
165 | * @param poff Where to store the offset into the HMA memory chunk.
|
---|
166 | */
|
---|
167 | DECLINLINE(PMMLOOKUPHYPER) mmHyperLookupRC(PVM pVM, RTRCPTR RCPtr, uint32_t *poff)
|
---|
168 | {
|
---|
169 | /** @todo cache last lookup this stuff ain't cheap! */
|
---|
170 | unsigned offRC = (RTRCUINTPTR)RCPtr - (RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC;
|
---|
171 | PMMLOOKUPHYPER pLookup = (PMMLOOKUPHYPER)((uint8_t *)pVM->mm.s.CTX_SUFF(pHyperHeap) + pVM->mm.s.offLookupHyper);
|
---|
172 | for (;;)
|
---|
173 | {
|
---|
174 | const uint32_t off = offRC - pLookup->off;
|
---|
175 | if (off < pLookup->cb)
|
---|
176 | {
|
---|
177 | switch (pLookup->enmType)
|
---|
178 | {
|
---|
179 | case MMLOOKUPHYPERTYPE_LOCKED:
|
---|
180 | case MMLOOKUPHYPERTYPE_HCPHYS:
|
---|
181 | *poff = off;
|
---|
182 | return pLookup;
|
---|
183 | default:
|
---|
184 | break;
|
---|
185 | }
|
---|
186 | AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
|
---|
187 | return NULL;
|
---|
188 | }
|
---|
189 |
|
---|
190 | /* next */
|
---|
191 | if (pLookup->offNext == (int32_t)NIL_OFFSET)
|
---|
192 | break;
|
---|
193 | pLookup = (PMMLOOKUPHYPER)((uint8_t *)pLookup + pLookup->offNext);
|
---|
194 | }
|
---|
195 |
|
---|
196 | AssertMsgFailed(("RCPtr=%RRv is not inside the hypervisor memory area!\n", RCPtr));
|
---|
197 | return NULL;
|
---|
198 | }
|
---|
199 |
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * Lookup a current context address.
|
---|
203 | *
|
---|
204 | * @returns Pointer to the corresponding lookup record.
|
---|
205 | * @returns NULL on failure.
|
---|
206 | * @param pVM The VM handle.
|
---|
207 | * @param pv The current context address to lookup.
|
---|
208 | * @param poff Where to store the offset into the HMA memory chunk.
|
---|
209 | */
|
---|
210 | DECLINLINE(PMMLOOKUPHYPER) mmHyperLookupCC(PVM pVM, void *pv, uint32_t *poff)
|
---|
211 | {
|
---|
212 | #ifdef IN_RC
|
---|
213 | return mmHyperLookupRC(pVM, (RTRCPTR)pv, poff);
|
---|
214 | #elif defined(IN_RING0)
|
---|
215 | return mmHyperLookupR0(pVM, pv, poff);
|
---|
216 | #else
|
---|
217 | return mmHyperLookupR3(pVM, pv, poff);
|
---|
218 | #endif
|
---|
219 | }
|
---|
220 |
|
---|
221 |
|
---|
222 | /**
|
---|
223 | * Calculate the host context ring-3 address of an offset into the HMA memory chunk.
|
---|
224 | *
|
---|
225 | * @returns the host context ring-3 address.
|
---|
226 | * @param pLookup The HMA lookup record.
|
---|
227 | * @param off The offset into the HMA memory chunk.
|
---|
228 | */
|
---|
229 | DECLINLINE(RTR3PTR) mmHyperLookupCalcR3(PMMLOOKUPHYPER pLookup, uint32_t off)
|
---|
230 | {
|
---|
231 | switch (pLookup->enmType)
|
---|
232 | {
|
---|
233 | case MMLOOKUPHYPERTYPE_LOCKED:
|
---|
234 | return (RTR3PTR)((RTR3UINTPTR)pLookup->u.Locked.pvR3 + off);
|
---|
235 | case MMLOOKUPHYPERTYPE_HCPHYS:
|
---|
236 | return (RTR3PTR)((RTR3UINTPTR)pLookup->u.HCPhys.pvR3 + off);
|
---|
237 | default:
|
---|
238 | AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
|
---|
239 | return NIL_RTR3PTR;
|
---|
240 | }
|
---|
241 | }
|
---|
242 |
|
---|
243 |
|
---|
244 | /**
|
---|
245 | * Calculate the host context ring-0 address of an offset into the HMA memory chunk.
|
---|
246 | *
|
---|
247 | * @returns the host context ring-0 address.
|
---|
248 | * @param pVM Pointer to the shared VM structure.
|
---|
249 | * @param pLookup The HMA lookup record.
|
---|
250 | * @param off The offset into the HMA memory chunk.
|
---|
251 | */
|
---|
252 | DECLINLINE(RTR0PTR) mmHyperLookupCalcR0(PVM pVM, PMMLOOKUPHYPER pLookup, uint32_t off)
|
---|
253 | {
|
---|
254 | switch (pLookup->enmType)
|
---|
255 | {
|
---|
256 | case MMLOOKUPHYPERTYPE_LOCKED:
|
---|
257 | if (pLookup->u.Locked.pvR0)
|
---|
258 | return (RTR0PTR)((RTR0UINTPTR)pLookup->u.Locked.pvR0 + off);
|
---|
259 | #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
|
---|
260 | AssertMsg(!VMMIsHwVirtExtForced(pVM), ("%s\n", R3STRING(pLookup->pszDesc)));
|
---|
261 | #else
|
---|
262 | AssertMsgFailed(("%s\n", R3STRING(pLookup->pszDesc)));
|
---|
263 | #endif
|
---|
264 | return NIL_RTR0PTR;
|
---|
265 |
|
---|
266 | case MMLOOKUPHYPERTYPE_HCPHYS:
|
---|
267 | if (pLookup->u.HCPhys.pvR0)
|
---|
268 | return (RTR0PTR)((RTR0UINTPTR)pLookup->u.HCPhys.pvR0 + off);
|
---|
269 | AssertMsgFailed(("%s\n", R3STRING(pLookup->pszDesc)));
|
---|
270 | return NIL_RTR0PTR;
|
---|
271 |
|
---|
272 | default:
|
---|
273 | AssertMsgFailed(("enmType=%d\n", pLookup->enmType));
|
---|
274 | return NIL_RTR0PTR;
|
---|
275 | }
|
---|
276 | }
|
---|
277 |
|
---|
278 |
|
---|
279 | /**
|
---|
280 | * Calculate the raw-mode context address of an offset into the HMA memory chunk.
|
---|
281 | *
|
---|
282 | * @returns the raw-mode context base address.
|
---|
283 | * @param pVM The the VM handle.
|
---|
284 | * @param pLookup The HMA lookup record.
|
---|
285 | * @param off The offset into the HMA memory chunk.
|
---|
286 | */
|
---|
287 | DECLINLINE(RTRCPTR) mmHyperLookupCalcRC(PVM pVM, PMMLOOKUPHYPER pLookup, uint32_t off)
|
---|
288 | {
|
---|
289 | return (RTRCPTR)((RTGCUINTPTR)pVM->mm.s.pvHyperAreaGC + pLookup->off + off);
|
---|
290 | }
|
---|
291 |
|
---|
292 |
|
---|
293 | /**
|
---|
294 | * Calculate the guest context address of an offset into the HMA memory chunk.
|
---|
295 | *
|
---|
296 | * @returns the guest context base address.
|
---|
297 | * @param pVM The the VM handle.
|
---|
298 | * @param pLookup The HMA lookup record.
|
---|
299 | * @param off The offset into the HMA memory chunk.
|
---|
300 | */
|
---|
301 | DECLINLINE(void *) mmHyperLookupCalcCC(PVM pVM, PMMLOOKUPHYPER pLookup, uint32_t off)
|
---|
302 | {
|
---|
303 | #ifdef IN_RC
|
---|
304 | return (void *)mmHyperLookupCalcRC(pVM, pLookup, off);
|
---|
305 | #elif defined(IN_RING0)
|
---|
306 | return mmHyperLookupCalcR0(pVM, pLookup, off);
|
---|
307 | #else
|
---|
308 | return mmHyperLookupCalcR3(pLookup, off);
|
---|
309 | #endif
|
---|
310 | }
|
---|
311 |
|
---|
312 |
|
---|
313 | /**
|
---|
314 | * Converts a ring-0 host context address in the Hypervisor memory region to a ring-3 host context address.
|
---|
315 | *
|
---|
316 | * @returns ring-3 host context address.
|
---|
317 | * @param pVM The VM to operate on.
|
---|
318 | * @param R0Ptr The ring-0 host context address.
|
---|
319 | * You'll be damned if this is not in the HMA! :-)
|
---|
320 | * @thread The Emulation Thread.
|
---|
321 | */
|
---|
322 | VMMDECL(RTR3PTR) MMHyperR0ToR3(PVM pVM, RTR0PTR R0Ptr)
|
---|
323 | {
|
---|
324 | uint32_t off;
|
---|
325 | PMMLOOKUPHYPER pLookup = mmHyperLookupR0(pVM, R0Ptr, &off);
|
---|
326 | if (pLookup)
|
---|
327 | return mmHyperLookupCalcR3(pLookup, off);
|
---|
328 | return NIL_RTR3PTR;
|
---|
329 | }
|
---|
330 |
|
---|
331 |
|
---|
332 | /**
|
---|
333 | * Converts a ring-0 host context address in the Hypervisor memory region to a raw-mode context address.
|
---|
334 | *
|
---|
335 | * @returns raw-mode context address.
|
---|
336 | * @param pVM The VM to operate on.
|
---|
337 | * @param R0Ptr The ring-0 host context address.
|
---|
338 | * You'll be damned if this is not in the HMA! :-)
|
---|
339 | * @thread The Emulation Thread.
|
---|
340 | */
|
---|
341 | VMMDECL(RTRCPTR) MMHyperR0ToRC(PVM pVM, RTR0PTR R0Ptr)
|
---|
342 | {
|
---|
343 | uint32_t off;
|
---|
344 | PMMLOOKUPHYPER pLookup = mmHyperLookupR0(pVM, R0Ptr, &off);
|
---|
345 | if (pLookup)
|
---|
346 | return mmHyperLookupCalcRC(pVM, pLookup, off);
|
---|
347 | return NIL_RTRCPTR;
|
---|
348 | }
|
---|
349 |
|
---|
350 |
|
---|
351 | #ifndef IN_RING0
|
---|
352 | /**
|
---|
353 | * Converts a ring-0 host context address in the Hypervisor memory region to a current context address.
|
---|
354 | *
|
---|
355 | * @returns current context address.
|
---|
356 | * @param pVM The VM to operate on.
|
---|
357 | * @param R0Ptr The ring-0 host context address.
|
---|
358 | * You'll be damned if this is not in the HMA! :-)
|
---|
359 | * @thread The Emulation Thread.
|
---|
360 | */
|
---|
361 | VMMDECL(void *) MMHyperR0ToCC(PVM pVM, RTR0PTR R0Ptr)
|
---|
362 | {
|
---|
363 | uint32_t off;
|
---|
364 | PMMLOOKUPHYPER pLookup = mmHyperLookupR0(pVM, R0Ptr, &off);
|
---|
365 | if (pLookup)
|
---|
366 | return mmHyperLookupCalcCC(pVM, pLookup, off);
|
---|
367 | return NULL;
|
---|
368 | }
|
---|
369 | #endif
|
---|
370 |
|
---|
371 |
|
---|
372 | /**
|
---|
373 | * Converts a ring-3 host context address in the Hypervisor memory region to a ring-0 host context address.
|
---|
374 | *
|
---|
375 | * @returns ring-0 host context address.
|
---|
376 | * @param pVM The VM to operate on.
|
---|
377 | * @param R3Ptr The ring-3 host context address.
|
---|
378 | * You'll be damned if this is not in the HMA! :-)
|
---|
379 | * @thread The Emulation Thread.
|
---|
380 | */
|
---|
381 | VMMDECL(RTR0PTR) MMHyperR3ToR0(PVM pVM, RTR3PTR R3Ptr)
|
---|
382 | {
|
---|
383 | uint32_t off;
|
---|
384 | PMMLOOKUPHYPER pLookup = mmHyperLookupR3(pVM, R3Ptr, &off);
|
---|
385 | if (pLookup)
|
---|
386 | return mmHyperLookupCalcR0(pVM, pLookup, off);
|
---|
387 | AssertMsgFailed(("R3Ptr=%p is not inside the hypervisor memory area!\n", R3Ptr));
|
---|
388 | return NIL_RTR0PTR;
|
---|
389 | }
|
---|
390 |
|
---|
391 |
|
---|
392 | /**
|
---|
393 | * Converts a ring-3 host context address in the Hypervisor memory region to a guest context address.
|
---|
394 | *
|
---|
395 | * @returns guest context address.
|
---|
396 | * @param pVM The VM to operate on.
|
---|
397 | * @param R3Ptr The ring-3 host context address.
|
---|
398 | * You'll be damned if this is not in the HMA! :-)
|
---|
399 | * @thread The Emulation Thread.
|
---|
400 | */
|
---|
401 | VMMDECL(RTRCPTR) MMHyperR3ToRC(PVM pVM, RTR3PTR R3Ptr)
|
---|
402 | {
|
---|
403 | uint32_t off;
|
---|
404 | PMMLOOKUPHYPER pLookup = mmHyperLookupR3(pVM, R3Ptr, &off);
|
---|
405 | if (pLookup)
|
---|
406 | return mmHyperLookupCalcRC(pVM, pLookup, off);
|
---|
407 | AssertMsgFailed(("R3Ptr=%p is not inside the hypervisor memory area!\n", R3Ptr));
|
---|
408 | return NIL_RTRCPTR;
|
---|
409 | }
|
---|
410 |
|
---|
411 |
|
---|
412 | /**
|
---|
413 | * Converts a ring-3 host context address in the Hypervisor memory region to a current context address.
|
---|
414 | *
|
---|
415 | * @returns current context address.
|
---|
416 | * @param pVM The VM to operate on.
|
---|
417 | * @param R3Ptr The ring-3 host context address.
|
---|
418 | * You'll be damned if this is not in the HMA! :-)
|
---|
419 | * @thread The Emulation Thread.
|
---|
420 | */
|
---|
421 | #ifndef IN_RING3
|
---|
422 | VMMDECL(void *) MMHyperR3ToCC(PVM pVM, RTR3PTR R3Ptr)
|
---|
423 | {
|
---|
424 | uint32_t off;
|
---|
425 | PMMLOOKUPHYPER pLookup = mmHyperLookupR3(pVM, R3Ptr, &off);
|
---|
426 | if (pLookup)
|
---|
427 | return mmHyperLookupCalcCC(pVM, pLookup, off);
|
---|
428 | return NULL;
|
---|
429 | }
|
---|
430 | #endif
|
---|
431 |
|
---|
432 |
|
---|
433 | /**
|
---|
434 | * Converts a raw-mode context address in the Hypervisor memory region to a ring-3 context address.
|
---|
435 | *
|
---|
436 | * @returns ring-3 host context address.
|
---|
437 | * @param pVM The VM to operate on.
|
---|
438 | * @param GCPtr The raw-mode context address.
|
---|
439 | * You'll be damned if this is not in the HMA! :-)
|
---|
440 | * @thread The Emulation Thread.
|
---|
441 | */
|
---|
442 | VMMDECL(RTR3PTR) MMHyperRCToR3(PVM pVM, RTRCPTR RCPtr)
|
---|
443 | {
|
---|
444 | uint32_t off;
|
---|
445 | PMMLOOKUPHYPER pLookup = mmHyperLookupRC(pVM, RCPtr, &off);
|
---|
446 | if (pLookup)
|
---|
447 | return mmHyperLookupCalcR3(pLookup, off);
|
---|
448 | return NIL_RTR3PTR;
|
---|
449 | }
|
---|
450 |
|
---|
451 |
|
---|
452 | /**
|
---|
453 | * Converts a raw-mode context address in the Hypervisor memory region to a ring-0 host context address.
|
---|
454 | *
|
---|
455 | * @returns ring-0 host context address.
|
---|
456 | * @param pVM The VM to operate on.
|
---|
457 | * @param RCPtr The raw-mode context address.
|
---|
458 | * You'll be damned if this is not in the HMA! :-)
|
---|
459 | * @thread The Emulation Thread.
|
---|
460 | */
|
---|
461 | VMMDECL(RTR0PTR) MMHyperRCToR0(PVM pVM, RTRCPTR RCPtr)
|
---|
462 | {
|
---|
463 | uint32_t off;
|
---|
464 | PMMLOOKUPHYPER pLookup = mmHyperLookupRC(pVM, RCPtr, &off);
|
---|
465 | if (pLookup)
|
---|
466 | return mmHyperLookupCalcR0(pVM, pLookup, off);
|
---|
467 | return NIL_RTR0PTR;
|
---|
468 | }
|
---|
469 |
|
---|
470 |
|
---|
471 | /**
|
---|
472 | * Converts a raw-mode context address in the Hypervisor memory region to a current context address.
|
---|
473 | *
|
---|
474 | * @returns current context address.
|
---|
475 | * @param pVM The VM to operate on.
|
---|
476 | * @param RCPtr The raw-mode host context address.
|
---|
477 | * You'll be damned if this is not in the HMA! :-)
|
---|
478 | * @thread The Emulation Thread.
|
---|
479 | */
|
---|
480 | #ifndef IN_RC
|
---|
481 | VMMDECL(void *) MMHyperRCToCC(PVM pVM, RTRCPTR RCPtr)
|
---|
482 | {
|
---|
483 | uint32_t off;
|
---|
484 | PMMLOOKUPHYPER pLookup = mmHyperLookupRC(pVM, RCPtr, &off);
|
---|
485 | if (pLookup)
|
---|
486 | return mmHyperLookupCalcCC(pVM, pLookup, off);
|
---|
487 | return NULL;
|
---|
488 | }
|
---|
489 | #endif
|
---|
490 |
|
---|
491 |
|
---|
492 |
|
---|
493 | /**
|
---|
494 | * Converts a current context address in the Hypervisor memory region to a ring-3 host context address.
|
---|
495 | *
|
---|
496 | * @returns ring-3 host context address.
|
---|
497 | * @param pVM The VM to operate on.
|
---|
498 | * @param pv The current context address.
|
---|
499 | * You'll be damned if this is not in the HMA! :-)
|
---|
500 | * @thread The Emulation Thread.
|
---|
501 | */
|
---|
502 | #ifndef IN_RING3
|
---|
503 | VMMDECL(RTR3PTR) MMHyperCCToR3(PVM pVM, void *pv)
|
---|
504 | {
|
---|
505 | uint32_t off;
|
---|
506 | PMMLOOKUPHYPER pLookup = mmHyperLookupCC(pVM, pv, &off);
|
---|
507 | if (pLookup)
|
---|
508 | return mmHyperLookupCalcR3(pLookup, off);
|
---|
509 | return NIL_RTR3PTR;
|
---|
510 | }
|
---|
511 | #endif
|
---|
512 |
|
---|
513 | /**
|
---|
514 | * Converts a current context address in the Hypervisor memory region to a ring-0 host context address.
|
---|
515 | *
|
---|
516 | * @returns ring-0 host context address.
|
---|
517 | * @param pVM The VM to operate on.
|
---|
518 | * @param pv The current context address.
|
---|
519 | * You'll be damned if this is not in the HMA! :-)
|
---|
520 | * @thread The Emulation Thread.
|
---|
521 | */
|
---|
522 | #ifndef IN_RING0
|
---|
523 | VMMDECL(RTR0PTR) MMHyperCCToR0(PVM pVM, void *pv)
|
---|
524 | {
|
---|
525 | uint32_t off;
|
---|
526 | PMMLOOKUPHYPER pLookup = mmHyperLookupCC(pVM, pv, &off);
|
---|
527 | if (pLookup)
|
---|
528 | return mmHyperLookupCalcR0(pVM, pLookup, off);
|
---|
529 | return NIL_RTR0PTR;
|
---|
530 | }
|
---|
531 | #endif
|
---|
532 |
|
---|
533 |
|
---|
534 | /**
|
---|
535 | * Converts a current context address in the Hypervisor memory region to a raw-mode context address.
|
---|
536 | *
|
---|
537 | * @returns guest context address.
|
---|
538 | * @param pVM The VM to operate on.
|
---|
539 | * @param pv The current context address.
|
---|
540 | * You'll be damned if this is not in the HMA! :-)
|
---|
541 | * @thread The Emulation Thread.
|
---|
542 | */
|
---|
543 | #ifndef IN_RC
|
---|
544 | VMMDECL(RTRCPTR) MMHyperCCToRC(PVM pVM, void *pv)
|
---|
545 | {
|
---|
546 | uint32_t off;
|
---|
547 | PMMLOOKUPHYPER pLookup = mmHyperLookupCC(pVM, pv, &off);
|
---|
548 | if (pLookup)
|
---|
549 | return mmHyperLookupCalcRC(pVM, pLookup, off);
|
---|
550 | return NIL_RTRCPTR;
|
---|
551 | }
|
---|
552 | #endif
|
---|
553 |
|
---|