VirtualBox

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

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

VMM: Make the setjmp code a bit stricter with when to resume a call. bugref:10064 ticketref:20090 ticketref:20456

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