VirtualBox

source: vbox/trunk/include/VBox/gmm.h@ 29286

Last change on this file since 29286 was 29201, checked in by vboxsync, 15 years ago

Shared paging updates

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 21.4 KB
Line 
1/** @file
2 * GMM - The Global Memory Manager. (VMM)
3 */
4
5/*
6 * Copyright (C) 2007 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_gmm_h
27#define ___VBox_gmm_h
28
29#include <VBox/types.h>
30#include <VBox/gvmm.h>
31#include <VBox/sup.h>
32#include <VBox/VMMDev.h> /* for VMMDEVSHAREDREGIONDESC */
33
34RT_C_DECLS_BEGIN
35
36/** @defgroup grp_gmm GMM - The Global Memory Manager
37 * @{
38 */
39
40/** @def IN_GMM_R0
41 * Used to indicate whether we're inside the same link module as the ring 0
42 * part of the Global Memory Manager or not.
43 */
44#ifdef DOXYGEN_RUNNING
45# define IN_GMM_R0
46#endif
47/** @def GMMR0DECL
48 * Ring 0 GMM export or import declaration.
49 * @param type The return type of the function declaration.
50 */
51#ifdef IN_GMM_R0
52# define GMMR0DECL(type) DECLEXPORT(type) VBOXCALL
53#else
54# define GMMR0DECL(type) DECLIMPORT(type) VBOXCALL
55#endif
56
57/** @def IN_GMM_R3
58 * Used to indicate whether we're inside the same link module as the ring 3
59 * part of the Global Memory Manager or not.
60 */
61#ifdef DOXYGEN_RUNNING
62# define IN_GMM_R3
63#endif
64/** @def GMMR3DECL
65 * Ring 3 GMM export or import declaration.
66 * @param type The return type of the function declaration.
67 */
68#ifdef IN_GMM_R3
69# define GMMR3DECL(type) DECLEXPORT(type) VBOXCALL
70#else
71# define GMMR3DECL(type) DECLIMPORT(type) VBOXCALL
72#endif
73
74
75/** The chunk shift. (2^21 = 2 MB) */
76#define GMM_CHUNK_SHIFT 21
77/** The allocation chunk size. */
78#define GMM_CHUNK_SIZE (1U << GMM_CHUNK_SHIFT)
79/** The allocation chunk size in pages. */
80#define GMM_CHUNK_NUM_PAGES (1U << (GMM_CHUNK_SHIFT - PAGE_SHIFT))
81/** The shift factor for converting a page id into a chunk id. */
82#define GMM_CHUNKID_SHIFT (GMM_CHUNK_SHIFT - PAGE_SHIFT)
83/** The last valid Chunk ID value. */
84#define GMM_CHUNKID_LAST (GMM_PAGEID_LAST >> GMM_CHUNKID_SHIFT)
85/** The last valid Page ID value.
86 * The current limit is 2^28 - 1, or almost 1TB if you like.
87 * The constraints are currently dictated by PGMPAGE. */
88#define GMM_PAGEID_LAST (RT_BIT_32(28) - 1)
89/** Mask out the page index from the Page ID. */
90#define GMM_PAGEID_IDX_MASK ((1U << GMM_CHUNKID_SHIFT) - 1)
91/** The NIL Chunk ID value. */
92#define NIL_GMM_CHUNKID 0
93/** The NIL Page ID value. */
94#define NIL_GMM_PAGEID 0
95
96#if 0 /* wrong - these are guest page pfns and not page ids! */
97/** Special Page ID used by unassigned pages. */
98#define GMM_PAGEID_UNASSIGNED 0x0fffffffU
99/** Special Page ID used by unsharable pages.
100 * Like MMIO2, shadow and heap. This is for later, obviously. */
101#define GMM_PAGEID_UNSHARABLE 0x0ffffffeU
102/** The end of the valid Page IDs. This is the first special one. */
103#define GMM_PAGEID_END 0x0ffffff0U
104#endif
105
106
107/** @def GMM_GCPHYS_LAST
108 * The last of the valid guest physical address as it applies to GMM pages.
109 *
110 * This must reflect the constraints imposed by the RTGCPHYS type and
111 * the guest page frame number used internally in GMMPAGE.
112 *
113 * @note Note this corresponds to GMM_PAGE_PFN_LAST. */
114#if HC_ARCH_BITS == 64
115# define GMM_GCPHYS_LAST UINT64_C(0x00000fffffff0000) /* 2^44 (16TB) - 0x10000 */
116#else
117# define GMM_GCPHYS_LAST UINT64_C(0x0000000fffff0000) /* 2^36 (64GB) - 0x10000 */
118#endif
119
120/**
121 * Over-commitment policy.
122 */
123typedef enum GMMOCPOLICY
124{
125 /** The usual invalid 0 value. */
126 GMMOCPOLICY_INVALID = 0,
127 /** No over-commitment, fully backed.
128 * The GMM guarantees that it will be able to allocate all of the
129 * guest RAM for a VM with OC policy. */
130 GMMOCPOLICY_NO_OC,
131 /** to-be-determined. */
132 GMMOCPOLICY_TBD,
133 /** The end of the valid policy range. */
134 GMMOCPOLICY_END,
135 /** The usual 32-bit hack. */
136 GMMOCPOLICY_32BIT_HACK = 0x7fffffff
137} GMMOCPOLICY;
138
139/**
140 * VM / Memory priority.
141 */
142typedef enum GMMPRIORITY
143{
144 /** The usual invalid 0 value. */
145 GMMPRIORITY_INVALID = 0,
146 /** High.
147 * When ballooning, ask these VMs last.
148 * When running out of memory, try not to interrupt these VMs. */
149 GMMPRIORITY_HIGH,
150 /** Normal.
151 * When ballooning, don't wait to ask these.
152 * When running out of memory, pause, save and/or kill these VMs. */
153 GMMPRIORITY_NORMAL,
154 /** Low.
155 * When ballooning, maximize these first.
156 * When running out of memory, save or kill these VMs. */
157 GMMPRIORITY_LOW,
158 /** The end of the valid priority range. */
159 GMMPRIORITY_END,
160 /** The custom 32-bit type blowup. */
161 GMMPRIORITY_32BIT_HACK = 0x7fffffff
162} GMMPRIORITY;
163
164
165/**
166 * GMM Memory Accounts.
167 */
168typedef enum GMMACCOUNT
169{
170 /** The customary invalid zero entry. */
171 GMMACCOUNT_INVALID = 0,
172 /** Account with the base allocations. */
173 GMMACCOUNT_BASE,
174 /** Account with the shadow allocations. */
175 GMMACCOUNT_SHADOW,
176 /** Account with the fixed allocations. */
177 GMMACCOUNT_FIXED,
178 /** The end of the valid values. */
179 GMMACCOUNT_END,
180 /** The usual 32-bit value to finish it off. */
181 GMMACCOUNT_32BIT_HACK = 0x7fffffff
182} GMMACCOUNT;
183
184
185/**
186 * Balloon actions.
187 */
188typedef enum
189{
190 /** Invalid zero entry. */
191 GMMBALLOONACTION_INVALID = 0,
192 /** Inflate the balloon. */
193 GMMBALLOONACTION_INFLATE,
194 /** Deflate the balloon. */
195 GMMBALLOONACTION_DEFLATE,
196 /** Puncture the balloon because of VM reset. */
197 GMMBALLOONACTION_RESET,
198 /** End of the valid actions. */
199 GMMBALLOONACTION_END,
200 /** hack forcing the size of the enum to 32-bits. */
201 GMMBALLOONACTION_MAKE_32BIT_HACK = 0x7fffffff
202} GMMBALLOONACTION;
203
204
205/**
206 * A page descriptor for use when freeing pages.
207 * See GMMR0FreePages, GMMR0BalloonedPages.
208 */
209typedef struct GMMFREEPAGEDESC
210{
211 /** The Page ID of the page to be freed. */
212 uint32_t idPage;
213} GMMFREEPAGEDESC;
214/** Pointer to a page descriptor for freeing pages. */
215typedef GMMFREEPAGEDESC *PGMMFREEPAGEDESC;
216
217
218/**
219 * A page descriptor for use when updating and allocating pages.
220 *
221 * This is a bit complicated because we want to do as much as possible
222 * with the same structure.
223 */
224typedef struct GMMPAGEDESC
225{
226 /** The physical address of the page.
227 *
228 * @input GMMR0AllocateHandyPages expects the guest physical address
229 * to update the GMMPAGE structure with. Pass GMM_GCPHYS_UNSHAREABLE
230 * when appropriate and NIL_RTHCPHYS when the page wasn't used
231 * for any specific guest address.
232 *
233 * GMMR0AllocatePage expects the guest physical address to put in
234 * the GMMPAGE structure for the page it allocates for this entry.
235 * Pass NIL_RTHCPHYS and GMM_GCPHYS_UNSHAREABLE as above.
236 *
237 * @output The host physical address of the allocated page.
238 * NIL_RTHCPHYS on allocation failure.
239 *
240 * ASSUMES: sizeof(RTHCPHYS) >= sizeof(RTGCPHYS).
241 */
242 RTHCPHYS HCPhysGCPhys;
243
244 /** The Page ID.
245 *
246 * @intput GMMR0AllocateHandyPages expects the Page ID of the page to
247 * update here. NIL_GMM_PAGEID means no page should be updated.
248 *
249 * GMMR0AllocatePages requires this to be initialized to
250 * NIL_GMM_PAGEID currently.
251 *
252 * @output The ID of the page, NIL_GMM_PAGEID if the allocation failed.
253 */
254 uint32_t idPage;
255
256 /** The Page ID of the shared page was replaced by this page.
257 *
258 * @input GMMR0AllocateHandyPages expects this to indicate a shared
259 * page that has been replaced by this page and should have its
260 * reference counter decremented and perhaps be freed up. Use
261 * NIL_GMM_PAGEID if no shared page was involved.
262 *
263 * All other APIs expects NIL_GMM_PAGEID here.
264 *
265 * @output All APIs sets this to NIL_GMM_PAGEID.
266 */
267 uint32_t idSharedPage;
268} GMMPAGEDESC;
269AssertCompileSize(GMMPAGEDESC, 16);
270/** Pointer to a page allocation. */
271typedef GMMPAGEDESC *PGMMPAGEDESC;
272
273/** GMMPAGEDESC::HCPhysGCPhys value that indicates that the page is unsharable.
274 * @note This corresponds to GMM_PAGE_PFN_UNSHAREABLE. */
275#if HC_ARCH_BITS == 64
276# define GMM_GCPHYS_UNSHAREABLE UINT64_C(0x00000fffffff1000)
277#else
278# define GMM_GCPHYS_UNSHAREABLE UINT64_C(0x0000000fffff1000)
279#endif
280
281GMMR0DECL(int) GMMR0Init(void);
282GMMR0DECL(void) GMMR0Term(void);
283GMMR0DECL(void) GMMR0InitPerVMData(PGVM pGVM);
284GMMR0DECL(void) GMMR0CleanupVM(PGVM pGVM);
285GMMR0DECL(int) GMMR0InitialReservation(PVM pVM, VMCPUID idCpu, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages,
286 GMMOCPOLICY enmPolicy, GMMPRIORITY enmPriority);
287GMMR0DECL(int) GMMR0UpdateReservation(PVM pVM, VMCPUID idCpu, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages);
288GMMR0DECL(int) GMMR0AllocateHandyPages(PVM pVM, VMCPUID idCpu, uint32_t cPagesToUpdate, uint32_t cPagesToAlloc, PGMMPAGEDESC paPages);
289GMMR0DECL(int) GMMR0AllocatePages(PVM pVM, VMCPUID idCpu, uint32_t cPages, PGMMPAGEDESC paPages, GMMACCOUNT enmAccount);
290GMMR0DECL(int) GMMR0AllocateLargePage(PVM pVM, VMCPUID idCpu, uint32_t cbPage, uint32_t *pIdPage, RTHCPHYS *pHCPhys);
291GMMR0DECL(int) GMMR0FreePages(PVM pVM, VMCPUID idCpu, uint32_t cPages, PGMMFREEPAGEDESC paPages, GMMACCOUNT enmAccount);
292GMMR0DECL(int) GMMR0FreeLargePage(PVM pVM, VMCPUID idCpu, uint32_t idPage);
293GMMR0DECL(int) GMMR0BalloonedPages(PVM pVM, VMCPUID idCpu, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages);
294GMMR0DECL(int) GMMR0MapUnmapChunk(PVM pVM, VMCPUID idCpu, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3);
295GMMR0DECL(int) GMMR0SeedChunk(PVM pVM, VMCPUID idCpu, RTR3PTR pvR3);
296GMMR0DECL(int) GMMR0RegisterSharedModule(PVM pVM, VMCPUID idCpu, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule, unsigned cRegions, VMMDEVSHAREDREGIONDESC *pRegions);
297GMMR0DECL(int) GMMR0UnregisterSharedModule(PVM pVM, VMCPUID idCpu, char *pszModuleName, char *pszVersion, RTGCPTR GCBaseAddr, uint32_t cbModule);
298GMMR0DECL(int) GMMR0UnregisterAllSharedModules(PVM pVM, VMCPUID idCpu);
299GMMR0DECL(int) GMMR0ResetSharedModules(PVM pVM, VMCPUID idCpu);
300
301
302
303/**
304 * Request buffer for GMMR0InitialReservationReq / VMMR0_DO_GMM_INITIAL_RESERVATION.
305 * @see GMMR0InitialReservation
306 */
307typedef struct GMMINITIALRESERVATIONREQ
308{
309 /** The header. */
310 SUPVMMR0REQHDR Hdr;
311 uint64_t cBasePages; /**< @see GMMR0InitialReservation */
312 uint32_t cShadowPages; /**< @see GMMR0InitialReservation */
313 uint32_t cFixedPages; /**< @see GMMR0InitialReservation */
314 GMMOCPOLICY enmPolicy; /**< @see GMMR0InitialReservation */
315 GMMPRIORITY enmPriority; /**< @see GMMR0InitialReservation */
316} GMMINITIALRESERVATIONREQ;
317/** Pointer to a GMMR0InitialReservationReq / VMMR0_DO_GMM_INITIAL_RESERVATION request buffer. */
318typedef GMMINITIALRESERVATIONREQ *PGMMINITIALRESERVATIONREQ;
319
320GMMR0DECL(int) GMMR0InitialReservationReq(PVM pVM, VMCPUID idCpu, PGMMINITIALRESERVATIONREQ pReq);
321
322
323/**
324 * Request buffer for GMMR0UpdateReservationReq / VMMR0_DO_GMM_UPDATE_RESERVATION.
325 * @see GMMR0UpdateReservation
326 */
327typedef struct GMMUPDATERESERVATIONREQ
328{
329 /** The header. */
330 SUPVMMR0REQHDR Hdr;
331 uint64_t cBasePages; /**< @see GMMR0UpdateReservation */
332 uint32_t cShadowPages; /**< @see GMMR0UpdateReservation */
333 uint32_t cFixedPages; /**< @see GMMR0UpdateReservation */
334} GMMUPDATERESERVATIONREQ;
335/** Pointer to a GMMR0InitialReservationReq / VMMR0_DO_GMM_INITIAL_RESERVATION request buffer. */
336typedef GMMUPDATERESERVATIONREQ *PGMMUPDATERESERVATIONREQ;
337
338GMMR0DECL(int) GMMR0UpdateReservationReq(PVM pVM, VMCPUID idCpu, PGMMUPDATERESERVATIONREQ pReq);
339
340
341/**
342 * Request buffer for GMMR0AllocatePagesReq / VMMR0_DO_GMM_ALLOCATE_PAGES.
343 * @see GMMR0AllocatePages.
344 */
345typedef struct GMMALLOCATEPAGESREQ
346{
347 /** The header. */
348 SUPVMMR0REQHDR Hdr;
349 /** The account to charge the allocation to. */
350 GMMACCOUNT enmAccount;
351 /** The number of pages to allocate. */
352 uint32_t cPages;
353 /** Array of page descriptors. */
354 GMMPAGEDESC aPages[1];
355} GMMALLOCATEPAGESREQ;
356/** Pointer to a GMMR0AllocatePagesReq / VMMR0_DO_GMM_ALLOCATE_PAGES request buffer. */
357typedef GMMALLOCATEPAGESREQ *PGMMALLOCATEPAGESREQ;
358
359GMMR0DECL(int) GMMR0AllocatePagesReq(PVM pVM, VMCPUID idCpu, PGMMALLOCATEPAGESREQ pReq);
360
361
362/**
363 * Request buffer for GMMR0FreePagesReq / VMMR0_DO_GMM_FREE_PAGES.
364 * @see GMMR0FreePages.
365 */
366typedef struct GMMFREEPAGESREQ
367{
368 /** The header. */
369 SUPVMMR0REQHDR Hdr;
370 /** The account this relates to. */
371 GMMACCOUNT enmAccount;
372 /** The number of pages to free. */
373 uint32_t cPages;
374 /** Array of free page descriptors. */
375 GMMFREEPAGEDESC aPages[1];
376} GMMFREEPAGESREQ;
377/** Pointer to a GMMR0FreePagesReq / VMMR0_DO_GMM_FREE_PAGES request buffer. */
378typedef GMMFREEPAGESREQ *PGMMFREEPAGESREQ;
379
380GMMR0DECL(int) GMMR0FreePagesReq(PVM pVM, VMCPUID idCpu, PGMMFREEPAGESREQ pReq);
381
382/**
383 * Request buffer for GMMR0BalloonedPagesReq / VMMR0_DO_GMM_BALLOONED_PAGES.
384 * @see GMMR0BalloonedPages.
385 */
386typedef struct GMMBALLOONEDPAGESREQ
387{
388 /** The header. */
389 SUPVMMR0REQHDR Hdr;
390 /** The number of ballooned pages. */
391 uint32_t cBalloonedPages;
392 /** Inflate or deflate the balloon. */
393 GMMBALLOONACTION enmAction;
394} GMMBALLOONEDPAGESREQ;
395/** Pointer to a GMMR0BalloonedPagesReq / VMMR0_DO_GMM_BALLOONED_PAGES request buffer. */
396typedef GMMBALLOONEDPAGESREQ *PGMMBALLOONEDPAGESREQ;
397
398GMMR0DECL(int) GMMR0BalloonedPagesReq(PVM pVM, VMCPUID idCpu, PGMMBALLOONEDPAGESREQ pReq);
399
400
401/**
402 * Request buffer for GMMR0QueryHypervisorMemoryStatsReq / VMMR0_DO_GMM_QUERY_VMM_MEM_STATS.
403 * @see GMMR0QueryHypervisorMemoryStatsReq.
404 */
405typedef struct GMMMEMSTATSREQ
406{
407 /** The header. */
408 SUPVMMR0REQHDR Hdr;
409 /** The number of allocated pages (out). */
410 uint64_t cAllocPages;
411 /** The number of free pages (out). */
412 uint64_t cFreePages;
413 /** The number of ballooned pages (out). */
414 uint64_t cBalloonedPages;
415 /** Maximum nr of pages (out). */
416 uint64_t cMaxPages;
417} GMMMEMSTATSREQ;
418/** Pointer to a GMMR0QueryHypervisorMemoryStatsReq / VMMR0_DO_GMM_QUERY_HYPERVISOR_MEM_STATS request buffer. */
419typedef GMMMEMSTATSREQ *PGMMMEMSTATSREQ;
420
421GMMR0DECL(int) GMMR0QueryHypervisorMemoryStatsReq(PVM pVM, PGMMMEMSTATSREQ pReq);
422GMMR0DECL(int) GMMR0QueryMemoryStatsReq(PVM pVM, VMCPUID idCpu, PGMMMEMSTATSREQ pReq);
423
424/**
425 * Request buffer for GMMR0MapUnmapChunkReq / VMMR0_DO_GMM_MAP_UNMAP_CHUNK.
426 * @see GMMR0MapUnmapChunk
427 */
428typedef struct GMMMAPUNMAPCHUNKREQ
429{
430 /** The header. */
431 SUPVMMR0REQHDR Hdr;
432 /** The chunk to map, NIL_GMM_CHUNKID if unmap only. (IN) */
433 uint32_t idChunkMap;
434 /** The chunk to unmap, NIL_GMM_CHUNKID if map only. (IN) */
435 uint32_t idChunkUnmap;
436 /** Where the mapping address is returned. (OUT) */
437 RTR3PTR pvR3;
438} GMMMAPUNMAPCHUNKREQ;
439/** Pointer to a GMMR0MapUnmapChunkReq / VMMR0_DO_GMM_MAP_UNMAP_CHUNK request buffer. */
440typedef GMMMAPUNMAPCHUNKREQ *PGMMMAPUNMAPCHUNKREQ;
441
442GMMR0DECL(int) GMMR0MapUnmapChunkReq(PVM pVM, VMCPUID idCpu, PGMMMAPUNMAPCHUNKREQ pReq);
443
444
445/**
446 * Request buffer for GMMR0FreeLargePageReq / VMMR0_DO_GMM_FREE_LARGE_PAGE.
447 * @see GMMR0FreeLargePage.
448 */
449typedef struct GMMFREELARGEPAGEREQ
450{
451 /** The header. */
452 SUPVMMR0REQHDR Hdr;
453 /** The Page ID. */
454 uint32_t idPage;
455} GMMFREELARGEPAGEREQ;
456/** Pointer to a GMMR0FreePagesReq / VMMR0_DO_GMM_FREE_PAGES request buffer. */
457typedef GMMFREELARGEPAGEREQ *PGMMFREELARGEPAGEREQ;
458
459GMMR0DECL(int) GMMR0FreeLargePageReq(PVM pVM, VMCPUID idCpu, PGMMFREELARGEPAGEREQ pReq);
460
461/** Maximum length of the shared module name string. */
462#define GMM_SHARED_MODULE_MAX_NAME_STRING 128
463/** Maximum length of the shared module version string. */
464#define GMM_SHARED_MODULE_MAX_VERSION_STRING 16
465
466/**
467 * Request buffer for GMMR0RegisterSharedModuleReq / VMMR0_DO_GMM_REGISTER_SHARED_MODULE.
468 * @see GMMR0RegisterSharedModule.
469 */
470typedef struct GMMREGISTERSHAREDMODULEREQ
471{
472 /** The header. */
473 SUPVMMR0REQHDR Hdr;
474 /** Shared module size. */
475 uint32_t cbModule;
476 /** Number of included region descriptors */
477 uint32_t cRegions;
478 /** Base address of the shared module. */
479 RTGCPTR64 GCBaseAddr;
480 /** Module name */
481 char szName[GMM_SHARED_MODULE_MAX_NAME_STRING];
482 /** Module version */
483 char szVersion[GMM_SHARED_MODULE_MAX_VERSION_STRING];
484 /** Shared region descriptor(s). */
485 VMMDEVSHAREDREGIONDESC aRegions[1];
486} GMMREGISTERSHAREDMODULEREQ;
487/** Pointer to a GMMR0RegisterSharedModuleReq / VMMR0_DO_GMM_REGISTER_SHARED_MODULE request buffer. */
488typedef GMMREGISTERSHAREDMODULEREQ *PGMMREGISTERSHAREDMODULEREQ;
489
490GMMR0DECL(int) GMMR0RegisterSharedModuleReq(PVM pVM, VMCPUID idCpu, PGMMREGISTERSHAREDMODULEREQ pReq);
491
492/**
493 * Page descriptor for GMMR0SharedModuleCheckRange
494 */
495typedef struct GMMSHAREDPAGEDESC
496{
497 /** HC Physical address (in/out) */
498 RTHCPHYS HCPhys;
499 /** GC Physical address (in) */
500 RTGCPHYS GCPhys;
501 /** GMM page id. (in/out) */
502 uint32_t uHCPhysPageId;
503 /** Align at 8 byte boundary. */
504 uint32_t uAlignment;
505} GMMSHAREDPAGEDESC;
506/** Pointer to a GMMSHAREDPAGEDESC. */
507typedef GMMSHAREDPAGEDESC *PGMMSHAREDPAGEDESC;
508
509GMMR0DECL(int) GMMR0SharedModuleCheckRange(PVM pVM, VMCPUID idCpu, PGMMREGISTERSHAREDMODULEREQ pReq, unsigned idxRegion, unsigned cPages, PGMMSHAREDPAGEDESC paPageDesc);
510
511/**
512 * Request buffer for GMMR0UnregisterSharedModuleReq / VMMR0_DO_GMM_UNREGISTER_SHARED_MODULE.
513 * @see GMMR0UnregisterSharedModule.
514 */
515typedef struct GMMUNREGISTERSHAREDMODULEREQ
516{
517 /** The header. */
518 SUPVMMR0REQHDR Hdr;
519 /** Shared module size. */
520 uint32_t cbModule;
521 /** Align at 8 byte boundary. */
522 uint32_t u32Alignment;
523 /** Base address of the shared module. */
524 RTGCPTR64 GCBaseAddr;
525 /** Module name */
526 char szName[GMM_SHARED_MODULE_MAX_NAME_STRING];
527 /** Module version */
528 char szVersion[GMM_SHARED_MODULE_MAX_VERSION_STRING];
529} GMMUNREGISTERSHAREDMODULEREQ;
530/** Pointer to a GMMR0UnregisterSharedModuleReq / VMMR0_DO_GMM_UNREGISTER_SHARED_MODULE request buffer. */
531typedef GMMUNREGISTERSHAREDMODULEREQ *PGMMUNREGISTERSHAREDMODULEREQ;
532
533GMMR0DECL(int) GMMR0UnregisterSharedModuleReq(PVM pVM, VMCPUID idCpu, PGMMUNREGISTERSHAREDMODULEREQ pReq);
534
535
536#ifdef IN_RING3
537/** @defgroup grp_gmm_r3 The Global Memory Manager Ring-3 API Wrappers
538 * @ingroup grp_gmm
539 * @{
540 */
541GMMR3DECL(int) GMMR3InitialReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages,
542 GMMOCPOLICY enmPolicy, GMMPRIORITY enmPriority);
543GMMR3DECL(int) GMMR3UpdateReservation(PVM pVM, uint64_t cBasePages, uint32_t cShadowPages, uint32_t cFixedPages);
544GMMR3DECL(int) GMMR3AllocatePagesPrepare(PVM pVM, PGMMALLOCATEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount);
545GMMR3DECL(int) GMMR3AllocatePagesPerform(PVM pVM, PGMMALLOCATEPAGESREQ pReq);
546GMMR3DECL(void) GMMR3AllocatePagesCleanup(PGMMALLOCATEPAGESREQ pReq);
547GMMR3DECL(int) GMMR3FreePagesPrepare(PVM pVM, PGMMFREEPAGESREQ *ppReq, uint32_t cPages, GMMACCOUNT enmAccount);
548GMMR3DECL(void) GMMR3FreePagesRePrep(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t cPages, GMMACCOUNT enmAccount);
549GMMR3DECL(int) GMMR3FreePagesPerform(PVM pVM, PGMMFREEPAGESREQ pReq, uint32_t cActualPages);
550GMMR3DECL(void) GMMR3FreePagesCleanup(PGMMFREEPAGESREQ pReq);
551GMMR3DECL(void) GMMR3FreeAllocatedPages(PVM pVM, GMMALLOCATEPAGESREQ const *pAllocReq);
552GMMR3DECL(int) GMMR3AllocateLargePage(PVM pVM, uint32_t cbPage);
553GMMR3DECL(int) GMMR3FreeLargePage(PVM pVM, uint32_t idPage);
554GMMR3DECL(int) GMMR3MapUnmapChunk(PVM pVM, uint32_t idChunkMap, uint32_t idChunkUnmap, PRTR3PTR ppvR3);
555GMMR3DECL(int) GMMR3SeedChunk(PVM pVM, RTR3PTR pvR3);
556GMMR3DECL(int) GMMR3QueryHypervisorMemoryStats(PVM pVM, uint64_t *pcTotalAllocPages, uint64_t *pcTotalFreePages, uint64_t *pcTotalBalloonPages);
557GMMR3DECL(int) GMMR3QueryMemoryStats(PVM pVM, uint64_t *pcAllocPages, uint64_t *pcMaxPages, uint64_t *pcBalloonPages);
558GMMR3DECL(int) GMMR3BalloonedPages(PVM pVM, GMMBALLOONACTION enmAction, uint32_t cBalloonedPages);
559GMMR3DECL(int) GMMR3RegisterSharedModule(PVM pVM, PGMMREGISTERSHAREDMODULEREQ pReq);
560GMMR3DECL(int) GMMR3UnregisterSharedModule(PVM pVM, PGMMREGISTERSHAREDMODULEREQ pReq);
561GMMR3DECL(int) GMMR3ResetSharedModules(PVM pVM);
562/** @} */
563#endif /* IN_RING3 */
564
565/** @} */
566
567RT_C_DECLS_END
568
569#endif
570
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