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