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