VirtualBox

source: vbox/trunk/include/VBox/param.h@ 108805

Last change on this file since 108805 was 108736, checked in by vboxsync, 8 weeks ago

VBox/param.h: Added GUEST_MIN_PAGE_SIZE/OFFSET_MASK/SHIFT and GUEST_MAX_PAGE_SIZE/OFFSET_MASK/SHIFT to better handle configurable page sizes on arm. jiraref:VBP-1598

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.4 KB
Line 
1/** @file
2 * VirtualBox Parameter Definitions. (VMM,+)
3 *
4 * param.mac is generated from this file by running 'kmk incs' in the root.
5 */
6
7/*
8 * Copyright (C) 2006-2024 Oracle and/or its affiliates.
9 *
10 * This file is part of VirtualBox base platform packages, as
11 * available from https://www.virtualbox.org.
12 *
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation, in version 3 of the
16 * License.
17 *
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 * General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, see <https://www.gnu.org/licenses>.
25 *
26 * The contents of this file may alternatively be used under the terms
27 * of the Common Development and Distribution License Version 1.0
28 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
29 * in the VirtualBox distribution, in which case the provisions of the
30 * CDDL are applicable instead of those of the GPL.
31 *
32 * You may elect to license modified versions of this file under the
33 * terms and conditions of either the GPL or the CDDL or both.
34 *
35 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
36 */
37
38#ifndef VBOX_INCLUDED_param_h
39#define VBOX_INCLUDED_param_h
40#ifndef RT_WITHOUT_PRAGMA_ONCE
41# pragma once
42#endif
43
44#include <iprt/param.h>
45#include <iprt/cdefs.h>
46#ifdef VMM_HOST_PAGE_SIZE_DYNAMIC
47# include <iprt/system.h>
48#endif
49
50
51/** @defgroup grp_vbox_param VBox Parameter Definition
52 * @{
53 */
54
55/** @def GUEST_MIN_PAGE_SIZE
56 * Minimum guest page size. */
57#define GUEST_MIN_PAGE_SIZE 0x1000
58/** @def GUEST_MIN_PAGE_OFFSET_MASK
59 * Minimum guest page size.
60 * @note If one-complementing this, always put a typecast after the operator! */
61#define GUEST_MIN_PAGE_OFFSET_MASK 0xfff
62/** @def GUEST_MIN_PAGE_SHIFT
63 * Minimum guest page size. */
64#define GUEST_MIN_PAGE_SHIFT 12
65
66/** @def GUEST_MAX_PAGE_SIZE
67 * Maximum guest page size. */
68#ifdef VBOX_VMM_TARGET_ARMV8
69# define GUEST_MAX_PAGE_SIZE 0x10000
70#elif defined(VBOX_VMM_TARGET_X86) || defined(DOXYGEN_RUNNING)
71# define GUEST_MAX_PAGE_SIZE 0x1000
72#endif
73/** @def GUEST_MAX_PAGE_OFFSET_MASK
74 * Maximum guest page size.
75 * @note If one-complementing this, always put a typecast after the operator! */
76#ifdef VBOX_VMM_TARGET_ARMV8
77# define GUEST_MAX_PAGE_OFFSET_MASK 0xffff
78#elif defined(VBOX_VMM_TARGET_X86) || defined(DOXYGEN_RUNNING)
79# define GUEST_MAX_PAGE_OFFSET_MASK 0xfff
80#endif
81/** @def GUEST_MAX_PAGE_SHIFT
82 * Maximum guest page size. */
83#ifdef VBOX_VMM_TARGET_ARMV8
84# define GUEST_MAX_PAGE_SHIFT 16
85#elif defined(VBOX_VMM_TARGET_X86) || defined(DOXYGEN_RUNNING)
86# define GUEST_MAX_PAGE_SHIFT 12
87#endif
88
89/** The guest page size (x86). */
90#define GUEST_PAGE_SIZE 0x1000
91/** The guest page offset mask (x86).
92 * @note If one-complementing this, always put a typecast after the operator! */
93#define GUEST_PAGE_OFFSET_MASK 0xfff
94/** The guest page shift (x86). */
95#define GUEST_PAGE_SHIFT 12
96
97
98/** Host page size. */
99#define HOST_PAGE_SIZE PAGE_SIZE
100/** Host page offset mask.
101 * @note If one-complementing this, always put a typecast after the operator! */
102#define HOST_PAGE_OFFSET_MASK PAGE_OFFSET_MASK
103/** Host page shift. */
104#define HOST_PAGE_SHIFT PAGE_SHIFT
105
106
107/** The host page size which can be dynamic on certain hosts, linux.arm64 for instance */
108#ifdef VMM_HOST_PAGE_SIZE_DYNAMIC
109# define HOST_PAGE_SIZE_DYNAMIC RTSystemGetPageSize()
110#else
111# define HOST_PAGE_SIZE_DYNAMIC HOST_PAGE_SIZE
112#endif
113/** The host page shift which can be dynamic on certain hosts, linux.arm64 for instance */
114#ifdef VMM_HOST_PAGE_SIZE_DYNAMIC
115# define HOST_PAGE_SHIFT_DYNAMIC RTSystemGetPageShift()
116#else
117# define HOST_PAGE_SHIFT_DYNAMIC HOST_PAGE_SHIFT
118#endif
119
120
121/** The maximum memory size that can be allocated and mapped
122 * by various MM, PGM and SUP APIs. */
123#define VBOX_MAX_ALLOC_SIZE _512M
124
125
126/** The maximum number of pages that can be allocated and mapped
127 * by various MM, PGM and SUP APIs. */
128#if ARCH_BITS == 64
129# define VBOX_MAX_ALLOC_PAGE_COUNT (VBOX_MAX_ALLOC_SIZE / PAGE_SIZE)
130#else
131# define VBOX_MAX_ALLOC_PAGE_COUNT (_256M / PAGE_SIZE) /** @todo r=aeichner Remove? */
132#endif
133
134/** @def VBOX_WITH_PAGE_SHARING
135 * Enables the page sharing code on the host side (do not use in guest code).
136 * @remarks Currently we only support page fusion on mainline AMD64 hosts,
137 * except Mac OS X (no ring-0). */
138#if ( HC_ARCH_BITS == 64 /* ASM-NOINC */ \
139 && defined(RT_ARCH_AMD64) /* ASM-NOINC */ \
140 && (defined(RT_OS_FREEBSD) || defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS) || defined(RT_OS_WINDOWS)) ) /* ASM-NOINC */ \
141 || defined(DOXYGEN_RUNNING) /* ASM-NOINC */
142# define VBOX_WITH_PAGE_SHARING /* ASM-NOINC */
143#endif /* ASM-NOINC */
144
145
146/** @defgroup grp_vbox_param_mm Memory Monitor Parameters
147 * @{
148 */
149/** Initial address of Hypervisor Memory Area.
150 * MUST BE PAGE TABLE ALIGNED! */
151#define MM_HYPER_AREA_ADDRESS UINT32_C(0xa0000000)
152
153/** The max size of the hypervisor memory area. */
154#define MM_HYPER_AREA_MAX_SIZE (40U * _1M) /**< @todo Readjust when floating RAMRANGEs have been implemented. Used to be 20 * _1MB */
155
156/** Maximum number of bytes we can dynamically map into the hypervisor region.
157 * This must be a power of 2 number of pages!
158 */
159#define MM_HYPER_DYNAMIC_SIZE (16U * PAGE_SIZE)
160
161/** The minimum guest RAM size in bytes. */
162#define MM_RAM_MIN UINT32_C(0x00400000)
163/** The maximum guest RAM size in bytes. */
164#if HC_ARCH_BITS == 64
165# define MM_RAM_MAX UINT64_C(0x20000000000)
166#else
167# define MM_RAM_MAX UINT64_C(0x000E0000000)
168#endif
169/** The minimum guest RAM size in MBs. */
170#define MM_RAM_MIN_IN_MB UINT32_C(4)
171/** The maximum guest RAM size in MBs. */
172#if HC_ARCH_BITS == 64
173# define MM_RAM_MAX_IN_MB UINT32_C(2097152)
174#else
175# define MM_RAM_MAX_IN_MB UINT32_C(3584)
176#endif
177/** The default size of the below 4GB RAM hole. */
178#define MM_RAM_HOLE_SIZE_DEFAULT (512U * _1M)
179/** The maximum 64-bit MMIO BAR size.
180 * @remarks There isn't really any limit here other than the size of the
181 * tracking structures we need (around 1/256 of the size). */
182#if HC_ARCH_BITS == 64
183# define MM_MMIO_64_MAX _1T
184#else
185# define MM_MMIO_64_MAX (_1G64 * 16)
186#endif
187/** The maximum 32-bit MMIO BAR size. */
188#define MM_MMIO_32_MAX _2G
189
190/** @} */
191
192/** @defgroup grp_vbox_param_pdm Pluggable Device Manager Parameters
193 * @{
194 */
195/** Max number of network shaper groups. */
196#define PDM_NET_SHAPER_MAX_GROUPS 32
197/** Max length of a network shaper group name (excluding terminator). */
198#define PDM_NET_SHAPER_MAX_NAME_LEN 63
199/** @} */
200
201
202/** @defgroup grp_vbox_param_pgm Page Manager Parameters
203 * @{
204 */
205/** The number of handy pages.
206 * This should be a power of two. */
207#define PGM_HANDY_PAGES 128
208/** The threshold at which allocation of more handy pages is flagged. */
209#define PGM_HANDY_PAGES_SET_FF 32
210/** The threshold at which we will allocate more when in ring-3.
211 * This is must be smaller than both PGM_HANDY_PAGES_SET_FF and
212 * PGM_HANDY_PAGES_MIN. */
213#define PGM_HANDY_PAGES_R3_ALLOC 8
214/** The threshold at which we will allocate more when in ring-0 or raw mode.
215 * The idea is that we should never go below this threshold while in ring-0 or
216 * raw mode because of PGM_HANDY_PAGES_RZ_TO_R3. However, should this happen and
217 * we are actually out of memory, we will have 8 page to get out of whatever
218 * code we're executing.
219 *
220 * This is must be smaller than both PGM_HANDY_PAGES_SET_FF and
221 * PGM_HANDY_PAGES_MIN. */
222#define PGM_HANDY_PAGES_RZ_ALLOC 8
223/** The threshold at which we force return to R3 ASAP.
224 * The idea is that this should be large enough to get out of any code and up to
225 * the main EM loop when we are out of memory.
226 * This must be less or equal to PGM_HANDY_PAGES_MIN. */
227#define PGM_HANDY_PAGES_RZ_TO_R3 24
228/** The minimum number of handy pages (after allocation).
229 * This must be greater or equal to PGM_HANDY_PAGES_SET_FF.
230 * Another name would be PGM_HANDY_PAGES_EXTRA_RESERVATION or _PARANOIA. :-) */
231#define PGM_HANDY_PAGES_MIN 32
232/** @} */
233
234
235/** @defgroup grp_vbox_param_vmm VMM Parameters
236 * @{
237 */
238/** VMM stack size. */
239#ifdef RT_OS_DARWIN
240# define VMM_STACK_SIZE 16384U
241#else
242# define VMM_STACK_SIZE 8192U
243#endif
244/** Min number of Virtual CPUs. */
245#define VMM_MIN_CPU_COUNT 1
246/** Max number of Virtual CPUs. */
247#define VMM_MAX_CPU_COUNT 64
248
249/** @} */
250
251
252/** @defgroup grp_vbox_pci PCI Identifiers
253 * @{ */
254/** VirtualBox PCI vendor ID. */
255#define VBOX_PCI_VENDORID (0x80ee)
256
257/** @name VirtualBox graphics card identifiers
258 * @{ */
259#define VBOX_VENDORID VBOX_PCI_VENDORID /**< @todo wonderful choice of name! Please squeeze a _VGA_ or something in there, please. */
260#define VBOX_DEVICEID (0xbeef) /**< @todo ditto. */
261#define VBOX_VESA_VENDORID VBOX_PCI_VENDORID
262#define VBOX_VESA_DEVICEID (0xbeef)
263/** @} */
264
265/** @name VMMDev PCI card identifiers
266 * @{ */
267#define VMMDEV_VENDORID VBOX_PCI_VENDORID
268#define VMMDEV_DEVICEID (0xcafe)
269/** @} */
270
271/** @} */
272
273
274/** @defgroup grp_vbox_param_vga VGA
275 * @{ */
276/** The default amount of VGA VRAM (in bytes). */
277#define VGA_VRAM_DEFAULT (_4M)
278/** The minimum amount of VGA VRAM (in bytes). */
279#define VGA_VRAM_MIN (_1M)
280/** The maximum amount of VGA VRAM (in bytes). */
281#define VGA_VRAM_MAX (_1G)
282
283/** The minimum amount of SVGA VRAM (in bytes). */
284#define VBOX_SVGA_VRAM_MIN_SIZE (4U * 640U * 480U)
285/** The maximum amount of SVGA VRAM (in bytes) when 3D acceleration is enabled. */
286#define VBOX_SVGA_VRAM_MIN_SIZE_3D _16M
287/** The maximum amount of SVGA VRAM (in bytes). */
288#define VBOX_SVGA_VRAM_MAX_SIZE _128M
289/** @} */
290
291
292/** @defgroup grp_vbox_param_misc Misc
293 * @{ */
294
295/** The maximum size of a generic segment offload (GSO) frame. This limit is
296 * imposed by the 16-bit frame size in internal networking header. */
297#define VBOX_MAX_GSO_SIZE 0xfff0
298
299/** @} */
300
301
302/** @} */
303
304#endif /* !VBOX_INCLUDED_param_h */
305
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette