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