1 | /** @file
|
---|
2 | * CPUM - CPU Monitor(/ Manager).
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2012 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_vmm_cpum_h
|
---|
27 | #define ___VBox_vmm_cpum_h
|
---|
28 |
|
---|
29 | #include <iprt/x86.h>
|
---|
30 | #include <VBox/types.h>
|
---|
31 | #include <VBox/vmm/cpumctx.h>
|
---|
32 |
|
---|
33 | RT_C_DECLS_BEGIN
|
---|
34 |
|
---|
35 | /** @defgroup grp_cpum The CPU Monitor / Manager API
|
---|
36 | * @{
|
---|
37 | */
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * CPUID feature to set or clear.
|
---|
41 | */
|
---|
42 | typedef enum CPUMCPUIDFEATURE
|
---|
43 | {
|
---|
44 | CPUMCPUIDFEATURE_INVALID = 0,
|
---|
45 | /** The APIC feature bit. (Std+Ext) */
|
---|
46 | CPUMCPUIDFEATURE_APIC,
|
---|
47 | /** The sysenter/sysexit feature bit. (Std) */
|
---|
48 | CPUMCPUIDFEATURE_SEP,
|
---|
49 | /** The SYSCALL/SYSEXIT feature bit (64 bits mode only for Intel CPUs). (Ext) */
|
---|
50 | CPUMCPUIDFEATURE_SYSCALL,
|
---|
51 | /** The PAE feature bit. (Std+Ext) */
|
---|
52 | CPUMCPUIDFEATURE_PAE,
|
---|
53 | /** The NX feature bit. (Ext) */
|
---|
54 | CPUMCPUIDFEATURE_NX,
|
---|
55 | /** The LAHF/SAHF feature bit (64 bits mode only). (Ext) */
|
---|
56 | CPUMCPUIDFEATURE_LAHF,
|
---|
57 | /** The LONG MODE feature bit. (Ext) */
|
---|
58 | CPUMCPUIDFEATURE_LONG_MODE,
|
---|
59 | /** The PAT feature bit. (Std+Ext) */
|
---|
60 | CPUMCPUIDFEATURE_PAT,
|
---|
61 | /** The x2APIC feature bit. (Std) */
|
---|
62 | CPUMCPUIDFEATURE_X2APIC,
|
---|
63 | /** The RDTSCP feature bit. (Ext) */
|
---|
64 | CPUMCPUIDFEATURE_RDTSCP,
|
---|
65 | /** The Hypervisor Present bit. (Std) */
|
---|
66 | CPUMCPUIDFEATURE_HVP,
|
---|
67 | /** 32bit hackishness. */
|
---|
68 | CPUMCPUIDFEATURE_32BIT_HACK = 0x7fffffff
|
---|
69 | } CPUMCPUIDFEATURE;
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * CPU Vendor.
|
---|
73 | */
|
---|
74 | typedef enum CPUMCPUVENDOR
|
---|
75 | {
|
---|
76 | CPUMCPUVENDOR_INVALID = 0,
|
---|
77 | CPUMCPUVENDOR_INTEL,
|
---|
78 | CPUMCPUVENDOR_AMD,
|
---|
79 | CPUMCPUVENDOR_VIA,
|
---|
80 | CPUMCPUVENDOR_UNKNOWN,
|
---|
81 | CPUMCPUVENDOR_SYNTHETIC,
|
---|
82 | /** 32bit hackishness. */
|
---|
83 | CPUMCPUVENDOR_32BIT_HACK = 0x7fffffff
|
---|
84 | } CPUMCPUVENDOR;
|
---|
85 |
|
---|
86 |
|
---|
87 | /** @name Guest Register Getters.
|
---|
88 | * @{ */
|
---|
89 | VMMDECL(void) CPUMGetGuestGDTR(PVMCPU pVCpu, PVBOXGDTR pGDTR);
|
---|
90 | VMMDECL(RTGCPTR) CPUMGetGuestIDTR(PVMCPU pVCpu, uint16_t *pcbLimit);
|
---|
91 | VMMDECL(RTSEL) CPUMGetGuestTR(PVMCPU pVCpu, PCPUMSELREGHID pHidden);
|
---|
92 | VMMDECL(RTSEL) CPUMGetGuestLDTR(PVMCPU pVCpu);
|
---|
93 | VMMDECL(RTSEL) CPUMGetGuestLdtrEx(PVMCPU pVCpu, uint64_t *pGCPtrBase, uint32_t *pcbLimit);
|
---|
94 | VMMDECL(uint64_t) CPUMGetGuestCR0(PVMCPU pVCpu);
|
---|
95 | VMMDECL(uint64_t) CPUMGetGuestCR2(PVMCPU pVCpu);
|
---|
96 | VMMDECL(uint64_t) CPUMGetGuestCR3(PVMCPU pVCpu);
|
---|
97 | VMMDECL(uint64_t) CPUMGetGuestCR4(PVMCPU pVCpu);
|
---|
98 | VMMDECL(uint64_t) CPUMGetGuestCR8(PVMCPU pVCpu);
|
---|
99 | VMMDECL(int) CPUMGetGuestCRx(PVMCPU pVCpu, unsigned iReg, uint64_t *pValue);
|
---|
100 | VMMDECL(uint32_t) CPUMGetGuestEFlags(PVMCPU pVCpu);
|
---|
101 | VMMDECL(uint32_t) CPUMGetGuestEIP(PVMCPU pVCpu);
|
---|
102 | VMMDECL(uint64_t) CPUMGetGuestRIP(PVMCPU pVCpu);
|
---|
103 | VMMDECL(uint32_t) CPUMGetGuestEAX(PVMCPU pVCpu);
|
---|
104 | VMMDECL(uint32_t) CPUMGetGuestEBX(PVMCPU pVCpu);
|
---|
105 | VMMDECL(uint32_t) CPUMGetGuestECX(PVMCPU pVCpu);
|
---|
106 | VMMDECL(uint32_t) CPUMGetGuestEDX(PVMCPU pVCpu);
|
---|
107 | VMMDECL(uint32_t) CPUMGetGuestESI(PVMCPU pVCpu);
|
---|
108 | VMMDECL(uint32_t) CPUMGetGuestEDI(PVMCPU pVCpu);
|
---|
109 | VMMDECL(uint32_t) CPUMGetGuestESP(PVMCPU pVCpu);
|
---|
110 | VMMDECL(uint32_t) CPUMGetGuestEBP(PVMCPU pVCpu);
|
---|
111 | VMMDECL(RTSEL) CPUMGetGuestCS(PVMCPU pVCpu);
|
---|
112 | VMMDECL(RTSEL) CPUMGetGuestDS(PVMCPU pVCpu);
|
---|
113 | VMMDECL(RTSEL) CPUMGetGuestES(PVMCPU pVCpu);
|
---|
114 | VMMDECL(RTSEL) CPUMGetGuestFS(PVMCPU pVCpu);
|
---|
115 | VMMDECL(RTSEL) CPUMGetGuestGS(PVMCPU pVCpu);
|
---|
116 | VMMDECL(RTSEL) CPUMGetGuestSS(PVMCPU pVCpu);
|
---|
117 | VMMDECL(uint64_t) CPUMGetGuestDR0(PVMCPU pVCpu);
|
---|
118 | VMMDECL(uint64_t) CPUMGetGuestDR1(PVMCPU pVCpu);
|
---|
119 | VMMDECL(uint64_t) CPUMGetGuestDR2(PVMCPU pVCpu);
|
---|
120 | VMMDECL(uint64_t) CPUMGetGuestDR3(PVMCPU pVCpu);
|
---|
121 | VMMDECL(uint64_t) CPUMGetGuestDR6(PVMCPU pVCpu);
|
---|
122 | VMMDECL(uint64_t) CPUMGetGuestDR7(PVMCPU pVCpu);
|
---|
123 | VMMDECL(int) CPUMGetGuestDRx(PVMCPU pVCpu, uint32_t iReg, uint64_t *pValue);
|
---|
124 | VMMDECL(void) CPUMGetGuestCpuId(PVMCPU pVCpu, uint32_t iLeaf, uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx);
|
---|
125 | VMMDECL(uint32_t) CPUMGetGuestCpuIdStdMax(PVM pVM);
|
---|
126 | VMMDECL(uint32_t) CPUMGetGuestCpuIdExtMax(PVM pVM);
|
---|
127 | VMMDECL(uint32_t) CPUMGetGuestCpuIdCentaurMax(PVM pVM);
|
---|
128 | VMMDECL(uint64_t) CPUMGetGuestEFER(PVMCPU pVCpu);
|
---|
129 | VMMDECL(int) CPUMQueryGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t *puValue);
|
---|
130 | VMMDECL(int) CPUMSetGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t uValue);
|
---|
131 | VMMDECL(CPUMCPUVENDOR) CPUMGetGuestCpuVendor(PVM pVM);
|
---|
132 | VMMDECL(CPUMCPUVENDOR) CPUMGetHostCpuVendor(PVM pVM);
|
---|
133 | /** @} */
|
---|
134 |
|
---|
135 | /** @name Guest Register Setters.
|
---|
136 | * @{ */
|
---|
137 | VMMDECL(int) CPUMSetGuestGDTR(PVMCPU pVCpu, uint64_t GCPtrBase, uint16_t cbLimit);
|
---|
138 | VMMDECL(int) CPUMSetGuestIDTR(PVMCPU pVCpu, uint64_t GCPtrBase, uint16_t cbLimit);
|
---|
139 | VMMDECL(int) CPUMSetGuestTR(PVMCPU pVCpu, uint16_t tr);
|
---|
140 | VMMDECL(int) CPUMSetGuestLDTR(PVMCPU pVCpu, uint16_t ldtr);
|
---|
141 | VMMDECL(int) CPUMSetGuestCR0(PVMCPU pVCpu, uint64_t cr0);
|
---|
142 | VMMDECL(int) CPUMSetGuestCR2(PVMCPU pVCpu, uint64_t cr2);
|
---|
143 | VMMDECL(int) CPUMSetGuestCR3(PVMCPU pVCpu, uint64_t cr3);
|
---|
144 | VMMDECL(int) CPUMSetGuestCR4(PVMCPU pVCpu, uint64_t cr4);
|
---|
145 | VMMDECL(int) CPUMSetGuestDR0(PVMCPU pVCpu, uint64_t uDr0);
|
---|
146 | VMMDECL(int) CPUMSetGuestDR1(PVMCPU pVCpu, uint64_t uDr1);
|
---|
147 | VMMDECL(int) CPUMSetGuestDR2(PVMCPU pVCpu, uint64_t uDr2);
|
---|
148 | VMMDECL(int) CPUMSetGuestDR3(PVMCPU pVCpu, uint64_t uDr3);
|
---|
149 | VMMDECL(int) CPUMSetGuestDR6(PVMCPU pVCpu, uint64_t uDr6);
|
---|
150 | VMMDECL(int) CPUMSetGuestDR7(PVMCPU pVCpu, uint64_t uDr7);
|
---|
151 | VMMDECL(int) CPUMSetGuestDRx(PVMCPU pVCpu, uint32_t iReg, uint64_t Value);
|
---|
152 | VMMDECL(int) CPUMSetGuestEFlags(PVMCPU pVCpu, uint32_t eflags);
|
---|
153 | VMMDECL(int) CPUMSetGuestEIP(PVMCPU pVCpu, uint32_t eip);
|
---|
154 | VMMDECL(int) CPUMSetGuestEAX(PVMCPU pVCpu, uint32_t eax);
|
---|
155 | VMMDECL(int) CPUMSetGuestEBX(PVMCPU pVCpu, uint32_t ebx);
|
---|
156 | VMMDECL(int) CPUMSetGuestECX(PVMCPU pVCpu, uint32_t ecx);
|
---|
157 | VMMDECL(int) CPUMSetGuestEDX(PVMCPU pVCpu, uint32_t edx);
|
---|
158 | VMMDECL(int) CPUMSetGuestESI(PVMCPU pVCpu, uint32_t esi);
|
---|
159 | VMMDECL(int) CPUMSetGuestEDI(PVMCPU pVCpu, uint32_t edi);
|
---|
160 | VMMDECL(int) CPUMSetGuestESP(PVMCPU pVCpu, uint32_t esp);
|
---|
161 | VMMDECL(int) CPUMSetGuestEBP(PVMCPU pVCpu, uint32_t ebp);
|
---|
162 | VMMDECL(int) CPUMSetGuestCS(PVMCPU pVCpu, uint16_t cs);
|
---|
163 | VMMDECL(int) CPUMSetGuestDS(PVMCPU pVCpu, uint16_t ds);
|
---|
164 | VMMDECL(int) CPUMSetGuestES(PVMCPU pVCpu, uint16_t es);
|
---|
165 | VMMDECL(int) CPUMSetGuestFS(PVMCPU pVCpu, uint16_t fs);
|
---|
166 | VMMDECL(int) CPUMSetGuestGS(PVMCPU pVCpu, uint16_t gs);
|
---|
167 | VMMDECL(int) CPUMSetGuestSS(PVMCPU pVCpu, uint16_t ss);
|
---|
168 | VMMDECL(void) CPUMSetGuestEFER(PVMCPU pVCpu, uint64_t val);
|
---|
169 | VMMDECL(void) CPUMSetGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature);
|
---|
170 | VMMDECL(void) CPUMClearGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature);
|
---|
171 | VMMDECL(bool) CPUMGetGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature);
|
---|
172 | VMMDECL(void) CPUMSetGuestCtx(PVMCPU pVCpu, const PCPUMCTX pCtx);
|
---|
173 | VMM_INT_DECL(void) CPUMGuestLazyLoadHiddenCsAndSs(PVMCPU pVCpu);
|
---|
174 | VMM_INT_DECL(void) CPUMGuestLazyLoadHiddenSelectorReg(PVMCPU pVCpu, PCPUMSELREG pSReg);
|
---|
175 | /** @} */
|
---|
176 |
|
---|
177 |
|
---|
178 | /** @name Misc Guest Predicate Functions.
|
---|
179 | * @{ */
|
---|
180 |
|
---|
181 | VMMDECL(bool) CPUMIsGuestIn16BitCode(PVMCPU pVCpu);
|
---|
182 | VMMDECL(bool) CPUMIsGuestIn32BitCode(PVMCPU pVCpu);
|
---|
183 | VMMDECL(bool) CPUMIsGuestIn64BitCode(PVMCPU pVCpu);
|
---|
184 | VMMDECL(bool) CPUMIsGuestNXEnabled(PVMCPU pVCpu);
|
---|
185 | VMMDECL(bool) CPUMIsGuestPageSizeExtEnabled(PVMCPU pVCpu);
|
---|
186 | VMMDECL(bool) CPUMIsGuestPagingEnabled(PVMCPU pVCpu);
|
---|
187 | VMMDECL(bool) CPUMIsGuestR0WriteProtEnabled(PVMCPU pVCpu);
|
---|
188 | VMMDECL(bool) CPUMIsGuestInRealMode(PVMCPU pVCpu);
|
---|
189 | VMMDECL(bool) CPUMIsGuestInRealOrV86Mode(PVMCPU pVCpu);
|
---|
190 | VMMDECL(bool) CPUMIsGuestInProtectedMode(PVMCPU pVCpu);
|
---|
191 | VMMDECL(bool) CPUMIsGuestInPagedProtectedMode(PVMCPU pVCpu);
|
---|
192 | VMMDECL(bool) CPUMIsGuestInLongMode(PVMCPU pVCpu);
|
---|
193 | VMMDECL(bool) CPUMIsGuestInPAEMode(PVMCPU pVCpu);
|
---|
194 | VMM_INT_DECL(bool) CPUMIsGuestInRawMode(PVMCPU pVCpu);
|
---|
195 |
|
---|
196 | #ifndef VBOX_WITHOUT_UNNAMED_UNIONS
|
---|
197 |
|
---|
198 | /**
|
---|
199 | * Tests if the guest is running in real mode or not.
|
---|
200 | *
|
---|
201 | * @returns true if in real mode, otherwise false.
|
---|
202 | * @param pCtx Current CPU context
|
---|
203 | */
|
---|
204 | DECLINLINE(bool) CPUMIsGuestInRealModeEx(PCPUMCTX pCtx)
|
---|
205 | {
|
---|
206 | return !(pCtx->cr0 & X86_CR0_PE);
|
---|
207 | }
|
---|
208 |
|
---|
209 | /**
|
---|
210 | * Tests if the guest is running in real or virtual 8086 mode.
|
---|
211 | *
|
---|
212 | * @returns @c true if it is, @c false if not.
|
---|
213 | * @param pCtx Current CPU context
|
---|
214 | */
|
---|
215 | DECLINLINE(bool) CPUMIsGuestInRealOrV86ModeEx(PCPUMCTX pCtx)
|
---|
216 | {
|
---|
217 | return !(pCtx->cr0 & X86_CR0_PE)
|
---|
218 | || pCtx->eflags.Bits.u1VM; /* Cannot be set in long mode. Intel spec 2.3.1 "System Flags and Fields in IA-32e Mode". */
|
---|
219 | }
|
---|
220 |
|
---|
221 | /**
|
---|
222 | * Tests if the guest is running in virtual 8086 mode.
|
---|
223 | *
|
---|
224 | * @returns @c true if it is, @c false if not.
|
---|
225 | * @param pCtx Current CPU context
|
---|
226 | */
|
---|
227 | DECLINLINE(bool) CPUMIsGuestInV86ModeEx(PCPUMCTX pCtx)
|
---|
228 | {
|
---|
229 | return (pCtx->eflags.Bits.u1VM == 1);
|
---|
230 | }
|
---|
231 |
|
---|
232 | /**
|
---|
233 | * Tests if the guest is running in paged protected or not.
|
---|
234 | *
|
---|
235 | * @returns true if in paged protected mode, otherwise false.
|
---|
236 | * @param pVM The VM handle.
|
---|
237 | */
|
---|
238 | DECLINLINE(bool) CPUMIsGuestInPagedProtectedModeEx(PCPUMCTX pCtx)
|
---|
239 | {
|
---|
240 | return (pCtx->cr0 & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG);
|
---|
241 | }
|
---|
242 |
|
---|
243 | /**
|
---|
244 | * Tests if the guest is running in long mode or not.
|
---|
245 | *
|
---|
246 | * @returns true if in long mode, otherwise false.
|
---|
247 | * @param pCtx Current CPU context
|
---|
248 | */
|
---|
249 | DECLINLINE(bool) CPUMIsGuestInLongModeEx(PCPUMCTX pCtx)
|
---|
250 | {
|
---|
251 | return (pCtx->msrEFER & MSR_K6_EFER_LMA) == MSR_K6_EFER_LMA;
|
---|
252 | }
|
---|
253 |
|
---|
254 | VMM_INT_DECL(bool) CPUMIsGuestIn64BitCodeSlow(PCPUMCTX pCtx);
|
---|
255 |
|
---|
256 | /**
|
---|
257 | * Tests if the guest is running in 64 bits mode or not.
|
---|
258 | *
|
---|
259 | * @returns true if in 64 bits protected mode, otherwise false.
|
---|
260 | * @param pVCpu The current virtual CPU.
|
---|
261 | * @param pCtx Current CPU context
|
---|
262 | */
|
---|
263 | DECLINLINE(bool) CPUMIsGuestIn64BitCodeEx(PCPUMCTX pCtx)
|
---|
264 | {
|
---|
265 | if (!(pCtx->msrEFER & MSR_K6_EFER_LMA))
|
---|
266 | return false;
|
---|
267 | if (!CPUMSELREG_ARE_HIDDEN_PARTS_VALID(NULL, &pCtx->cs))
|
---|
268 | return CPUMIsGuestIn64BitCodeSlow(pCtx);
|
---|
269 | return pCtx->cs.Attr.n.u1Long;
|
---|
270 | }
|
---|
271 |
|
---|
272 | /**
|
---|
273 | * Tests if the guest has paging enabled or not.
|
---|
274 | *
|
---|
275 | * @returns true if paging is enabled, otherwise false.
|
---|
276 | * @param pCtx Current CPU context
|
---|
277 | */
|
---|
278 | DECLINLINE(bool) CPUMIsGuestPagingEnabledEx(PCPUMCTX pCtx)
|
---|
279 | {
|
---|
280 | return !!(pCtx->cr0 & X86_CR0_PG);
|
---|
281 | }
|
---|
282 |
|
---|
283 | /**
|
---|
284 | * Tests if the guest is running in PAE mode or not.
|
---|
285 | *
|
---|
286 | * @returns true if in PAE mode, otherwise false.
|
---|
287 | * @param pCtx Current CPU context
|
---|
288 | */
|
---|
289 | DECLINLINE(bool) CPUMIsGuestInPAEModeEx(PCPUMCTX pCtx)
|
---|
290 | {
|
---|
291 | #ifdef VBOX_WITH_OLD_VTX_CODE
|
---|
292 | return ( (pCtx->cr4 & X86_CR4_PAE)
|
---|
293 | && CPUMIsGuestInPagedProtectedModeEx(pCtx)
|
---|
294 | && !CPUMIsGuestInLongModeEx(pCtx));
|
---|
295 | #else
|
---|
296 | return ( (pCtx->cr4 & X86_CR4_PAE)
|
---|
297 | && CPUMIsGuestPagingEnabledEx(pCtx)
|
---|
298 | && !(pCtx->msrEFER & MSR_K6_EFER_LME));
|
---|
299 | #endif
|
---|
300 | }
|
---|
301 |
|
---|
302 | #endif /* VBOX_WITHOUT_UNNAMED_UNIONS */
|
---|
303 |
|
---|
304 | /** @} */
|
---|
305 |
|
---|
306 |
|
---|
307 | /** @name Hypervisor Register Getters.
|
---|
308 | * @{ */
|
---|
309 | VMMDECL(RTSEL) CPUMGetHyperCS(PVMCPU pVCpu);
|
---|
310 | VMMDECL(RTSEL) CPUMGetHyperDS(PVMCPU pVCpu);
|
---|
311 | VMMDECL(RTSEL) CPUMGetHyperES(PVMCPU pVCpu);
|
---|
312 | VMMDECL(RTSEL) CPUMGetHyperFS(PVMCPU pVCpu);
|
---|
313 | VMMDECL(RTSEL) CPUMGetHyperGS(PVMCPU pVCpu);
|
---|
314 | VMMDECL(RTSEL) CPUMGetHyperSS(PVMCPU pVCpu);
|
---|
315 | #if 0 /* these are not correct. */
|
---|
316 | VMMDECL(uint32_t) CPUMGetHyperCR0(PVMCPU pVCpu);
|
---|
317 | VMMDECL(uint32_t) CPUMGetHyperCR2(PVMCPU pVCpu);
|
---|
318 | VMMDECL(uint32_t) CPUMGetHyperCR3(PVMCPU pVCpu);
|
---|
319 | VMMDECL(uint32_t) CPUMGetHyperCR4(PVMCPU pVCpu);
|
---|
320 | #endif
|
---|
321 | /** This register is only saved on fatal traps. */
|
---|
322 | VMMDECL(uint32_t) CPUMGetHyperEAX(PVMCPU pVCpu);
|
---|
323 | VMMDECL(uint32_t) CPUMGetHyperEBX(PVMCPU pVCpu);
|
---|
324 | /** This register is only saved on fatal traps. */
|
---|
325 | VMMDECL(uint32_t) CPUMGetHyperECX(PVMCPU pVCpu);
|
---|
326 | /** This register is only saved on fatal traps. */
|
---|
327 | VMMDECL(uint32_t) CPUMGetHyperEDX(PVMCPU pVCpu);
|
---|
328 | VMMDECL(uint32_t) CPUMGetHyperESI(PVMCPU pVCpu);
|
---|
329 | VMMDECL(uint32_t) CPUMGetHyperEDI(PVMCPU pVCpu);
|
---|
330 | VMMDECL(uint32_t) CPUMGetHyperEBP(PVMCPU pVCpu);
|
---|
331 | VMMDECL(uint32_t) CPUMGetHyperESP(PVMCPU pVCpu);
|
---|
332 | VMMDECL(uint32_t) CPUMGetHyperEFlags(PVMCPU pVCpu);
|
---|
333 | VMMDECL(uint32_t) CPUMGetHyperEIP(PVMCPU pVCpu);
|
---|
334 | VMMDECL(uint64_t) CPUMGetHyperRIP(PVMCPU pVCpu);
|
---|
335 | VMMDECL(uint32_t) CPUMGetHyperIDTR(PVMCPU pVCpu, uint16_t *pcbLimit);
|
---|
336 | VMMDECL(uint32_t) CPUMGetHyperGDTR(PVMCPU pVCpu, uint16_t *pcbLimit);
|
---|
337 | VMMDECL(RTSEL) CPUMGetHyperLDTR(PVMCPU pVCpu);
|
---|
338 | VMMDECL(RTGCUINTREG) CPUMGetHyperDR0(PVMCPU pVCpu);
|
---|
339 | VMMDECL(RTGCUINTREG) CPUMGetHyperDR1(PVMCPU pVCpu);
|
---|
340 | VMMDECL(RTGCUINTREG) CPUMGetHyperDR2(PVMCPU pVCpu);
|
---|
341 | VMMDECL(RTGCUINTREG) CPUMGetHyperDR3(PVMCPU pVCpu);
|
---|
342 | VMMDECL(RTGCUINTREG) CPUMGetHyperDR6(PVMCPU pVCpu);
|
---|
343 | VMMDECL(RTGCUINTREG) CPUMGetHyperDR7(PVMCPU pVCpu);
|
---|
344 | VMMDECL(void) CPUMGetHyperCtx(PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
345 | VMMDECL(uint32_t) CPUMGetHyperCR3(PVMCPU pVCpu);
|
---|
346 | /** @} */
|
---|
347 |
|
---|
348 | /** @name Hypervisor Register Setters.
|
---|
349 | * @{ */
|
---|
350 | VMMDECL(void) CPUMSetHyperGDTR(PVMCPU pVCpu, uint32_t addr, uint16_t limit);
|
---|
351 | VMMDECL(void) CPUMSetHyperLDTR(PVMCPU pVCpu, RTSEL SelLDTR);
|
---|
352 | VMMDECL(void) CPUMSetHyperIDTR(PVMCPU pVCpu, uint32_t addr, uint16_t limit);
|
---|
353 | VMMDECL(void) CPUMSetHyperCR3(PVMCPU pVCpu, uint32_t cr3);
|
---|
354 | VMMDECL(void) CPUMSetHyperTR(PVMCPU pVCpu, RTSEL SelTR);
|
---|
355 | VMMDECL(void) CPUMSetHyperCS(PVMCPU pVCpu, RTSEL SelCS);
|
---|
356 | VMMDECL(void) CPUMSetHyperDS(PVMCPU pVCpu, RTSEL SelDS);
|
---|
357 | VMMDECL(void) CPUMSetHyperES(PVMCPU pVCpu, RTSEL SelDS);
|
---|
358 | VMMDECL(void) CPUMSetHyperFS(PVMCPU pVCpu, RTSEL SelDS);
|
---|
359 | VMMDECL(void) CPUMSetHyperGS(PVMCPU pVCpu, RTSEL SelDS);
|
---|
360 | VMMDECL(void) CPUMSetHyperSS(PVMCPU pVCpu, RTSEL SelSS);
|
---|
361 | VMMDECL(void) CPUMSetHyperESP(PVMCPU pVCpu, uint32_t u32ESP);
|
---|
362 | VMMDECL(int) CPUMSetHyperEFlags(PVMCPU pVCpu, uint32_t Efl);
|
---|
363 | VMMDECL(void) CPUMSetHyperEIP(PVMCPU pVCpu, uint32_t u32EIP);
|
---|
364 | VMM_INT_DECL(void) CPUMSetHyperState(PVMCPU pVCpu, uint32_t u32EIP, uint32_t u32ESP, uint32_t u32EAX, uint32_t u32EDX);
|
---|
365 | VMMDECL(void) CPUMSetHyperDR0(PVMCPU pVCpu, RTGCUINTREG uDr0);
|
---|
366 | VMMDECL(void) CPUMSetHyperDR1(PVMCPU pVCpu, RTGCUINTREG uDr1);
|
---|
367 | VMMDECL(void) CPUMSetHyperDR2(PVMCPU pVCpu, RTGCUINTREG uDr2);
|
---|
368 | VMMDECL(void) CPUMSetHyperDR3(PVMCPU pVCpu, RTGCUINTREG uDr3);
|
---|
369 | VMMDECL(void) CPUMSetHyperDR6(PVMCPU pVCpu, RTGCUINTREG uDr6);
|
---|
370 | VMMDECL(void) CPUMSetHyperDR7(PVMCPU pVCpu, RTGCUINTREG uDr7);
|
---|
371 | VMMDECL(void) CPUMSetHyperCtx(PVMCPU pVCpu, const PCPUMCTX pCtx);
|
---|
372 | VMMDECL(int) CPUMRecalcHyperDRx(PVMCPU pVCpu);
|
---|
373 | /** @} */
|
---|
374 |
|
---|
375 | VMMDECL(void) CPUMPushHyper(PVMCPU pVCpu, uint32_t u32);
|
---|
376 | VMMDECL(int) CPUMQueryHyperCtxPtr(PVMCPU pVCpu, PCPUMCTX *ppCtx);
|
---|
377 | VMMDECL(PCPUMCTX) CPUMGetHyperCtxPtr(PVMCPU pVCpu);
|
---|
378 | VMMDECL(PCCPUMCTXCORE) CPUMGetHyperCtxCore(PVMCPU pVCpu);
|
---|
379 | VMMDECL(PCPUMCTX) CPUMQueryGuestCtxPtr(PVMCPU pVCpu);
|
---|
380 | VMMDECL(PCCPUMCTXCORE) CPUMGetGuestCtxCore(PVMCPU pVCpu);
|
---|
381 | VMM_INT_DECL(int) CPUMRawEnter(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore);
|
---|
382 | VMM_INT_DECL(int) CPUMRawLeave(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore, int rc);
|
---|
383 | VMMDECL(uint32_t) CPUMRawGetEFlags(PVMCPU pVCpu);
|
---|
384 | VMMDECL(void) CPUMRawSetEFlags(PVMCPU pVCpu, uint32_t fEfl);
|
---|
385 | VMMDECL(int) CPUMHandleLazyFPU(PVMCPU pVCpu);
|
---|
386 |
|
---|
387 | /** @name Changed flags.
|
---|
388 | * These flags are used to keep track of which important register that
|
---|
389 | * have been changed since last they were reset. The only one allowed
|
---|
390 | * to clear them is REM!
|
---|
391 | * @{
|
---|
392 | */
|
---|
393 | #define CPUM_CHANGED_FPU_REM RT_BIT(0)
|
---|
394 | #define CPUM_CHANGED_CR0 RT_BIT(1)
|
---|
395 | #define CPUM_CHANGED_CR4 RT_BIT(2)
|
---|
396 | #define CPUM_CHANGED_GLOBAL_TLB_FLUSH RT_BIT(3)
|
---|
397 | #define CPUM_CHANGED_CR3 RT_BIT(4)
|
---|
398 | #define CPUM_CHANGED_GDTR RT_BIT(5)
|
---|
399 | #define CPUM_CHANGED_IDTR RT_BIT(6)
|
---|
400 | #define CPUM_CHANGED_LDTR RT_BIT(7)
|
---|
401 | #define CPUM_CHANGED_TR RT_BIT(8) /**@< Currently unused. */
|
---|
402 | #define CPUM_CHANGED_SYSENTER_MSR RT_BIT(9)
|
---|
403 | #define CPUM_CHANGED_HIDDEN_SEL_REGS RT_BIT(10) /**@< Currently unused. */
|
---|
404 | #define CPUM_CHANGED_CPUID RT_BIT(11)
|
---|
405 | #define CPUM_CHANGED_ALL ( CPUM_CHANGED_FPU_REM \
|
---|
406 | | CPUM_CHANGED_CR0 \
|
---|
407 | | CPUM_CHANGED_CR4 \
|
---|
408 | | CPUM_CHANGED_GLOBAL_TLB_FLUSH \
|
---|
409 | | CPUM_CHANGED_CR3 \
|
---|
410 | | CPUM_CHANGED_GDTR \
|
---|
411 | | CPUM_CHANGED_IDTR \
|
---|
412 | | CPUM_CHANGED_LDTR \
|
---|
413 | | CPUM_CHANGED_TR \
|
---|
414 | | CPUM_CHANGED_SYSENTER_MSR \
|
---|
415 | | CPUM_CHANGED_HIDDEN_SEL_REGS \
|
---|
416 | | CPUM_CHANGED_CPUID )
|
---|
417 | /** @} */
|
---|
418 |
|
---|
419 | VMMDECL(void) CPUMSetChangedFlags(PVMCPU pVCpu, uint32_t fChangedFlags);
|
---|
420 | VMMR3DECL(uint32_t) CPUMR3RemEnter(PVMCPU pVCpu, uint32_t *puCpl);
|
---|
421 | VMMR3DECL(void) CPUMR3RemLeave(PVMCPU pVCpu, bool fNoOutOfSyncSels);
|
---|
422 | VMMDECL(bool) CPUMSupportsFXSR(PVM pVM);
|
---|
423 | VMMDECL(bool) CPUMIsHostUsingSysEnter(PVM pVM);
|
---|
424 | VMMDECL(bool) CPUMIsHostUsingSysCall(PVM pVM);
|
---|
425 | VMMDECL(bool) CPUMIsGuestFPUStateActive(PVMCPU pVCpu);
|
---|
426 | VMMDECL(void) CPUMDeactivateGuestFPUState(PVMCPU pVCpu);
|
---|
427 | VMMDECL(bool) CPUMIsGuestDebugStateActive(PVMCPU pVCpu);
|
---|
428 | VMMDECL(void) CPUMDeactivateGuestDebugState(PVMCPU pVCpu);
|
---|
429 | VMMDECL(bool) CPUMIsHyperDebugStateActive(PVMCPU pVCpu);
|
---|
430 | VMMDECL(void) CPUMDeactivateHyperDebugState(PVMCPU pVCpu);
|
---|
431 | VMMDECL(uint32_t) CPUMGetGuestCPL(PVMCPU pVCpu);
|
---|
432 | VMMDECL(CPUMMODE) CPUMGetGuestMode(PVMCPU pVCpu);
|
---|
433 | VMMDECL(uint32_t) CPUMGetGuestCodeBits(PVMCPU pVCpu);
|
---|
434 | VMMDECL(DISCPUMODE) CPUMGetGuestDisMode(PVMCPU pVCpu);
|
---|
435 |
|
---|
436 |
|
---|
437 | #ifdef IN_RING3
|
---|
438 | /** @defgroup grp_cpum_r3 The CPU Monitor(/Manager) API
|
---|
439 | * @ingroup grp_cpum
|
---|
440 | * @{
|
---|
441 | */
|
---|
442 |
|
---|
443 | VMMR3DECL(int) CPUMR3Init(PVM pVM);
|
---|
444 | VMMR3DECL(int) CPUMR3InitCompleted(PVM pVM);
|
---|
445 | VMMR3DECL(void) CPUMR3LogCpuIds(PVM pVM);
|
---|
446 | VMMR3DECL(void) CPUMR3Relocate(PVM pVM);
|
---|
447 | VMMR3DECL(int) CPUMR3Term(PVM pVM);
|
---|
448 | VMMR3DECL(void) CPUMR3Reset(PVM pVM);
|
---|
449 | VMMR3DECL(void) CPUMR3ResetCpu(PVMCPU pVCpu);
|
---|
450 | VMMDECL(bool) CPUMR3IsStateRestorePending(PVM pVM);
|
---|
451 | VMMR3DECL(void) CPUMR3SetHWVirtEx(PVM pVM, bool fHWVirtExEnabled);
|
---|
452 | VMMR3DECL(int) CPUMR3SetCR4Feature(PVM pVM, RTHCUINTREG fOr, RTHCUINTREG fAnd);
|
---|
453 | VMMR3DECL(RCPTRTYPE(PCCPUMCPUID)) CPUMR3GetGuestCpuIdStdRCPtr(PVM pVM);
|
---|
454 | VMMR3DECL(RCPTRTYPE(PCCPUMCPUID)) CPUMR3GetGuestCpuIdExtRCPtr(PVM pVM);
|
---|
455 | VMMR3DECL(RCPTRTYPE(PCCPUMCPUID)) CPUMR3GetGuestCpuIdCentaurRCPtr(PVM pVM);
|
---|
456 | VMMR3DECL(RCPTRTYPE(PCCPUMCPUID)) CPUMR3GetGuestCpuIdDefRCPtr(PVM pVM);
|
---|
457 |
|
---|
458 | /** @} */
|
---|
459 | #endif /* IN_RING3 */
|
---|
460 |
|
---|
461 | #ifdef IN_RC
|
---|
462 | /** @defgroup grp_cpum_gc The CPU Monitor(/Manager) API
|
---|
463 | * @ingroup grp_cpum
|
---|
464 | * @{
|
---|
465 | */
|
---|
466 |
|
---|
467 | /**
|
---|
468 | * Calls a guest trap/interrupt handler directly
|
---|
469 | *
|
---|
470 | * Assumes a trap stack frame has already been setup on the guest's stack!
|
---|
471 | * This function does not return!
|
---|
472 | *
|
---|
473 | * @param pRegFrame Original trap/interrupt context
|
---|
474 | * @param selCS Code selector of handler
|
---|
475 | * @param pHandler GC virtual address of handler
|
---|
476 | * @param eflags Callee's EFLAGS
|
---|
477 | * @param selSS Stack selector for handler
|
---|
478 | * @param pEsp Stack address for handler
|
---|
479 | */
|
---|
480 | DECLASM(void) CPUMGCCallGuestTrapHandler(PCPUMCTXCORE pRegFrame, uint32_t selCS, RTRCPTR pHandler,
|
---|
481 | uint32_t eflags, uint32_t selSS, RTRCPTR pEsp);
|
---|
482 |
|
---|
483 | /**
|
---|
484 | * Call guest V86 code directly.
|
---|
485 | *
|
---|
486 | * This function does not return!
|
---|
487 | *
|
---|
488 | * @param pRegFrame Original trap/interrupt context
|
---|
489 | */
|
---|
490 | DECLASM(void) CPUMGCCallV86Code(PCPUMCTXCORE pRegFrame);
|
---|
491 |
|
---|
492 |
|
---|
493 | VMMDECL(uint32_t) CPUMRCGetGuestCPL(PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
|
---|
494 | #ifdef VBOX_WITH_RAW_RING1
|
---|
495 | VMMDECL(void) CPUMRCRecheckRawState(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore);
|
---|
496 | #endif
|
---|
497 |
|
---|
498 | /** @} */
|
---|
499 | #endif /* IN_RC */
|
---|
500 |
|
---|
501 | #ifdef IN_RING0
|
---|
502 | /** @defgroup grp_cpum_r0 The CPU Monitor(/Manager) API
|
---|
503 | * @ingroup grp_cpum
|
---|
504 | * @{
|
---|
505 | */
|
---|
506 | VMMR0DECL(int) CPUMR0ModuleInit(void);
|
---|
507 | VMMR0DECL(int) CPUMR0ModuleTerm(void);
|
---|
508 | VMMR0DECL(int) CPUMR0Init(PVM pVM);
|
---|
509 | VMMR0DECL(int) CPUMR0LoadGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
510 | VMMR0DECL(int) CPUMR0SaveGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
511 | VMMR0DECL(int) CPUMR0SaveGuestDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, bool fDR6);
|
---|
512 | VMMR0DECL(int) CPUMR0LoadGuestDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, bool fDR6);
|
---|
513 | VMMR0DECL(int) CPUMR0LoadHostDebugState(PVM pVM, PVMCPU pVCpu);
|
---|
514 | VMMR0DECL(int) CPUMR0SaveHostDebugState(PVM pVM, PVMCPU pVCpu);
|
---|
515 | VMMR0DECL(int) CPUMR0LoadHyperDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx, bool fDR6);
|
---|
516 | #ifdef VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
|
---|
517 | VMMR0DECL(void) CPUMR0SetLApic(PVM pVM, RTCPUID idHostCpu);
|
---|
518 | #endif
|
---|
519 |
|
---|
520 | /** @} */
|
---|
521 | #endif /* IN_RING0 */
|
---|
522 |
|
---|
523 | /** @} */
|
---|
524 | RT_C_DECLS_END
|
---|
525 |
|
---|
526 |
|
---|
527 | #endif
|
---|
528 |
|
---|