VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/GMMR0Internal.h@ 102092

Last change on this file since 102092 was 98103, checked in by vboxsync, 2 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 3.9 KB
Line 
1/* $Id: GMMR0Internal.h 98103 2023-01-17 14:15:46Z vboxsync $ */
2/** @file
3 * GMM - The Global Memory Manager, Internal Header.
4 */
5
6/*
7 * Copyright (C) 2007-2023 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_VMMR0_GMMR0Internal_h
29#define VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h
30#ifndef RT_WITHOUT_PRAGMA_ONCE
31# pragma once
32#endif
33
34#include <VBox/vmm/gmm.h>
35#include <iprt/avl.h>
36
37
38/**
39 * Shared module registration info (per VM)
40 */
41typedef struct GMMSHAREDMODULEPERVM
42{
43 /** Tree node. */
44 AVLGCPTRNODECORE Core;
45 /** Pointer to global shared module info. */
46 PGMMSHAREDMODULE pGlobalModule;
47 /** Pointer to the region addresses.
48 *
49 * They can differe between VMs because of address space scrambling or
50 * simply different loading order. */
51 RTGCPTR64 aRegionsGCPtrs[1];
52} GMMSHAREDMODULEPERVM;
53/** Pointer to a GMMSHAREDMODULEPERVM. */
54typedef GMMSHAREDMODULEPERVM *PGMMSHAREDMODULEPERVM;
55
56
57/** Pointer to a GMM allocation chunk. */
58typedef struct GMMCHUNK *PGMMCHUNK;
59
60
61/** The GMMCHUNK::cFree shift count employed by gmmR0SelectFreeSetList. */
62#define GMM_CHUNK_FREE_SET_SHIFT 4
63/** Index of the list containing completely unused chunks.
64 * The code ASSUMES this is the last list. */
65#define GMM_CHUNK_FREE_SET_UNUSED_LIST (GMM_CHUNK_NUM_PAGES >> GMM_CHUNK_FREE_SET_SHIFT)
66
67/**
68 * A set of free chunks.
69 */
70typedef struct GMMCHUNKFREESET
71{
72 /** The number of free pages in the set. */
73 uint64_t cFreePages;
74 /** The generation ID for the set. This is incremented whenever
75 * something is linked or unlinked from this set. */
76 uint64_t idGeneration;
77 /** Chunks ordered by increasing number of free pages.
78 * In the final list the chunks are completely unused. */
79 PGMMCHUNK apLists[GMM_CHUNK_FREE_SET_UNUSED_LIST + 1];
80} GMMCHUNKFREESET;
81
82
83/**
84 * A per-VM allocation chunk lookup TLB entry (for GMMR0PageIdToVirt).
85 */
86typedef struct GMMPERVMCHUNKTLBE
87{
88 /** The GMM::idFreeGeneration value this is valid for. */
89 uint64_t idGeneration;
90 /** The chunk. */
91 PGMMCHUNK pChunk;
92} GMMPERVMCHUNKTLBE;
93/** Poitner to a per-VM allocation chunk TLB entry. */
94typedef GMMPERVMCHUNKTLBE *PGMMPERVMCHUNKTLBE;
95
96/** The number of entries in the allocation chunk lookup TLB. */
97#define GMMPERVM_CHUNKTLB_ENTRIES 32
98/** Gets the TLB entry index for the given Chunk ID. */
99#define GMMPERVM_CHUNKTLB_IDX(a_idChunk) ( (a_idChunk) & (GMMPERVM_CHUNKTLB_ENTRIES - 1) )
100
101
102/**
103 * The per-VM GMM data.
104 */
105typedef struct GMMPERVM
106{
107 /** Free set for use in bound mode. */
108 GMMCHUNKFREESET Private;
109 /** The VM statistics. */
110 GMMVMSTATS Stats;
111 /** Shared module tree (per-vm). */
112 PAVLGCPTRNODECORE pSharedModuleTree;
113 /** Hints at the last chunk we allocated some memory from. */
114 uint32_t idLastChunkHint;
115 uint32_t u32Padding;
116
117 /** Spinlock protecting the chunk lookup TLB. */
118 RTSPINLOCK hChunkTlbSpinLock;
119 /** The chunk lookup TLB used by GMMR0PageIdToVirt. */
120 GMMPERVMCHUNKTLBE aChunkTlbEntries[GMMPERVM_CHUNKTLB_ENTRIES];
121} GMMPERVM;
122/** Pointer to the per-VM GMM data. */
123typedef GMMPERVM *PGMMPERVM;
124
125#endif /* !VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h */
126
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