VirtualBox

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

Last change on this file since 83850 was 83850, checked in by vboxsync, 5 years ago

AMD IOMMU: bugref:9654 R0 registration bits.

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