VirtualBox

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

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

*: scm --fix-header-guard-endif

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