VirtualBox

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

Last change on this file since 75565 was 69475, checked in by vboxsync, 7 years ago

*: scm updates - header files should have 'svn:keywords=Id Revision' too (doesn't mean they have to use them).

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