1 | /* $Id: gvm.h 78438 2019-05-07 15:57:37Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * GVM - The Global VM Data.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2007-2019 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 | * The contents of this file may alternatively be used under the terms
|
---|
18 | * of the Common Development and Distribution License Version 1.0
|
---|
19 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
20 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
21 | * CDDL are applicable instead of those of the GPL.
|
---|
22 | *
|
---|
23 | * You may elect to license modified versions of this file under the
|
---|
24 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
25 | */
|
---|
26 |
|
---|
27 | #ifndef VBOX_INCLUDED_vmm_gvm_h
|
---|
28 | #define VBOX_INCLUDED_vmm_gvm_h
|
---|
29 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
30 | # pragma once
|
---|
31 | #endif
|
---|
32 |
|
---|
33 | #include <VBox/types.h>
|
---|
34 | #ifdef VBOX_BUGREF_9217
|
---|
35 | # include <VBox/vmm/vm.h>
|
---|
36 | #endif
|
---|
37 | #include <iprt/thread.h>
|
---|
38 | #include <iprt/assertcompile.h>
|
---|
39 |
|
---|
40 |
|
---|
41 | /** @defgroup grp_gvmcpu GVMCPU - The Global VMCPU Data
|
---|
42 | * @ingroup grp_vmm
|
---|
43 | * @{
|
---|
44 | */
|
---|
45 |
|
---|
46 | #if defined(VBOX_BUGREF_9217) && defined(__cplusplus)
|
---|
47 | typedef struct GVMCPU : public VMCPU
|
---|
48 | #else
|
---|
49 | typedef struct GVMCPU
|
---|
50 | #endif
|
---|
51 | {
|
---|
52 | #if defined(VBOX_BUGREF_9217) && !defined(__cplusplus)
|
---|
53 | VMCPU s;
|
---|
54 | #endif
|
---|
55 |
|
---|
56 | /** VCPU id (0 - (pVM->cCpus - 1). */
|
---|
57 | #ifdef VBOX_BUGREF_9217
|
---|
58 | VMCPUID idCpuSafe;
|
---|
59 | #else
|
---|
60 | VMCPUID idCpu;
|
---|
61 | #endif
|
---|
62 | /** Padding. */
|
---|
63 | uint32_t uPadding;
|
---|
64 |
|
---|
65 | /** Handle to the EMT thread. */
|
---|
66 | RTNATIVETHREAD hEMT;
|
---|
67 |
|
---|
68 | /** Pointer to the global (ring-0) VM structure this CPU belongs to. */
|
---|
69 | R0PTRTYPE(PGVM) pGVM;
|
---|
70 | #ifndef VBOX_BUGREF_9217
|
---|
71 | /** Pointer to the corresponding cross context CPU structure. */
|
---|
72 | PVMCPU pVCpu;
|
---|
73 | /** Pointer to the corresponding cross context VM structure. */
|
---|
74 | PVM pVM;
|
---|
75 | #endif
|
---|
76 |
|
---|
77 | /** Padding so gvmm starts on a 64 byte boundrary. */
|
---|
78 | #ifdef VBOX_BUGREF_9217
|
---|
79 | uint8_t abPadding[HC_ARCH_BITS == 32 ? 48 : 40];
|
---|
80 | #else
|
---|
81 | uint8_t abPadding[HC_ARCH_BITS == 32 ? 4*4 + 24 : 24];
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | /** The GVMM per vcpu data. */
|
---|
85 | union
|
---|
86 | {
|
---|
87 | #ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
|
---|
88 | struct GVMMPERVCPU s;
|
---|
89 | #endif
|
---|
90 | uint8_t padding[64];
|
---|
91 | } gvmm;
|
---|
92 |
|
---|
93 | #ifdef VBOX_WITH_NEM_R0
|
---|
94 | /** The NEM per vcpu data. */
|
---|
95 | union
|
---|
96 | {
|
---|
97 | # if defined(VMM_INCLUDED_SRC_include_NEMInternal_h) && defined(IN_RING0)
|
---|
98 | struct NEMR0PERVCPU s;
|
---|
99 | # endif
|
---|
100 | uint8_t padding[64];
|
---|
101 | } nem;
|
---|
102 | #endif
|
---|
103 |
|
---|
104 | #ifdef VBOX_BUGREF_9217
|
---|
105 | /** Padding the structure size to page boundrary. */
|
---|
106 | # ifdef VBOX_WITH_NEM_R0
|
---|
107 | uint8_t abPadding2[3904];
|
---|
108 | # else
|
---|
109 | uint8_t abPadding2[3840];
|
---|
110 | # endif
|
---|
111 | #endif
|
---|
112 |
|
---|
113 | } GVMCPU;
|
---|
114 | #ifdef VBOX_BUGREF_9217
|
---|
115 | AssertCompileMemberAlignment(GVMCPU, gvmm, 64);
|
---|
116 | # ifdef VBOX_WITH_NEM_R0
|
---|
117 | AssertCompileMemberAlignment(GVMCPU, nem, 64);
|
---|
118 | # endif
|
---|
119 | AssertCompileSizeAlignment(GVMCPU, 4096);
|
---|
120 | #else
|
---|
121 | AssertCompileMemberOffset(GVMCPU, gvmm, 64);
|
---|
122 | # ifdef VBOX_WITH_NEM_R0
|
---|
123 | AssertCompileMemberOffset(GVMCPU, nem, 64 + 64);
|
---|
124 | AssertCompileSize( GVMCPU, 64 + 64 + 64);
|
---|
125 | # else
|
---|
126 | AssertCompileSize( GVMCPU, 64 + 64);
|
---|
127 | # endif
|
---|
128 | #endif
|
---|
129 |
|
---|
130 | /** @} */
|
---|
131 |
|
---|
132 | /** @defgroup grp_gvm GVM - The Global VM Data
|
---|
133 | * @ingroup grp_vmm
|
---|
134 | * @{
|
---|
135 | */
|
---|
136 |
|
---|
137 | /**
|
---|
138 | * The Global VM Data.
|
---|
139 | *
|
---|
140 | * This is a ring-0 only structure where we put items we don't need to
|
---|
141 | * share with ring-3 or GC, like for instance various RTR0MEMOBJ handles.
|
---|
142 | *
|
---|
143 | * Unlike VM, there are no special alignment restrictions here. The
|
---|
144 | * paddings are checked by compile time assertions.
|
---|
145 | */
|
---|
146 | #ifdef VBOX_BUGREF_9217
|
---|
147 | typedef struct GVM : public VM
|
---|
148 | #else
|
---|
149 | typedef struct GVM
|
---|
150 | #endif
|
---|
151 | {
|
---|
152 | /** Magic / eye-catcher (GVM_MAGIC). */
|
---|
153 | uint32_t u32Magic;
|
---|
154 | /** The global VM handle for this VM. */
|
---|
155 | #ifdef VBOX_BUGREF_9217
|
---|
156 | uint32_t hSelfSafe;
|
---|
157 | #else
|
---|
158 | uint32_t hSelf;
|
---|
159 | #endif
|
---|
160 | #ifndef VBOX_BUGREF_9217
|
---|
161 | /** The ring-0 mapping of the VM structure. */
|
---|
162 | PVM pVM;
|
---|
163 | #endif
|
---|
164 | /** The ring-3 mapping of the VM structure. */
|
---|
165 | PVMR3 pVMR3;
|
---|
166 | /** The support driver session the VM is associated with. */
|
---|
167 | #ifdef VBOX_BUGREF_9217
|
---|
168 | PSUPDRVSESSION pSessionSafe;
|
---|
169 | #else
|
---|
170 | PSUPDRVSESSION pSession;
|
---|
171 | #endif
|
---|
172 | /** Number of Virtual CPUs, i.e. how many entries there are in aCpus.
|
---|
173 | * Same same as VM::cCpus. */
|
---|
174 | #ifdef VBOX_BUGREF_9217
|
---|
175 | uint32_t cCpusSafe;
|
---|
176 | #else
|
---|
177 | uint32_t cCpus;
|
---|
178 | #endif
|
---|
179 | /** Padding so gvmm starts on a 64 byte boundrary. */
|
---|
180 | #ifdef VBOX_BUGREF_9217
|
---|
181 | uint8_t abPadding[HC_ARCH_BITS == 32 ? 12 + 28 + 4 : 28 + 8];
|
---|
182 | #else
|
---|
183 | uint8_t abPadding[HC_ARCH_BITS == 32 ? 12 + 28 : 28];
|
---|
184 | #endif
|
---|
185 |
|
---|
186 | /** The GVMM per vm data. */
|
---|
187 | union
|
---|
188 | {
|
---|
189 | #ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
|
---|
190 | struct GVMMPERVM s;
|
---|
191 | #endif
|
---|
192 | uint8_t padding[256];
|
---|
193 | } gvmm;
|
---|
194 |
|
---|
195 | /** The GMM per vm data. */
|
---|
196 | union
|
---|
197 | {
|
---|
198 | #ifdef VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h
|
---|
199 | struct GMMPERVM s;
|
---|
200 | #endif
|
---|
201 | uint8_t padding[512];
|
---|
202 | } gmm;
|
---|
203 |
|
---|
204 | #ifdef VBOX_WITH_NEM_R0
|
---|
205 | /** The NEM per vcpu data. */
|
---|
206 | union
|
---|
207 | {
|
---|
208 | # if defined(VMM_INCLUDED_SRC_include_NEMInternal_h) && defined(IN_RING0)
|
---|
209 | struct NEMR0PERVM s;
|
---|
210 | # endif
|
---|
211 | uint8_t padding[256];
|
---|
212 | } nem;
|
---|
213 | #endif
|
---|
214 |
|
---|
215 | /** The RAWPCIVM per vm data. */
|
---|
216 | union
|
---|
217 | {
|
---|
218 | #ifdef VBOX_INCLUDED_rawpci_h
|
---|
219 | struct RAWPCIPERVM s;
|
---|
220 | #endif
|
---|
221 | uint8_t padding[64];
|
---|
222 | } rawpci;
|
---|
223 |
|
---|
224 | #ifdef VBOX_BUGREF_9217
|
---|
225 | /** Padding so aCpus starts on a page boundrary. */
|
---|
226 | # ifdef VBOX_WITH_NEM_R0
|
---|
227 | uint8_t abPadding2[4096 - 64 - 256 - 512 - 256 - 64];
|
---|
228 | # else
|
---|
229 | uint8_t abPadding2[4096 - 64 - 256 - 512 - 64];
|
---|
230 | # endif
|
---|
231 | #endif
|
---|
232 |
|
---|
233 | /** GVMCPU array for the configured number of virtual CPUs. */
|
---|
234 | GVMCPU aCpus[1];
|
---|
235 | } GVM;
|
---|
236 | #ifdef VBOX_BUGREF_9217
|
---|
237 | AssertCompileMemberAlignment(GVM, gvmm, 64);
|
---|
238 | AssertCompileMemberAlignment(GVM, gmm, 64);
|
---|
239 | # ifdef VBOX_WITH_NEM_R0
|
---|
240 | AssertCompileMemberAlignment(GVM, nem, 64);
|
---|
241 | # endif
|
---|
242 | AssertCompileMemberAlignment(GVM, rawpci, 64);
|
---|
243 | AssertCompileMemberAlignment(GVM, aCpus, 4096);
|
---|
244 | AssertCompileSizeAlignment(GVM, 4096);
|
---|
245 | #else
|
---|
246 | AssertCompileMemberOffset(GVM, gvmm, 64);
|
---|
247 | AssertCompileMemberOffset(GVM, gmm, 64 + 256);
|
---|
248 | # ifdef VBOX_WITH_NEM_R0
|
---|
249 | AssertCompileMemberOffset(GVM, nem, 64 + 256 + 512);
|
---|
250 | AssertCompileMemberOffset(GVM, rawpci, 64 + 256 + 512 + 256);
|
---|
251 | AssertCompileMemberOffset(GVM, aCpus, 64 + 256 + 512 + 256 + 64);
|
---|
252 | # else
|
---|
253 | AssertCompileMemberOffset(GVM, rawpci, 64 + 256 + 512);
|
---|
254 | AssertCompileMemberOffset(GVM, aCpus, 64 + 256 + 512 + 64);
|
---|
255 | # endif
|
---|
256 | #endif
|
---|
257 |
|
---|
258 | /** The GVM::u32Magic value (Wayne Shorter). */
|
---|
259 | #define GVM_MAGIC 0x19330825
|
---|
260 |
|
---|
261 | /** @} */
|
---|
262 |
|
---|
263 | #endif /* !VBOX_INCLUDED_vmm_gvm_h */
|
---|
264 |
|
---|