VirtualBox

source: vbox/trunk/src/VBox/VMM/include/MMInternal.h@ 94249

Last change on this file since 94249 was 93718, checked in by vboxsync, 3 years ago

VMM/MM: Removed the hyper heap. bugref:10093 bugref:9517

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.4 KB
Line 
1/* $Id: MMInternal.h 93718 2022-02-14 11:09:36Z vboxsync $ */
2/** @file
3 * MM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2022 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#ifndef VMM_INCLUDED_SRC_include_MMInternal_h
19#define VMM_INCLUDED_SRC_include_MMInternal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/cdefs.h>
25#include <VBox/types.h>
26#include <VBox/sup.h>
27#include <VBox/vmm/stam.h>
28#include <VBox/vmm/pdmcritsect.h>
29#include <iprt/assert.h>
30#include <iprt/avl.h>
31#include <iprt/critsect.h>
32
33
34
35/** @defgroup grp_mm_int Internals
36 * @ingroup grp_mm
37 * @internal
38 * @{
39 */
40
41
42/** @name MMR3Heap - VM Ring-3 Heap Internals
43 * @{
44 */
45
46/** @def MMR3HEAP_SIZE_ALIGNMENT
47 * The allocation size alignment of the MMR3Heap.
48 */
49#define MMR3HEAP_SIZE_ALIGNMENT 16
50
51/** @def MMR3HEAP_WITH_STATISTICS
52 * Enable MMR3Heap statistics.
53 */
54#if !defined(MMR3HEAP_WITH_STATISTICS) && defined(VBOX_WITH_STATISTICS)
55# define MMR3HEAP_WITH_STATISTICS
56#endif
57
58/**
59 * Heap statistics record.
60 * There is one global and one per allocation tag.
61 */
62typedef struct MMHEAPSTAT
63{
64 /** Core avl node, key is the tag. */
65 AVLULNODECORE Core;
66 /** Pointer to the heap the memory belongs to. */
67 struct MMHEAP *pHeap;
68#ifdef MMR3HEAP_WITH_STATISTICS
69 /** Number of bytes currently allocated. */
70 size_t cbCurAllocated;
71 /** Number of allocation. */
72 uint64_t cAllocations;
73 /** Number of reallocations. */
74 uint64_t cReallocations;
75 /** Number of frees. */
76 uint64_t cFrees;
77 /** Failures. */
78 uint64_t cFailures;
79 /** Number of bytes allocated (sum). */
80 uint64_t cbAllocated;
81 /** Number of bytes freed. */
82 uint64_t cbFreed;
83#endif
84} MMHEAPSTAT;
85#if defined(MMR3HEAP_WITH_STATISTICS) && defined(IN_RING3)
86AssertCompileMemberAlignment(MMHEAPSTAT, cAllocations, 8);
87AssertCompileSizeAlignment(MMHEAPSTAT, 8);
88#endif
89/** Pointer to heap statistics record. */
90typedef MMHEAPSTAT *PMMHEAPSTAT;
91
92
93
94
95/**
96 * Additional heap block header for relating allocations to the VM.
97 */
98typedef struct MMHEAPHDR
99{
100 /** Pointer to the next record. */
101 struct MMHEAPHDR *pNext;
102 /** Pointer to the previous record. */
103 struct MMHEAPHDR *pPrev;
104 /** Pointer to the heap statistics record.
105 * (Where the a PVM can be found.) */
106 PMMHEAPSTAT pStat;
107 /** Size of the allocation (including this header). */
108 size_t cbSize;
109} MMHEAPHDR;
110/** Pointer to MM heap header. */
111typedef MMHEAPHDR *PMMHEAPHDR;
112
113
114/** MM Heap structure. */
115typedef struct MMHEAP
116{
117 /** Lock protecting the heap. */
118 RTCRITSECT Lock;
119 /** Heap block list head. */
120 PMMHEAPHDR pHead;
121 /** Heap block list tail. */
122 PMMHEAPHDR pTail;
123 /** Heap per tag statistics tree. */
124 PAVLULNODECORE pStatTree;
125 /** The VM handle. */
126 PUVM pUVM;
127 /** Heap global statistics. */
128 MMHEAPSTAT Stat;
129} MMHEAP;
130/** Pointer to MM Heap structure. */
131typedef MMHEAP *PMMHEAP;
132
133/** @} */
134
135/**
136 * MM Data (part of VM)
137 */
138typedef struct MM
139{
140 /** Set if MMR3InitPaging has been called. */
141 bool fDoneMMR3InitPaging;
142 /** Padding. */
143 bool afPadding1[7];
144
145 /** Size of the base RAM in bytes. (The CFGM RamSize value.) */
146 uint64_t cbRamBase;
147 /** Number of bytes of RAM above 4GB, starting at address 4GB. */
148 uint64_t cbRamAbove4GB;
149 /** Size of the below 4GB RAM hole. */
150 uint32_t cbRamHole;
151 /** Number of bytes of RAM below 4GB, starting at address 0. */
152 uint32_t cbRamBelow4GB;
153 /** The number of base RAM pages that PGM has reserved (GMM).
154 * @remarks Shadow ROMs will be counted twice (RAM+ROM), so it won't be 1:1 with
155 * what the guest sees. */
156 uint64_t cBasePages;
157 /** The number of handy pages that PGM has reserved (GMM).
158 * These are kept out of cBasePages and thus out of the saved state. */
159 uint32_t cHandyPages;
160 /** The number of shadow pages PGM has reserved (GMM). */
161 uint32_t cShadowPages;
162 /** The number of fixed pages we've reserved (GMM). */
163 uint32_t cFixedPages;
164 /** Padding. */
165 uint32_t u32Padding2;
166} MM;
167/** Pointer to MM Data (part of VM). */
168typedef MM *PMM;
169
170
171/**
172 * MM data kept in the UVM.
173 */
174typedef struct MMUSERPERVM
175{
176 /** Pointer to the MM R3 Heap. */
177 R3PTRTYPE(PMMHEAP) pHeap;
178} MMUSERPERVM;
179/** Pointer to the MM data kept in the UVM. */
180typedef MMUSERPERVM *PMMUSERPERVM;
181
182
183RT_C_DECLS_BEGIN
184
185int mmR3UpdateReservation(PVM pVM);
186
187int mmR3HeapCreateU(PUVM pUVM, PMMHEAP *ppHeap);
188void mmR3HeapDestroy(PMMHEAP pHeap);
189
190const char *mmGetTagName(MMTAG enmTag);
191
192RT_C_DECLS_END
193
194/** @} */
195
196#endif /* !VMM_INCLUDED_SRC_include_MMInternal_h */
197
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