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