VirtualBox

source: vbox/trunk/include/VBox/vmm/gvm.h@ 97342

Last change on this file since 97342 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 9.9 KB
Line 
1/* $Id: gvm.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * GVM - The Global VM Data.
4 */
5
6/*
7 * Copyright (C) 2007-2022 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 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef VBOX_INCLUDED_vmm_gvm_h
38#define VBOX_INCLUDED_vmm_gvm_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#ifndef USING_VMM_COMMON_DEFS
44# error "Compile job does not include VMM_COMMON_DEFS from src/VBox/Config.kmk - make sure you really need to include this file!"
45#endif
46#include <VBox/types.h>
47#include <VBox/vmm/vm.h>
48#include <VBox/param.h>
49#include <iprt/thread.h>
50#include <iprt/assertcompile.h>
51
52
53/** @defgroup grp_gvmcpu GVMCPU - The Global VMCPU Data
54 * @ingroup grp_vmm
55 * @{
56 */
57
58#if defined(__cplusplus) && !defined(GVM_C_STYLE_STRUCTURES)
59typedef struct GVMCPU : public VMCPU
60#else
61typedef struct GVMCPU
62#endif
63{
64#if !defined(__cplusplus) || defined(GVM_C_STYLE_STRUCTURES)
65 VMCPU s;
66#endif
67
68 /** VCPU id (0 - (pVM->cCpus - 1). */
69 VMCPUID idCpu;
70 /** Padding. */
71 uint32_t uPadding0;
72
73 /** Handle to the EMT thread. */
74 RTNATIVETHREAD hEMT;
75
76 /** Pointer to the global (ring-0) VM structure this CPU belongs to. */
77 R0PTRTYPE(PGVM) pGVM;
78 /** Pointer to the GVM structure, for CTX_SUFF use in VMMAll code. */
79 PGVM pVMR0;
80 /** The ring-3 address of this structure (only VMCPU part). */
81 PVMCPUR3 pVCpuR3;
82
83 /** Padding so the noisy stuff on a 64 byte boundrary.
84 * @note Keeping this working for 32-bit header syntax checking. */
85 uint8_t abPadding1[HC_ARCH_BITS == 32 ? 40 : 24];
86
87 /** Which host CPU ID is this EMT running on.
88 * Only valid when in RC or HMR0 with scheduling disabled. */
89 RTCPUID volatile idHostCpu;
90 /** The CPU set index corresponding to idHostCpu, UINT32_MAX if not valid.
91 * @remarks Best to make sure iHostCpuSet shares cache line with idHostCpu! */
92 uint32_t volatile iHostCpuSet;
93
94 /** Padding so gvmm starts on a 64 byte boundrary.
95 * @note Keeping this working for 32-bit header syntax checking. */
96 uint8_t abPadding2[56];
97
98 /** The GVMM per vcpu data. */
99 union
100 {
101#ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
102 struct GVMMPERVCPU s;
103#endif
104 uint8_t padding[256];
105 } gvmm;
106
107 /** The HM per vcpu data. */
108 union
109 {
110#if defined(VMM_INCLUDED_SRC_include_HMInternal_h) && defined(IN_RING0)
111 struct HMR0PERVCPU s;
112#endif
113 uint8_t padding[1024];
114 } hmr0;
115
116#ifdef VBOX_WITH_NEM_R0
117 /** The NEM per vcpu data. */
118 union
119 {
120# if defined(VMM_INCLUDED_SRC_include_NEMInternal_h) && defined(IN_RING0)
121 struct NEMR0PERVCPU s;
122# endif
123 uint8_t padding[64];
124 } nemr0;
125#endif
126
127 union
128 {
129#if defined(VMM_INCLUDED_SRC_include_VMMInternal_h) && defined(IN_RING0)
130 struct VMMR0PERVCPU s;
131#endif
132 uint8_t padding[896];
133 } vmmr0;
134
135 union
136 {
137#if defined(VMM_INCLUDED_SRC_include_PGMInternal_h) && defined(IN_RING0)
138 struct PGMR0PERVCPU s;
139#endif
140 uint8_t padding[64];
141 } pgmr0;
142
143 /** Padding the structure size to page boundrary. */
144#ifdef VBOX_WITH_NEM_R0
145 uint8_t abPadding3[16384 - 64*2 - 256 - 1024 - 64 - 896 - 64];
146#else
147 uint8_t abPadding3[16384 - 64*2 - 256 - 1024 - 896 - 64];
148#endif
149} GVMCPU;
150#if RT_GNUC_PREREQ(4, 6) && defined(__cplusplus)
151# pragma GCC diagnostic push
152#endif
153#if RT_GNUC_PREREQ(4, 3) && defined(__cplusplus)
154# pragma GCC diagnostic ignored "-Winvalid-offsetof"
155#endif
156AssertCompileMemberAlignment(GVMCPU, idCpu, 16384);
157AssertCompileMemberAlignment(GVMCPU, gvmm, 64);
158#ifdef VBOX_WITH_NEM_R0
159AssertCompileMemberAlignment(GVMCPU, nemr0, 64);
160#endif
161AssertCompileSizeAlignment(GVMCPU, 16384);
162#if RT_GNUC_PREREQ(4, 6) && defined(__cplusplus)
163# pragma GCC diagnostic pop
164#endif
165
166/** @} */
167
168/** @defgroup grp_gvm GVM - The Global VM Data
169 * @ingroup grp_vmm
170 * @{
171 */
172
173/**
174 * The Global VM Data.
175 *
176 * This is a ring-0 only structure where we put items we don't need to
177 * share with ring-3 or GC, like for instance various RTR0MEMOBJ handles.
178 *
179 * Unlike VM, there are no special alignment restrictions here. The
180 * paddings are checked by compile time assertions.
181 */
182#if defined(__cplusplus) && !defined(GVM_C_STYLE_STRUCTURES)
183typedef struct GVM : public VM
184#else
185typedef struct GVM
186#endif
187{
188#if !defined(__cplusplus) || defined(GVM_C_STYLE_STRUCTURES)
189 VM s;
190#endif
191 /** Magic / eye-catcher (GVM_MAGIC). */
192 uint32_t u32Magic;
193 /** The global VM handle for this VM. */
194 uint32_t hSelf;
195 /** Pointer to this structure (for validation purposes). */
196 PGVM pSelf;
197 /** The ring-3 mapping of the VM structure. */
198 PVMR3 pVMR3;
199 /** The support driver session the VM is associated with. */
200 PSUPDRVSESSION pSession;
201 /** Number of Virtual CPUs, i.e. how many entries there are in aCpus.
202 * Same same as VM::cCpus. */
203 uint32_t cCpus;
204 /** Padding so gvmm starts on a 64 byte boundrary. */
205 uint8_t abPadding[HC_ARCH_BITS == 32 ? 12 + 28 : 28];
206
207 /** The GVMM per vm data. */
208 union
209 {
210#ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
211 struct GVMMPERVM s;
212#endif
213 uint8_t padding[4352];
214 } gvmm;
215
216 /** The GMM per vm data. */
217 union
218 {
219#ifdef VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h
220 struct GMMPERVM s;
221#endif
222 uint8_t padding[1024];
223 } gmm;
224
225 /** The HM per vm data. */
226 union
227 {
228#if defined(VMM_INCLUDED_SRC_include_HMInternal_h) && defined(IN_RING0)
229 struct HMR0PERVM s;
230#endif
231 uint8_t padding[256];
232 } hmr0;
233
234#ifdef VBOX_WITH_NEM_R0
235 /** The NEM per vcpu data. */
236 union
237 {
238# if defined(VMM_INCLUDED_SRC_include_NEMInternal_h) && defined(IN_RING0)
239 struct NEMR0PERVM s;
240# endif
241 uint8_t padding[256];
242 } nemr0;
243#endif
244
245 /** The RAWPCIVM per vm data. */
246 union
247 {
248#ifdef VBOX_INCLUDED_rawpci_h
249 struct RAWPCIPERVM s;
250#endif
251 uint8_t padding[64];
252 } rawpci;
253
254 union
255 {
256#if defined(VMM_INCLUDED_SRC_include_PDMInternal_h) && defined(IN_RING0)
257 struct PDMR0PERVM s;
258#endif
259 uint8_t padding[3008];
260 } pdmr0;
261
262 union
263 {
264#if defined(VMM_INCLUDED_SRC_include_PGMInternal_h) && defined(IN_RING0)
265 struct PGMR0PERVM s;
266#endif
267 uint8_t padding[1920];
268 } pgmr0;
269
270 union
271 {
272#if defined(VMM_INCLUDED_SRC_include_IOMInternal_h) && defined(IN_RING0)
273 struct IOMR0PERVM s;
274#endif
275 uint8_t padding[512];
276 } iomr0;
277
278 union
279 {
280#if defined(VMM_INCLUDED_SRC_include_APICInternal_h) && defined(IN_RING0)
281 struct APICR0PERVM s;
282#endif
283 uint8_t padding[64];
284 } apicr0;
285
286 union
287 {
288#if defined(VMM_INCLUDED_SRC_include_DBGFInternal_h) && defined(IN_RING0)
289 struct DBGFR0PERVM s;
290#endif
291 uint8_t padding[1024];
292 } dbgfr0;
293
294 union
295 {
296#if defined(VMM_INCLUDED_SRC_include_TMInternal_h) && defined(IN_RING0)
297 TMR0PERVM s;
298#endif
299 uint8_t padding[192];
300 } tmr0;
301
302 union
303 {
304#if defined(VMM_INCLUDED_SRC_include_VMMInternal_h) && defined(IN_RING0)
305 VMMR0PERVM s;
306#endif
307 uint8_t padding[704];
308 } vmmr0;
309
310 /** Padding so aCpus starts on a page boundrary. */
311#ifdef VBOX_WITH_NEM_R0
312 uint8_t abPadding2[16384 - 64 - 4352 - 1024 - 256 - 256 - 64 - 3008 - 1920 - 512 - 64 - 1024 - 192 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
313#else
314 uint8_t abPadding2[16384 - 64 - 4352 - 1024 - 256 - 64 - 3008 - 1920 - 512 - 64 - 1024 - 192 - 704 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
315#endif
316
317 /** For simplifying CPU enumeration in VMMAll code. */
318 PGVMCPU apCpusR0[VMM_MAX_CPU_COUNT];
319
320 /** GVMCPU array for the configured number of virtual CPUs. */
321 GVMCPU aCpus[1];
322} GVM;
323#if 0
324#if RT_GNUC_PREREQ(4, 6) && defined(__cplusplus)
325# pragma GCC diagnostic push
326#endif
327#if RT_GNUC_PREREQ(4, 3) && defined(__cplusplus)
328# pragma GCC diagnostic ignored "-Winvalid-offsetof"
329#endif
330AssertCompileMemberAlignment(GVM, u32Magic, 64);
331AssertCompileMemberAlignment(GVM, gvmm, 64);
332AssertCompileMemberAlignment(GVM, gmm, 64);
333#ifdef VBOX_WITH_NEM_R0
334AssertCompileMemberAlignment(GVM, nemr0, 64);
335#endif
336AssertCompileMemberAlignment(GVM, rawpci, 64);
337AssertCompileMemberAlignment(GVM, pdmr0, 64);
338AssertCompileMemberAlignment(GVM, aCpus, 16384);
339AssertCompileSizeAlignment(GVM, 16384);
340#if RT_GNUC_PREREQ(4, 6) && defined(__cplusplus)
341# pragma GCC diagnostic pop
342#endif
343#endif
344
345/** The GVM::u32Magic value (Wayne Shorter). */
346#define GVM_MAGIC 0x19330825
347
348/** @} */
349
350#endif /* !VBOX_INCLUDED_vmm_gvm_h */
351
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