[5033] | 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 | /*
|
---|
[98103] | 7 | * Copyright (C) 2007-2023 Oracle and/or its affiliates.
|
---|
[5033] | 8 | *
|
---|
[96407] | 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
|
---|
[5033] | 26 | */
|
---|
| 27 |
|
---|
[76561] | 28 | #ifndef VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h
|
---|
| 29 | #define VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h
|
---|
[76543] | 30 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
| 31 | # pragma once
|
---|
| 32 | #endif
|
---|
[5033] | 33 |
|
---|
[35346] | 34 | #include <VBox/vmm/gmm.h>
|
---|
[28806] | 35 | #include <iprt/avl.h>
|
---|
[5033] | 36 |
|
---|
| 37 |
|
---|
[29138] | 38 | /**
|
---|
[28986] | 39 | * Shared module registration info (per VM)
|
---|
| 40 | */
|
---|
| 41 | typedef struct GMMSHAREDMODULEPERVM
|
---|
| 42 | {
|
---|
[29168] | 43 | /** Tree node. */
|
---|
[28986] | 44 | AVLGCPTRNODECORE Core;
|
---|
[29168] | 45 | /** Pointer to global shared module info. */
|
---|
| 46 | PGMMSHAREDMODULE pGlobalModule;
|
---|
[40054] | 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];
|
---|
[28986] | 52 | } GMMSHAREDMODULEPERVM;
|
---|
| 53 | /** Pointer to a GMMSHAREDMODULEPERVM. */
|
---|
| 54 | typedef GMMSHAREDMODULEPERVM *PGMMSHAREDMODULEPERVM;
|
---|
| 55 |
|
---|
[37242] | 56 |
|
---|
| 57 | /** Pointer to a GMM allocation chunk. */
|
---|
| 58 | typedef 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 |
|
---|
[28986] | 67 | /**
|
---|
[37242] | 68 | * A set of free chunks.
|
---|
| 69 | */
|
---|
| 70 | typedef 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 |
|
---|
[82989] | 83 | /**
|
---|
| 84 | * A per-VM allocation chunk lookup TLB entry (for GMMR0PageIdToVirt).
|
---|
| 85 | */
|
---|
| 86 | typedef 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. */
|
---|
| 94 | typedef GMMPERVMCHUNKTLBE *PGMMPERVMCHUNKTLBE;
|
---|
[37242] | 95 |
|
---|
[82989] | 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 |
|
---|
[37242] | 102 | /**
|
---|
[5033] | 103 | * The per-VM GMM data.
|
---|
| 104 | */
|
---|
| 105 | typedef struct GMMPERVM
|
---|
| 106 | {
|
---|
[37242] | 107 | /** Free set for use in bound mode. */
|
---|
| 108 | GMMCHUNKFREESET Private;
|
---|
[39917] | 109 | /** The VM statistics. */
|
---|
| 110 | GMMVMSTATS Stats;
|
---|
| 111 | /** Shared module tree (per-vm). */
|
---|
| 112 | PAVLGCPTRNODECORE pSharedModuleTree;
|
---|
[37248] | 113 | /** Hints at the last chunk we allocated some memory from. */
|
---|
| 114 | uint32_t idLastChunkHint;
|
---|
[82989] | 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];
|
---|
[5033] | 121 | } GMMPERVM;
|
---|
| 122 | /** Pointer to the per-VM GMM data. */
|
---|
| 123 | typedef GMMPERVM *PGMMPERVM;
|
---|
| 124 |
|
---|
[76585] | 125 | #endif /* !VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h */
|
---|
[5033] | 126 |
|
---|