VirtualBox

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

Last change on this file since 91250 was 91250, checked in by vboxsync, 3 years ago

VMM/PGM: Moved pStatTrap0eAttributionR0 to GVMCPU. bugref:10093

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