VirtualBox

source: vbox/trunk/include/VBox/vmm/cpum.h@ 42337

Last change on this file since 42337 was 42186, checked in by vboxsync, 12 years ago

SELM,DIS,CPUM,EM: Hidden selector register cleanups.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette