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