VirtualBox

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

Last change on this file since 107044 was 106061, checked in by vboxsync, 2 months ago

Copyright year updates by scm.

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