VirtualBox

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

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

VMM,++: Refactoring code to use VMMC & VMMCPUCC. bugref:9217

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 7.3 KB
Line 
1/* $Id: gvm.h 80281 2019-08-15 07:29:37Z 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#include <VBox/types.h>
34#ifdef VBOX_BUGREF_9217
35# include <VBox/vmm/vm.h>
36#endif
37#include <VBox/param.h>
38#include <iprt/thread.h>
39#include <iprt/assertcompile.h>
40
41
42/** @defgroup grp_gvmcpu GVMCPU - The Global VMCPU Data
43 * @ingroup grp_vmm
44 * @{
45 */
46
47#if defined(VBOX_BUGREF_9217) && defined(__cplusplus)
48typedef struct GVMCPU : public VMCPU
49#else
50typedef struct GVMCPU
51#endif
52{
53#if defined(VBOX_BUGREF_9217) && !defined(__cplusplus)
54 VMCPU s;
55#endif
56
57 /** VCPU id (0 - (pVM->cCpus - 1). */
58 VMCPUID idCpu;
59 /** Padding. */
60 uint32_t uPadding;
61
62 /** Handle to the EMT thread. */
63 RTNATIVETHREAD hEMT;
64
65 /** Pointer to the global (ring-0) VM structure this CPU belongs to. */
66 R0PTRTYPE(PGVM) pGVM;
67#ifndef VBOX_BUGREF_9217
68 /** Pointer to the corresponding cross context CPU structure. */
69 PVMCPU pVCpu;
70 /** Pointer to the corresponding cross context VM structure. */
71 PVM pVM;
72#else
73 /** Pointer to the GVM structure, for CTX_SUFF use in VMMAll code. */
74 PGVM pVMR0;
75 /** The ring-3 address of this structure (only VMCPU part). */
76 PVMCPUR3 pVCpuR3;
77#endif
78
79 /** Padding so gvmm starts on a 64 byte boundrary.
80 * @note Keeping this working for 32-bit header syntax checking. */
81 uint8_t abPadding[HC_ARCH_BITS == 32 ? 40 : 24];
82
83 /** The GVMM per vcpu data. */
84 union
85 {
86#ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
87 struct GVMMPERVCPU s;
88#endif
89 uint8_t padding[64];
90 } gvmm;
91
92#ifdef VBOX_WITH_NEM_R0
93 /** The NEM per vcpu data. */
94 union
95 {
96# if defined(VMM_INCLUDED_SRC_include_NEMInternal_h) && defined(IN_RING0)
97 struct NEMR0PERVCPU s;
98# endif
99 uint8_t padding[64];
100 } nemr0;
101#endif
102
103#ifdef VBOX_BUGREF_9217
104 /** Padding the structure size to page boundrary. */
105# ifdef VBOX_WITH_NEM_R0
106 uint8_t abPadding2[4096 - 64 - 64 - 64];
107# else
108 uint8_t abPadding2[4096 - 64 - 64];
109# endif
110#endif
111} GVMCPU;
112#ifdef VBOX_BUGREF_9217
113AssertCompileMemberAlignment(GVMCPU, idCpu, 4096);
114AssertCompileMemberAlignment(GVMCPU, gvmm, 64);
115# ifdef VBOX_WITH_NEM_R0
116AssertCompileMemberAlignment(GVMCPU, nem, 64);
117# endif
118AssertCompileSizeAlignment(GVMCPU, 4096);
119#else
120AssertCompileMemberOffset(GVMCPU, gvmm, 64);
121# ifdef VBOX_WITH_NEM_R0
122AssertCompileMemberOffset(GVMCPU, nemr0, 64 + 64);
123AssertCompileSize( GVMCPU, 64 + 64 + 64);
124# else
125AssertCompileSize( GVMCPU, 64 + 64);
126# endif
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#ifdef VBOX_BUGREF_9217
146typedef struct GVM : public VM
147#else
148typedef struct GVM
149#endif
150{
151 /** Magic / eye-catcher (GVM_MAGIC). */
152 uint32_t u32Magic;
153 /** The global VM handle for this VM. */
154 uint32_t hSelf;
155#ifdef VBOX_BUGREF_9217
156 /** Pointer to this structure (for validation purposes). */
157 PGVM pSelf;
158#else
159 /** The ring-0 mapping of the VM structure. */
160 PVM pVM;
161#endif
162 /** The ring-3 mapping of the VM structure. */
163 PVMR3 pVMR3;
164 /** The support driver session the VM is associated with. */
165 PSUPDRVSESSION pSession;
166 /** Number of Virtual CPUs, i.e. how many entries there are in aCpus.
167 * Same same as VM::cCpus. */
168 uint32_t cCpus;
169 /** Padding so gvmm starts on a 64 byte boundrary. */
170 uint8_t abPadding[HC_ARCH_BITS == 32 ? 12 + 28 : 28];
171
172 /** The GVMM per vm data. */
173 union
174 {
175#ifdef VMM_INCLUDED_SRC_VMMR0_GVMMR0Internal_h
176 struct GVMMPERVM s;
177#endif
178 uint8_t padding[256];
179 } gvmm;
180
181 /** The GMM per vm data. */
182 union
183 {
184#ifdef VMM_INCLUDED_SRC_VMMR0_GMMR0Internal_h
185 struct GMMPERVM s;
186#endif
187 uint8_t padding[512];
188 } gmm;
189
190#ifdef VBOX_WITH_NEM_R0
191 /** The NEM per vcpu data. */
192 union
193 {
194# if defined(VMM_INCLUDED_SRC_include_NEMInternal_h) && defined(IN_RING0)
195 struct NEMR0PERVM s;
196# endif
197 uint8_t padding[256];
198 } nemr0;
199#endif
200
201 /** The RAWPCIVM per vm data. */
202 union
203 {
204#ifdef VBOX_INCLUDED_rawpci_h
205 struct RAWPCIPERVM s;
206#endif
207 uint8_t padding[64];
208 } rawpci;
209
210#ifdef VBOX_BUGREF_9217
211 /** Padding so aCpus starts on a page boundrary. */
212# ifdef VBOX_WITH_NEM_R0
213 uint8_t abPadding2[4096 - 64 - 256 - 512 - 256 - 64 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
214# else
215 uint8_t abPadding2[4096 - 64 - 256 - 512 - 64 - sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT];
216# endif
217#endif
218 /** For simplifying CPU enumeration in VMMAll code. */
219 PGVMCPU apCpusR0[VMM_MAX_CPU_COUNT];
220
221 /** GVMCPU array for the configured number of virtual CPUs. */
222 GVMCPU aCpus[1];
223} GVM;
224#ifdef VBOX_BUGREF_9217
225AssertCompileMemberAlignment(GVM, gvmm, 64);
226AssertCompileMemberAlignment(GVM, gmm, 64);
227# ifdef VBOX_WITH_NEM_R0
228AssertCompileMemberAlignment(GVM, nem, 64);
229# endif
230AssertCompileMemberAlignment(GVM, rawpci, 64);
231AssertCompileMemberAlignment(GVM, aCpus, 4096);
232AssertCompileSizeAlignment(GVM, 4096);
233#else
234AssertCompileMemberOffset(GVM, gvmm, 64);
235AssertCompileMemberOffset(GVM, gmm, 64 + 256);
236# ifdef VBOX_WITH_NEM_R0
237AssertCompileMemberOffset(GVM, nemr0, 64 + 256 + 512);
238AssertCompileMemberOffset(GVM, rawpci, 64 + 256 + 512 + 256);
239AssertCompileMemberOffset(GVM, aCpus, 64 + 256 + 512 + 256 + 64 + sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT);
240# else
241AssertCompileMemberOffset(GVM, rawpci, 64 + 256 + 512);
242AssertCompileMemberOffset(GVM, aCpus, 64 + 256 + 512 + 64 + sizeof(PGVMCPU) * VMM_MAX_CPU_COUNT);
243# endif
244#endif
245
246/** The GVM::u32Magic value (Wayne Shorter). */
247#define GVM_MAGIC 0x19330825
248
249/** @} */
250
251#endif /* !VBOX_INCLUDED_vmm_gvm_h */
252
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette