1 | /** @file
|
---|
2 | * GVM - The Global VM Data.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2007-2024 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/param.h>
|
---|
43 | #include <VBox/types.h>
|
---|
44 | #include <iprt/assert.h>
|
---|
45 |
|
---|
46 | /** @addtogroup grp_vm
|
---|
47 | * @{ */
|
---|
48 |
|
---|
49 |
|
---|
50 | /**
|
---|
51 | * Per virtual CPU ring-3 (user mode) data.
|
---|
52 | */
|
---|
53 | typedef struct UVMCPU
|
---|
54 | {
|
---|
55 | /** Pointer to the UVM structure. */
|
---|
56 | PUVM pUVM;
|
---|
57 | /** Pointer to the VM structure. */
|
---|
58 | PVM pVM;
|
---|
59 | /** Pointer to the VMCPU structure. */
|
---|
60 | PVMCPU pVCpu;
|
---|
61 | /** The virtual CPU ID. */
|
---|
62 | RTCPUID idCpu;
|
---|
63 | /** Alignment padding. */
|
---|
64 | uint8_t abAlignment0[HC_ARCH_BITS == 32 ? 16 : 4];
|
---|
65 |
|
---|
66 | /** The VM internal data. */
|
---|
67 | union
|
---|
68 | {
|
---|
69 | #ifdef VMM_INCLUDED_SRC_include_VMInternal_h
|
---|
70 | struct VMINTUSERPERVMCPU s;
|
---|
71 | #endif
|
---|
72 | uint8_t padding[512];
|
---|
73 | } vm;
|
---|
74 |
|
---|
75 | /** The DBGF data. */
|
---|
76 | union
|
---|
77 | {
|
---|
78 | #ifdef VMM_INCLUDED_SRC_include_DBGFInternal_h
|
---|
79 | struct DBGFUSERPERVMCPU s;
|
---|
80 | #endif
|
---|
81 | uint8_t padding[64];
|
---|
82 | } dbgf;
|
---|
83 |
|
---|
84 | } UVMCPU;
|
---|
85 | AssertCompileMemberAlignment(UVMCPU, vm, 32);
|
---|
86 |
|
---|
87 |
|
---|
88 | /**
|
---|
89 | * The ring-3 (user mode) VM structure.
|
---|
90 | *
|
---|
91 | * This structure is similar to VM and GVM except that it resides in swappable
|
---|
92 | * user memory. The main purpose is to assist bootstrapping, where it allows us
|
---|
93 | * to start EMT much earlier and gives PDMLdr somewhere to put it's VMMR0 data.
|
---|
94 | * It is also a nice place to put big things that are user mode only.
|
---|
95 | */
|
---|
96 | typedef struct UVM
|
---|
97 | {
|
---|
98 | /** Magic / eye-catcher (UVM_MAGIC). */
|
---|
99 | uint32_t u32Magic;
|
---|
100 | /** The number of virtual CPUs. */
|
---|
101 | uint32_t cCpus;
|
---|
102 | /** The ring-3 mapping of the shared VM structure. */
|
---|
103 | PVM pVM;
|
---|
104 | /** Pointer to the next VM.
|
---|
105 | * We keep a per process list of VM for the event that a process could
|
---|
106 | * contain more than one VM.
|
---|
107 | * @todo move this into vm.s!
|
---|
108 | */
|
---|
109 | struct UVM *pNext;
|
---|
110 |
|
---|
111 | /** Pointer to the optional method table provided by the VMM user. */
|
---|
112 | PCVMM2USERMETHODS pVmm2UserMethods;
|
---|
113 |
|
---|
114 | #if HC_ARCH_BITS == 32
|
---|
115 | /** Align the next member on a 32 byte boundary. */
|
---|
116 | uint8_t abAlignment0[HC_ARCH_BITS == 32 ? 12 : 0];
|
---|
117 | #endif
|
---|
118 |
|
---|
119 | /** The VM internal data. */
|
---|
120 | union
|
---|
121 | {
|
---|
122 | #ifdef VMM_INCLUDED_SRC_include_VMInternal_h
|
---|
123 | struct VMINTUSERPERVM s;
|
---|
124 | #endif
|
---|
125 | uint8_t padding[512];
|
---|
126 | } vm;
|
---|
127 |
|
---|
128 | /** The MM data. */
|
---|
129 | union
|
---|
130 | {
|
---|
131 | #ifdef VMM_INCLUDED_SRC_include_MMInternal_h
|
---|
132 | struct MMUSERPERVM s;
|
---|
133 | #endif
|
---|
134 | uint8_t padding[32];
|
---|
135 | } mm;
|
---|
136 |
|
---|
137 | /** The PDM data. */
|
---|
138 | union
|
---|
139 | {
|
---|
140 | #ifdef VMM_INCLUDED_SRC_include_PDMInternal_h
|
---|
141 | struct PDMUSERPERVM s;
|
---|
142 | #endif
|
---|
143 | uint8_t padding[256];
|
---|
144 | } pdm;
|
---|
145 |
|
---|
146 | /** The STAM data. */
|
---|
147 | union
|
---|
148 | {
|
---|
149 | #ifdef VMM_INCLUDED_SRC_include_STAMInternal_h
|
---|
150 | struct STAMUSERPERVM s;
|
---|
151 | #endif
|
---|
152 | uint8_t padding[30208];
|
---|
153 | } stam;
|
---|
154 |
|
---|
155 | /** The DBGF data. */
|
---|
156 | union
|
---|
157 | {
|
---|
158 | #ifdef VMM_INCLUDED_SRC_include_DBGFInternal_h
|
---|
159 | struct DBGFUSERPERVM s;
|
---|
160 | #endif
|
---|
161 | uint8_t padding[1024];
|
---|
162 | } dbgf;
|
---|
163 |
|
---|
164 | /** Per virtual CPU data. */
|
---|
165 | UVMCPU aCpus[1];
|
---|
166 | } UVM;
|
---|
167 | AssertCompileMemberAlignment(UVM, vm, 32);
|
---|
168 | AssertCompileMemberAlignment(UVM, mm, 32);
|
---|
169 | AssertCompileMemberAlignment(UVM, pdm, 32);
|
---|
170 | AssertCompileMemberAlignment(UVM, stam, 32);
|
---|
171 | AssertCompileMemberAlignment(UVM, aCpus, 32);
|
---|
172 |
|
---|
173 | /** The UVM::u32Magic value (Brad Mehldau). */
|
---|
174 | #define UVM_MAGIC 0x19700823
|
---|
175 |
|
---|
176 | /** @def UVM_ASSERT_VALID_EXT_RETURN
|
---|
177 | * Asserts a user mode VM handle is valid for external access.
|
---|
178 | */
|
---|
179 | #define UVM_ASSERT_VALID_EXT_RETURN(a_pUVM, a_rc) \
|
---|
180 | AssertMsgReturn( RT_VALID_ALIGNED_PTR(a_pUVM, HOST_PAGE_SIZE_DYNAMIC) \
|
---|
181 | && (a_pUVM)->u32Magic == UVM_MAGIC, \
|
---|
182 | ("a_pUVM=%p u32Magic=%#x\n", (a_pUVM), \
|
---|
183 | RT_VALID_ALIGNED_PTR(a_pUVM, HOST_PAGE_SIZE_DYNAMIC) ? (a_pUVM)->u32Magic : 0), \
|
---|
184 | (a_rc))
|
---|
185 | /** @def UVM_ASSERT_VALID_EXT_RETURN
|
---|
186 | * Asserts a user mode VM handle is valid for external access.
|
---|
187 | */
|
---|
188 | #define UVM_ASSERT_VALID_EXT_RETURN_VOID(a_pUVM) \
|
---|
189 | AssertMsgReturnVoid( RT_VALID_ALIGNED_PTR(a_pUVM, HOST_PAGE_SIZE_DYNAMIC) \
|
---|
190 | && (a_pUVM)->u32Magic == UVM_MAGIC, \
|
---|
191 | ("a_pUVM=%p u32Magic=%#x\n", (a_pUVM), \
|
---|
192 | RT_VALID_ALIGNED_PTR(a_pUVM, HOST_PAGE_SIZE_DYNAMIC) ? (a_pUVM)->u32Magic : 0))
|
---|
193 |
|
---|
194 | /** @} */
|
---|
195 | #endif /* !VBOX_INCLUDED_vmm_uvm_h */
|
---|
196 |
|
---|