VirtualBox

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

Last change on this file since 58650 was 58126, checked in by vboxsync, 9 years ago

VMM: Fixed almost all the Doxygen warnings.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 60.9 KB
Line 
1/** @file
2 * CPUM - CPU Monitor(/ Manager).
3 */
4
5/*
6 * Copyright (C) 2006-2015 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#include <VBox/vmm/stam.h>
33
34RT_C_DECLS_BEGIN
35
36/** @defgroup grp_cpum The CPU Monitor / Manager API
37 * @ingroup grp_vmm
38 * @{
39 */
40
41/**
42 * CPUID feature to set or clear.
43 */
44typedef enum CPUMCPUIDFEATURE
45{
46 CPUMCPUIDFEATURE_INVALID = 0,
47 /** The APIC feature bit. (Std+Ext) */
48 CPUMCPUIDFEATURE_APIC,
49 /** The sysenter/sysexit feature bit. (Std) */
50 CPUMCPUIDFEATURE_SEP,
51 /** The SYSCALL/SYSEXIT feature bit (64 bits mode only for Intel CPUs). (Ext) */
52 CPUMCPUIDFEATURE_SYSCALL,
53 /** The PAE feature bit. (Std+Ext) */
54 CPUMCPUIDFEATURE_PAE,
55 /** The NX feature bit. (Ext) */
56 CPUMCPUIDFEATURE_NX,
57 /** The LAHF/SAHF feature bit (64 bits mode only). (Ext) */
58 CPUMCPUIDFEATURE_LAHF,
59 /** The LONG MODE feature bit. (Ext) */
60 CPUMCPUIDFEATURE_LONG_MODE,
61 /** The PAT feature bit. (Std+Ext) */
62 CPUMCPUIDFEATURE_PAT,
63 /** The x2APIC feature bit. (Std) */
64 CPUMCPUIDFEATURE_X2APIC,
65 /** The RDTSCP feature bit. (Ext) */
66 CPUMCPUIDFEATURE_RDTSCP,
67 /** The Hypervisor Present bit. (Std) */
68 CPUMCPUIDFEATURE_HVP,
69 /** The MWait Extensions bits (Std) */
70 CPUMCPUIDFEATURE_MWAIT_EXTS,
71 /** The CR4.OSXSAVE bit CPUID mirroring, only use from CPUMSetGuestCR4. */
72 CPUMCPUIDFEATURE_OSXSAVE,
73 /** 32bit hackishness. */
74 CPUMCPUIDFEATURE_32BIT_HACK = 0x7fffffff
75} CPUMCPUIDFEATURE;
76
77/**
78 * CPU Vendor.
79 */
80typedef enum CPUMCPUVENDOR
81{
82 CPUMCPUVENDOR_INVALID = 0,
83 CPUMCPUVENDOR_INTEL,
84 CPUMCPUVENDOR_AMD,
85 CPUMCPUVENDOR_VIA,
86 CPUMCPUVENDOR_CYRIX,
87 CPUMCPUVENDOR_UNKNOWN,
88 /** 32bit hackishness. */
89 CPUMCPUVENDOR_32BIT_HACK = 0x7fffffff
90} CPUMCPUVENDOR;
91
92
93/**
94 * X86 and AMD64 CPU microarchitectures and in processor generations.
95 *
96 * @remarks The separation here is sometimes a little bit too finely grained,
97 * and the differences is more like processor generation than micro
98 * arch. This can be useful, so we'll provide functions for getting at
99 * more coarse grained info.
100 */
101typedef enum CPUMMICROARCH
102{
103 kCpumMicroarch_Invalid = 0,
104
105 kCpumMicroarch_Intel_First,
106
107 kCpumMicroarch_Intel_8086 = kCpumMicroarch_Intel_First,
108 kCpumMicroarch_Intel_80186,
109 kCpumMicroarch_Intel_80286,
110 kCpumMicroarch_Intel_80386,
111 kCpumMicroarch_Intel_80486,
112 kCpumMicroarch_Intel_P5,
113
114 kCpumMicroarch_Intel_P6_Core_Atom_First,
115 kCpumMicroarch_Intel_P6 = kCpumMicroarch_Intel_P6_Core_Atom_First,
116 kCpumMicroarch_Intel_P6_II,
117 kCpumMicroarch_Intel_P6_III,
118
119 kCpumMicroarch_Intel_P6_M_Banias,
120 kCpumMicroarch_Intel_P6_M_Dothan,
121 kCpumMicroarch_Intel_Core_Yonah, /**< Core, also known as Enhanced Pentium M. */
122
123 kCpumMicroarch_Intel_Core2_First,
124 kCpumMicroarch_Intel_Core2_Merom = kCpumMicroarch_Intel_Core2_First,
125 kCpumMicroarch_Intel_Core2_Penryn,
126
127 kCpumMicroarch_Intel_Core7_First,
128 kCpumMicroarch_Intel_Core7_Nehalem = kCpumMicroarch_Intel_Core7_First,
129 kCpumMicroarch_Intel_Core7_Westmere,
130 kCpumMicroarch_Intel_Core7_SandyBridge,
131 kCpumMicroarch_Intel_Core7_IvyBridge,
132 kCpumMicroarch_Intel_Core7_Haswell,
133 kCpumMicroarch_Intel_Core7_Broadwell,
134 kCpumMicroarch_Intel_Core7_Skylake,
135 kCpumMicroarch_Intel_Core7_Cannonlake,
136 kCpumMicroarch_Intel_Core7_End,
137
138 kCpumMicroarch_Intel_Atom_First,
139 kCpumMicroarch_Intel_Atom_Bonnell = kCpumMicroarch_Intel_Atom_First,
140 kCpumMicroarch_Intel_Atom_Lincroft, /**< Second generation bonnell (44nm). */
141 kCpumMicroarch_Intel_Atom_Saltwell, /**< 32nm shrink of Bonnell. */
142 kCpumMicroarch_Intel_Atom_Silvermont, /**< 22nm */
143 kCpumMicroarch_Intel_Atom_Airmount, /**< 14nm */
144 kCpumMicroarch_Intel_Atom_Goldmont, /**< 14nm */
145 kCpumMicroarch_Intel_Atom_Unknown,
146 kCpumMicroarch_Intel_Atom_End,
147
148 kCpumMicroarch_Intel_P6_Core_Atom_End,
149
150 kCpumMicroarch_Intel_NB_First,
151 kCpumMicroarch_Intel_NB_Willamette = kCpumMicroarch_Intel_NB_First, /**< 180nm */
152 kCpumMicroarch_Intel_NB_Northwood, /**< 130nm */
153 kCpumMicroarch_Intel_NB_Prescott, /**< 90nm */
154 kCpumMicroarch_Intel_NB_Prescott2M, /**< 90nm */
155 kCpumMicroarch_Intel_NB_CedarMill, /**< 65nm */
156 kCpumMicroarch_Intel_NB_Gallatin, /**< 90nm Xeon, Pentium 4 Extreme Edition ("Emergency Edition"). */
157 kCpumMicroarch_Intel_NB_Unknown,
158 kCpumMicroarch_Intel_NB_End,
159
160 kCpumMicroarch_Intel_Unknown,
161 kCpumMicroarch_Intel_End,
162
163 kCpumMicroarch_AMD_First,
164 kCpumMicroarch_AMD_Am286 = kCpumMicroarch_AMD_First,
165 kCpumMicroarch_AMD_Am386,
166 kCpumMicroarch_AMD_Am486,
167 kCpumMicroarch_AMD_Am486Enh, /**< Covers Am5x86 as well. */
168 kCpumMicroarch_AMD_K5,
169 kCpumMicroarch_AMD_K6,
170
171 kCpumMicroarch_AMD_K7_First,
172 kCpumMicroarch_AMD_K7_Palomino = kCpumMicroarch_AMD_K7_First,
173 kCpumMicroarch_AMD_K7_Spitfire,
174 kCpumMicroarch_AMD_K7_Thunderbird,
175 kCpumMicroarch_AMD_K7_Morgan,
176 kCpumMicroarch_AMD_K7_Thoroughbred,
177 kCpumMicroarch_AMD_K7_Barton,
178 kCpumMicroarch_AMD_K7_Unknown,
179 kCpumMicroarch_AMD_K7_End,
180
181 kCpumMicroarch_AMD_K8_First,
182 kCpumMicroarch_AMD_K8_130nm = kCpumMicroarch_AMD_K8_First, /**< 130nm Clawhammer, Sledgehammer, Newcastle, Paris, Odessa, Dublin */
183 kCpumMicroarch_AMD_K8_90nm, /**< 90nm shrink */
184 kCpumMicroarch_AMD_K8_90nm_DualCore, /**< 90nm with two cores. */
185 kCpumMicroarch_AMD_K8_90nm_AMDV, /**< 90nm with AMD-V (usually) and two cores (usually). */
186 kCpumMicroarch_AMD_K8_65nm, /**< 65nm shrink. */
187 kCpumMicroarch_AMD_K8_End,
188
189 kCpumMicroarch_AMD_K10,
190 kCpumMicroarch_AMD_K10_Lion,
191 kCpumMicroarch_AMD_K10_Llano,
192 kCpumMicroarch_AMD_Bobcat,
193 kCpumMicroarch_AMD_Jaguar,
194
195 kCpumMicroarch_AMD_15h_First,
196 kCpumMicroarch_AMD_15h_Bulldozer = kCpumMicroarch_AMD_15h_First,
197 kCpumMicroarch_AMD_15h_Piledriver,
198 kCpumMicroarch_AMD_15h_Steamroller, /**< Yet to be released, might have different family. */
199 kCpumMicroarch_AMD_15h_Excavator, /**< Yet to be released, might have different family. */
200 kCpumMicroarch_AMD_15h_Unknown,
201 kCpumMicroarch_AMD_15h_End,
202
203 kCpumMicroarch_AMD_16h_First,
204 kCpumMicroarch_AMD_16h_End,
205
206 kCpumMicroarch_AMD_Unknown,
207 kCpumMicroarch_AMD_End,
208
209 kCpumMicroarch_VIA_First,
210 kCpumMicroarch_Centaur_C6 = kCpumMicroarch_VIA_First,
211 kCpumMicroarch_Centaur_C2,
212 kCpumMicroarch_Centaur_C3,
213 kCpumMicroarch_VIA_C3_M2,
214 kCpumMicroarch_VIA_C3_C5A, /**< 180nm Samuel - Cyrix III, C3, 1GigaPro. */
215 kCpumMicroarch_VIA_C3_C5B, /**< 150nm Samuel 2 - Cyrix III, C3, 1GigaPro, Eden ESP, XP 2000+. */
216 kCpumMicroarch_VIA_C3_C5C, /**< 130nm Ezra - C3, Eden ESP. */
217 kCpumMicroarch_VIA_C3_C5N, /**< 130nm Ezra-T - C3. */
218 kCpumMicroarch_VIA_C3_C5XL, /**< 130nm Nehemiah - C3, Eden ESP, Eden-N. */
219 kCpumMicroarch_VIA_C3_C5P, /**< 130nm Nehemiah+ - C3. */
220 kCpumMicroarch_VIA_C7_C5J, /**< 90nm Esther - C7, C7-D, C7-M, Eden, Eden ULV. */
221 kCpumMicroarch_VIA_Isaiah,
222 kCpumMicroarch_VIA_Unknown,
223 kCpumMicroarch_VIA_End,
224
225 kCpumMicroarch_Cyrix_First,
226 kCpumMicroarch_Cyrix_5x86 = kCpumMicroarch_Cyrix_First,
227 kCpumMicroarch_Cyrix_M1,
228 kCpumMicroarch_Cyrix_MediaGX,
229 kCpumMicroarch_Cyrix_MediaGXm,
230 kCpumMicroarch_Cyrix_M2,
231 kCpumMicroarch_Cyrix_Unknown,
232 kCpumMicroarch_Cyrix_End,
233
234 kCpumMicroarch_Unknown,
235
236 kCpumMicroarch_32BitHack = 0x7fffffff
237} CPUMMICROARCH;
238
239
240/** Predicate macro for catching netburst CPUs. */
241#define CPUMMICROARCH_IS_INTEL_NETBURST(a_enmMicroarch) \
242 ((a_enmMicroarch) >= kCpumMicroarch_Intel_NB_First && (a_enmMicroarch) <= kCpumMicroarch_Intel_NB_End)
243
244/** Predicate macro for catching Core7 CPUs. */
245#define CPUMMICROARCH_IS_INTEL_CORE7(a_enmMicroarch) \
246 ((a_enmMicroarch) >= kCpumMicroarch_Intel_Core7_First && (a_enmMicroarch) <= kCpumMicroarch_Intel_Core7_End)
247
248/** Predicate macro for catching AMD Family OFh CPUs (aka K8). */
249#define CPUMMICROARCH_IS_AMD_FAM_0FH(a_enmMicroarch) \
250 ((a_enmMicroarch) >= kCpumMicroarch_AMD_K8_First && (a_enmMicroarch) <= kCpumMicroarch_AMD_K8_End)
251
252/** Predicate macro for catching AMD Family 10H CPUs (aka K10). */
253#define CPUMMICROARCH_IS_AMD_FAM_10H(a_enmMicroarch) ((a_enmMicroarch) == kCpumMicroarch_AMD_K10)
254
255/** Predicate macro for catching AMD Family 11H CPUs (aka Lion). */
256#define CPUMMICROARCH_IS_AMD_FAM_11H(a_enmMicroarch) ((a_enmMicroarch) == kCpumMicroarch_AMD_K10_Lion)
257
258/** Predicate macro for catching AMD Family 12H CPUs (aka Llano). */
259#define CPUMMICROARCH_IS_AMD_FAM_12H(a_enmMicroarch) ((a_enmMicroarch) == kCpumMicroarch_AMD_K10_Llano)
260
261/** Predicate macro for catching AMD Family 14H CPUs (aka Bobcat). */
262#define CPUMMICROARCH_IS_AMD_FAM_14H(a_enmMicroarch) ((a_enmMicroarch) == kCpumMicroarch_AMD_Bobcat)
263
264/** Predicate macro for catching AMD Family 15H CPUs (bulldozer and it's
265 * decendants). */
266#define CPUMMICROARCH_IS_AMD_FAM_15H(a_enmMicroarch) \
267 ((a_enmMicroarch) >= kCpumMicroarch_AMD_15h_First && (a_enmMicroarch) <= kCpumMicroarch_AMD_15h_End)
268
269/** Predicate macro for catching AMD Family 16H CPUs. */
270#define CPUMMICROARCH_IS_AMD_FAM_16H(a_enmMicroarch) \
271 ((a_enmMicroarch) >= kCpumMicroarch_AMD_16h_First && (a_enmMicroarch) <= kCpumMicroarch_AMD_16h_End)
272
273
274
275/**
276 * CPUID leaf.
277 *
278 * @remarks This structure is used by the patch manager and is therefore
279 * more or less set in stone.
280 */
281typedef struct CPUMCPUIDLEAF
282{
283 /** The leaf number. */
284 uint32_t uLeaf;
285 /** The sub-leaf number. */
286 uint32_t uSubLeaf;
287 /** Sub-leaf mask. This is 0 when sub-leaves aren't used. */
288 uint32_t fSubLeafMask;
289
290 /** The EAX value. */
291 uint32_t uEax;
292 /** The EBX value. */
293 uint32_t uEbx;
294 /** The ECX value. */
295 uint32_t uEcx;
296 /** The EDX value. */
297 uint32_t uEdx;
298
299 /** Flags. */
300 uint32_t fFlags;
301} CPUMCPUIDLEAF;
302AssertCompileSize(CPUMCPUIDLEAF, 32);
303/** Pointer to a CPUID leaf. */
304typedef CPUMCPUIDLEAF *PCPUMCPUIDLEAF;
305/** Pointer to a const CPUID leaf. */
306typedef CPUMCPUIDLEAF const *PCCPUMCPUIDLEAF;
307
308/** @name CPUMCPUIDLEAF::fFlags
309 * @{ */
310/** Indicates working intel leaf 0xb where the lower 8 ECX bits are not modified
311 * and EDX containing the extended APIC ID. */
312#define CPUMCPUIDLEAF_F_INTEL_TOPOLOGY_SUBLEAVES RT_BIT_32(0)
313/** The leaf contains an APIC ID that needs changing to that of the current CPU. */
314#define CPUMCPUIDLEAF_F_CONTAINS_APIC_ID RT_BIT_32(1)
315/** The leaf contains an OSXSAVE which needs individual handling on each CPU. */
316#define CPUMCPUIDLEAF_F_CONTAINS_OSXSAVE RT_BIT_32(2)
317/** Mask of the valid flags. */
318#define CPUMCPUIDLEAF_F_VALID_MASK UINT32_C(0x7)
319/** @} */
320
321/**
322 * Method used to deal with unknown CPUID leaves.
323 * @remarks Used in patch code.
324 */
325typedef enum CPUMUNKNOWNCPUID
326{
327 /** Invalid zero value. */
328 CPUMUNKNOWNCPUID_INVALID = 0,
329 /** Use given default values (DefCpuId). */
330 CPUMUNKNOWNCPUID_DEFAULTS,
331 /** Return the last standard leaf.
332 * Intel Sandy Bridge has been observed doing this. */
333 CPUMUNKNOWNCPUID_LAST_STD_LEAF,
334 /** Return the last standard leaf, with ecx observed.
335 * Intel Sandy Bridge has been observed doing this. */
336 CPUMUNKNOWNCPUID_LAST_STD_LEAF_WITH_ECX,
337 /** The register values are passed thru unmodified. */
338 CPUMUNKNOWNCPUID_PASSTHRU,
339 /** End of valid value. */
340 CPUMUNKNOWNCPUID_END,
341 /** Ensure 32-bit type. */
342 CPUMUNKNOWNCPUID_32BIT_HACK = 0x7fffffff
343} CPUMUNKNOWNCPUID;
344/** Pointer to unknown CPUID leaf method. */
345typedef CPUMUNKNOWNCPUID *PCPUMUNKNOWNCPUID;
346
347
348/**
349 * MSR read functions.
350 */
351typedef enum CPUMMSRRDFN
352{
353 /** Invalid zero value. */
354 kCpumMsrRdFn_Invalid = 0,
355 /** Return the CPUMMSRRANGE::uValue. */
356 kCpumMsrRdFn_FixedValue,
357 /** Alias to the MSR range starting at the MSR given by
358 * CPUMMSRRANGE::uValue. Must be used in pair with
359 * kCpumMsrWrFn_MsrAlias. */
360 kCpumMsrRdFn_MsrAlias,
361 /** Write only register, GP all read attempts. */
362 kCpumMsrRdFn_WriteOnly,
363
364 kCpumMsrRdFn_Ia32P5McAddr,
365 kCpumMsrRdFn_Ia32P5McType,
366 kCpumMsrRdFn_Ia32TimestampCounter,
367 kCpumMsrRdFn_Ia32PlatformId, /**< Takes real CPU value for reference. */
368 kCpumMsrRdFn_Ia32ApicBase,
369 kCpumMsrRdFn_Ia32FeatureControl,
370 kCpumMsrRdFn_Ia32BiosSignId, /**< Range value returned. */
371 kCpumMsrRdFn_Ia32SmmMonitorCtl,
372 kCpumMsrRdFn_Ia32PmcN,
373 kCpumMsrRdFn_Ia32MonitorFilterLineSize,
374 kCpumMsrRdFn_Ia32MPerf,
375 kCpumMsrRdFn_Ia32APerf,
376 kCpumMsrRdFn_Ia32MtrrCap, /**< Takes real CPU value for reference. */
377 kCpumMsrRdFn_Ia32MtrrPhysBaseN, /**< Takes register number. */
378 kCpumMsrRdFn_Ia32MtrrPhysMaskN, /**< Takes register number. */
379 kCpumMsrRdFn_Ia32MtrrFixed, /**< Takes CPUMCPU offset. */
380 kCpumMsrRdFn_Ia32MtrrDefType,
381 kCpumMsrRdFn_Ia32Pat,
382 kCpumMsrRdFn_Ia32SysEnterCs,
383 kCpumMsrRdFn_Ia32SysEnterEsp,
384 kCpumMsrRdFn_Ia32SysEnterEip,
385 kCpumMsrRdFn_Ia32McgCap,
386 kCpumMsrRdFn_Ia32McgStatus,
387 kCpumMsrRdFn_Ia32McgCtl,
388 kCpumMsrRdFn_Ia32DebugCtl,
389 kCpumMsrRdFn_Ia32SmrrPhysBase,
390 kCpumMsrRdFn_Ia32SmrrPhysMask,
391 kCpumMsrRdFn_Ia32PlatformDcaCap,
392 kCpumMsrRdFn_Ia32CpuDcaCap,
393 kCpumMsrRdFn_Ia32Dca0Cap,
394 kCpumMsrRdFn_Ia32PerfEvtSelN, /**< Range value indicates the register number. */
395 kCpumMsrRdFn_Ia32PerfStatus, /**< Range value returned. */
396 kCpumMsrRdFn_Ia32PerfCtl, /**< Range value returned. */
397 kCpumMsrRdFn_Ia32FixedCtrN, /**< Takes register number of start of range. */
398 kCpumMsrRdFn_Ia32PerfCapabilities, /**< Takes reference value. */
399 kCpumMsrRdFn_Ia32FixedCtrCtrl,
400 kCpumMsrRdFn_Ia32PerfGlobalStatus, /**< Takes reference value. */
401 kCpumMsrRdFn_Ia32PerfGlobalCtrl,
402 kCpumMsrRdFn_Ia32PerfGlobalOvfCtrl,
403 kCpumMsrRdFn_Ia32PebsEnable,
404 kCpumMsrRdFn_Ia32ClockModulation, /**< Range value returned. */
405 kCpumMsrRdFn_Ia32ThermInterrupt, /**< Range value returned. */
406 kCpumMsrRdFn_Ia32ThermStatus, /**< Range value returned. */
407 kCpumMsrRdFn_Ia32Therm2Ctl, /**< Range value returned. */
408 kCpumMsrRdFn_Ia32MiscEnable, /**< Range value returned. */
409 kCpumMsrRdFn_Ia32McCtlStatusAddrMiscN, /**< Takes bank number. */
410 kCpumMsrRdFn_Ia32McNCtl2, /**< Takes register number of start of range. */
411 kCpumMsrRdFn_Ia32DsArea,
412 kCpumMsrRdFn_Ia32TscDeadline,
413 kCpumMsrRdFn_Ia32X2ApicN,
414 kCpumMsrRdFn_Ia32DebugInterface,
415 kCpumMsrRdFn_Ia32VmxBase, /**< Takes real value as reference. */
416 kCpumMsrRdFn_Ia32VmxPinbasedCtls, /**< Takes real value as reference. */
417 kCpumMsrRdFn_Ia32VmxProcbasedCtls, /**< Takes real value as reference. */
418 kCpumMsrRdFn_Ia32VmxExitCtls, /**< Takes real value as reference. */
419 kCpumMsrRdFn_Ia32VmxEntryCtls, /**< Takes real value as reference. */
420 kCpumMsrRdFn_Ia32VmxMisc, /**< Takes real value as reference. */
421 kCpumMsrRdFn_Ia32VmxCr0Fixed0, /**< Takes real value as reference. */
422 kCpumMsrRdFn_Ia32VmxCr0Fixed1, /**< Takes real value as reference. */
423 kCpumMsrRdFn_Ia32VmxCr4Fixed0, /**< Takes real value as reference. */
424 kCpumMsrRdFn_Ia32VmxCr4Fixed1, /**< Takes real value as reference. */
425 kCpumMsrRdFn_Ia32VmxVmcsEnum, /**< Takes real value as reference. */
426 kCpumMsrRdFn_Ia32VmxProcBasedCtls2, /**< Takes real value as reference. */
427 kCpumMsrRdFn_Ia32VmxEptVpidCap, /**< Takes real value as reference. */
428 kCpumMsrRdFn_Ia32VmxTruePinbasedCtls, /**< Takes real value as reference. */
429 kCpumMsrRdFn_Ia32VmxTrueProcbasedCtls, /**< Takes real value as reference. */
430 kCpumMsrRdFn_Ia32VmxTrueExitCtls, /**< Takes real value as reference. */
431 kCpumMsrRdFn_Ia32VmxTrueEntryCtls, /**< Takes real value as reference. */
432
433 kCpumMsrRdFn_Amd64Efer,
434 kCpumMsrRdFn_Amd64SyscallTarget,
435 kCpumMsrRdFn_Amd64LongSyscallTarget,
436 kCpumMsrRdFn_Amd64CompSyscallTarget,
437 kCpumMsrRdFn_Amd64SyscallFlagMask,
438 kCpumMsrRdFn_Amd64FsBase,
439 kCpumMsrRdFn_Amd64GsBase,
440 kCpumMsrRdFn_Amd64KernelGsBase,
441 kCpumMsrRdFn_Amd64TscAux,
442
443 kCpumMsrRdFn_IntelEblCrPowerOn,
444 kCpumMsrRdFn_IntelI7CoreThreadCount,
445 kCpumMsrRdFn_IntelP4EbcHardPowerOn,
446 kCpumMsrRdFn_IntelP4EbcSoftPowerOn,
447 kCpumMsrRdFn_IntelP4EbcFrequencyId,
448 kCpumMsrRdFn_IntelP6FsbFrequency, /**< Takes real value as reference. */
449 kCpumMsrRdFn_IntelPlatformInfo,
450 kCpumMsrRdFn_IntelFlexRatio, /**< Takes real value as reference. */
451 kCpumMsrRdFn_IntelPkgCStConfigControl,
452 kCpumMsrRdFn_IntelPmgIoCaptureBase,
453 kCpumMsrRdFn_IntelLastBranchFromToN,
454 kCpumMsrRdFn_IntelLastBranchFromN,
455 kCpumMsrRdFn_IntelLastBranchToN,
456 kCpumMsrRdFn_IntelLastBranchTos,
457 kCpumMsrRdFn_IntelBblCrCtl,
458 kCpumMsrRdFn_IntelBblCrCtl3,
459 kCpumMsrRdFn_IntelI7TemperatureTarget, /**< Range value returned. */
460 kCpumMsrRdFn_IntelI7MsrOffCoreResponseN,/**< Takes register number. */
461 kCpumMsrRdFn_IntelI7MiscPwrMgmt,
462 kCpumMsrRdFn_IntelP6CrN,
463 kCpumMsrRdFn_IntelCpuId1FeatureMaskEcdx,
464 kCpumMsrRdFn_IntelCpuId1FeatureMaskEax,
465 kCpumMsrRdFn_IntelCpuId80000001FeatureMaskEcdx,
466 kCpumMsrRdFn_IntelI7SandyAesNiCtl,
467 kCpumMsrRdFn_IntelI7TurboRatioLimit, /**< Returns range value. */
468 kCpumMsrRdFn_IntelI7LbrSelect,
469 kCpumMsrRdFn_IntelI7SandyErrorControl,
470 kCpumMsrRdFn_IntelI7VirtualLegacyWireCap,/**< Returns range value. */
471 kCpumMsrRdFn_IntelI7PowerCtl,
472 kCpumMsrRdFn_IntelI7SandyPebsNumAlt,
473 kCpumMsrRdFn_IntelI7PebsLdLat,
474 kCpumMsrRdFn_IntelI7PkgCnResidencyN, /**< Takes C-state number. */
475 kCpumMsrRdFn_IntelI7CoreCnResidencyN, /**< Takes C-state number. */
476 kCpumMsrRdFn_IntelI7SandyVrCurrentConfig,/**< Takes real value as reference. */
477 kCpumMsrRdFn_IntelI7SandyVrMiscConfig, /**< Takes real value as reference. */
478 kCpumMsrRdFn_IntelI7SandyRaplPowerUnit, /**< Takes real value as reference. */
479 kCpumMsrRdFn_IntelI7SandyPkgCnIrtlN, /**< Takes real value as reference. */
480 kCpumMsrRdFn_IntelI7SandyPkgC2Residency, /**< Takes real value as reference. */
481 kCpumMsrRdFn_IntelI7RaplPkgPowerLimit, /**< Takes real value as reference. */
482 kCpumMsrRdFn_IntelI7RaplPkgEnergyStatus, /**< Takes real value as reference. */
483 kCpumMsrRdFn_IntelI7RaplPkgPerfStatus, /**< Takes real value as reference. */
484 kCpumMsrRdFn_IntelI7RaplPkgPowerInfo, /**< Takes real value as reference. */
485 kCpumMsrRdFn_IntelI7RaplDramPowerLimit, /**< Takes real value as reference. */
486 kCpumMsrRdFn_IntelI7RaplDramEnergyStatus,/**< Takes real value as reference. */
487 kCpumMsrRdFn_IntelI7RaplDramPerfStatus, /**< Takes real value as reference. */
488 kCpumMsrRdFn_IntelI7RaplDramPowerInfo, /**< Takes real value as reference. */
489 kCpumMsrRdFn_IntelI7RaplPp0PowerLimit, /**< Takes real value as reference. */
490 kCpumMsrRdFn_IntelI7RaplPp0EnergyStatus, /**< Takes real value as reference. */
491 kCpumMsrRdFn_IntelI7RaplPp0Policy, /**< Takes real value as reference. */
492 kCpumMsrRdFn_IntelI7RaplPp0PerfStatus, /**< Takes real value as reference. */
493 kCpumMsrRdFn_IntelI7RaplPp1PowerLimit, /**< Takes real value as reference. */
494 kCpumMsrRdFn_IntelI7RaplPp1EnergyStatus, /**< Takes real value as reference. */
495 kCpumMsrRdFn_IntelI7RaplPp1Policy, /**< Takes real value as reference. */
496 kCpumMsrRdFn_IntelI7IvyConfigTdpNominal, /**< Takes real value as reference. */
497 kCpumMsrRdFn_IntelI7IvyConfigTdpLevel1, /**< Takes real value as reference. */
498 kCpumMsrRdFn_IntelI7IvyConfigTdpLevel2, /**< Takes real value as reference. */
499 kCpumMsrRdFn_IntelI7IvyConfigTdpControl,
500 kCpumMsrRdFn_IntelI7IvyTurboActivationRatio,
501 kCpumMsrRdFn_IntelI7UncPerfGlobalCtrl,
502 kCpumMsrRdFn_IntelI7UncPerfGlobalStatus,
503 kCpumMsrRdFn_IntelI7UncPerfGlobalOvfCtrl,
504 kCpumMsrRdFn_IntelI7UncPerfFixedCtrCtrl,
505 kCpumMsrRdFn_IntelI7UncPerfFixedCtr,
506 kCpumMsrRdFn_IntelI7UncCBoxConfig,
507 kCpumMsrRdFn_IntelI7UncArbPerfCtrN,
508 kCpumMsrRdFn_IntelI7UncArbPerfEvtSelN,
509 kCpumMsrRdFn_IntelCore2EmttmCrTablesN, /**< Range value returned. */
510 kCpumMsrRdFn_IntelCore2SmmCStMiscInfo,
511 kCpumMsrRdFn_IntelCore1ExtConfig,
512 kCpumMsrRdFn_IntelCore1DtsCalControl,
513 kCpumMsrRdFn_IntelCore2PeciControl,
514
515 kCpumMsrRdFn_P6LastBranchFromIp,
516 kCpumMsrRdFn_P6LastBranchToIp,
517 kCpumMsrRdFn_P6LastIntFromIp,
518 kCpumMsrRdFn_P6LastIntToIp,
519
520 kCpumMsrRdFn_AmdFam15hTscRate,
521 kCpumMsrRdFn_AmdFam15hLwpCfg,
522 kCpumMsrRdFn_AmdFam15hLwpCbAddr,
523 kCpumMsrRdFn_AmdFam10hMc4MiscN,
524 kCpumMsrRdFn_AmdK8PerfCtlN,
525 kCpumMsrRdFn_AmdK8PerfCtrN,
526 kCpumMsrRdFn_AmdK8SysCfg, /**< Range value returned. */
527 kCpumMsrRdFn_AmdK8HwCr,
528 kCpumMsrRdFn_AmdK8IorrBaseN,
529 kCpumMsrRdFn_AmdK8IorrMaskN,
530 kCpumMsrRdFn_AmdK8TopOfMemN,
531 kCpumMsrRdFn_AmdK8NbCfg1,
532 kCpumMsrRdFn_AmdK8McXcptRedir,
533 kCpumMsrRdFn_AmdK8CpuNameN,
534 kCpumMsrRdFn_AmdK8HwThermalCtrl, /**< Range value returned. */
535 kCpumMsrRdFn_AmdK8SwThermalCtrl,
536 kCpumMsrRdFn_AmdK8FidVidControl, /**< Range value returned. */
537 kCpumMsrRdFn_AmdK8FidVidStatus, /**< Range value returned. */
538 kCpumMsrRdFn_AmdK8McCtlMaskN,
539 kCpumMsrRdFn_AmdK8SmiOnIoTrapN,
540 kCpumMsrRdFn_AmdK8SmiOnIoTrapCtlSts,
541 kCpumMsrRdFn_AmdK8IntPendingMessage,
542 kCpumMsrRdFn_AmdK8SmiTriggerIoCycle,
543 kCpumMsrRdFn_AmdFam10hMmioCfgBaseAddr,
544 kCpumMsrRdFn_AmdFam10hTrapCtlMaybe,
545 kCpumMsrRdFn_AmdFam10hPStateCurLimit, /**< Returns range value. */
546 kCpumMsrRdFn_AmdFam10hPStateControl, /**< Returns range value. */
547 kCpumMsrRdFn_AmdFam10hPStateStatus, /**< Returns range value. */
548 kCpumMsrRdFn_AmdFam10hPStateN, /**< Returns range value. This isn't an register index! */
549 kCpumMsrRdFn_AmdFam10hCofVidControl, /**< Returns range value. */
550 kCpumMsrRdFn_AmdFam10hCofVidStatus, /**< Returns range value. */
551 kCpumMsrRdFn_AmdFam10hCStateIoBaseAddr,
552 kCpumMsrRdFn_AmdFam10hCpuWatchdogTimer,
553 kCpumMsrRdFn_AmdK8SmmBase,
554 kCpumMsrRdFn_AmdK8SmmAddr,
555 kCpumMsrRdFn_AmdK8SmmMask,
556 kCpumMsrRdFn_AmdK8VmCr,
557 kCpumMsrRdFn_AmdK8IgnNe,
558 kCpumMsrRdFn_AmdK8SmmCtl,
559 kCpumMsrRdFn_AmdK8VmHSavePa,
560 kCpumMsrRdFn_AmdFam10hVmLockKey,
561 kCpumMsrRdFn_AmdFam10hSmmLockKey,
562 kCpumMsrRdFn_AmdFam10hLocalSmiStatus,
563 kCpumMsrRdFn_AmdFam10hOsVisWrkIdLength,
564 kCpumMsrRdFn_AmdFam10hOsVisWrkStatus,
565 kCpumMsrRdFn_AmdFam16hL2IPerfCtlN,
566 kCpumMsrRdFn_AmdFam16hL2IPerfCtrN,
567 kCpumMsrRdFn_AmdFam15hNorthbridgePerfCtlN,
568 kCpumMsrRdFn_AmdFam15hNorthbridgePerfCtrN,
569 kCpumMsrRdFn_AmdK7MicrocodeCtl, /**< Returns range value. */
570 kCpumMsrRdFn_AmdK7ClusterIdMaybe, /**< Returns range value. */
571 kCpumMsrRdFn_AmdK8CpuIdCtlStd07hEbax,
572 kCpumMsrRdFn_AmdK8CpuIdCtlStd06hEcx,
573 kCpumMsrRdFn_AmdK8CpuIdCtlStd01hEdcx,
574 kCpumMsrRdFn_AmdK8CpuIdCtlExt01hEdcx,
575 kCpumMsrRdFn_AmdK8PatchLevel, /**< Returns range value. */
576 kCpumMsrRdFn_AmdK7DebugStatusMaybe,
577 kCpumMsrRdFn_AmdK7BHTraceBaseMaybe,
578 kCpumMsrRdFn_AmdK7BHTracePtrMaybe,
579 kCpumMsrRdFn_AmdK7BHTraceLimitMaybe,
580 kCpumMsrRdFn_AmdK7HardwareDebugToolCfgMaybe,
581 kCpumMsrRdFn_AmdK7FastFlushCountMaybe,
582 kCpumMsrRdFn_AmdK7NodeId,
583 kCpumMsrRdFn_AmdK7DrXAddrMaskN, /**< Takes register index. */
584 kCpumMsrRdFn_AmdK7Dr0DataMatchMaybe,
585 kCpumMsrRdFn_AmdK7Dr0DataMaskMaybe,
586 kCpumMsrRdFn_AmdK7LoadStoreCfg,
587 kCpumMsrRdFn_AmdK7InstrCacheCfg,
588 kCpumMsrRdFn_AmdK7DataCacheCfg,
589 kCpumMsrRdFn_AmdK7BusUnitCfg,
590 kCpumMsrRdFn_AmdK7DebugCtl2Maybe,
591 kCpumMsrRdFn_AmdFam15hFpuCfg,
592 kCpumMsrRdFn_AmdFam15hDecoderCfg,
593 kCpumMsrRdFn_AmdFam10hBusUnitCfg2,
594 kCpumMsrRdFn_AmdFam15hCombUnitCfg,
595 kCpumMsrRdFn_AmdFam15hCombUnitCfg2,
596 kCpumMsrRdFn_AmdFam15hCombUnitCfg3,
597 kCpumMsrRdFn_AmdFam15hExecUnitCfg,
598 kCpumMsrRdFn_AmdFam15hLoadStoreCfg2,
599 kCpumMsrRdFn_AmdFam10hIbsFetchCtl,
600 kCpumMsrRdFn_AmdFam10hIbsFetchLinAddr,
601 kCpumMsrRdFn_AmdFam10hIbsFetchPhysAddr,
602 kCpumMsrRdFn_AmdFam10hIbsOpExecCtl,
603 kCpumMsrRdFn_AmdFam10hIbsOpRip,
604 kCpumMsrRdFn_AmdFam10hIbsOpData,
605 kCpumMsrRdFn_AmdFam10hIbsOpData2,
606 kCpumMsrRdFn_AmdFam10hIbsOpData3,
607 kCpumMsrRdFn_AmdFam10hIbsDcLinAddr,
608 kCpumMsrRdFn_AmdFam10hIbsDcPhysAddr,
609 kCpumMsrRdFn_AmdFam10hIbsCtl,
610 kCpumMsrRdFn_AmdFam14hIbsBrTarget,
611
612 kCpumMsrRdFn_Gim,
613
614 /** End of valid MSR read function indexes. */
615 kCpumMsrRdFn_End
616} CPUMMSRRDFN;
617
618/**
619 * MSR write functions.
620 */
621typedef enum CPUMMSRWRFN
622{
623 /** Invalid zero value. */
624 kCpumMsrWrFn_Invalid = 0,
625 /** Writes are ignored, the fWrGpMask is observed though. */
626 kCpumMsrWrFn_IgnoreWrite,
627 /** Writes cause GP(0) to be raised, the fWrGpMask should be UINT64_MAX. */
628 kCpumMsrWrFn_ReadOnly,
629 /** Alias to the MSR range starting at the MSR given by
630 * CPUMMSRRANGE::uValue. Must be used in pair with
631 * kCpumMsrRdFn_MsrAlias. */
632 kCpumMsrWrFn_MsrAlias,
633
634 kCpumMsrWrFn_Ia32P5McAddr,
635 kCpumMsrWrFn_Ia32P5McType,
636 kCpumMsrWrFn_Ia32TimestampCounter,
637 kCpumMsrWrFn_Ia32ApicBase,
638 kCpumMsrWrFn_Ia32FeatureControl,
639 kCpumMsrWrFn_Ia32BiosSignId,
640 kCpumMsrWrFn_Ia32BiosUpdateTrigger,
641 kCpumMsrWrFn_Ia32SmmMonitorCtl,
642 kCpumMsrWrFn_Ia32PmcN,
643 kCpumMsrWrFn_Ia32MonitorFilterLineSize,
644 kCpumMsrWrFn_Ia32MPerf,
645 kCpumMsrWrFn_Ia32APerf,
646 kCpumMsrWrFn_Ia32MtrrPhysBaseN, /**< Takes register number. */
647 kCpumMsrWrFn_Ia32MtrrPhysMaskN, /**< Takes register number. */
648 kCpumMsrWrFn_Ia32MtrrFixed, /**< Takes CPUMCPU offset. */
649 kCpumMsrWrFn_Ia32MtrrDefType,
650 kCpumMsrWrFn_Ia32Pat,
651 kCpumMsrWrFn_Ia32SysEnterCs,
652 kCpumMsrWrFn_Ia32SysEnterEsp,
653 kCpumMsrWrFn_Ia32SysEnterEip,
654 kCpumMsrWrFn_Ia32McgStatus,
655 kCpumMsrWrFn_Ia32McgCtl,
656 kCpumMsrWrFn_Ia32DebugCtl,
657 kCpumMsrWrFn_Ia32SmrrPhysBase,
658 kCpumMsrWrFn_Ia32SmrrPhysMask,
659 kCpumMsrWrFn_Ia32PlatformDcaCap,
660 kCpumMsrWrFn_Ia32Dca0Cap,
661 kCpumMsrWrFn_Ia32PerfEvtSelN, /**< Range value indicates the register number. */
662 kCpumMsrWrFn_Ia32PerfStatus,
663 kCpumMsrWrFn_Ia32PerfCtl,
664 kCpumMsrWrFn_Ia32FixedCtrN, /**< Takes register number of start of range. */
665 kCpumMsrWrFn_Ia32PerfCapabilities,
666 kCpumMsrWrFn_Ia32FixedCtrCtrl,
667 kCpumMsrWrFn_Ia32PerfGlobalStatus,
668 kCpumMsrWrFn_Ia32PerfGlobalCtrl,
669 kCpumMsrWrFn_Ia32PerfGlobalOvfCtrl,
670 kCpumMsrWrFn_Ia32PebsEnable,
671 kCpumMsrWrFn_Ia32ClockModulation,
672 kCpumMsrWrFn_Ia32ThermInterrupt,
673 kCpumMsrWrFn_Ia32ThermStatus,
674 kCpumMsrWrFn_Ia32Therm2Ctl,
675 kCpumMsrWrFn_Ia32MiscEnable,
676 kCpumMsrWrFn_Ia32McCtlStatusAddrMiscN, /**< Takes bank number. */
677 kCpumMsrWrFn_Ia32McNCtl2, /**< Takes register number of start of range. */
678 kCpumMsrWrFn_Ia32DsArea,
679 kCpumMsrWrFn_Ia32TscDeadline,
680 kCpumMsrWrFn_Ia32X2ApicN,
681 kCpumMsrWrFn_Ia32DebugInterface,
682
683 kCpumMsrWrFn_Amd64Efer,
684 kCpumMsrWrFn_Amd64SyscallTarget,
685 kCpumMsrWrFn_Amd64LongSyscallTarget,
686 kCpumMsrWrFn_Amd64CompSyscallTarget,
687 kCpumMsrWrFn_Amd64SyscallFlagMask,
688 kCpumMsrWrFn_Amd64FsBase,
689 kCpumMsrWrFn_Amd64GsBase,
690 kCpumMsrWrFn_Amd64KernelGsBase,
691 kCpumMsrWrFn_Amd64TscAux,
692 kCpumMsrWrFn_IntelEblCrPowerOn,
693 kCpumMsrWrFn_IntelP4EbcHardPowerOn,
694 kCpumMsrWrFn_IntelP4EbcSoftPowerOn,
695 kCpumMsrWrFn_IntelP4EbcFrequencyId,
696 kCpumMsrWrFn_IntelFlexRatio,
697 kCpumMsrWrFn_IntelPkgCStConfigControl,
698 kCpumMsrWrFn_IntelPmgIoCaptureBase,
699 kCpumMsrWrFn_IntelLastBranchFromToN,
700 kCpumMsrWrFn_IntelLastBranchFromN,
701 kCpumMsrWrFn_IntelLastBranchToN,
702 kCpumMsrWrFn_IntelLastBranchTos,
703 kCpumMsrWrFn_IntelBblCrCtl,
704 kCpumMsrWrFn_IntelBblCrCtl3,
705 kCpumMsrWrFn_IntelI7TemperatureTarget,
706 kCpumMsrWrFn_IntelI7MsrOffCoreResponseN, /**< Takes register number. */
707 kCpumMsrWrFn_IntelI7MiscPwrMgmt,
708 kCpumMsrWrFn_IntelP6CrN,
709 kCpumMsrWrFn_IntelCpuId1FeatureMaskEcdx,
710 kCpumMsrWrFn_IntelCpuId1FeatureMaskEax,
711 kCpumMsrWrFn_IntelCpuId80000001FeatureMaskEcdx,
712 kCpumMsrWrFn_IntelI7SandyAesNiCtl,
713 kCpumMsrWrFn_IntelI7TurboRatioLimit,
714 kCpumMsrWrFn_IntelI7LbrSelect,
715 kCpumMsrWrFn_IntelI7SandyErrorControl,
716 kCpumMsrWrFn_IntelI7PowerCtl,
717 kCpumMsrWrFn_IntelI7SandyPebsNumAlt,
718 kCpumMsrWrFn_IntelI7PebsLdLat,
719 kCpumMsrWrFn_IntelI7SandyVrCurrentConfig,
720 kCpumMsrWrFn_IntelI7SandyVrMiscConfig,
721 kCpumMsrWrFn_IntelI7SandyPkgCnIrtlN,
722 kCpumMsrWrFn_IntelI7RaplPkgPowerLimit,
723 kCpumMsrWrFn_IntelI7RaplDramPowerLimit,
724 kCpumMsrWrFn_IntelI7RaplPp0PowerLimit,
725 kCpumMsrWrFn_IntelI7RaplPp0Policy,
726 kCpumMsrWrFn_IntelI7RaplPp1PowerLimit,
727 kCpumMsrWrFn_IntelI7RaplPp1Policy,
728 kCpumMsrWrFn_IntelI7IvyConfigTdpControl,
729 kCpumMsrWrFn_IntelI7IvyTurboActivationRatio,
730 kCpumMsrWrFn_IntelI7UncPerfGlobalCtrl,
731 kCpumMsrWrFn_IntelI7UncPerfGlobalStatus,
732 kCpumMsrWrFn_IntelI7UncPerfGlobalOvfCtrl,
733 kCpumMsrWrFn_IntelI7UncPerfFixedCtrCtrl,
734 kCpumMsrWrFn_IntelI7UncPerfFixedCtr,
735 kCpumMsrWrFn_IntelI7UncArbPerfCtrN,
736 kCpumMsrWrFn_IntelI7UncArbPerfEvtSelN,
737 kCpumMsrWrFn_IntelCore2EmttmCrTablesN,
738 kCpumMsrWrFn_IntelCore2SmmCStMiscInfo,
739 kCpumMsrWrFn_IntelCore1ExtConfig,
740 kCpumMsrWrFn_IntelCore1DtsCalControl,
741 kCpumMsrWrFn_IntelCore2PeciControl,
742
743 kCpumMsrWrFn_P6LastIntFromIp,
744 kCpumMsrWrFn_P6LastIntToIp,
745
746 kCpumMsrWrFn_AmdFam15hTscRate,
747 kCpumMsrWrFn_AmdFam15hLwpCfg,
748 kCpumMsrWrFn_AmdFam15hLwpCbAddr,
749 kCpumMsrWrFn_AmdFam10hMc4MiscN,
750 kCpumMsrWrFn_AmdK8PerfCtlN,
751 kCpumMsrWrFn_AmdK8PerfCtrN,
752 kCpumMsrWrFn_AmdK8SysCfg,
753 kCpumMsrWrFn_AmdK8HwCr,
754 kCpumMsrWrFn_AmdK8IorrBaseN,
755 kCpumMsrWrFn_AmdK8IorrMaskN,
756 kCpumMsrWrFn_AmdK8TopOfMemN,
757 kCpumMsrWrFn_AmdK8NbCfg1,
758 kCpumMsrWrFn_AmdK8McXcptRedir,
759 kCpumMsrWrFn_AmdK8CpuNameN,
760 kCpumMsrWrFn_AmdK8HwThermalCtrl,
761 kCpumMsrWrFn_AmdK8SwThermalCtrl,
762 kCpumMsrWrFn_AmdK8FidVidControl,
763 kCpumMsrWrFn_AmdK8McCtlMaskN,
764 kCpumMsrWrFn_AmdK8SmiOnIoTrapN,
765 kCpumMsrWrFn_AmdK8SmiOnIoTrapCtlSts,
766 kCpumMsrWrFn_AmdK8IntPendingMessage,
767 kCpumMsrWrFn_AmdK8SmiTriggerIoCycle,
768 kCpumMsrWrFn_AmdFam10hMmioCfgBaseAddr,
769 kCpumMsrWrFn_AmdFam10hTrapCtlMaybe,
770 kCpumMsrWrFn_AmdFam10hPStateControl,
771 kCpumMsrWrFn_AmdFam10hPStateStatus,
772 kCpumMsrWrFn_AmdFam10hPStateN,
773 kCpumMsrWrFn_AmdFam10hCofVidControl,
774 kCpumMsrWrFn_AmdFam10hCofVidStatus,
775 kCpumMsrWrFn_AmdFam10hCStateIoBaseAddr,
776 kCpumMsrWrFn_AmdFam10hCpuWatchdogTimer,
777 kCpumMsrWrFn_AmdK8SmmBase,
778 kCpumMsrWrFn_AmdK8SmmAddr,
779 kCpumMsrWrFn_AmdK8SmmMask,
780 kCpumMsrWrFn_AmdK8VmCr,
781 kCpumMsrWrFn_AmdK8IgnNe,
782 kCpumMsrWrFn_AmdK8SmmCtl,
783 kCpumMsrWrFn_AmdK8VmHSavePa,
784 kCpumMsrWrFn_AmdFam10hVmLockKey,
785 kCpumMsrWrFn_AmdFam10hSmmLockKey,
786 kCpumMsrWrFn_AmdFam10hLocalSmiStatus,
787 kCpumMsrWrFn_AmdFam10hOsVisWrkIdLength,
788 kCpumMsrWrFn_AmdFam10hOsVisWrkStatus,
789 kCpumMsrWrFn_AmdFam16hL2IPerfCtlN,
790 kCpumMsrWrFn_AmdFam16hL2IPerfCtrN,
791 kCpumMsrWrFn_AmdFam15hNorthbridgePerfCtlN,
792 kCpumMsrWrFn_AmdFam15hNorthbridgePerfCtrN,
793 kCpumMsrWrFn_AmdK7MicrocodeCtl,
794 kCpumMsrWrFn_AmdK7ClusterIdMaybe,
795 kCpumMsrWrFn_AmdK8CpuIdCtlStd07hEbax,
796 kCpumMsrWrFn_AmdK8CpuIdCtlStd06hEcx,
797 kCpumMsrWrFn_AmdK8CpuIdCtlStd01hEdcx,
798 kCpumMsrWrFn_AmdK8CpuIdCtlExt01hEdcx,
799 kCpumMsrWrFn_AmdK8PatchLoader,
800 kCpumMsrWrFn_AmdK7DebugStatusMaybe,
801 kCpumMsrWrFn_AmdK7BHTraceBaseMaybe,
802 kCpumMsrWrFn_AmdK7BHTracePtrMaybe,
803 kCpumMsrWrFn_AmdK7BHTraceLimitMaybe,
804 kCpumMsrWrFn_AmdK7HardwareDebugToolCfgMaybe,
805 kCpumMsrWrFn_AmdK7FastFlushCountMaybe,
806 kCpumMsrWrFn_AmdK7NodeId,
807 kCpumMsrWrFn_AmdK7DrXAddrMaskN, /**< Takes register index. */
808 kCpumMsrWrFn_AmdK7Dr0DataMatchMaybe,
809 kCpumMsrWrFn_AmdK7Dr0DataMaskMaybe,
810 kCpumMsrWrFn_AmdK7LoadStoreCfg,
811 kCpumMsrWrFn_AmdK7InstrCacheCfg,
812 kCpumMsrWrFn_AmdK7DataCacheCfg,
813 kCpumMsrWrFn_AmdK7BusUnitCfg,
814 kCpumMsrWrFn_AmdK7DebugCtl2Maybe,
815 kCpumMsrWrFn_AmdFam15hFpuCfg,
816 kCpumMsrWrFn_AmdFam15hDecoderCfg,
817 kCpumMsrWrFn_AmdFam10hBusUnitCfg2,
818 kCpumMsrWrFn_AmdFam15hCombUnitCfg,
819 kCpumMsrWrFn_AmdFam15hCombUnitCfg2,
820 kCpumMsrWrFn_AmdFam15hCombUnitCfg3,
821 kCpumMsrWrFn_AmdFam15hExecUnitCfg,
822 kCpumMsrWrFn_AmdFam15hLoadStoreCfg2,
823 kCpumMsrWrFn_AmdFam10hIbsFetchCtl,
824 kCpumMsrWrFn_AmdFam10hIbsFetchLinAddr,
825 kCpumMsrWrFn_AmdFam10hIbsFetchPhysAddr,
826 kCpumMsrWrFn_AmdFam10hIbsOpExecCtl,
827 kCpumMsrWrFn_AmdFam10hIbsOpRip,
828 kCpumMsrWrFn_AmdFam10hIbsOpData,
829 kCpumMsrWrFn_AmdFam10hIbsOpData2,
830 kCpumMsrWrFn_AmdFam10hIbsOpData3,
831 kCpumMsrWrFn_AmdFam10hIbsDcLinAddr,
832 kCpumMsrWrFn_AmdFam10hIbsDcPhysAddr,
833 kCpumMsrWrFn_AmdFam10hIbsCtl,
834 kCpumMsrWrFn_AmdFam14hIbsBrTarget,
835
836 kCpumMsrWrFn_Gim,
837
838 /** End of valid MSR write function indexes. */
839 kCpumMsrWrFn_End
840} CPUMMSRWRFN;
841
842/**
843 * MSR range.
844 */
845typedef struct CPUMMSRRANGE
846{
847 /** The first MSR. [0] */
848 uint32_t uFirst;
849 /** The last MSR. [4] */
850 uint32_t uLast;
851 /** The read function (CPUMMSRRDFN). [8] */
852 uint16_t enmRdFn;
853 /** The write function (CPUMMSRWRFN). [10] */
854 uint16_t enmWrFn;
855 /** The offset of the 64-bit MSR value relative to the start of CPUMCPU.
856 * UINT16_MAX if not used by the read and write functions. [12] */
857 uint16_t offCpumCpu;
858 /** Reserved for future hacks. [14] */
859 uint16_t fReserved;
860 /** The init/read value. [16]
861 * When enmRdFn is kCpumMsrRdFn_INIT_VALUE, this is the value returned on RDMSR.
862 * offCpumCpu must be UINT16_MAX in that case, otherwise it must be a valid
863 * offset into CPUM. */
864 uint64_t uValue;
865 /** The bits to ignore when writing. [24] */
866 uint64_t fWrIgnMask;
867 /** The bits that will cause a GP(0) when writing. [32]
868 * This is always checked prior to calling the write function. Using
869 * UINT64_MAX effectively marks the MSR as read-only. */
870 uint64_t fWrGpMask;
871 /** The register name, if applicable. [40] */
872 char szName[56];
873
874#ifdef VBOX_WITH_STATISTICS
875 /** The number of reads. */
876 STAMCOUNTER cReads;
877 /** The number of writes. */
878 STAMCOUNTER cWrites;
879 /** The number of times ignored bits were written. */
880 STAMCOUNTER cIgnoredBits;
881 /** The number of GPs generated. */
882 STAMCOUNTER cGps;
883#endif
884} CPUMMSRRANGE;
885#ifdef VBOX_WITH_STATISTICS
886AssertCompileSize(CPUMMSRRANGE, 128);
887#else
888AssertCompileSize(CPUMMSRRANGE, 96);
889#endif
890/** Pointer to an MSR range. */
891typedef CPUMMSRRANGE *PCPUMMSRRANGE;
892/** Pointer to a const MSR range. */
893typedef CPUMMSRRANGE const *PCCPUMMSRRANGE;
894
895
896/**
897 * CPU features and quirks.
898 * This is mostly exploded CPUID info.
899 */
900typedef struct CPUMFEATURES
901{
902 /** The CPU vendor (CPUMCPUVENDOR). */
903 uint8_t enmCpuVendor;
904 /** The CPU family. */
905 uint8_t uFamily;
906 /** The CPU model. */
907 uint8_t uModel;
908 /** The CPU stepping. */
909 uint8_t uStepping;
910 /** The microarchitecture. */
911#ifndef VBOX_FOR_DTRACE_LIB
912 CPUMMICROARCH enmMicroarch;
913#else
914 uint32_t enmMicroarch;
915#endif
916 /** The maximum physical address with of the CPU. */
917 uint8_t cMaxPhysAddrWidth;
918 /** Alignment padding. */
919 uint8_t abPadding[1];
920 /** Max size of the extended state (or FPU state if no XSAVE). */
921 uint16_t cbMaxExtendedState;
922
923 /** Supports MSRs. */
924 uint32_t fMsr : 1;
925 /** Supports the page size extension (4/2 MB pages). */
926 uint32_t fPse : 1;
927 /** Supports 36-bit page size extension (4 MB pages can map memory above
928 * 4GB). */
929 uint32_t fPse36 : 1;
930 /** Supports physical address extension (PAE). */
931 uint32_t fPae : 1;
932 /** Page attribute table (PAT) support (page level cache control). */
933 uint32_t fPat : 1;
934 /** Supports the FXSAVE and FXRSTOR instructions. */
935 uint32_t fFxSaveRstor : 1;
936 /** Supports the XSAVE and XRSTOR instructions. */
937 uint32_t fXSaveRstor : 1;
938 /** The XSAVE/XRSTOR bit in CR4 has been set (only applicable for host!). */
939 uint32_t fOpSysXSaveRstor : 1;
940 /** Supports MMX. */
941 uint32_t fMmx : 1;
942 /** Supports AMD extensions to MMX instructions. */
943 uint32_t fAmdMmxExts : 1;
944 /** Supports SSE. */
945 uint32_t fSse : 1;
946 /** Supports SSE2. */
947 uint32_t fSse2 : 1;
948 /** Supports SSE3. */
949 uint32_t fSse3 : 1;
950 /** Supports SSSE3. */
951 uint32_t fSsse3 : 1;
952 /** Supports SSE4.1. */
953 uint32_t fSse41 : 1;
954 /** Supports SSE4.2. */
955 uint32_t fSse42 : 1;
956 /** Supports AVX. */
957 uint32_t fAvx : 1;
958 /** Supports AVX2. */
959 uint32_t fAvx2 : 1;
960 /** Supports AVX512 foundation. */
961 uint32_t fAvx512Foundation : 1;
962 /** Supports RDTSC. */
963 uint32_t fTsc : 1;
964 /** Intel SYSENTER/SYSEXIT support */
965 uint32_t fSysEnter : 1;
966 /** First generation APIC. */
967 uint32_t fApic : 1;
968 /** Second generation APIC. */
969 uint32_t fX2Apic : 1;
970 /** Hypervisor present. */
971 uint32_t fHypervisorPresent : 1;
972 /** MWAIT & MONITOR instructions supported. */
973 uint32_t fMonitorMWait : 1;
974 /** MWAIT Extensions present. */
975 uint32_t fMWaitExtensions : 1;
976
977 /** Supports AMD 3DNow instructions. */
978 uint32_t f3DNow : 1;
979 /** Supports the 3DNow/AMD64 prefetch instructions (could be nops). */
980 uint32_t f3DNowPrefetch : 1;
981
982 /** AMD64: Supports long mode. */
983 uint32_t fLongMode : 1;
984 /** AMD64: SYSCALL/SYSRET support. */
985 uint32_t fSysCall : 1;
986 /** AMD64: No-execute page table bit. */
987 uint32_t fNoExecute : 1;
988 /** AMD64: Supports LAHF & SAHF instructions in 64-bit mode. */
989 uint32_t fLahfSahf : 1;
990 /** AMD64: Supports RDTSCP. */
991 uint32_t fRdTscP : 1;
992 /** AMD64: Supports MOV CR8 in 32-bit code (lock prefix hack). */
993 uint32_t fMovCr8In32Bit : 1;
994
995 /** Indicates that FPU instruction and data pointers may leak.
996 * This generally applies to recent AMD CPUs, where the FPU IP and DP pointer
997 * is only saved and restored if an exception is pending. */
998 uint32_t fLeakyFxSR : 1;
999
1000 /** Alignment padding / reserved for future use. */
1001 uint32_t fPadding : 29;
1002 uint32_t auPadding[3];
1003} CPUMFEATURES;
1004#ifndef VBOX_FOR_DTRACE_LIB
1005AssertCompileSize(CPUMFEATURES, 32);
1006#endif
1007/** Pointer to a CPU feature structure. */
1008typedef CPUMFEATURES *PCPUMFEATURES;
1009/** Pointer to a const CPU feature structure. */
1010typedef CPUMFEATURES const *PCCPUMFEATURES;
1011
1012
1013
1014/** @name Guest Register Getters.
1015 * @{ */
1016VMMDECL(void) CPUMGetGuestGDTR(PVMCPU pVCpu, PVBOXGDTR pGDTR);
1017VMMDECL(RTGCPTR) CPUMGetGuestIDTR(PVMCPU pVCpu, uint16_t *pcbLimit);
1018VMMDECL(RTSEL) CPUMGetGuestTR(PVMCPU pVCpu, PCPUMSELREGHID pHidden);
1019VMMDECL(RTSEL) CPUMGetGuestLDTR(PVMCPU pVCpu);
1020VMMDECL(RTSEL) CPUMGetGuestLdtrEx(PVMCPU pVCpu, uint64_t *pGCPtrBase, uint32_t *pcbLimit);
1021VMMDECL(uint64_t) CPUMGetGuestCR0(PVMCPU pVCpu);
1022VMMDECL(uint64_t) CPUMGetGuestCR2(PVMCPU pVCpu);
1023VMMDECL(uint64_t) CPUMGetGuestCR3(PVMCPU pVCpu);
1024VMMDECL(uint64_t) CPUMGetGuestCR4(PVMCPU pVCpu);
1025VMMDECL(uint64_t) CPUMGetGuestCR8(PVMCPU pVCpu);
1026VMMDECL(int) CPUMGetGuestCRx(PVMCPU pVCpu, unsigned iReg, uint64_t *pValue);
1027VMMDECL(uint32_t) CPUMGetGuestEFlags(PVMCPU pVCpu);
1028VMMDECL(uint32_t) CPUMGetGuestEIP(PVMCPU pVCpu);
1029VMMDECL(uint64_t) CPUMGetGuestRIP(PVMCPU pVCpu);
1030VMMDECL(uint32_t) CPUMGetGuestEAX(PVMCPU pVCpu);
1031VMMDECL(uint32_t) CPUMGetGuestEBX(PVMCPU pVCpu);
1032VMMDECL(uint32_t) CPUMGetGuestECX(PVMCPU pVCpu);
1033VMMDECL(uint32_t) CPUMGetGuestEDX(PVMCPU pVCpu);
1034VMMDECL(uint32_t) CPUMGetGuestESI(PVMCPU pVCpu);
1035VMMDECL(uint32_t) CPUMGetGuestEDI(PVMCPU pVCpu);
1036VMMDECL(uint32_t) CPUMGetGuestESP(PVMCPU pVCpu);
1037VMMDECL(uint32_t) CPUMGetGuestEBP(PVMCPU pVCpu);
1038VMMDECL(RTSEL) CPUMGetGuestCS(PVMCPU pVCpu);
1039VMMDECL(RTSEL) CPUMGetGuestDS(PVMCPU pVCpu);
1040VMMDECL(RTSEL) CPUMGetGuestES(PVMCPU pVCpu);
1041VMMDECL(RTSEL) CPUMGetGuestFS(PVMCPU pVCpu);
1042VMMDECL(RTSEL) CPUMGetGuestGS(PVMCPU pVCpu);
1043VMMDECL(RTSEL) CPUMGetGuestSS(PVMCPU pVCpu);
1044VMMDECL(uint64_t) CPUMGetGuestDR0(PVMCPU pVCpu);
1045VMMDECL(uint64_t) CPUMGetGuestDR1(PVMCPU pVCpu);
1046VMMDECL(uint64_t) CPUMGetGuestDR2(PVMCPU pVCpu);
1047VMMDECL(uint64_t) CPUMGetGuestDR3(PVMCPU pVCpu);
1048VMMDECL(uint64_t) CPUMGetGuestDR6(PVMCPU pVCpu);
1049VMMDECL(uint64_t) CPUMGetGuestDR7(PVMCPU pVCpu);
1050VMMDECL(int) CPUMGetGuestDRx(PVMCPU pVCpu, uint32_t iReg, uint64_t *pValue);
1051VMMDECL(void) CPUMGetGuestCpuId(PVMCPU pVCpu, uint32_t iLeaf, uint32_t iSubLeaf,
1052 uint32_t *pEax, uint32_t *pEbx, uint32_t *pEcx, uint32_t *pEdx);
1053VMMDECL(uint64_t) CPUMGetGuestEFER(PVMCPU pVCpu);
1054VMMDECL(VBOXSTRICTRC) CPUMQueryGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t *puValue);
1055VMMDECL(VBOXSTRICTRC) CPUMSetGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t uValue);
1056VMMDECL(CPUMCPUVENDOR) CPUMGetGuestCpuVendor(PVM pVM);
1057VMMDECL(CPUMCPUVENDOR) CPUMGetHostCpuVendor(PVM pVM);
1058/** @} */
1059
1060/** @name Guest Register Setters.
1061 * @{ */
1062VMMDECL(int) CPUMSetGuestGDTR(PVMCPU pVCpu, uint64_t GCPtrBase, uint16_t cbLimit);
1063VMMDECL(int) CPUMSetGuestIDTR(PVMCPU pVCpu, uint64_t GCPtrBase, uint16_t cbLimit);
1064VMMDECL(int) CPUMSetGuestTR(PVMCPU pVCpu, uint16_t tr);
1065VMMDECL(int) CPUMSetGuestLDTR(PVMCPU pVCpu, uint16_t ldtr);
1066VMMDECL(int) CPUMSetGuestCR0(PVMCPU pVCpu, uint64_t cr0);
1067VMMDECL(int) CPUMSetGuestCR2(PVMCPU pVCpu, uint64_t cr2);
1068VMMDECL(int) CPUMSetGuestCR3(PVMCPU pVCpu, uint64_t cr3);
1069VMMDECL(int) CPUMSetGuestCR4(PVMCPU pVCpu, uint64_t cr4);
1070VMMDECL(int) CPUMSetGuestDR0(PVMCPU pVCpu, uint64_t uDr0);
1071VMMDECL(int) CPUMSetGuestDR1(PVMCPU pVCpu, uint64_t uDr1);
1072VMMDECL(int) CPUMSetGuestDR2(PVMCPU pVCpu, uint64_t uDr2);
1073VMMDECL(int) CPUMSetGuestDR3(PVMCPU pVCpu, uint64_t uDr3);
1074VMMDECL(int) CPUMSetGuestDR6(PVMCPU pVCpu, uint64_t uDr6);
1075VMMDECL(int) CPUMSetGuestDR7(PVMCPU pVCpu, uint64_t uDr7);
1076VMMDECL(int) CPUMSetGuestDRx(PVMCPU pVCpu, uint32_t iReg, uint64_t Value);
1077VMM_INT_DECL(int) CPUMSetGuestXcr0(PVMCPU pVCpu, uint64_t uNewValue);
1078VMMDECL(int) CPUMSetGuestEFlags(PVMCPU pVCpu, uint32_t eflags);
1079VMMDECL(int) CPUMSetGuestEIP(PVMCPU pVCpu, uint32_t eip);
1080VMMDECL(int) CPUMSetGuestEAX(PVMCPU pVCpu, uint32_t eax);
1081VMMDECL(int) CPUMSetGuestEBX(PVMCPU pVCpu, uint32_t ebx);
1082VMMDECL(int) CPUMSetGuestECX(PVMCPU pVCpu, uint32_t ecx);
1083VMMDECL(int) CPUMSetGuestEDX(PVMCPU pVCpu, uint32_t edx);
1084VMMDECL(int) CPUMSetGuestESI(PVMCPU pVCpu, uint32_t esi);
1085VMMDECL(int) CPUMSetGuestEDI(PVMCPU pVCpu, uint32_t edi);
1086VMMDECL(int) CPUMSetGuestESP(PVMCPU pVCpu, uint32_t esp);
1087VMMDECL(int) CPUMSetGuestEBP(PVMCPU pVCpu, uint32_t ebp);
1088VMMDECL(int) CPUMSetGuestCS(PVMCPU pVCpu, uint16_t cs);
1089VMMDECL(int) CPUMSetGuestDS(PVMCPU pVCpu, uint16_t ds);
1090VMMDECL(int) CPUMSetGuestES(PVMCPU pVCpu, uint16_t es);
1091VMMDECL(int) CPUMSetGuestFS(PVMCPU pVCpu, uint16_t fs);
1092VMMDECL(int) CPUMSetGuestGS(PVMCPU pVCpu, uint16_t gs);
1093VMMDECL(int) CPUMSetGuestSS(PVMCPU pVCpu, uint16_t ss);
1094VMMDECL(void) CPUMSetGuestEFER(PVMCPU pVCpu, uint64_t val);
1095VMMDECL(void) CPUMSetGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature);
1096VMMDECL(void) CPUMClearGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature);
1097VMMDECL(bool) CPUMGetGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature);
1098VMMDECL(void) CPUMSetGuestCtx(PVMCPU pVCpu, const PCPUMCTX pCtx);
1099VMM_INT_DECL(void) CPUMGuestLazyLoadHiddenCsAndSs(PVMCPU pVCpu);
1100VMM_INT_DECL(void) CPUMGuestLazyLoadHiddenSelectorReg(PVMCPU pVCpu, PCPUMSELREG pSReg);
1101VMMR0_INT_DECL(void) CPUMR0SetGuestTscAux(PVMCPU pVCpu, uint64_t uValue);
1102VMMR0_INT_DECL(uint64_t) CPUMR0GetGuestTscAux(PVMCPU pVCpu);
1103/** @} */
1104
1105
1106/** @name Misc Guest Predicate Functions.
1107 * @{ */
1108
1109VMMDECL(bool) CPUMIsGuestIn16BitCode(PVMCPU pVCpu);
1110VMMDECL(bool) CPUMIsGuestIn32BitCode(PVMCPU pVCpu);
1111VMMDECL(bool) CPUMIsGuestIn64BitCode(PVMCPU pVCpu);
1112VMMDECL(bool) CPUMIsGuestNXEnabled(PVMCPU pVCpu);
1113VMMDECL(bool) CPUMIsGuestPageSizeExtEnabled(PVMCPU pVCpu);
1114VMMDECL(bool) CPUMIsGuestPagingEnabled(PVMCPU pVCpu);
1115VMMDECL(bool) CPUMIsGuestR0WriteProtEnabled(PVMCPU pVCpu);
1116VMMDECL(bool) CPUMIsGuestInRealMode(PVMCPU pVCpu);
1117VMMDECL(bool) CPUMIsGuestInRealOrV86Mode(PVMCPU pVCpu);
1118VMMDECL(bool) CPUMIsGuestInProtectedMode(PVMCPU pVCpu);
1119VMMDECL(bool) CPUMIsGuestInPagedProtectedMode(PVMCPU pVCpu);
1120VMMDECL(bool) CPUMIsGuestInLongMode(PVMCPU pVCpu);
1121VMMDECL(bool) CPUMIsGuestInPAEMode(PVMCPU pVCpu);
1122VMM_INT_DECL(bool) CPUMIsGuestInRawMode(PVMCPU pVCpu);
1123
1124#ifndef VBOX_WITHOUT_UNNAMED_UNIONS
1125
1126/**
1127 * Tests if the guest is running in real mode or not.
1128 *
1129 * @returns true if in real mode, otherwise false.
1130 * @param pCtx Current CPU context
1131 */
1132DECLINLINE(bool) CPUMIsGuestInRealModeEx(PCPUMCTX pCtx)
1133{
1134 return !(pCtx->cr0 & X86_CR0_PE);
1135}
1136
1137/**
1138 * Tests if the guest is running in real or virtual 8086 mode.
1139 *
1140 * @returns @c true if it is, @c false if not.
1141 * @param pCtx Current CPU context
1142 */
1143DECLINLINE(bool) CPUMIsGuestInRealOrV86ModeEx(PCPUMCTX pCtx)
1144{
1145 return !(pCtx->cr0 & X86_CR0_PE)
1146 || pCtx->eflags.Bits.u1VM; /* Cannot be set in long mode. Intel spec 2.3.1 "System Flags and Fields in IA-32e Mode". */
1147}
1148
1149/**
1150 * Tests if the guest is running in virtual 8086 mode.
1151 *
1152 * @returns @c true if it is, @c false if not.
1153 * @param pCtx Current CPU context
1154 */
1155DECLINLINE(bool) CPUMIsGuestInV86ModeEx(PCPUMCTX pCtx)
1156{
1157 return (pCtx->eflags.Bits.u1VM == 1);
1158}
1159
1160/**
1161 * Tests if the guest is running in paged protected or not.
1162 *
1163 * @returns true if in paged protected mode, otherwise false.
1164 * @param pCtx Current CPU context
1165 */
1166DECLINLINE(bool) CPUMIsGuestInPagedProtectedModeEx(PCPUMCTX pCtx)
1167{
1168 return (pCtx->cr0 & (X86_CR0_PE | X86_CR0_PG)) == (X86_CR0_PE | X86_CR0_PG);
1169}
1170
1171/**
1172 * Tests if the guest is running in long mode or not.
1173 *
1174 * @returns true if in long mode, otherwise false.
1175 * @param pCtx Current CPU context
1176 */
1177DECLINLINE(bool) CPUMIsGuestInLongModeEx(PCPUMCTX pCtx)
1178{
1179 return (pCtx->msrEFER & MSR_K6_EFER_LMA) == MSR_K6_EFER_LMA;
1180}
1181
1182VMM_INT_DECL(bool) CPUMIsGuestIn64BitCodeSlow(PCPUMCTX pCtx);
1183
1184/**
1185 * Tests if the guest is running in 64 bits mode or not.
1186 *
1187 * @returns true if in 64 bits protected mode, otherwise false.
1188 * @param pCtx Current CPU context
1189 */
1190DECLINLINE(bool) CPUMIsGuestIn64BitCodeEx(PCPUMCTX pCtx)
1191{
1192 if (!(pCtx->msrEFER & MSR_K6_EFER_LMA))
1193 return false;
1194 if (!CPUMSELREG_ARE_HIDDEN_PARTS_VALID(NULL, &pCtx->cs))
1195 return CPUMIsGuestIn64BitCodeSlow(pCtx);
1196 return pCtx->cs.Attr.n.u1Long;
1197}
1198
1199/**
1200 * Tests if the guest has paging enabled or not.
1201 *
1202 * @returns true if paging is enabled, otherwise false.
1203 * @param pCtx Current CPU context
1204 */
1205DECLINLINE(bool) CPUMIsGuestPagingEnabledEx(PCPUMCTX pCtx)
1206{
1207 return !!(pCtx->cr0 & X86_CR0_PG);
1208}
1209
1210/**
1211 * Tests if the guest is running in PAE mode or not.
1212 *
1213 * @returns true if in PAE mode, otherwise false.
1214 * @param pCtx Current CPU context
1215 */
1216DECLINLINE(bool) CPUMIsGuestInPAEModeEx(PCPUMCTX pCtx)
1217{
1218 /* Intel mentions EFER.LMA and EFER.LME in different parts of their spec. We shall use EFER.LMA rather
1219 than EFER.LME as it reflects if the CPU has entered paging with EFER.LME set. */
1220 return ( (pCtx->cr4 & X86_CR4_PAE)
1221 && CPUMIsGuestPagingEnabledEx(pCtx)
1222 && !(pCtx->msrEFER & MSR_K6_EFER_LMA));
1223}
1224
1225#endif /* VBOX_WITHOUT_UNNAMED_UNIONS */
1226
1227/** @} */
1228
1229
1230/** @name Hypervisor Register Getters.
1231 * @{ */
1232VMMDECL(RTSEL) CPUMGetHyperCS(PVMCPU pVCpu);
1233VMMDECL(RTSEL) CPUMGetHyperDS(PVMCPU pVCpu);
1234VMMDECL(RTSEL) CPUMGetHyperES(PVMCPU pVCpu);
1235VMMDECL(RTSEL) CPUMGetHyperFS(PVMCPU pVCpu);
1236VMMDECL(RTSEL) CPUMGetHyperGS(PVMCPU pVCpu);
1237VMMDECL(RTSEL) CPUMGetHyperSS(PVMCPU pVCpu);
1238#if 0 /* these are not correct. */
1239VMMDECL(uint32_t) CPUMGetHyperCR0(PVMCPU pVCpu);
1240VMMDECL(uint32_t) CPUMGetHyperCR2(PVMCPU pVCpu);
1241VMMDECL(uint32_t) CPUMGetHyperCR3(PVMCPU pVCpu);
1242VMMDECL(uint32_t) CPUMGetHyperCR4(PVMCPU pVCpu);
1243#endif
1244/** This register is only saved on fatal traps. */
1245VMMDECL(uint32_t) CPUMGetHyperEAX(PVMCPU pVCpu);
1246VMMDECL(uint32_t) CPUMGetHyperEBX(PVMCPU pVCpu);
1247/** This register is only saved on fatal traps. */
1248VMMDECL(uint32_t) CPUMGetHyperECX(PVMCPU pVCpu);
1249/** This register is only saved on fatal traps. */
1250VMMDECL(uint32_t) CPUMGetHyperEDX(PVMCPU pVCpu);
1251VMMDECL(uint32_t) CPUMGetHyperESI(PVMCPU pVCpu);
1252VMMDECL(uint32_t) CPUMGetHyperEDI(PVMCPU pVCpu);
1253VMMDECL(uint32_t) CPUMGetHyperEBP(PVMCPU pVCpu);
1254VMMDECL(uint32_t) CPUMGetHyperESP(PVMCPU pVCpu);
1255VMMDECL(uint32_t) CPUMGetHyperEFlags(PVMCPU pVCpu);
1256VMMDECL(uint32_t) CPUMGetHyperEIP(PVMCPU pVCpu);
1257VMMDECL(uint64_t) CPUMGetHyperRIP(PVMCPU pVCpu);
1258VMMDECL(uint32_t) CPUMGetHyperIDTR(PVMCPU pVCpu, uint16_t *pcbLimit);
1259VMMDECL(uint32_t) CPUMGetHyperGDTR(PVMCPU pVCpu, uint16_t *pcbLimit);
1260VMMDECL(RTSEL) CPUMGetHyperLDTR(PVMCPU pVCpu);
1261VMMDECL(RTGCUINTREG) CPUMGetHyperDR0(PVMCPU pVCpu);
1262VMMDECL(RTGCUINTREG) CPUMGetHyperDR1(PVMCPU pVCpu);
1263VMMDECL(RTGCUINTREG) CPUMGetHyperDR2(PVMCPU pVCpu);
1264VMMDECL(RTGCUINTREG) CPUMGetHyperDR3(PVMCPU pVCpu);
1265VMMDECL(RTGCUINTREG) CPUMGetHyperDR6(PVMCPU pVCpu);
1266VMMDECL(RTGCUINTREG) CPUMGetHyperDR7(PVMCPU pVCpu);
1267VMMDECL(void) CPUMGetHyperCtx(PVMCPU pVCpu, PCPUMCTX pCtx);
1268VMMDECL(uint32_t) CPUMGetHyperCR3(PVMCPU pVCpu);
1269/** @} */
1270
1271/** @name Hypervisor Register Setters.
1272 * @{ */
1273VMMDECL(void) CPUMSetHyperGDTR(PVMCPU pVCpu, uint32_t addr, uint16_t limit);
1274VMMDECL(void) CPUMSetHyperLDTR(PVMCPU pVCpu, RTSEL SelLDTR);
1275VMMDECL(void) CPUMSetHyperIDTR(PVMCPU pVCpu, uint32_t addr, uint16_t limit);
1276VMMDECL(void) CPUMSetHyperCR3(PVMCPU pVCpu, uint32_t cr3);
1277VMMDECL(void) CPUMSetHyperTR(PVMCPU pVCpu, RTSEL SelTR);
1278VMMDECL(void) CPUMSetHyperCS(PVMCPU pVCpu, RTSEL SelCS);
1279VMMDECL(void) CPUMSetHyperDS(PVMCPU pVCpu, RTSEL SelDS);
1280VMMDECL(void) CPUMSetHyperES(PVMCPU pVCpu, RTSEL SelDS);
1281VMMDECL(void) CPUMSetHyperFS(PVMCPU pVCpu, RTSEL SelDS);
1282VMMDECL(void) CPUMSetHyperGS(PVMCPU pVCpu, RTSEL SelDS);
1283VMMDECL(void) CPUMSetHyperSS(PVMCPU pVCpu, RTSEL SelSS);
1284VMMDECL(void) CPUMSetHyperESP(PVMCPU pVCpu, uint32_t u32ESP);
1285VMMDECL(int) CPUMSetHyperEFlags(PVMCPU pVCpu, uint32_t Efl);
1286VMMDECL(void) CPUMSetHyperEIP(PVMCPU pVCpu, uint32_t u32EIP);
1287VMM_INT_DECL(void) CPUMSetHyperState(PVMCPU pVCpu, uint32_t u32EIP, uint32_t u32ESP, uint32_t u32EAX, uint32_t u32EDX);
1288VMMDECL(void) CPUMSetHyperDR0(PVMCPU pVCpu, RTGCUINTREG uDr0);
1289VMMDECL(void) CPUMSetHyperDR1(PVMCPU pVCpu, RTGCUINTREG uDr1);
1290VMMDECL(void) CPUMSetHyperDR2(PVMCPU pVCpu, RTGCUINTREG uDr2);
1291VMMDECL(void) CPUMSetHyperDR3(PVMCPU pVCpu, RTGCUINTREG uDr3);
1292VMMDECL(void) CPUMSetHyperDR6(PVMCPU pVCpu, RTGCUINTREG uDr6);
1293VMMDECL(void) CPUMSetHyperDR7(PVMCPU pVCpu, RTGCUINTREG uDr7);
1294VMMDECL(void) CPUMSetHyperCtx(PVMCPU pVCpu, const PCPUMCTX pCtx);
1295VMMDECL(int) CPUMRecalcHyperDRx(PVMCPU pVCpu, uint8_t iGstReg, bool fForceHyper);
1296/** @} */
1297
1298VMMDECL(void) CPUMPushHyper(PVMCPU pVCpu, uint32_t u32);
1299VMMDECL(int) CPUMQueryHyperCtxPtr(PVMCPU pVCpu, PCPUMCTX *ppCtx);
1300VMMDECL(PCPUMCTX) CPUMGetHyperCtxPtr(PVMCPU pVCpu);
1301VMMDECL(PCCPUMCTXCORE) CPUMGetHyperCtxCore(PVMCPU pVCpu);
1302VMMDECL(PCPUMCTX) CPUMQueryGuestCtxPtr(PVMCPU pVCpu);
1303VMMDECL(PCCPUMCTXCORE) CPUMGetGuestCtxCore(PVMCPU pVCpu);
1304VMM_INT_DECL(int) CPUMRawEnter(PVMCPU pVCpu);
1305VMM_INT_DECL(int) CPUMRawLeave(PVMCPU pVCpu, int rc);
1306VMMDECL(uint32_t) CPUMRawGetEFlags(PVMCPU pVCpu);
1307VMMDECL(void) CPUMRawSetEFlags(PVMCPU pVCpu, uint32_t fEfl);
1308
1309/** @name Changed flags.
1310 * These flags are used to keep track of which important register that
1311 * have been changed since last they were reset. The only one allowed
1312 * to clear them is REM!
1313 * @{
1314 */
1315#define CPUM_CHANGED_FPU_REM RT_BIT(0)
1316#define CPUM_CHANGED_CR0 RT_BIT(1)
1317#define CPUM_CHANGED_CR4 RT_BIT(2)
1318#define CPUM_CHANGED_GLOBAL_TLB_FLUSH RT_BIT(3)
1319#define CPUM_CHANGED_CR3 RT_BIT(4)
1320#define CPUM_CHANGED_GDTR RT_BIT(5)
1321#define CPUM_CHANGED_IDTR RT_BIT(6)
1322#define CPUM_CHANGED_LDTR RT_BIT(7)
1323#define CPUM_CHANGED_TR RT_BIT(8) /**@< Currently unused. */
1324#define CPUM_CHANGED_SYSENTER_MSR RT_BIT(9)
1325#define CPUM_CHANGED_HIDDEN_SEL_REGS RT_BIT(10) /**@< Currently unused. */
1326#define CPUM_CHANGED_CPUID RT_BIT(11)
1327#define CPUM_CHANGED_ALL ( CPUM_CHANGED_FPU_REM \
1328 | CPUM_CHANGED_CR0 \
1329 | CPUM_CHANGED_CR4 \
1330 | CPUM_CHANGED_GLOBAL_TLB_FLUSH \
1331 | CPUM_CHANGED_CR3 \
1332 | CPUM_CHANGED_GDTR \
1333 | CPUM_CHANGED_IDTR \
1334 | CPUM_CHANGED_LDTR \
1335 | CPUM_CHANGED_TR \
1336 | CPUM_CHANGED_SYSENTER_MSR \
1337 | CPUM_CHANGED_HIDDEN_SEL_REGS \
1338 | CPUM_CHANGED_CPUID )
1339/** @} */
1340
1341VMMDECL(void) CPUMSetChangedFlags(PVMCPU pVCpu, uint32_t fChangedAdd);
1342VMMR3DECL(uint32_t) CPUMR3RemEnter(PVMCPU pVCpu, uint32_t *puCpl);
1343VMMR3DECL(void) CPUMR3RemLeave(PVMCPU pVCpu, bool fNoOutOfSyncSels);
1344VMMDECL(bool) CPUMSupportsXSave(PVM pVM);
1345VMMDECL(bool) CPUMIsHostUsingSysEnter(PVM pVM);
1346VMMDECL(bool) CPUMIsHostUsingSysCall(PVM pVM);
1347VMMDECL(bool) CPUMIsGuestFPUStateActive(PVMCPU pVCpu);
1348VMMDECL(bool) CPUMIsGuestDebugStateActive(PVMCPU pVCpu);
1349VMMDECL(bool) CPUMIsGuestDebugStateActivePending(PVMCPU pVCpu);
1350VMMDECL(void) CPUMDeactivateGuestDebugState(PVMCPU pVCpu);
1351VMMDECL(bool) CPUMIsHyperDebugStateActive(PVMCPU pVCpu);
1352VMMDECL(bool) CPUMIsHyperDebugStateActivePending(PVMCPU pVCpu);
1353VMMDECL(uint32_t) CPUMGetGuestCPL(PVMCPU pVCpu);
1354VMMDECL(CPUMMODE) CPUMGetGuestMode(PVMCPU pVCpu);
1355VMMDECL(uint32_t) CPUMGetGuestCodeBits(PVMCPU pVCpu);
1356VMMDECL(DISCPUMODE) CPUMGetGuestDisMode(PVMCPU pVCpu);
1357VMMDECL(uint64_t) CPUMGetGuestScalableBusFrequency(PVM pVM);
1358
1359/** @name Typical scalable bus frequency values.
1360 * @{ */
1361/** Special internal value indicating that we don't know the frequency.
1362 * @internal */
1363#define CPUM_SBUSFREQ_UNKNOWN UINT64_C(1)
1364#define CPUM_SBUSFREQ_100MHZ UINT64_C(100000000)
1365#define CPUM_SBUSFREQ_133MHZ UINT64_C(133333333)
1366#define CPUM_SBUSFREQ_167MHZ UINT64_C(166666666)
1367#define CPUM_SBUSFREQ_200MHZ UINT64_C(200000000)
1368#define CPUM_SBUSFREQ_267MHZ UINT64_C(266666666)
1369#define CPUM_SBUSFREQ_333MHZ UINT64_C(333333333)
1370#define CPUM_SBUSFREQ_400MHZ UINT64_C(400000000)
1371/** @} */
1372
1373
1374#ifdef IN_RING3
1375/** @defgroup grp_cpum_r3 The CPUM ring-3 API
1376 * @{
1377 */
1378
1379VMMR3DECL(int) CPUMR3Init(PVM pVM);
1380VMMR3DECL(int) CPUMR3InitCompleted(PVM pVM);
1381VMMR3DECL(void) CPUMR3LogCpuIds(PVM pVM);
1382VMMR3DECL(void) CPUMR3Relocate(PVM pVM);
1383VMMR3DECL(int) CPUMR3Term(PVM pVM);
1384VMMR3DECL(void) CPUMR3Reset(PVM pVM);
1385VMMR3DECL(void) CPUMR3ResetCpu(PVM pVM, PVMCPU pVCpu);
1386VMMDECL(bool) CPUMR3IsStateRestorePending(PVM pVM);
1387VMMR3DECL(void) CPUMR3SetHWVirtEx(PVM pVM, bool fHWVirtExEnabled);
1388VMMR3DECL(int) CPUMR3SetCR4Feature(PVM pVM, RTHCUINTREG fOr, RTHCUINTREG fAnd);
1389
1390VMMR3DECL(int) CPUMR3CpuIdInsert(PVM pVM, PCPUMCPUIDLEAF pNewLeaf);
1391VMMR3DECL(int) CPUMR3CpuIdGetLeaf(PVM pVM, PCPUMCPUIDLEAF pLeaf, uint32_t uLeaf, uint32_t uSubLeaf);
1392VMMR3DECL(CPUMMICROARCH) CPUMR3CpuIdDetermineMicroarchEx(CPUMCPUVENDOR enmVendor, uint8_t bFamily,
1393 uint8_t bModel, uint8_t bStepping);
1394VMMR3DECL(const char *) CPUMR3MicroarchName(CPUMMICROARCH enmMicroarch);
1395VMMR3DECL(int) CPUMR3CpuIdCollectLeaves(PCPUMCPUIDLEAF *ppaLeaves, uint32_t *pcLeaves);
1396VMMR3DECL(int) CPUMR3CpuIdDetectUnknownLeafMethod(PCPUMUNKNOWNCPUID penmUnknownMethod, PCPUMCPUID pDefUnknown);
1397VMMR3DECL(const char *) CPUMR3CpuIdUnknownLeafMethodName(CPUMUNKNOWNCPUID enmUnknownMethod);
1398VMMR3DECL(CPUMCPUVENDOR) CPUMR3CpuIdDetectVendorEx(uint32_t uEAX, uint32_t uEBX, uint32_t uECX, uint32_t uEDX);
1399VMMR3DECL(const char *) CPUMR3CpuVendorName(CPUMCPUVENDOR enmVendor);
1400
1401VMMR3DECL(int) CPUMR3MsrRangesInsert(PVM pVM, PCCPUMMSRRANGE pNewRange);
1402
1403# if defined(VBOX_WITH_RAW_MODE) || defined(DOXYGEN_RUNNING)
1404/** @name APIs for the CPUID raw-mode patch (legacy).
1405 * @{ */
1406VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID)) CPUMR3GetGuestCpuIdPatmDefRCPtr(PVM pVM);
1407VMMR3_INT_DECL(uint32_t) CPUMR3GetGuestCpuIdPatmStdMax(PVM pVM);
1408VMMR3_INT_DECL(uint32_t) CPUMR3GetGuestCpuIdPatmExtMax(PVM pVM);
1409VMMR3_INT_DECL(uint32_t) CPUMR3GetGuestCpuIdPatmCentaurMax(PVM pVM);
1410VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID)) CPUMR3GetGuestCpuIdPatmStdRCPtr(PVM pVM);
1411VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID)) CPUMR3GetGuestCpuIdPatmExtRCPtr(PVM pVM);
1412VMMR3_INT_DECL(RCPTRTYPE(PCCPUMCPUID)) CPUMR3GetGuestCpuIdPatmCentaurRCPtr(PVM pVM);
1413/** @} */
1414# endif
1415
1416/** @} */
1417#endif /* IN_RING3 */
1418
1419#ifdef IN_RC
1420/** @defgroup grp_cpum_rc The CPUM Raw-mode Context API
1421 * @{
1422 */
1423
1424/**
1425 * Calls a guest trap/interrupt handler directly
1426 *
1427 * Assumes a trap stack frame has already been setup on the guest's stack!
1428 * This function does not return!
1429 *
1430 * @param pRegFrame Original trap/interrupt context
1431 * @param selCS Code selector of handler
1432 * @param pHandler GC virtual address of handler
1433 * @param eflags Callee's EFLAGS
1434 * @param selSS Stack selector for handler
1435 * @param pEsp Stack address for handler
1436 */
1437DECLASM(void) CPUMGCCallGuestTrapHandler(PCPUMCTXCORE pRegFrame, uint32_t selCS, RTRCPTR pHandler,
1438 uint32_t eflags, uint32_t selSS, RTRCPTR pEsp);
1439
1440/**
1441 * Call guest V86 code directly.
1442 *
1443 * This function does not return!
1444 *
1445 * @param pRegFrame Original trap/interrupt context
1446 */
1447DECLASM(void) CPUMGCCallV86Code(PCPUMCTXCORE pRegFrame);
1448
1449VMMDECL(int) CPUMHandleLazyFPU(PVMCPU pVCpu);
1450VMMDECL(uint32_t) CPUMRCGetGuestCPL(PVMCPU pVCpu, PCPUMCTXCORE pRegFrame);
1451#ifdef VBOX_WITH_RAW_RING1
1452VMMDECL(void) CPUMRCRecheckRawState(PVMCPU pVCpu, PCPUMCTXCORE pCtxCore);
1453#endif
1454
1455/** @} */
1456#endif /* IN_RC */
1457
1458#ifdef IN_RING0
1459/** @defgroup grp_cpum_r0 The CPUM ring-0 API
1460 * @{
1461 */
1462VMMR0_INT_DECL(int) CPUMR0ModuleInit(void);
1463VMMR0_INT_DECL(int) CPUMR0ModuleTerm(void);
1464VMMR0_INT_DECL(int) CPUMR0InitVM(PVM pVM);
1465VMMR0_INT_DECL(int) CPUMR0Trap07Handler(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
1466VMMR0_INT_DECL(int) CPUMR0LoadGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
1467VMMR0_INT_DECL(int) CPUMR0SaveGuestFPU(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
1468VMMR0_INT_DECL(int) CPUMR0SaveHostDebugState(PVM pVM, PVMCPU pVCpu);
1469VMMR0_INT_DECL(bool) CPUMR0DebugStateMaybeSaveGuestAndRestoreHost(PVMCPU pVCpu, bool fDr6);
1470VMMR0_INT_DECL(bool) CPUMR0DebugStateMaybeSaveGuest(PVMCPU pVCpu, bool fDr6);
1471
1472VMMR0_INT_DECL(void) CPUMR0LoadGuestDebugState(PVMCPU pVCpu, bool fDr6);
1473VMMR0_INT_DECL(void) CPUMR0LoadHyperDebugState(PVMCPU pVCpu, bool fDr6);
1474#ifdef VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
1475VMMR0_INT_DECL(void) CPUMR0SetLApic(PVMCPU pVCpu, uint32_t iHostCpuSet);
1476#endif
1477
1478/** @} */
1479#endif /* IN_RING0 */
1480
1481/** @} */
1482RT_C_DECLS_END
1483
1484
1485#endif
1486
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