VirtualBox

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

Last change on this file since 87511 was 87511, checked in by vboxsync, 4 years ago

VMM/HMSVM: Moving some SVM stuff to HMR0PERVM. Removed 3 unused HM::svm members related to I/O bitmap. bugref:9217

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 8.3 KB
Line 
1/* $Id: gvm.h 87511 2021-02-01 15:48:11Z 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 uPadding;
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 gvmm starts on a 64 byte boundrary.
74 * @note Keeping this working for 32-bit header syntax checking. */
75 uint8_t abPadding[HC_ARCH_BITS == 32 ? 40 : 24];
76
77 /** The GVMM per vcpu data. */
78 union
79 {
80#ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
81 struct GVMMPERVCPU s;
82#endif
83 uint8_t padding[64];
84 } gvmm;
85
86 /** The HM per vcpu data. */
87 union
88 {
89#if defined(VMM_INCLUDED_SRC_include_HMInternal_h) && defined(IN_RING0)
90 struct HMR0PERVCPU s;
91#endif
92 uint8_t padding[1024];
93 } hmr0;
94
95#ifdef VBOX_WITH_NEM_R0
96 /** The NEM per vcpu data. */
97 union
98 {
99# if defined(VMM_INCLUDED_SRC_include_NEMInternal_h) && defined(IN_RING0)
100 struct NEMR0PERVCPU s;
101# endif
102 uint8_t padding[64];
103 } nemr0;
104#endif
105
106 /** Padding the structure size to page boundrary. */
107#ifdef VBOX_WITH_NEM_R0
108 uint8_t abPadding2[4096 - 64 - 64 - 1024 - 64];
109#else
110 uint8_t abPadding2[4096 - 64 - 64 - 1024];
111#endif
112} GVMCPU;
113#if RT_GNUC_PREREQ(4, 6) && defined(__cplusplus)
114# pragma GCC diagnostic push
115#endif
116#if RT_GNUC_PREREQ(4, 3) && defined(__cplusplus)
117# pragma GCC diagnostic ignored "-Winvalid-offsetof"
118#endif
119AssertCompileMemberAlignment(GVMCPU, idCpu, 4096);
120AssertCompileMemberAlignment(GVMCPU, gvmm, 64);
121#ifdef VBOX_WITH_NEM_R0
122AssertCompileMemberAlignment(GVMCPU, nemr0, 64);
123#endif
124AssertCompileSizeAlignment(GVMCPU, 4096);
125#if RT_GNUC_PREREQ(4, 6) && defined(__cplusplus)
126# pragma GCC diagnostic pop
127#endif
128
129/** @} */
130
131/** @defgroup grp_gvm GVM - The Global VM Data
132 * @ingroup grp_vmm
133 * @{
134 */
135
136/**
137 * The Global VM Data.
138 *
139 * This is a ring-0 only structure where we put items we don't need to
140 * share with ring-3 or GC, like for instance various RTR0MEMOBJ handles.
141 *
142 * Unlike VM, there are no special alignment restrictions here. The
143 * paddings are checked by compile time assertions.
144 */
145#if defined(__cplusplus) && !defined(GVM_C_STYLE_STRUCTURES)
146typedef struct GVM : public VM
147#else
148typedef struct GVM
149#endif
150{
151#if !defined(__cplusplus) || defined(GVM_C_STYLE_STRUCTURES)
152 VM s;
153#endif
154 /** Magic / eye-catcher (GVM_MAGIC). */
155 uint32_t u32Magic;
156 /** The global VM handle for this VM. */
157 uint32_t hSelf;
158 /** Pointer to this structure (for validation purposes). */
159 PGVM pSelf;
160 /** The ring-3 mapping of the VM structure. */
161 PVMR3 pVMR3;
162 /** The support driver session the VM is associated with. */
163 PSUPDRVSESSION pSession;
164 /** Number of Virtual CPUs, i.e. how many entries there are in aCpus.
165 * Same same as VM::cCpus. */
166 uint32_t cCpus;
167 /** Padding so gvmm starts on a 64 byte boundrary. */
168 uint8_t abPadding[HC_ARCH_BITS == 32 ? 12 + 28 : 28];
169
170 /** The GVMM per vm data. */
171 union
172 {
173#ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
174 struct GVMMPERVM s;
175#endif
176 uint8_t padding[256];
177 } gvmm;
178
179 /** The GMM per vm data. */
180 union
181 {
182#ifdef VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h
183 struct GMMPERVM s;
184#endif
185 uint8_t padding[1024];
186 } gmm;
187
188 /** The HM per vm data. */
189 union
190 {
191#if defined(VMM_INCLUDED_SRC_include_HMInternal_h) && defined(IN_RING0)
192 struct HMR0PERVM s;
193#endif
194 uint8_t padding[256];
195 } hmr0;
196
197#ifdef VBOX_WITH_NEM_R0
198 /** The NEM per vcpu data. */
199 union
200 {
201# if defined(VMM_INCLUDED_SRC_include_NEMInternal_h) && defined(IN_RING0)
202 struct NEMR0PERVM s;
203# endif
204 uint8_t padding[256];
205 } nemr0;
206#endif
207
208 /** The RAWPCIVM per vm data. */
209 union
210 {
211#ifdef VBOX_INCLUDED_rawpci_h
212 struct RAWPCIPERVM s;
213#endif
214 uint8_t padding[64];
215 } rawpci;
216
217 union
218 {
219#if defined(VMM_INCLUDED_SRC_include_PDMInternal_h) && defined(IN_RING0)
220 struct PDMR0PERVM s;
221#endif
222 uint8_t padding[2176];
223 } pdmr0;
224
225 union
226 {
227#if defined(VMM_INCLUDED_SRC_include_PGMInternal_h) && defined(IN_RING0)
228 struct PGMR0PERVM s;
229#endif
230 uint8_t padding[640];
231 } pgmr0;
232
233 union
234 {
235#if defined(VMM_INCLUDED_SRC_include_IOMInternal_h) && defined(IN_RING0)
236 struct IOMR0PERVM s;
237#endif
238 uint8_t padding[512];
239 } iomr0;
240
241 union
242 {
243#if defined(VMM_INCLUDED_SRC_include_APICInternal_h) && defined(IN_RING0)
244 struct APICR0PERVM s;
245#endif
246 uint8_t padding[64];
247 } apicr0;
248
249 union
250 {
251#if defined(VMM_INCLUDED_SRC_include_DBGFInternal_h) && defined(IN_RING0)
252 struct DBGFR0PERVM s;
253#endif
254 uint8_t padding[1024];
255 } dbgfr0;
256
257 /** Padding so aCpus starts on a page boundrary. */
258#ifdef VBOX_WITH_NEM_R0
259 uint8_t abPadding2[4096*2 - 64 - 256 - 256 - 1024 - 256 - 64 - 2176 - 640 - 512 - 64 - 1024 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
260#else
261 uint8_t abPadding2[4096*2 - 64 - 256 - 256 - 1024 - 64 - 2176 - 640 - 512 - 64 - 1024 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
262#endif
263
264 /** For simplifying CPU enumeration in VMMAll code. */
265 PGVMCPU apCpusR0[VMM_MAX_CPU_COUNT];
266
267 /** GVMCPU array for the configured number of virtual CPUs. */
268 GVMCPU aCpus[1];
269} GVM;
270#if 0
271#if RT_GNUC_PREREQ(4, 6) && defined(__cplusplus)
272# pragma GCC diagnostic push
273#endif
274#if RT_GNUC_PREREQ(4, 3) && defined(__cplusplus)
275# pragma GCC diagnostic ignored "-Winvalid-offsetof"
276#endif
277AssertCompileMemberAlignment(GVM, u32Magic, 64);
278AssertCompileMemberAlignment(GVM, gvmm, 64);
279AssertCompileMemberAlignment(GVM, gmm, 64);
280#ifdef VBOX_WITH_NEM_R0
281AssertCompileMemberAlignment(GVM, nemr0, 64);
282#endif
283AssertCompileMemberAlignment(GVM, rawpci, 64);
284AssertCompileMemberAlignment(GVM, pdmr0, 64);
285AssertCompileMemberAlignment(GVM, aCpus, 4096);
286AssertCompileSizeAlignment(GVM, 4096);
287#if RT_GNUC_PREREQ(4, 6) && defined(__cplusplus)
288# pragma GCC diagnostic pop
289#endif
290#endif
291
292/** The GVM::u32Magic value (Wayne Shorter). */
293#define GVM_MAGIC 0x19330825
294
295/** @} */
296
297#endif /* !VBOX_INCLUDED_vmm_gvm_h */
298
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