VirtualBox

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

Last change on this file since 80309 was 80309, checked in by vboxsync, 6 years ago

vm.h,gvm.h: Only allow including these when VMM_COMMON_DEFS is in use. VBOX_BUGREF_9217 must be set globally since it influences VBox/types.h. Oh well, it just temporary. bugref:9217

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 7.4 KB
Line 
1/* $Id: gvm.h 80309 2019-08-15 19:53:56Z 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#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#ifdef VBOX_BUGREF_9217
38# include <VBox/vmm/vm.h>
39#endif
40#include <VBox/param.h>
41#include <iprt/thread.h>
42#include <iprt/assertcompile.h>
43
44
45/** @defgroup grp_gvmcpu GVMCPU - The Global VMCPU Data
46 * @ingroup grp_vmm
47 * @{
48 */
49
50#if defined(VBOX_BUGREF_9217) && defined(__cplusplus)
51typedef struct GVMCPU : public VMCPU
52#else
53typedef struct GVMCPU
54#endif
55{
56#if defined(VBOX_BUGREF_9217) && !defined(__cplusplus)
57 VMCPU s;
58#endif
59
60 /** VCPU id (0 - (pVM->cCpus - 1). */
61 VMCPUID idCpu;
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#else
76 /** Pointer to the GVM structure, for CTX_SUFF use in VMMAll code. */
77 PGVM pVMR0;
78 /** The ring-3 address of this structure (only VMCPU part). */
79 PVMCPUR3 pVCpuR3;
80#endif
81
82 /** Padding so gvmm starts on a 64 byte boundrary.
83 * @note Keeping this working for 32-bit header syntax checking. */
84 uint8_t abPadding[HC_ARCH_BITS == 32 ? 40 : 24];
85
86 /** The GVMM per vcpu data. */
87 union
88 {
89#ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
90 struct GVMMPERVCPU s;
91#endif
92 uint8_t padding[64];
93 } gvmm;
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#ifdef VBOX_BUGREF_9217
107 /** Padding the structure size to page boundrary. */
108# ifdef VBOX_WITH_NEM_R0
109 uint8_t abPadding2[4096 - 64 - 64 - 64];
110# else
111 uint8_t abPadding2[4096 - 64 - 64];
112# endif
113#endif
114} GVMCPU;
115#ifdef VBOX_BUGREF_9217
116AssertCompileMemberAlignment(GVMCPU, idCpu, 4096);
117AssertCompileMemberAlignment(GVMCPU, gvmm, 64);
118# ifdef VBOX_WITH_NEM_R0
119AssertCompileMemberAlignment(GVMCPU, nem, 64);
120# endif
121AssertCompileSizeAlignment(GVMCPU, 4096);
122#else
123AssertCompileMemberOffset(GVMCPU, gvmm, 64);
124# ifdef VBOX_WITH_NEM_R0
125AssertCompileMemberOffset(GVMCPU, nemr0, 64 + 64);
126AssertCompileSize( GVMCPU, 64 + 64 + 64);
127# else
128AssertCompileSize( GVMCPU, 64 + 64);
129# endif
130#endif
131
132/** @} */
133
134/** @defgroup grp_gvm GVM - The Global VM Data
135 * @ingroup grp_vmm
136 * @{
137 */
138
139/**
140 * The Global VM Data.
141 *
142 * This is a ring-0 only structure where we put items we don't need to
143 * share with ring-3 or GC, like for instance various RTR0MEMOBJ handles.
144 *
145 * Unlike VM, there are no special alignment restrictions here. The
146 * paddings are checked by compile time assertions.
147 */
148#ifdef VBOX_BUGREF_9217
149typedef struct GVM : public VM
150#else
151typedef struct GVM
152#endif
153{
154 /** Magic / eye-catcher (GVM_MAGIC). */
155 uint32_t u32Magic;
156 /** The global VM handle for this VM. */
157 uint32_t hSelf;
158#ifdef VBOX_BUGREF_9217
159 /** Pointer to this structure (for validation purposes). */
160 PGVM pSelf;
161#else
162 /** The ring-0 mapping of the VM structure. */
163 PVM pVM;
164#endif
165 /** The ring-3 mapping of the VM structure. */
166 PVMR3 pVMR3;
167 /** The support driver session the VM is associated with. */
168 PSUPDRVSESSION pSession;
169 /** Number of Virtual CPUs, i.e. how many entries there are in aCpus.
170 * Same same as VM::cCpus. */
171 uint32_t cCpus;
172 /** Padding so gvmm starts on a 64 byte boundrary. */
173 uint8_t abPadding[HC_ARCH_BITS == 32 ? 12 + 28 : 28];
174
175 /** The GVMM per vm data. */
176 union
177 {
178#ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
179 struct GVMMPERVM s;
180#endif
181 uint8_t padding[256];
182 } gvmm;
183
184 /** The GMM per vm data. */
185 union
186 {
187#ifdef VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h
188 struct GMMPERVM s;
189#endif
190 uint8_t padding[512];
191 } gmm;
192
193#ifdef VBOX_WITH_NEM_R0
194 /** The NEM per vcpu data. */
195 union
196 {
197# if defined(VMM_INCLUDED_SRC_include_NEMInternal_h) && defined(IN_RING0)
198 struct NEMR0PERVM s;
199# endif
200 uint8_t padding[256];
201 } nemr0;
202#endif
203
204 /** The RAWPCIVM per vm data. */
205 union
206 {
207#ifdef VBOX_INCLUDED_rawpci_h
208 struct RAWPCIPERVM s;
209#endif
210 uint8_t padding[64];
211 } rawpci;
212
213#ifdef VBOX_BUGREF_9217
214 /** Padding so aCpus starts on a page boundrary. */
215# ifdef VBOX_WITH_NEM_R0
216 uint8_t abPadding2[4096 - 64 - 256 - 512 - 256 - 64 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
217# else
218 uint8_t abPadding2[4096 - 64 - 256 - 512 - 64 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
219# endif
220#endif
221 /** For simplifying CPU enumeration in VMMAll code. */
222 PGVMCPU apCpusR0[VMM_MAX_CPU_COUNT];
223
224 /** GVMCPU array for the configured number of virtual CPUs. */
225 GVMCPU aCpus[1];
226} GVM;
227#ifdef VBOX_BUGREF_9217
228AssertCompileMemberAlignment(GVM, gvmm, 64);
229AssertCompileMemberAlignment(GVM, gmm, 64);
230# ifdef VBOX_WITH_NEM_R0
231AssertCompileMemberAlignment(GVM, nem, 64);
232# endif
233AssertCompileMemberAlignment(GVM, rawpci, 64);
234AssertCompileMemberAlignment(GVM, aCpus, 4096);
235AssertCompileSizeAlignment(GVM, 4096);
236#else
237AssertCompileMemberOffset(GVM, gvmm, 64);
238AssertCompileMemberOffset(GVM, gmm, 64 + 256);
239# ifdef VBOX_WITH_NEM_R0
240AssertCompileMemberOffset(GVM, nemr0, 64 + 256 + 512);
241AssertCompileMemberOffset(GVM, rawpci, 64 + 256 + 512 + 256);
242AssertCompileMemberOffset(GVM, aCpus, 64 + 256 + 512 + 256 + 64 + sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT);
243# else
244AssertCompileMemberOffset(GVM, rawpci, 64 + 256 + 512);
245AssertCompileMemberOffset(GVM, aCpus, 64 + 256 + 512 + 64 + sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT);
246# endif
247#endif
248
249/** The GVM::u32Magic value (Wayne Shorter). */
250#define GVM_MAGIC 0x19330825
251
252/** @} */
253
254#endif /* !VBOX_INCLUDED_vmm_gvm_h */
255
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