VirtualBox

source: vbox/trunk/include/VBox/vmm/uvm.h@ 104384

Last change on this file since 104384 was 98103, checked in by vboxsync, 20 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 5.8 KB
Line 
1/** @file
2 * GVM - The Global VM Data.
3 */
4
5/*
6 * Copyright (C) 2007-2023 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef VBOX_INCLUDED_vmm_uvm_h
37#define VBOX_INCLUDED_vmm_uvm_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <VBox/types.h>
43#include <iprt/assert.h>
44
45/** @addtogroup grp_vm
46 * @{ */
47
48
49/**
50 * Per virtual CPU ring-3 (user mode) data.
51 */
52typedef struct UVMCPU
53{
54 /** Pointer to the UVM structure. */
55 PUVM pUVM;
56 /** Pointer to the VM structure. */
57 PVM pVM;
58 /** Pointer to the VMCPU structure. */
59 PVMCPU pVCpu;
60 /** The virtual CPU ID. */
61 RTCPUID idCpu;
62 /** Alignment padding. */
63 uint8_t abAlignment0[HC_ARCH_BITS == 32 ? 16 : 4];
64
65 /** The VM internal data. */
66 union
67 {
68#ifdef VMM_INCLUDED_SRC_include_VMInternal_h
69 struct VMINTUSERPERVMCPU s;
70#endif
71 uint8_t padding[512];
72 } vm;
73
74 /** The DBGF data. */
75 union
76 {
77#ifdef VMM_INCLUDED_SRC_include_DBGFInternal_h
78 struct DBGFUSERPERVMCPU s;
79#endif
80 uint8_t padding[64];
81 } dbgf;
82
83} UVMCPU;
84AssertCompileMemberAlignment(UVMCPU, vm, 32);
85
86
87/**
88 * The ring-3 (user mode) VM structure.
89 *
90 * This structure is similar to VM and GVM except that it resides in swappable
91 * user memory. The main purpose is to assist bootstrapping, where it allows us
92 * to start EMT much earlier and gives PDMLdr somewhere to put it's VMMR0 data.
93 * It is also a nice place to put big things that are user mode only.
94 */
95typedef struct UVM
96{
97 /** Magic / eye-catcher (UVM_MAGIC). */
98 uint32_t u32Magic;
99 /** The number of virtual CPUs. */
100 uint32_t cCpus;
101 /** The ring-3 mapping of the shared VM structure. */
102 PVM pVM;
103 /** Pointer to the next VM.
104 * We keep a per process list of VM for the event that a process could
105 * contain more than one VM.
106 * @todo move this into vm.s!
107 */
108 struct UVM *pNext;
109
110 /** Pointer to the optional method table provided by the VMM user. */
111 PCVMM2USERMETHODS pVmm2UserMethods;
112
113#if HC_ARCH_BITS == 32
114 /** Align the next member on a 32 byte boundary. */
115 uint8_t abAlignment0[HC_ARCH_BITS == 32 ? 12 : 0];
116#endif
117
118 /** The VM internal data. */
119 union
120 {
121#ifdef VMM_INCLUDED_SRC_include_VMInternal_h
122 struct VMINTUSERPERVM s;
123#endif
124 uint8_t padding[512];
125 } vm;
126
127 /** The MM data. */
128 union
129 {
130#ifdef VMM_INCLUDED_SRC_include_MMInternal_h
131 struct MMUSERPERVM s;
132#endif
133 uint8_t padding[32];
134 } mm;
135
136 /** The PDM data. */
137 union
138 {
139#ifdef VMM_INCLUDED_SRC_include_PDMInternal_h
140 struct PDMUSERPERVM s;
141#endif
142 uint8_t padding[256];
143 } pdm;
144
145 /** The STAM data. */
146 union
147 {
148#ifdef VMM_INCLUDED_SRC_include_STAMInternal_h
149 struct STAMUSERPERVM s;
150#endif
151 uint8_t padding[30208];
152 } stam;
153
154 /** The DBGF data. */
155 union
156 {
157#ifdef VMM_INCLUDED_SRC_include_DBGFInternal_h
158 struct DBGFUSERPERVM s;
159#endif
160 uint8_t padding[1024];
161 } dbgf;
162
163 /** Per virtual CPU data. */
164 UVMCPU aCpus[1];
165} UVM;
166AssertCompileMemberAlignment(UVM, vm, 32);
167AssertCompileMemberAlignment(UVM, mm, 32);
168AssertCompileMemberAlignment(UVM, pdm, 32);
169AssertCompileMemberAlignment(UVM, stam, 32);
170AssertCompileMemberAlignment(UVM, aCpus, 32);
171
172/** The UVM::u32Magic value (Brad Mehldau). */
173#define UVM_MAGIC 0x19700823
174
175/** @def UVM_ASSERT_VALID_EXT_RETURN
176 * Asserts a user mode VM handle is valid for external access.
177 */
178#define UVM_ASSERT_VALID_EXT_RETURN(a_pUVM, a_rc) \
179 AssertMsgReturn( RT_VALID_ALIGNED_PTR(a_pUVM, PAGE_SIZE) \
180 && (a_pUVM)->u32Magic == UVM_MAGIC, \
181 ("a_pUVM=%p u32Magic=%#x\n", (a_pUVM), \
182 RT_VALID_ALIGNED_PTR(a_pUVM, PAGE_SIZE) ? (a_pUVM)->u32Magic : 0), \
183 (a_rc))
184/** @def UVM_ASSERT_VALID_EXT_RETURN
185 * Asserts a user mode VM handle is valid for external access.
186 */
187#define UVM_ASSERT_VALID_EXT_RETURN_VOID(a_pUVM) \
188 AssertMsgReturnVoid( RT_VALID_ALIGNED_PTR(a_pUVM, PAGE_SIZE) \
189 && (a_pUVM)->u32Magic == UVM_MAGIC, \
190 ("a_pUVM=%p u32Magic=%#x\n", (a_pUVM), \
191 RT_VALID_ALIGNED_PTR(a_pUVM, PAGE_SIZE) ? (a_pUVM)->u32Magic : 0))
192
193/** @} */
194#endif /* !VBOX_INCLUDED_vmm_uvm_h */
195
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