1 | /** @file
|
---|
2 | * CPUM - CPU Monitor(/ Manager), Context Structures from v1.6 (saved state).
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-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_cpumctx_v1_6_h
|
---|
37 | #define VBOX_INCLUDED_vmm_cpumctx_v1_6_h
|
---|
38 | #ifndef RT_WITHOUT_PRAGMA_ONCE
|
---|
39 | # pragma once
|
---|
40 | #endif
|
---|
41 |
|
---|
42 | #include <iprt/x86.h>
|
---|
43 | #include <VBox/vmm/cpumctx.h>
|
---|
44 |
|
---|
45 |
|
---|
46 | RT_C_DECLS_BEGIN
|
---|
47 |
|
---|
48 | /** @defgroup grp_cpum_ctx_v1_6 The CPUM Context Structures from v1.6
|
---|
49 | * @ingroup grp_cpum
|
---|
50 | * @{
|
---|
51 | */
|
---|
52 |
|
---|
53 | #pragma pack(1)
|
---|
54 | /** IDTR from version 1.6 */
|
---|
55 | typedef struct VBOXIDTR_VER1_6
|
---|
56 | {
|
---|
57 | /** Size of the IDT. */
|
---|
58 | uint16_t cbIdt;
|
---|
59 | /** Address of the IDT. */
|
---|
60 | uint32_t pIdt;
|
---|
61 | } VBOXIDTR_VER1_6;
|
---|
62 | #pragma pack()
|
---|
63 |
|
---|
64 | #pragma pack(1)
|
---|
65 | /** GDTR from version 1.6 */
|
---|
66 | typedef struct VBOXGDTR_VER1_6
|
---|
67 | {
|
---|
68 | /** Size of the GDT. */
|
---|
69 | uint16_t cbGdt;
|
---|
70 | /** Address of the GDT. */
|
---|
71 | uint32_t pGdt;
|
---|
72 | } VBOXGDTR_VER1_6;
|
---|
73 | #pragma pack()
|
---|
74 |
|
---|
75 |
|
---|
76 | /**
|
---|
77 | * Selector hidden registers, for version 1.6 saved state.
|
---|
78 | */
|
---|
79 | typedef struct CPUMSELREGHID_VER1_6
|
---|
80 | {
|
---|
81 | /** Base register. */
|
---|
82 | uint32_t u32Base;
|
---|
83 | /** Limit (expanded). */
|
---|
84 | uint32_t u32Limit;
|
---|
85 | /** Flags.
|
---|
86 | * This is the high 32-bit word of the descriptor entry.
|
---|
87 | * Only the flags, dpl and type are used. */
|
---|
88 | X86DESCATTR Attr;
|
---|
89 | } CPUMSELREGHID_VER1_6;
|
---|
90 |
|
---|
91 | /**
|
---|
92 | * CPU context, for version 1.6 saved state.
|
---|
93 | * @remarks PATM uses this, which is why it has to be here.
|
---|
94 | */
|
---|
95 | # pragma pack(1)
|
---|
96 | typedef struct CPUMCTX_VER1_6
|
---|
97 | {
|
---|
98 | /** FPU state. (16-byte alignment)
|
---|
99 | * @todo This doesn't have to be in X86FXSTATE on CPUs without fxsr - we need a type for the
|
---|
100 | * actual format or convert it (waste of time). */
|
---|
101 | X86FXSTATE fpu;
|
---|
102 |
|
---|
103 | /** CPUMCTXCORE Part.
|
---|
104 | * @{ */
|
---|
105 | union
|
---|
106 | {
|
---|
107 | uint32_t edi;
|
---|
108 | uint64_t rdi;
|
---|
109 | } CPUM_UNION_NM(rdi);
|
---|
110 | union
|
---|
111 | {
|
---|
112 | uint32_t esi;
|
---|
113 | uint64_t rsi;
|
---|
114 | } CPUM_UNION_NM(rsi);
|
---|
115 | union
|
---|
116 | {
|
---|
117 | uint32_t ebp;
|
---|
118 | uint64_t rbp;
|
---|
119 | } CPUM_UNION_NM(rbp);
|
---|
120 | union
|
---|
121 | {
|
---|
122 | uint32_t eax;
|
---|
123 | uint64_t rax;
|
---|
124 | } CPUM_UNION_NM(rax);
|
---|
125 | union
|
---|
126 | {
|
---|
127 | uint32_t ebx;
|
---|
128 | uint64_t rbx;
|
---|
129 | } CPUM_UNION_NM(rbx);
|
---|
130 | union
|
---|
131 | {
|
---|
132 | uint32_t edx;
|
---|
133 | uint64_t rdx;
|
---|
134 | } CPUM_UNION_NM(rdx);
|
---|
135 | union
|
---|
136 | {
|
---|
137 | uint32_t ecx;
|
---|
138 | uint64_t rcx;
|
---|
139 | } CPUM_UNION_NM(rcx);
|
---|
140 | /** @note We rely on the exact layout, because we use lss esp, [] in the
|
---|
141 | * switcher. */
|
---|
142 | uint32_t esp;
|
---|
143 | RTSEL ss;
|
---|
144 | RTSEL ssPadding;
|
---|
145 | /* Note: no overlap with esp here. */
|
---|
146 | uint64_t rsp_notused;
|
---|
147 |
|
---|
148 | RTSEL gs;
|
---|
149 | RTSEL gsPadding;
|
---|
150 | RTSEL fs;
|
---|
151 | RTSEL fsPadding;
|
---|
152 | RTSEL es;
|
---|
153 | RTSEL esPadding;
|
---|
154 | RTSEL ds;
|
---|
155 | RTSEL dsPadding;
|
---|
156 | RTSEL cs;
|
---|
157 | RTSEL csPadding[3]; /**< 3 words to force 8 byte alignment for the remainder. */
|
---|
158 |
|
---|
159 | union
|
---|
160 | {
|
---|
161 | X86EFLAGS eflags;
|
---|
162 | X86RFLAGS rflags;
|
---|
163 | } CPUM_UNION_NM(rflags);
|
---|
164 | union
|
---|
165 | {
|
---|
166 | uint32_t eip;
|
---|
167 | uint64_t rip;
|
---|
168 | } CPUM_UNION_NM(rip);
|
---|
169 |
|
---|
170 | uint64_t r8;
|
---|
171 | uint64_t r9;
|
---|
172 | uint64_t r10;
|
---|
173 | uint64_t r11;
|
---|
174 | uint64_t r12;
|
---|
175 | uint64_t r13;
|
---|
176 | uint64_t r14;
|
---|
177 | uint64_t r15;
|
---|
178 |
|
---|
179 | /** Hidden selector registers.
|
---|
180 | * @{ */
|
---|
181 | CPUMSELREGHID_VER1_6 esHid;
|
---|
182 | CPUMSELREGHID_VER1_6 csHid;
|
---|
183 | CPUMSELREGHID_VER1_6 ssHid;
|
---|
184 | CPUMSELREGHID_VER1_6 dsHid;
|
---|
185 | CPUMSELREGHID_VER1_6 fsHid;
|
---|
186 | CPUMSELREGHID_VER1_6 gsHid;
|
---|
187 | /** @} */
|
---|
188 |
|
---|
189 | /** @} */
|
---|
190 |
|
---|
191 | /** Control registers.
|
---|
192 | * @{ */
|
---|
193 | uint64_t cr0;
|
---|
194 | uint64_t cr2;
|
---|
195 | uint64_t cr3;
|
---|
196 | uint64_t cr4;
|
---|
197 | uint64_t cr8;
|
---|
198 | /** @} */
|
---|
199 |
|
---|
200 | /** Debug registers.
|
---|
201 | * @{ */
|
---|
202 | uint64_t dr0;
|
---|
203 | uint64_t dr1;
|
---|
204 | uint64_t dr2;
|
---|
205 | uint64_t dr3;
|
---|
206 | uint64_t dr4; /**< @todo remove dr4 and dr5. */
|
---|
207 | uint64_t dr5;
|
---|
208 | uint64_t dr6;
|
---|
209 | uint64_t dr7;
|
---|
210 | /* DR8-15 are currently not supported */
|
---|
211 | /** @} */
|
---|
212 |
|
---|
213 | /** Global Descriptor Table register. */
|
---|
214 | VBOXGDTR_VER1_6 gdtr;
|
---|
215 | uint16_t gdtrPadding;
|
---|
216 | uint32_t gdtrPadding64;/** @todo fix this hack */
|
---|
217 | /** Interrupt Descriptor Table register. */
|
---|
218 | VBOXIDTR_VER1_6 idtr;
|
---|
219 | uint16_t idtrPadding;
|
---|
220 | uint32_t idtrPadding64;/** @todo fix this hack */
|
---|
221 | /** The task register.
|
---|
222 | * Only the guest context uses all the members. */
|
---|
223 | RTSEL ldtr;
|
---|
224 | RTSEL ldtrPadding;
|
---|
225 | /** The task register.
|
---|
226 | * Only the guest context uses all the members. */
|
---|
227 | RTSEL tr;
|
---|
228 | RTSEL trPadding;
|
---|
229 |
|
---|
230 | /** The sysenter msr registers.
|
---|
231 | * This member is not used by the hypervisor context. */
|
---|
232 | CPUMSYSENTER SysEnter;
|
---|
233 |
|
---|
234 | /** System MSRs.
|
---|
235 | * @{ */
|
---|
236 | uint64_t msrEFER;
|
---|
237 | uint64_t msrSTAR;
|
---|
238 | uint64_t msrPAT;
|
---|
239 | uint64_t msrLSTAR;
|
---|
240 | uint64_t msrCSTAR;
|
---|
241 | uint64_t msrSFMASK;
|
---|
242 | uint64_t msrFSBASE;
|
---|
243 | uint64_t msrGSBASE;
|
---|
244 | uint64_t msrKERNELGSBASE;
|
---|
245 | /** @} */
|
---|
246 |
|
---|
247 | /** Hidden selector registers.
|
---|
248 | * @{ */
|
---|
249 | CPUMSELREGHID_VER1_6 ldtrHid;
|
---|
250 | CPUMSELREGHID_VER1_6 trHid;
|
---|
251 | /** @} */
|
---|
252 |
|
---|
253 | /** padding to get 32byte aligned size. */
|
---|
254 | uint32_t padding[2];
|
---|
255 | } CPUMCTX_VER1_6;
|
---|
256 | # pragma pack()
|
---|
257 |
|
---|
258 | /** @} */
|
---|
259 |
|
---|
260 | RT_C_DECLS_END
|
---|
261 |
|
---|
262 | #endif /* !VBOX_INCLUDED_vmm_cpumctx_v1_6_h */
|
---|
263 |
|
---|