VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/CPUMAllMsrs.cpp@ 71223

Last change on this file since 71223 was 71108, checked in by vboxsync, 7 years ago

Added speculation control settings to API, refined implementation.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 233.5 KB
Line 
1/* $Id: CPUMAllMsrs.cpp 71108 2018-02-22 15:38:35Z vboxsync $ */
2/** @file
3 * CPUM - CPU MSR Registers.
4 */
5
6/*
7 * Copyright (C) 2013-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19/*********************************************************************************************************************************
20* Header Files *
21*********************************************************************************************************************************/
22#define LOG_GROUP LOG_GROUP_CPUM
23#include <VBox/vmm/cpum.h>
24#include <VBox/vmm/apic.h>
25#include <VBox/vmm/hm.h>
26#include <VBox/vmm/tm.h>
27#include <VBox/vmm/gim.h>
28#include "CPUMInternal.h"
29#include <VBox/vmm/vm.h>
30#include <VBox/err.h>
31
32
33/*********************************************************************************************************************************
34* Defined Constants And Macros *
35*********************************************************************************************************************************/
36/**
37 * Validates the CPUMMSRRANGE::offCpumCpu value and declares a local variable
38 * pointing to it.
39 *
40 * ASSUMES sizeof(a_Type) is a power of two and that the member is aligned
41 * correctly.
42 */
43#define CPUM_MSR_ASSERT_CPUMCPU_OFFSET_RETURN(a_pVCpu, a_pRange, a_Type, a_VarName) \
44 AssertMsgReturn( (a_pRange)->offCpumCpu >= 8 \
45 && (a_pRange)->offCpumCpu < sizeof(CPUMCPU) \
46 && !((a_pRange)->offCpumCpu & (RT_MIN(sizeof(a_Type), 8) - 1)) \
47 , ("offCpumCpu=%#x %s\n", (a_pRange)->offCpumCpu, (a_pRange)->szName), \
48 VERR_CPUM_MSR_BAD_CPUMCPU_OFFSET); \
49 a_Type *a_VarName = (a_Type *)((uintptr_t)&(a_pVCpu)->cpum.s + (a_pRange)->offCpumCpu)
50
51
52/*********************************************************************************************************************************
53* Structures and Typedefs *
54*********************************************************************************************************************************/
55
56/**
57 * Implements reading one or more MSRs.
58 *
59 * @returns VBox status code.
60 * @retval VINF_SUCCESS on success.
61 * @retval VINF_CPUM_R3_MSR_READ if the MSR read could not be serviced in the
62 * current context (raw-mode or ring-0).
63 * @retval VERR_CPUM_RAISE_GP_0 on failure (invalid MSR).
64 *
65 * @param pVCpu The cross context virtual CPU structure.
66 * @param idMsr The MSR we're reading.
67 * @param pRange The MSR range descriptor.
68 * @param puValue Where to return the value.
69 */
70typedef DECLCALLBACK(VBOXSTRICTRC) FNCPUMRDMSR(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue);
71/** Pointer to a RDMSR worker for a specific MSR or range of MSRs. */
72typedef FNCPUMRDMSR *PFNCPUMRDMSR;
73
74
75/**
76 * Implements writing one or more MSRs.
77 *
78 * @retval VINF_SUCCESS on success.
79 * @retval VINF_CPUM_R3_MSR_WRITE if the MSR write could not be serviced in the
80 * current context (raw-mode or ring-0).
81 * @retval VERR_CPUM_RAISE_GP_0 on failure.
82 *
83 * @param pVCpu The cross context virtual CPU structure.
84 * @param idMsr The MSR we're writing.
85 * @param pRange The MSR range descriptor.
86 * @param uValue The value to set, ignored bits masked.
87 * @param uRawValue The raw value with the ignored bits not masked.
88 */
89typedef DECLCALLBACK(VBOXSTRICTRC) FNCPUMWRMSR(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue);
90/** Pointer to a WRMSR worker for a specific MSR or range of MSRs. */
91typedef FNCPUMWRMSR *PFNCPUMWRMSR;
92
93
94
95/*
96 * Generic functions.
97 * Generic functions.
98 * Generic functions.
99 */
100
101
102/** @callback_method_impl{FNCPUMRDMSR} */
103static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_FixedValue(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
104{
105 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr);
106 *puValue = pRange->uValue;
107 return VINF_SUCCESS;
108}
109
110
111/** @callback_method_impl{FNCPUMWRMSR} */
112static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IgnoreWrite(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
113{
114 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
115 Log(("CPUM: Ignoring WRMSR %#x (%s), %#llx\n", idMsr, pRange->szName, uValue));
116 return VINF_SUCCESS;
117}
118
119
120/** @callback_method_impl{FNCPUMRDMSR} */
121static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_WriteOnly(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
122{
123 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(puValue);
124 return VERR_CPUM_RAISE_GP_0;
125}
126
127
128/** @callback_method_impl{FNCPUMWRMSR} */
129static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_ReadOnly(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
130{
131 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
132 Assert(pRange->fWrGpMask == UINT64_MAX);
133 return VERR_CPUM_RAISE_GP_0;
134}
135
136
137
138
139/*
140 * IA32
141 * IA32
142 * IA32
143 */
144
145/** @callback_method_impl{FNCPUMRDMSR} */
146static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32P5McAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
147{
148 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
149 *puValue = 0; /** @todo implement machine check injection. */
150 return VINF_SUCCESS;
151}
152
153
154/** @callback_method_impl{FNCPUMWRMSR} */
155static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32P5McAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
156{
157 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
158 /** @todo implement machine check injection. */
159 return VINF_SUCCESS;
160}
161
162
163/** @callback_method_impl{FNCPUMRDMSR} */
164static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32P5McType(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
165{
166 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
167 *puValue = 0; /** @todo implement machine check injection. */
168 return VINF_SUCCESS;
169}
170
171
172/** @callback_method_impl{FNCPUMWRMSR} */
173static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32P5McType(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
174{
175 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
176 /** @todo implement machine check injection. */
177 return VINF_SUCCESS;
178}
179
180
181/** @callback_method_impl{FNCPUMRDMSR} */
182static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32TimestampCounter(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
183{
184 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
185 *puValue = TMCpuTickGet(pVCpu);
186#ifdef VBOX_WITH_NESTED_HWVIRT
187 *puValue = CPUMApplyNestedGuestTscOffset(pVCpu, *puValue);
188#endif
189 return VINF_SUCCESS;
190}
191
192
193/** @callback_method_impl{FNCPUMWRMSR} */
194static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32TimestampCounter(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
195{
196 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
197 TMCpuTickSet(pVCpu->CTX_SUFF(pVM), pVCpu, uValue);
198 return VINF_SUCCESS;
199}
200
201
202/** @callback_method_impl{FNCPUMRDMSR} */
203static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PlatformId(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
204{
205 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr);
206 uint64_t uValue = pRange->uValue;
207 if (uValue & 0x1f00)
208 {
209 /* Max allowed bus ratio present. */
210 /** @todo Implement scaled BUS frequency. */
211 }
212
213 *puValue = uValue;
214 return VINF_SUCCESS;
215}
216
217
218/** @callback_method_impl{FNCPUMRDMSR} */
219static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32ApicBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
220{
221 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
222 return APICGetBaseMsr(pVCpu, puValue);
223}
224
225
226/** @callback_method_impl{FNCPUMWRMSR} */
227static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32ApicBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
228{
229 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
230 return APICSetBaseMsr(pVCpu, uValue);
231}
232
233
234/** @callback_method_impl{FNCPUMRDMSR} */
235static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32FeatureControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
236{
237 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
238 *puValue = 1; /* Locked, no VT-X, no SYSENTER micromanagement. */
239 return VINF_SUCCESS;
240}
241
242
243/** @callback_method_impl{FNCPUMWRMSR} */
244static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32FeatureControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
245{
246 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
247 return VERR_CPUM_RAISE_GP_0;
248}
249
250
251/** @callback_method_impl{FNCPUMRDMSR} */
252static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32BiosSignId(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
253{
254 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
255 /** @todo fake microcode update. */
256 *puValue = pRange->uValue;
257 return VINF_SUCCESS;
258}
259
260
261/** @callback_method_impl{FNCPUMWRMSR} */
262static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32BiosSignId(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
263{
264 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
265 /* Normally, zero is written to Ia32BiosSignId before reading it in order
266 to select the signature instead of the BBL_CR_D3 behaviour. The GP mask
267 of the database entry should take care of most illegal writes for now, so
268 just ignore all writes atm. */
269 return VINF_SUCCESS;
270}
271
272
273/** @callback_method_impl{FNCPUMWRMSR} */
274static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32BiosUpdateTrigger(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
275{
276 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
277 /** @todo Fake bios update trigger better. The value is the address to an
278 * update package, I think. We should probably GP if it's invalid. */
279 return VINF_SUCCESS;
280}
281
282
283/** @callback_method_impl{FNCPUMRDMSR} */
284static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32SmmMonitorCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
285{
286 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
287 /** @todo SMM. */
288 *puValue = 0;
289 return VINF_SUCCESS;
290}
291
292
293/** @callback_method_impl{FNCPUMWRMSR} */
294static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32SmmMonitorCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
295{
296 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
297 /** @todo SMM. */
298 return VINF_SUCCESS;
299}
300
301
302/** @callback_method_impl{FNCPUMRDMSR} */
303static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PmcN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
304{
305 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
306 /** @todo check CPUID leaf 0ah. */
307 *puValue = 0;
308 return VINF_SUCCESS;
309}
310
311
312/** @callback_method_impl{FNCPUMWRMSR} */
313static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PmcN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
314{
315 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
316 /** @todo check CPUID leaf 0ah. */
317 return VINF_SUCCESS;
318}
319
320
321/** @callback_method_impl{FNCPUMRDMSR} */
322static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32MonitorFilterLineSize(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
323{
324 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
325 /** @todo return 0x1000 if we try emulate mwait 100% correctly. */
326 *puValue = 0x40; /** @todo Change to CPU cache line size. */
327 return VINF_SUCCESS;
328}
329
330
331/** @callback_method_impl{FNCPUMWRMSR} */
332static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32MonitorFilterLineSize(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
333{
334 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
335 /** @todo should remember writes, though it's supposedly something only a BIOS
336 * would write so, it's not extremely important. */
337 return VINF_SUCCESS;
338}
339
340/** @callback_method_impl{FNCPUMRDMSR} */
341static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32MPerf(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
342{
343 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
344 /** @todo Read MPERF: Adjust against previously written MPERF value. Is TSC
345 * what we want? */
346 *puValue = TMCpuTickGet(pVCpu);
347#ifdef VBOX_WITH_NESTED_HWVIRT
348 *puValue = CPUMApplyNestedGuestTscOffset(pVCpu, *puValue);
349#endif
350 return VINF_SUCCESS;
351}
352
353
354/** @callback_method_impl{FNCPUMWRMSR} */
355static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32MPerf(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
356{
357 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
358 /** @todo Write MPERF: Calc adjustment. */
359 return VINF_SUCCESS;
360}
361
362
363/** @callback_method_impl{FNCPUMRDMSR} */
364static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32APerf(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
365{
366 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
367 /** @todo Read APERF: Adjust against previously written MPERF value. Is TSC
368 * what we want? */
369 *puValue = TMCpuTickGet(pVCpu);
370#ifdef VBOX_WITH_NESTED_HWVIRT
371 *puValue = CPUMApplyNestedGuestTscOffset(pVCpu, *puValue);
372#endif
373 return VINF_SUCCESS;
374}
375
376
377/** @callback_method_impl{FNCPUMWRMSR} */
378static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32APerf(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
379{
380 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
381 /** @todo Write APERF: Calc adjustment. */
382 return VINF_SUCCESS;
383}
384
385
386/** @callback_method_impl{FNCPUMRDMSR} */
387static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32MtrrCap(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
388{
389 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
390
391 /* This is currently a bit weird. :-) */
392 uint8_t const cVariableRangeRegs = 0;
393 bool const fSystemManagementRangeRegisters = false;
394 bool const fFixedRangeRegisters = false;
395 bool const fWriteCombiningType = false;
396 *puValue = cVariableRangeRegs
397 | (fFixedRangeRegisters ? RT_BIT_64(8) : 0)
398 | (fWriteCombiningType ? RT_BIT_64(10) : 0)
399 | (fSystemManagementRangeRegisters ? RT_BIT_64(11) : 0);
400 return VINF_SUCCESS;
401}
402
403
404/** @callback_method_impl{FNCPUMRDMSR} */
405static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32MtrrPhysBaseN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
406{
407 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
408 /** @todo Implement variable MTRR storage. */
409 Assert(pRange->uValue == (idMsr - 0x200) / 2);
410 *puValue = 0;
411 return VINF_SUCCESS;
412}
413
414
415/** @callback_method_impl{FNCPUMWRMSR} */
416static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32MtrrPhysBaseN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
417{
418 /*
419 * Validate the value.
420 */
421 Assert(pRange->uValue == (idMsr - 0x200) / 2);
422 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(uRawValue); RT_NOREF_PV(pRange);
423
424 uint8_t uType = uValue & 0xff;
425 if ((uType >= 7) || (uType == 2) || (uType == 3))
426 {
427 Log(("CPUM: Invalid type set writing MTRR PhysBase MSR %#x: %#llx (%#llx)\n", idMsr, uValue, uType));
428 return VERR_CPUM_RAISE_GP_0;
429 }
430
431 uint64_t fInvPhysMask = ~(RT_BIT_64(pVCpu->CTX_SUFF(pVM)->cpum.s.GuestFeatures.cMaxPhysAddrWidth) - 1U);
432 if (fInvPhysMask & uValue)
433 {
434 Log(("CPUM: Invalid physical address bits set writing MTRR PhysBase MSR %#x: %#llx (%#llx)\n",
435 idMsr, uValue, uValue & fInvPhysMask));
436 return VERR_CPUM_RAISE_GP_0;
437 }
438
439 /*
440 * Store it.
441 */
442 /** @todo Implement variable MTRR storage. */
443 return VINF_SUCCESS;
444}
445
446
447/** @callback_method_impl{FNCPUMRDMSR} */
448static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32MtrrPhysMaskN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
449{
450 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
451 /** @todo Implement variable MTRR storage. */
452 Assert(pRange->uValue == (idMsr - 0x200) / 2);
453 *puValue = 0;
454 return VINF_SUCCESS;
455}
456
457
458/** @callback_method_impl{FNCPUMWRMSR} */
459static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32MtrrPhysMaskN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
460{
461 /*
462 * Validate the value.
463 */
464 Assert(pRange->uValue == (idMsr - 0x200) / 2);
465 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(uRawValue); RT_NOREF_PV(pRange);
466
467 uint64_t fInvPhysMask = ~(RT_BIT_64(pVCpu->CTX_SUFF(pVM)->cpum.s.GuestFeatures.cMaxPhysAddrWidth) - 1U);
468 if (fInvPhysMask & uValue)
469 {
470 Log(("CPUM: Invalid physical address bits set writing MTRR PhysMask MSR %#x: %#llx (%#llx)\n",
471 idMsr, uValue, uValue & fInvPhysMask));
472 return VERR_CPUM_RAISE_GP_0;
473 }
474
475 /*
476 * Store it.
477 */
478 /** @todo Implement variable MTRR storage. */
479 return VINF_SUCCESS;
480}
481
482
483/** @callback_method_impl{FNCPUMRDMSR} */
484static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32MtrrFixed(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
485{
486 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
487 CPUM_MSR_ASSERT_CPUMCPU_OFFSET_RETURN(pVCpu, pRange, uint64_t, puFixedMtrr);
488 *puValue = *puFixedMtrr;
489 return VINF_SUCCESS;
490}
491
492
493/** @callback_method_impl{FNCPUMWRMSR} */
494static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32MtrrFixed(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
495{
496 CPUM_MSR_ASSERT_CPUMCPU_OFFSET_RETURN(pVCpu, pRange, uint64_t, puFixedMtrr);
497 RT_NOREF_PV(idMsr); RT_NOREF_PV(uRawValue);
498
499 for (uint32_t cShift = 0; cShift < 63; cShift += 8)
500 {
501 uint8_t uType = (uint8_t)(uValue >> cShift);
502 if ((uType >= 7) || (uType == 2) || (uType == 3))
503 {
504 Log(("CPUM: Invalid MTRR type at %u:%u in fixed range (%#x/%s): %#llx (%#llx)\n",
505 cShift + 7, cShift, idMsr, pRange->szName, uValue, uType));
506 return VERR_CPUM_RAISE_GP_0;
507 }
508 }
509 *puFixedMtrr = uValue;
510 return VINF_SUCCESS;
511}
512
513
514/** @callback_method_impl{FNCPUMRDMSR} */
515static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32MtrrDefType(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
516{
517 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
518 *puValue = pVCpu->cpum.s.GuestMsrs.msr.MtrrDefType;
519 return VINF_SUCCESS;
520}
521
522
523/** @callback_method_impl{FNCPUMWRMSR} */
524static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32MtrrDefType(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
525{
526 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
527
528 uint8_t uType = uValue & 0xff;
529 if ((uType >= 7) || (uType == 2) || (uType == 3))
530 {
531 Log(("CPUM: Invalid MTRR default type value on %s: %#llx (%#llx)\n", pRange->szName, uValue, uType));
532 return VERR_CPUM_RAISE_GP_0;
533 }
534
535 pVCpu->cpum.s.GuestMsrs.msr.MtrrDefType = uValue;
536 return VINF_SUCCESS;
537}
538
539
540/** @callback_method_impl{FNCPUMRDMSR} */
541static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32Pat(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
542{
543 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
544 *puValue = pVCpu->cpum.s.Guest.msrPAT;
545 return VINF_SUCCESS;
546}
547
548
549/** @callback_method_impl{FNCPUMWRMSR} */
550static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32Pat(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
551{
552 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
553
554 for (uint32_t cShift = 0; cShift < 63; cShift += 8)
555 {
556 /* Check all eight bits because the top 5 bits of each byte are reserved. */
557 uint8_t uType = (uint8_t)(uValue >> cShift);
558 if ((uType >= 8) || (uType == 2) || (uType == 3))
559 {
560 Log(("CPUM: Invalid PAT type at %u:%u in IA32_PAT: %#llx (%#llx)\n",
561 cShift + 7, cShift, uValue, uType));
562 return VERR_CPUM_RAISE_GP_0;
563 }
564 }
565
566 pVCpu->cpum.s.Guest.msrPAT = uValue;
567 return VINF_SUCCESS;
568}
569
570
571/** @callback_method_impl{FNCPUMRDMSR} */
572static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32SysEnterCs(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
573{
574 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
575 *puValue = pVCpu->cpum.s.Guest.SysEnter.cs;
576 return VINF_SUCCESS;
577}
578
579
580/** @callback_method_impl{FNCPUMWRMSR} */
581static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32SysEnterCs(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
582{
583 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
584
585 /* Note! We used to mask this by 0xffff, but turns out real HW doesn't and
586 there are generally 32-bit working bits backing this register. */
587 pVCpu->cpum.s.Guest.SysEnter.cs = uValue;
588 return VINF_SUCCESS;
589}
590
591
592/** @callback_method_impl{FNCPUMRDMSR} */
593static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32SysEnterEsp(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
594{
595 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
596 *puValue = pVCpu->cpum.s.Guest.SysEnter.esp;
597 return VINF_SUCCESS;
598}
599
600
601/** @callback_method_impl{FNCPUMWRMSR} */
602static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32SysEnterEsp(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
603{
604 if (X86_IS_CANONICAL(uValue))
605 {
606 pVCpu->cpum.s.Guest.SysEnter.esp = uValue;
607 return VINF_SUCCESS;
608 }
609 Log(("CPUM: IA32_SYSENTER_ESP not canonical! %#llx\n", uValue));
610 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
611 return VERR_CPUM_RAISE_GP_0;
612}
613
614
615/** @callback_method_impl{FNCPUMRDMSR} */
616static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32SysEnterEip(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
617{
618 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
619 *puValue = pVCpu->cpum.s.Guest.SysEnter.eip;
620 return VINF_SUCCESS;
621}
622
623
624/** @callback_method_impl{FNCPUMWRMSR} */
625static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32SysEnterEip(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
626{
627 if (X86_IS_CANONICAL(uValue))
628 {
629 pVCpu->cpum.s.Guest.SysEnter.eip = uValue;
630 return VINF_SUCCESS;
631 }
632#ifdef IN_RING3
633 LogRel(("CPUM: IA32_SYSENTER_EIP not canonical! %#llx\n", uValue));
634#else
635 Log(("CPUM: IA32_SYSENTER_EIP not canonical! %#llx\n", uValue));
636#endif
637 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
638 return VERR_CPUM_RAISE_GP_0;
639}
640
641
642/** @callback_method_impl{FNCPUMRDMSR} */
643static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32McgCap(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
644{
645#if 0 /** @todo implement machine checks. */
646 *puValue = pRange->uValue & (RT_BIT_64(8) | 0);
647#else
648 *puValue = 0;
649#endif
650 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
651 return VINF_SUCCESS;
652}
653
654
655/** @callback_method_impl{FNCPUMRDMSR} */
656static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32McgStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
657{
658 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
659 /** @todo implement machine checks. */
660 *puValue = 0;
661 return VINF_SUCCESS;
662}
663
664
665/** @callback_method_impl{FNCPUMWRMSR} */
666static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32McgStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
667{
668 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
669 /** @todo implement machine checks. */
670 return VINF_SUCCESS;
671}
672
673
674/** @callback_method_impl{FNCPUMRDMSR} */
675static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32McgCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
676{
677 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
678 /** @todo implement machine checks. */
679 *puValue = 0;
680 return VINF_SUCCESS;
681}
682
683
684/** @callback_method_impl{FNCPUMWRMSR} */
685static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32McgCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
686{
687 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
688 /** @todo implement machine checks. */
689 return VINF_SUCCESS;
690}
691
692
693/** @callback_method_impl{FNCPUMRDMSR} */
694static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32DebugCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
695{
696 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
697 /** @todo implement IA32_DEBUGCTL. */
698 *puValue = 0;
699 return VINF_SUCCESS;
700}
701
702
703/** @callback_method_impl{FNCPUMWRMSR} */
704static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32DebugCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
705{
706 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
707 /** @todo implement IA32_DEBUGCTL. */
708 return VINF_SUCCESS;
709}
710
711
712/** @callback_method_impl{FNCPUMRDMSR} */
713static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32SmrrPhysBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
714{
715 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
716 /** @todo implement intel SMM. */
717 *puValue = 0;
718 return VINF_SUCCESS;
719}
720
721
722/** @callback_method_impl{FNCPUMWRMSR} */
723static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32SmrrPhysBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
724{
725 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
726 /** @todo implement intel SMM. */
727 return VERR_CPUM_RAISE_GP_0;
728}
729
730
731/** @callback_method_impl{FNCPUMRDMSR} */
732static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32SmrrPhysMask(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
733{
734 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
735 /** @todo implement intel SMM. */
736 *puValue = 0;
737 return VINF_SUCCESS;
738}
739
740
741/** @callback_method_impl{FNCPUMWRMSR} */
742static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32SmrrPhysMask(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
743{
744 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
745 /** @todo implement intel SMM. */
746 return VERR_CPUM_RAISE_GP_0;
747}
748
749
750/** @callback_method_impl{FNCPUMRDMSR} */
751static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PlatformDcaCap(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
752{
753 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
754 /** @todo implement intel direct cache access (DCA)?? */
755 *puValue = 0;
756 return VINF_SUCCESS;
757}
758
759
760/** @callback_method_impl{FNCPUMWRMSR} */
761static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PlatformDcaCap(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
762{
763 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
764 /** @todo implement intel direct cache access (DCA)?? */
765 return VINF_SUCCESS;
766}
767
768
769/** @callback_method_impl{FNCPUMRDMSR} */
770static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32CpuDcaCap(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
771{
772 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
773 /** @todo implement intel direct cache access (DCA)?? */
774 *puValue = 0;
775 return VINF_SUCCESS;
776}
777
778
779/** @callback_method_impl{FNCPUMRDMSR} */
780static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32Dca0Cap(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
781{
782 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
783 /** @todo implement intel direct cache access (DCA)?? */
784 *puValue = 0;
785 return VINF_SUCCESS;
786}
787
788
789/** @callback_method_impl{FNCPUMWRMSR} */
790static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32Dca0Cap(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
791{
792 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
793 /** @todo implement intel direct cache access (DCA)?? */
794 return VINF_SUCCESS;
795}
796
797
798/** @callback_method_impl{FNCPUMRDMSR} */
799static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PerfEvtSelN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
800{
801 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
802 /** @todo implement IA32_PERFEVTSEL0+. */
803 *puValue = 0;
804 return VINF_SUCCESS;
805}
806
807
808/** @callback_method_impl{FNCPUMWRMSR} */
809static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PerfEvtSelN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
810{
811 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
812 /** @todo implement IA32_PERFEVTSEL0+. */
813 return VINF_SUCCESS;
814}
815
816
817/** @callback_method_impl{FNCPUMRDMSR} */
818static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PerfStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
819{
820 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
821 uint64_t uValue = pRange->uValue;
822
823 /* Always provide the max bus ratio for now. XNU expects it. */
824 uValue &= ~((UINT64_C(0x1f) << 40) | RT_BIT_64(46));
825
826 PVM pVM = pVCpu->CTX_SUFF(pVM);
827 uint64_t uScalableBusHz = CPUMGetGuestScalableBusFrequency(pVM);
828 uint64_t uTscHz = TMCpuTicksPerSecond(pVM);
829 uint8_t uTscRatio = (uint8_t)((uTscHz + uScalableBusHz / 2) / uScalableBusHz);
830 if (uTscRatio > 0x1f)
831 uTscRatio = 0x1f;
832 uValue |= (uint64_t)uTscRatio << 40;
833
834 *puValue = uValue;
835 return VINF_SUCCESS;
836}
837
838
839/** @callback_method_impl{FNCPUMWRMSR} */
840static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PerfStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
841{
842 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
843 /* Pentium4 allows writing, but all bits are ignored. */
844 return VINF_SUCCESS;
845}
846
847
848/** @callback_method_impl{FNCPUMRDMSR} */
849static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PerfCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
850{
851 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
852 /** @todo implement IA32_PERFCTL. */
853 *puValue = 0;
854 return VINF_SUCCESS;
855}
856
857
858/** @callback_method_impl{FNCPUMWRMSR} */
859static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PerfCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
860{
861 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
862 /** @todo implement IA32_PERFCTL. */
863 return VINF_SUCCESS;
864}
865
866
867/** @callback_method_impl{FNCPUMRDMSR} */
868static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32FixedCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
869{
870 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
871 /** @todo implement IA32_FIXED_CTRn (fixed performance counters). */
872 *puValue = 0;
873 return VINF_SUCCESS;
874}
875
876
877/** @callback_method_impl{FNCPUMWRMSR} */
878static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32FixedCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
879{
880 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
881 /** @todo implement IA32_FIXED_CTRn (fixed performance counters). */
882 return VINF_SUCCESS;
883}
884
885
886/** @callback_method_impl{FNCPUMRDMSR} */
887static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PerfCapabilities(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
888{
889 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
890 /** @todo implement performance counters. */
891 *puValue = 0;
892 return VINF_SUCCESS;
893}
894
895
896/** @callback_method_impl{FNCPUMWRMSR} */
897static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PerfCapabilities(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
898{
899 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
900 /** @todo implement performance counters. */
901 return VINF_SUCCESS;
902}
903
904
905/** @callback_method_impl{FNCPUMRDMSR} */
906static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32FixedCtrCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
907{
908 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
909 /** @todo implement performance counters. */
910 *puValue = 0;
911 return VINF_SUCCESS;
912}
913
914
915/** @callback_method_impl{FNCPUMWRMSR} */
916static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32FixedCtrCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
917{
918 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
919 /** @todo implement performance counters. */
920 return VINF_SUCCESS;
921}
922
923
924/** @callback_method_impl{FNCPUMRDMSR} */
925static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PerfGlobalStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
926{
927 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
928 /** @todo implement performance counters. */
929 *puValue = 0;
930 return VINF_SUCCESS;
931}
932
933
934/** @callback_method_impl{FNCPUMWRMSR} */
935static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PerfGlobalStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
936{
937 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
938 /** @todo implement performance counters. */
939 return VINF_SUCCESS;
940}
941
942
943/** @callback_method_impl{FNCPUMRDMSR} */
944static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PerfGlobalCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
945{
946 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
947 /** @todo implement performance counters. */
948 *puValue = 0;
949 return VINF_SUCCESS;
950}
951
952
953/** @callback_method_impl{FNCPUMWRMSR} */
954static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PerfGlobalCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
955{
956 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
957 /** @todo implement performance counters. */
958 return VINF_SUCCESS;
959}
960
961
962/** @callback_method_impl{FNCPUMRDMSR} */
963static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PerfGlobalOvfCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
964{
965 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
966 /** @todo implement performance counters. */
967 *puValue = 0;
968 return VINF_SUCCESS;
969}
970
971
972/** @callback_method_impl{FNCPUMWRMSR} */
973static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PerfGlobalOvfCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
974{
975 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
976 /** @todo implement performance counters. */
977 return VINF_SUCCESS;
978}
979
980
981/** @callback_method_impl{FNCPUMRDMSR} */
982static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32PebsEnable(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
983{
984 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
985 /** @todo implement performance counters. */
986 *puValue = 0;
987 return VINF_SUCCESS;
988}
989
990
991/** @callback_method_impl{FNCPUMWRMSR} */
992static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PebsEnable(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
993{
994 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
995 /** @todo implement performance counters. */
996 return VINF_SUCCESS;
997}
998
999
1000/** @callback_method_impl{FNCPUMRDMSR} */
1001static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32ClockModulation(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1002{
1003 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1004 /** @todo implement IA32_CLOCK_MODULATION. */
1005 *puValue = 0;
1006 return VINF_SUCCESS;
1007}
1008
1009
1010/** @callback_method_impl{FNCPUMWRMSR} */
1011static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32ClockModulation(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1012{
1013 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1014 /** @todo implement IA32_CLOCK_MODULATION. */
1015 return VINF_SUCCESS;
1016}
1017
1018
1019/** @callback_method_impl{FNCPUMRDMSR} */
1020static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32ThermInterrupt(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1021{
1022 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1023 /** @todo implement IA32_THERM_INTERRUPT. */
1024 *puValue = 0;
1025 return VINF_SUCCESS;
1026}
1027
1028
1029/** @callback_method_impl{FNCPUMWRMSR} */
1030static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32ThermInterrupt(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1031{
1032 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1033 /** @todo implement IA32_THERM_STATUS. */
1034 return VINF_SUCCESS;
1035}
1036
1037
1038/** @callback_method_impl{FNCPUMRDMSR} */
1039static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32ThermStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1040{
1041 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1042 /** @todo implement IA32_THERM_STATUS. */
1043 *puValue = 0;
1044 return VINF_SUCCESS;
1045}
1046
1047
1048/** @callback_method_impl{FNCPUMWRMSR} */
1049static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32ThermStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1050{
1051 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1052 /** @todo implement IA32_THERM_INTERRUPT. */
1053 return VINF_SUCCESS;
1054}
1055
1056
1057/** @callback_method_impl{FNCPUMRDMSR} */
1058static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32Therm2Ctl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1059{
1060 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1061 /** @todo implement IA32_THERM2_CTL. */
1062 *puValue = 0;
1063 return VINF_SUCCESS;
1064}
1065
1066
1067/** @callback_method_impl{FNCPUMWRMSR} */
1068static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32Therm2Ctl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1069{
1070 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1071 /** @todo implement IA32_THERM2_CTL. */
1072 return VINF_SUCCESS;
1073}
1074
1075
1076/** @callback_method_impl{FNCPUMRDMSR} */
1077static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32MiscEnable(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1078{
1079 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1080 *puValue = pVCpu->cpum.s.GuestMsrs.msr.MiscEnable;
1081 return VINF_SUCCESS;
1082}
1083
1084
1085/** @callback_method_impl{FNCPUMWRMSR} */
1086static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32MiscEnable(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1087{
1088 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1089#ifdef LOG_ENABLED
1090 uint64_t const uOld = pVCpu->cpum.s.GuestMsrs.msr.MiscEnable;
1091#endif
1092
1093 /* Unsupported bits are generally ignored and stripped by the MSR range
1094 entry that got us here. So, we just need to preserve fixed bits. */
1095 pVCpu->cpum.s.GuestMsrs.msr.MiscEnable = uValue
1096 | MSR_IA32_MISC_ENABLE_PEBS_UNAVAIL
1097 | MSR_IA32_MISC_ENABLE_BTS_UNAVAIL;
1098
1099 Log(("CPUM: IA32_MISC_ENABLE; old=%#llx written=%#llx => %#llx\n",
1100 uOld, uValue, pVCpu->cpum.s.GuestMsrs.msr.MiscEnable));
1101
1102 /** @todo Wire IA32_MISC_ENABLE bit 22 to our NT 4 CPUID trick. */
1103 /** @todo Wire up MSR_IA32_MISC_ENABLE_XD_DISABLE. */
1104 return VINF_SUCCESS;
1105}
1106
1107
1108/** @callback_method_impl{FNCPUMRDMSR} */
1109static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32McCtlStatusAddrMiscN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1110{
1111 RT_NOREF_PV(pVCpu); RT_NOREF_PV(pRange);
1112
1113 /** @todo Implement machine check exception injection. */
1114 switch (idMsr & 3)
1115 {
1116 case 0:
1117 case 1:
1118 *puValue = 0;
1119 break;
1120
1121 /* The ADDR and MISC registers aren't accessible since the
1122 corresponding STATUS bits are zero. */
1123 case 2:
1124 Log(("CPUM: Reading IA32_MCi_ADDR %#x -> #GP\n", idMsr));
1125 return VERR_CPUM_RAISE_GP_0;
1126 case 3:
1127 Log(("CPUM: Reading IA32_MCi_MISC %#x -> #GP\n", idMsr));
1128 return VERR_CPUM_RAISE_GP_0;
1129 }
1130 return VINF_SUCCESS;
1131}
1132
1133
1134/** @callback_method_impl{FNCPUMWRMSR} */
1135static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32McCtlStatusAddrMiscN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1136{
1137 RT_NOREF_PV(pVCpu); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1138 switch (idMsr & 3)
1139 {
1140 case 0:
1141 /* Ignore writes to the CTL register. */
1142 break;
1143
1144 case 1:
1145 /* According to specs, the STATUS register can only be written to
1146 with the value 0. VBoxCpuReport thinks different for a
1147 Pentium M Dothan, but implementing according to specs now. */
1148 if (uValue != 0)
1149 {
1150 Log(("CPUM: Writing non-zero value (%#llx) to IA32_MCi_STATUS %#x -> #GP\n", uValue, idMsr));
1151 return VERR_CPUM_RAISE_GP_0;
1152 }
1153 break;
1154
1155 /* Specs states that ADDR and MISC can be cleared by writing zeros.
1156 Writing 1s will GP. Need to figure out how this relates to the
1157 ADDRV and MISCV status flags. If writing is independent of those
1158 bits, we need to know whether the CPU really implements them since
1159 that is exposed by writing 0 to them.
1160 Implementing the solution with the fewer GPs for now. */
1161 case 2:
1162 if (uValue != 0)
1163 {
1164 Log(("CPUM: Writing non-zero value (%#llx) to IA32_MCi_ADDR %#x -> #GP\n", uValue, idMsr));
1165 return VERR_CPUM_RAISE_GP_0;
1166 }
1167 break;
1168 case 3:
1169 if (uValue != 0)
1170 {
1171 Log(("CPUM: Writing non-zero value (%#llx) to IA32_MCi_MISC %#x -> #GP\n", uValue, idMsr));
1172 return VERR_CPUM_RAISE_GP_0;
1173 }
1174 break;
1175 }
1176 return VINF_SUCCESS;
1177}
1178
1179
1180/** @callback_method_impl{FNCPUMRDMSR} */
1181static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32McNCtl2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1182{
1183 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1184 /** @todo Implement machine check exception injection. */
1185 *puValue = 0;
1186 return VINF_SUCCESS;
1187}
1188
1189
1190/** @callback_method_impl{FNCPUMWRMSR} */
1191static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32McNCtl2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1192{
1193 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1194 /** @todo Implement machine check exception injection. */
1195 return VINF_SUCCESS;
1196}
1197
1198
1199/** @callback_method_impl{FNCPUMRDMSR} */
1200static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32DsArea(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1201{
1202 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1203 /** @todo implement IA32_DS_AREA. */
1204 *puValue = 0;
1205 return VINF_SUCCESS;
1206}
1207
1208
1209/** @callback_method_impl{FNCPUMWRMSR} */
1210static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32DsArea(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1211{
1212 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1213 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1214 return VINF_SUCCESS;
1215}
1216
1217
1218/** @callback_method_impl{FNCPUMRDMSR} */
1219static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32TscDeadline(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1220{
1221 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1222 /** @todo implement TSC deadline timer. */
1223 *puValue = 0;
1224 return VINF_SUCCESS;
1225}
1226
1227
1228/** @callback_method_impl{FNCPUMWRMSR} */
1229static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32TscDeadline(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1230{
1231 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1232 /** @todo implement TSC deadline timer. */
1233 return VINF_SUCCESS;
1234}
1235
1236
1237/** @callback_method_impl{FNCPUMRDMSR} */
1238static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32X2ApicN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1239{
1240 RT_NOREF_PV(pRange);
1241 return APICReadMsr(pVCpu, idMsr, puValue);
1242}
1243
1244
1245/** @callback_method_impl{FNCPUMWRMSR} */
1246static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32X2ApicN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1247{
1248 RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1249 return APICWriteMsr(pVCpu, idMsr, uValue);
1250}
1251
1252
1253/** @callback_method_impl{FNCPUMRDMSR} */
1254static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32DebugInterface(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1255{
1256 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1257 /** @todo IA32_DEBUG_INTERFACE (no docs) */
1258 *puValue = 0;
1259 return VINF_SUCCESS;
1260}
1261
1262
1263/** @callback_method_impl{FNCPUMWRMSR} */
1264static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32DebugInterface(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1265{
1266 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1267 /** @todo IA32_DEBUG_INTERFACE (no docs) */
1268 return VINF_SUCCESS;
1269}
1270
1271
1272/** @callback_method_impl{FNCPUMRDMSR} */
1273static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1274{
1275 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1276 *puValue = 0;
1277 return VINF_SUCCESS;
1278}
1279
1280
1281/** @callback_method_impl{FNCPUMRDMSR} */
1282static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxPinbasedCtls(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1283{
1284 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1285 *puValue = 0;
1286 return VINF_SUCCESS;
1287}
1288
1289
1290/** @callback_method_impl{FNCPUMRDMSR} */
1291static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxProcbasedCtls(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1292{
1293 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1294 *puValue = 0;
1295 return VINF_SUCCESS;
1296}
1297
1298
1299/** @callback_method_impl{FNCPUMRDMSR} */
1300static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxExitCtls(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1301{
1302 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1303 *puValue = 0;
1304 return VINF_SUCCESS;
1305}
1306
1307
1308/** @callback_method_impl{FNCPUMRDMSR} */
1309static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxEntryCtls(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1310{
1311 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1312 *puValue = 0;
1313 return VINF_SUCCESS;
1314}
1315
1316
1317/** @callback_method_impl{FNCPUMRDMSR} */
1318static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxMisc(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1319{
1320 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1321 *puValue = 0;
1322 return VINF_SUCCESS;
1323}
1324
1325
1326/** @callback_method_impl{FNCPUMRDMSR} */
1327static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxCr0Fixed0(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1328{
1329 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1330 *puValue = 0;
1331 return VINF_SUCCESS;
1332}
1333
1334
1335/** @callback_method_impl{FNCPUMRDMSR} */
1336static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxCr0Fixed1(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1337{
1338 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1339 *puValue = 0;
1340 return VINF_SUCCESS;
1341}
1342
1343
1344/** @callback_method_impl{FNCPUMRDMSR} */
1345static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxCr4Fixed0(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1346{
1347 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1348 *puValue = 0;
1349 return VINF_SUCCESS;
1350}
1351
1352
1353/** @callback_method_impl{FNCPUMRDMSR} */
1354static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxCr4Fixed1(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1355{
1356 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1357 *puValue = 0;
1358 return VINF_SUCCESS;
1359}
1360
1361
1362/** @callback_method_impl{FNCPUMRDMSR} */
1363static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxVmcsEnum(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1364{
1365 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1366 *puValue = 0;
1367 return VINF_SUCCESS;
1368}
1369
1370
1371/** @callback_method_impl{FNCPUMRDMSR} */
1372static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxProcBasedCtls2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1373{
1374 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1375 *puValue = 0;
1376 return VINF_SUCCESS;
1377}
1378
1379
1380/** @callback_method_impl{FNCPUMRDMSR} */
1381static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxEptVpidCap(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1382{
1383 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1384 *puValue = 0;
1385 return VINF_SUCCESS;
1386}
1387
1388
1389/** @callback_method_impl{FNCPUMRDMSR} */
1390static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxTruePinbasedCtls(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1391{
1392 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1393 *puValue = 0;
1394 return VINF_SUCCESS;
1395}
1396
1397
1398/** @callback_method_impl{FNCPUMRDMSR} */
1399static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxTrueProcbasedCtls(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1400{
1401 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1402 *puValue = 0;
1403 return VINF_SUCCESS;
1404}
1405
1406
1407/** @callback_method_impl{FNCPUMRDMSR} */
1408static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxTrueExitCtls(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1409{
1410 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1411 *puValue = 0;
1412 return VINF_SUCCESS;
1413}
1414
1415
1416/** @callback_method_impl{FNCPUMRDMSR} */
1417static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxTrueEntryCtls(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1418{
1419 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1420 *puValue = 0;
1421 return VINF_SUCCESS;
1422}
1423
1424
1425/** @callback_method_impl{FNCPUMRDMSR} */
1426static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32VmxVmFunc(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1427{
1428 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1429 *puValue = 0;
1430 return VINF_SUCCESS;
1431}
1432
1433
1434/** @callback_method_impl{FNCPUMRDMSR} */
1435static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32SpecCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1436{
1437 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1438 *puValue = pVCpu->cpum.s.GuestMsrs.msr.SpecCtrl;
1439 return VINF_SUCCESS;
1440}
1441
1442
1443/** @callback_method_impl{FNCPUMWRMSR} */
1444static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32SpecCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1445{
1446 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1447
1448 /* NB: The STIBP bit can be set even when IBRS is present, regardless of whether STIBP is actually implemented. */
1449 if (uValue & ~(MSR_IA32_SPEC_CTRL_F_IBRS | MSR_IA32_SPEC_CTRL_F_STIBP))
1450 {
1451 Log(("CPUM: Invalid IA32_SPEC_CTRL bits (trying to write %#llx)\n", uValue));
1452 return VERR_CPUM_RAISE_GP_0;
1453 }
1454
1455 pVCpu->cpum.s.GuestMsrs.msr.SpecCtrl = uValue;
1456 return VINF_SUCCESS;
1457}
1458
1459
1460/** @callback_method_impl{FNCPUMWRMSR} */
1461static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Ia32PredCmd(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1462{
1463 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1464 return VINF_SUCCESS;
1465}
1466
1467
1468/** @callback_method_impl{FNCPUMRDMSR} */
1469static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Ia32ArchCapabilities(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1470{
1471 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1472 *puValue = pVCpu->cpum.s.GuestMsrs.msr.ArchCaps;
1473 return VINF_SUCCESS;
1474}
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487/*
1488 * AMD64
1489 * AMD64
1490 * AMD64
1491 */
1492
1493
1494/** @callback_method_impl{FNCPUMRDMSR} */
1495static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Amd64Efer(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1496{
1497 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1498 *puValue = pVCpu->cpum.s.Guest.msrEFER;
1499 return VINF_SUCCESS;
1500}
1501
1502
1503/** @callback_method_impl{FNCPUMWRMSR} */
1504static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Amd64Efer(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1505{
1506 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1507 uint64_t uValidatedEfer;
1508 uint64_t const uOldEfer = pVCpu->cpum.s.Guest.msrEFER;
1509 int rc = CPUMQueryValidatedGuestEfer(pVCpu->CTX_SUFF(pVM), pVCpu->cpum.s.Guest.cr0, uOldEfer, uValue, &uValidatedEfer);
1510 if (RT_FAILURE(rc))
1511 return VERR_CPUM_RAISE_GP_0;
1512
1513 CPUMSetGuestMsrEferNoCheck(pVCpu, uOldEfer, uValidatedEfer);
1514 return VINF_SUCCESS;
1515}
1516
1517
1518/** @callback_method_impl{FNCPUMRDMSR} */
1519static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Amd64SyscallTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1520{
1521 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1522 *puValue = pVCpu->cpum.s.Guest.msrSTAR;
1523 return VINF_SUCCESS;
1524}
1525
1526
1527/** @callback_method_impl{FNCPUMWRMSR} */
1528static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Amd64SyscallTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1529{
1530 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1531 pVCpu->cpum.s.Guest.msrSTAR = uValue;
1532 return VINF_SUCCESS;
1533}
1534
1535
1536/** @callback_method_impl{FNCPUMRDMSR} */
1537static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Amd64LongSyscallTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1538{
1539 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1540 *puValue = pVCpu->cpum.s.Guest.msrLSTAR;
1541 return VINF_SUCCESS;
1542}
1543
1544
1545/** @callback_method_impl{FNCPUMWRMSR} */
1546static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Amd64LongSyscallTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1547{
1548 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1549 if (!X86_IS_CANONICAL(uValue))
1550 {
1551 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue));
1552 return VERR_CPUM_RAISE_GP_0;
1553 }
1554 pVCpu->cpum.s.Guest.msrLSTAR = uValue;
1555 return VINF_SUCCESS;
1556}
1557
1558
1559/** @callback_method_impl{FNCPUMRDMSR} */
1560static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Amd64CompSyscallTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1561{
1562 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1563 *puValue = pVCpu->cpum.s.Guest.msrCSTAR;
1564 return VINF_SUCCESS;
1565}
1566
1567
1568/** @callback_method_impl{FNCPUMWRMSR} */
1569static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Amd64CompSyscallTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1570{
1571 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1572 if (!X86_IS_CANONICAL(uValue))
1573 {
1574 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue));
1575 return VERR_CPUM_RAISE_GP_0;
1576 }
1577 pVCpu->cpum.s.Guest.msrCSTAR = uValue;
1578 return VINF_SUCCESS;
1579}
1580
1581
1582/** @callback_method_impl{FNCPUMRDMSR} */
1583static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Amd64SyscallFlagMask(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1584{
1585 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1586 *puValue = pVCpu->cpum.s.Guest.msrSFMASK;
1587 return VINF_SUCCESS;
1588}
1589
1590
1591/** @callback_method_impl{FNCPUMWRMSR} */
1592static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Amd64SyscallFlagMask(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1593{
1594 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1595 pVCpu->cpum.s.Guest.msrSFMASK = uValue;
1596 return VINF_SUCCESS;
1597}
1598
1599
1600/** @callback_method_impl{FNCPUMRDMSR} */
1601static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Amd64FsBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1602{
1603 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1604 *puValue = pVCpu->cpum.s.Guest.fs.u64Base;
1605 return VINF_SUCCESS;
1606}
1607
1608
1609/** @callback_method_impl{FNCPUMWRMSR} */
1610static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Amd64FsBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1611{
1612 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1613 pVCpu->cpum.s.Guest.fs.u64Base = uValue;
1614 return VINF_SUCCESS;
1615}
1616
1617
1618/** @callback_method_impl{FNCPUMRDMSR} */
1619static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Amd64GsBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1620{
1621 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1622 *puValue = pVCpu->cpum.s.Guest.gs.u64Base;
1623 return VINF_SUCCESS;
1624}
1625
1626/** @callback_method_impl{FNCPUMWRMSR} */
1627static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Amd64GsBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1628{
1629 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1630 pVCpu->cpum.s.Guest.gs.u64Base = uValue;
1631 return VINF_SUCCESS;
1632}
1633
1634
1635
1636/** @callback_method_impl{FNCPUMRDMSR} */
1637static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Amd64KernelGsBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1638{
1639 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1640 *puValue = pVCpu->cpum.s.Guest.msrKERNELGSBASE;
1641 return VINF_SUCCESS;
1642}
1643
1644/** @callback_method_impl{FNCPUMWRMSR} */
1645static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Amd64KernelGsBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1646{
1647 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1648 pVCpu->cpum.s.Guest.msrKERNELGSBASE = uValue;
1649 return VINF_SUCCESS;
1650}
1651
1652
1653/** @callback_method_impl{FNCPUMRDMSR} */
1654static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Amd64TscAux(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1655{
1656 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1657 *puValue = pVCpu->cpum.s.GuestMsrs.msr.TscAux;
1658 return VINF_SUCCESS;
1659}
1660
1661/** @callback_method_impl{FNCPUMWRMSR} */
1662static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Amd64TscAux(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1663{
1664 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1665 pVCpu->cpum.s.GuestMsrs.msr.TscAux = uValue;
1666 return VINF_SUCCESS;
1667}
1668
1669
1670/*
1671 * Intel specific
1672 * Intel specific
1673 * Intel specific
1674 */
1675
1676/** @callback_method_impl{FNCPUMRDMSR} */
1677static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelEblCrPowerOn(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1678{
1679 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1680 /** @todo recalc clock frequency ratio? */
1681 *puValue = pRange->uValue;
1682 return VINF_SUCCESS;
1683}
1684
1685
1686/** @callback_method_impl{FNCPUMWRMSR} */
1687static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelEblCrPowerOn(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1688{
1689 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1690 /** @todo Write EBL_CR_POWERON: Remember written bits. */
1691 return VINF_SUCCESS;
1692}
1693
1694
1695/** @callback_method_impl{FNCPUMRDMSR} */
1696static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7CoreThreadCount(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1697{
1698 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1699
1700 /* Note! According to cpuid_set_info in XNU (10.7.0), Westmere CPU only
1701 have a 4-bit core count. */
1702 uint16_t cCores = pVCpu->CTX_SUFF(pVM)->cCpus;
1703 uint16_t cThreads = cCores; /** @todo hyper-threading. */
1704 *puValue = RT_MAKE_U32(cThreads, cCores);
1705 return VINF_SUCCESS;
1706}
1707
1708
1709/** @callback_method_impl{FNCPUMRDMSR} */
1710static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelP4EbcHardPowerOn(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1711{
1712 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1713 /** @todo P4 hard power on config */
1714 *puValue = pRange->uValue;
1715 return VINF_SUCCESS;
1716}
1717
1718
1719/** @callback_method_impl{FNCPUMWRMSR} */
1720static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelP4EbcHardPowerOn(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1721{
1722 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1723 /** @todo P4 hard power on config */
1724 return VINF_SUCCESS;
1725}
1726
1727
1728/** @callback_method_impl{FNCPUMRDMSR} */
1729static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelP4EbcSoftPowerOn(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1730{
1731 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1732 /** @todo P4 soft power on config */
1733 *puValue = pRange->uValue;
1734 return VINF_SUCCESS;
1735}
1736
1737
1738/** @callback_method_impl{FNCPUMWRMSR} */
1739static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelP4EbcSoftPowerOn(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1740{
1741 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1742 /** @todo P4 soft power on config */
1743 return VINF_SUCCESS;
1744}
1745
1746
1747/** @callback_method_impl{FNCPUMRDMSR} */
1748static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelP4EbcFrequencyId(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1749{
1750 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1751
1752 uint64_t uValue;
1753 PVM pVM = pVCpu->CTX_SUFF(pVM);
1754 uint64_t uScalableBusHz = CPUMGetGuestScalableBusFrequency(pVM);
1755 if (pVM->cpum.s.GuestFeatures.uModel >= 2)
1756 {
1757 if (uScalableBusHz <= CPUM_SBUSFREQ_100MHZ && pVM->cpum.s.GuestFeatures.uModel <= 2)
1758 {
1759 uScalableBusHz = CPUM_SBUSFREQ_100MHZ;
1760 uValue = 0;
1761 }
1762 else if (uScalableBusHz <= CPUM_SBUSFREQ_133MHZ)
1763 {
1764 uScalableBusHz = CPUM_SBUSFREQ_133MHZ;
1765 uValue = 1;
1766 }
1767 else if (uScalableBusHz <= CPUM_SBUSFREQ_167MHZ)
1768 {
1769 uScalableBusHz = CPUM_SBUSFREQ_167MHZ;
1770 uValue = 3;
1771 }
1772 else if (uScalableBusHz <= CPUM_SBUSFREQ_200MHZ)
1773 {
1774 uScalableBusHz = CPUM_SBUSFREQ_200MHZ;
1775 uValue = 2;
1776 }
1777 else if (uScalableBusHz <= CPUM_SBUSFREQ_267MHZ && pVM->cpum.s.GuestFeatures.uModel > 2)
1778 {
1779 uScalableBusHz = CPUM_SBUSFREQ_267MHZ;
1780 uValue = 0;
1781 }
1782 else
1783 {
1784 uScalableBusHz = CPUM_SBUSFREQ_333MHZ;
1785 uValue = 6;
1786 }
1787 uValue <<= 16;
1788
1789 uint64_t uTscHz = TMCpuTicksPerSecond(pVM);
1790 uint8_t uTscRatio = (uint8_t)((uTscHz + uScalableBusHz / 2) / uScalableBusHz);
1791 uValue |= (uint32_t)uTscRatio << 24;
1792
1793 uValue |= pRange->uValue & ~UINT64_C(0xff0f0000);
1794 }
1795 else
1796 {
1797 /* Probably more stuff here, but intel doesn't want to tell us. */
1798 uValue = pRange->uValue;
1799 uValue &= ~(RT_BIT_64(21) | RT_BIT_64(22) | RT_BIT_64(23)); /* 100 MHz is only documented value */
1800 }
1801
1802 *puValue = uValue;
1803 return VINF_SUCCESS;
1804}
1805
1806
1807/** @callback_method_impl{FNCPUMWRMSR} */
1808static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelP4EbcFrequencyId(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1809{
1810 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1811 /** @todo P4 bus frequency config */
1812 return VINF_SUCCESS;
1813}
1814
1815
1816/** @callback_method_impl{FNCPUMRDMSR} */
1817static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelP6FsbFrequency(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1818{
1819 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1820
1821 /* Convert the scalable bus frequency to the encoding in the intel manual (for core+). */
1822 uint64_t uScalableBusHz = CPUMGetGuestScalableBusFrequency(pVCpu->CTX_SUFF(pVM));
1823 if (uScalableBusHz <= CPUM_SBUSFREQ_100MHZ)
1824 *puValue = 5;
1825 else if (uScalableBusHz <= CPUM_SBUSFREQ_133MHZ)
1826 *puValue = 1;
1827 else if (uScalableBusHz <= CPUM_SBUSFREQ_167MHZ)
1828 *puValue = 3;
1829 else if (uScalableBusHz <= CPUM_SBUSFREQ_200MHZ)
1830 *puValue = 2;
1831 else if (uScalableBusHz <= CPUM_SBUSFREQ_267MHZ)
1832 *puValue = 0;
1833 else if (uScalableBusHz <= CPUM_SBUSFREQ_333MHZ)
1834 *puValue = 4;
1835 else /*if (uScalableBusHz <= CPUM_SBUSFREQ_400MHZ)*/
1836 *puValue = 6;
1837
1838 *puValue |= pRange->uValue & ~UINT64_C(0x7);
1839
1840 return VINF_SUCCESS;
1841}
1842
1843
1844/** @callback_method_impl{FNCPUMRDMSR} */
1845static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelPlatformInfo(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1846{
1847 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1848
1849 /* Just indicate a fixed TSC, no turbo boost, no programmable anything. */
1850 PVM pVM = pVCpu->CTX_SUFF(pVM);
1851 uint64_t uScalableBusHz = CPUMGetGuestScalableBusFrequency(pVM);
1852 uint64_t uTscHz = TMCpuTicksPerSecond(pVM);
1853 uint8_t uTscRatio = (uint8_t)((uTscHz + uScalableBusHz / 2) / uScalableBusHz);
1854 uint64_t uValue = ((uint32_t)uTscRatio << 8) /* TSC invariant frequency. */
1855 | ((uint64_t)uTscRatio << 40); /* The max turbo frequency. */
1856
1857 /* Ivy bridge has a minimum operating ratio as well. */
1858 if (true) /** @todo detect sandy bridge. */
1859 uValue |= (uint64_t)uTscRatio << 48;
1860
1861 *puValue = uValue;
1862 return VINF_SUCCESS;
1863}
1864
1865
1866/** @callback_method_impl{FNCPUMRDMSR} */
1867static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelFlexRatio(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1868{
1869 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1870
1871 uint64_t uValue = pRange->uValue & ~UINT64_C(0x1ff00);
1872
1873 PVM pVM = pVCpu->CTX_SUFF(pVM);
1874 uint64_t uScalableBusHz = CPUMGetGuestScalableBusFrequency(pVM);
1875 uint64_t uTscHz = TMCpuTicksPerSecond(pVM);
1876 uint8_t uTscRatio = (uint8_t)((uTscHz + uScalableBusHz / 2) / uScalableBusHz);
1877 uValue |= (uint32_t)uTscRatio << 8;
1878
1879 *puValue = uValue;
1880 return VINF_SUCCESS;
1881}
1882
1883
1884/** @callback_method_impl{FNCPUMWRMSR} */
1885static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelFlexRatio(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1886{
1887 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1888 /** @todo implement writing MSR_FLEX_RATIO. */
1889 return VINF_SUCCESS;
1890}
1891
1892
1893/** @callback_method_impl{FNCPUMRDMSR} */
1894static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelPkgCStConfigControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1895{
1896 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1897 *puValue = pVCpu->cpum.s.GuestMsrs.msr.PkgCStateCfgCtrl;
1898 return VINF_SUCCESS;
1899}
1900
1901
1902/** @callback_method_impl{FNCPUMWRMSR} */
1903static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelPkgCStConfigControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1904{
1905 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1906
1907 if (pVCpu->cpum.s.GuestMsrs.msr.PkgCStateCfgCtrl & RT_BIT_64(15))
1908 {
1909 Log(("CPUM: WRMSR %#x (%s), %#llx: Write protected -> #GP\n", idMsr, pRange->szName, uValue));
1910 return VERR_CPUM_RAISE_GP_0;
1911 }
1912#if 0 /** @todo check what real (old) hardware does. */
1913 if ((uValue & 7) >= 5)
1914 {
1915 Log(("CPUM: WRMSR %#x (%s), %#llx: Invalid limit (%d) -> #GP\n", idMsr, pRange->szName, uValue, (uint32_t)(uValue & 7)));
1916 return VERR_CPUM_RAISE_GP_0;
1917 }
1918#endif
1919 pVCpu->cpum.s.GuestMsrs.msr.PkgCStateCfgCtrl = uValue;
1920 return VINF_SUCCESS;
1921}
1922
1923
1924/** @callback_method_impl{FNCPUMRDMSR} */
1925static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelPmgIoCaptureBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1926{
1927 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1928 /** @todo implement I/O mwait wakeup. */
1929 *puValue = 0;
1930 return VINF_SUCCESS;
1931}
1932
1933
1934/** @callback_method_impl{FNCPUMWRMSR} */
1935static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelPmgIoCaptureBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1936{
1937 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1938 /** @todo implement I/O mwait wakeup. */
1939 return VINF_SUCCESS;
1940}
1941
1942
1943/** @callback_method_impl{FNCPUMRDMSR} */
1944static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelLastBranchFromToN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1945{
1946 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1947 /** @todo implement last branch records. */
1948 *puValue = 0;
1949 return VINF_SUCCESS;
1950}
1951
1952
1953/** @callback_method_impl{FNCPUMWRMSR} */
1954static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelLastBranchFromToN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1955{
1956 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
1957 /** @todo implement last branch records. */
1958 return VINF_SUCCESS;
1959}
1960
1961
1962/** @callback_method_impl{FNCPUMRDMSR} */
1963static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelLastBranchFromN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1964{
1965 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1966 /** @todo implement last branch records. */
1967 *puValue = 0;
1968 return VINF_SUCCESS;
1969}
1970
1971
1972/** @callback_method_impl{FNCPUMWRMSR} */
1973static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelLastBranchFromN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
1974{
1975 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
1976 /** @todo implement last branch records. */
1977 /** @todo Probing indicates that bit 63 is settable on SandyBridge, at least
1978 * if the rest of the bits are zero. Automatic sign extending?
1979 * Investigate! */
1980 if (!X86_IS_CANONICAL(uValue))
1981 {
1982 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue));
1983 return VERR_CPUM_RAISE_GP_0;
1984 }
1985 return VINF_SUCCESS;
1986}
1987
1988
1989/** @callback_method_impl{FNCPUMRDMSR} */
1990static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelLastBranchToN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
1991{
1992 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
1993 /** @todo implement last branch records. */
1994 *puValue = 0;
1995 return VINF_SUCCESS;
1996}
1997
1998
1999/** @callback_method_impl{FNCPUMWRMSR} */
2000static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelLastBranchToN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2001{
2002 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2003 /** @todo implement last branch records. */
2004 /** @todo Probing indicates that bit 63 is settable on SandyBridge, at least
2005 * if the rest of the bits are zero. Automatic sign extending?
2006 * Investigate! */
2007 if (!X86_IS_CANONICAL(uValue))
2008 {
2009 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue));
2010 return VERR_CPUM_RAISE_GP_0;
2011 }
2012 return VINF_SUCCESS;
2013}
2014
2015
2016/** @callback_method_impl{FNCPUMRDMSR} */
2017static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelLastBranchTos(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2018{
2019 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2020 /** @todo implement last branch records. */
2021 *puValue = 0;
2022 return VINF_SUCCESS;
2023}
2024
2025
2026/** @callback_method_impl{FNCPUMWRMSR} */
2027static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelLastBranchTos(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2028{
2029 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2030 /** @todo implement last branch records. */
2031 return VINF_SUCCESS;
2032}
2033
2034
2035/** @callback_method_impl{FNCPUMRDMSR} */
2036static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelBblCrCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2037{
2038 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2039 *puValue = pRange->uValue;
2040 return VINF_SUCCESS;
2041}
2042
2043
2044/** @callback_method_impl{FNCPUMWRMSR} */
2045static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelBblCrCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2046{
2047 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2048 return VINF_SUCCESS;
2049}
2050
2051
2052/** @callback_method_impl{FNCPUMRDMSR} */
2053static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelBblCrCtl3(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2054{
2055 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2056 *puValue = pRange->uValue;
2057 return VINF_SUCCESS;
2058}
2059
2060
2061/** @callback_method_impl{FNCPUMWRMSR} */
2062static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelBblCrCtl3(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2063{
2064 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2065 return VINF_SUCCESS;
2066}
2067
2068
2069/** @callback_method_impl{FNCPUMRDMSR} */
2070static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7TemperatureTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2071{
2072 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2073 *puValue = pRange->uValue;
2074 return VINF_SUCCESS;
2075}
2076
2077
2078/** @callback_method_impl{FNCPUMWRMSR} */
2079static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7TemperatureTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2080{
2081 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2082 return VINF_SUCCESS;
2083}
2084
2085
2086/** @callback_method_impl{FNCPUMRDMSR} */
2087static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7MsrOffCoreResponseN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2088{
2089 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2090 /** @todo machine check. */
2091 *puValue = pRange->uValue;
2092 return VINF_SUCCESS;
2093}
2094
2095
2096/** @callback_method_impl{FNCPUMWRMSR} */
2097static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7MsrOffCoreResponseN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2098{
2099 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2100 /** @todo machine check. */
2101 return VINF_SUCCESS;
2102}
2103
2104
2105/** @callback_method_impl{FNCPUMRDMSR} */
2106static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7MiscPwrMgmt(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2107{
2108 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2109 *puValue = 0;
2110 return VINF_SUCCESS;
2111}
2112
2113
2114/** @callback_method_impl{FNCPUMWRMSR} */
2115static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7MiscPwrMgmt(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2116{
2117 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2118 return VINF_SUCCESS;
2119}
2120
2121
2122/** @callback_method_impl{FNCPUMRDMSR} */
2123static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelP6CrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2124{
2125 RT_NOREF_PV(idMsr);
2126 int rc = CPUMGetGuestCRx(pVCpu, pRange->uValue, puValue);
2127 AssertRC(rc);
2128 return VINF_SUCCESS;
2129}
2130
2131
2132/** @callback_method_impl{FNCPUMWRMSR} */
2133static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelP6CrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2134{
2135 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2136 /* This CRx interface differs from the MOV CRx, GReg interface in that
2137 #GP(0) isn't raised if unsupported bits are written to. Instead they
2138 are simply ignored and masked off. (Pentium M Dothan) */
2139 /** @todo Implement MSR_P6_CRx writing. Too much effort for very little, if
2140 * any, gain. */
2141 return VINF_SUCCESS;
2142}
2143
2144
2145/** @callback_method_impl{FNCPUMRDMSR} */
2146static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelCpuId1FeatureMaskEcdx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2147{
2148 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2149 /** @todo implement CPUID masking. */
2150 *puValue = UINT64_MAX;
2151 return VINF_SUCCESS;
2152}
2153
2154
2155/** @callback_method_impl{FNCPUMWRMSR} */
2156static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelCpuId1FeatureMaskEcdx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2157{
2158 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2159 /** @todo implement CPUID masking. */
2160 return VINF_SUCCESS;
2161}
2162
2163
2164/** @callback_method_impl{FNCPUMRDMSR} */
2165static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelCpuId1FeatureMaskEax(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2166{
2167 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2168 /** @todo implement CPUID masking. */
2169 *puValue = 0;
2170 return VINF_SUCCESS;
2171}
2172
2173
2174/** @callback_method_impl{FNCPUMWRMSR} */
2175static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelCpuId1FeatureMaskEax(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2176{
2177 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2178 /** @todo implement CPUID masking. */
2179 return VINF_SUCCESS;
2180}
2181
2182
2183
2184/** @callback_method_impl{FNCPUMRDMSR} */
2185static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelCpuId80000001FeatureMaskEcdx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2186{
2187 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2188 /** @todo implement CPUID masking. */
2189 *puValue = UINT64_MAX;
2190 return VINF_SUCCESS;
2191}
2192
2193
2194/** @callback_method_impl{FNCPUMWRMSR} */
2195static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelCpuId80000001FeatureMaskEcdx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2196{
2197 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2198 /** @todo implement CPUID masking. */
2199 return VINF_SUCCESS;
2200}
2201
2202
2203
2204/** @callback_method_impl{FNCPUMRDMSR} */
2205static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7SandyAesNiCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2206{
2207 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2208 /** @todo implement AES-NI. */
2209 *puValue = 3; /* Bit 0 is lock bit, bit 1 disables AES-NI. That's what they say. */
2210 return VINF_SUCCESS;
2211}
2212
2213
2214/** @callback_method_impl{FNCPUMWRMSR} */
2215static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7SandyAesNiCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2216{
2217 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2218 /** @todo implement AES-NI. */
2219 return VERR_CPUM_RAISE_GP_0;
2220}
2221
2222
2223/** @callback_method_impl{FNCPUMRDMSR} */
2224static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7TurboRatioLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2225{
2226 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2227 /** @todo implement intel C states. */
2228 *puValue = pRange->uValue;
2229 return VINF_SUCCESS;
2230}
2231
2232
2233/** @callback_method_impl{FNCPUMWRMSR} */
2234static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7TurboRatioLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2235{
2236 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2237 /** @todo implement intel C states. */
2238 return VINF_SUCCESS;
2239}
2240
2241
2242/** @callback_method_impl{FNCPUMRDMSR} */
2243static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7LbrSelect(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2244{
2245 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2246 /** @todo implement last-branch-records. */
2247 *puValue = 0;
2248 return VINF_SUCCESS;
2249}
2250
2251
2252/** @callback_method_impl{FNCPUMWRMSR} */
2253static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7LbrSelect(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2254{
2255 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2256 /** @todo implement last-branch-records. */
2257 return VINF_SUCCESS;
2258}
2259
2260
2261/** @callback_method_impl{FNCPUMRDMSR} */
2262static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7SandyErrorControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2263{
2264 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2265 /** @todo implement memory error injection (MSR_ERROR_CONTROL). */
2266 *puValue = 0;
2267 return VINF_SUCCESS;
2268}
2269
2270
2271/** @callback_method_impl{FNCPUMWRMSR} */
2272static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7SandyErrorControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2273{
2274 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2275 /** @todo implement memory error injection (MSR_ERROR_CONTROL). */
2276 return VINF_SUCCESS;
2277}
2278
2279
2280/** @callback_method_impl{FNCPUMRDMSR} */
2281static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7VirtualLegacyWireCap(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2282{
2283 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2284 /** @todo implement memory VLW? */
2285 *puValue = pRange->uValue;
2286 /* Note: A20M is known to be bit 1 as this was disclosed in spec update
2287 AAJ49/AAK51/????, which documents the inversion of this bit. The
2288 Sandy bridge CPU here has value 0x74, so it probably doesn't have a BIOS
2289 that correct things. Some guesses at the other bits:
2290 bit 2 = INTR
2291 bit 4 = SMI
2292 bit 5 = INIT
2293 bit 6 = NMI */
2294 return VINF_SUCCESS;
2295}
2296
2297
2298/** @callback_method_impl{FNCPUMRDMSR} */
2299static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7PowerCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2300{
2301 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2302 /** @todo intel power management */
2303 *puValue = 0;
2304 return VINF_SUCCESS;
2305}
2306
2307
2308/** @callback_method_impl{FNCPUMWRMSR} */
2309static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7PowerCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2310{
2311 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2312 /** @todo intel power management */
2313 return VINF_SUCCESS;
2314}
2315
2316
2317/** @callback_method_impl{FNCPUMRDMSR} */
2318static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7SandyPebsNumAlt(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2319{
2320 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2321 /** @todo intel performance counters. */
2322 *puValue = 0;
2323 return VINF_SUCCESS;
2324}
2325
2326
2327/** @callback_method_impl{FNCPUMWRMSR} */
2328static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7SandyPebsNumAlt(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2329{
2330 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2331 /** @todo intel performance counters. */
2332 return VINF_SUCCESS;
2333}
2334
2335
2336/** @callback_method_impl{FNCPUMRDMSR} */
2337static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7PebsLdLat(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2338{
2339 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2340 /** @todo intel performance counters. */
2341 *puValue = 0;
2342 return VINF_SUCCESS;
2343}
2344
2345
2346/** @callback_method_impl{FNCPUMWRMSR} */
2347static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7PebsLdLat(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2348{
2349 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2350 /** @todo intel performance counters. */
2351 return VINF_SUCCESS;
2352}
2353
2354
2355/** @callback_method_impl{FNCPUMRDMSR} */
2356static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7PkgCnResidencyN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2357{
2358 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2359 /** @todo intel power management. */
2360 *puValue = 0;
2361 return VINF_SUCCESS;
2362}
2363
2364
2365/** @callback_method_impl{FNCPUMRDMSR} */
2366static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7CoreCnResidencyN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2367{
2368 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2369 /** @todo intel power management. */
2370 *puValue = 0;
2371 return VINF_SUCCESS;
2372}
2373
2374
2375/** @callback_method_impl{FNCPUMRDMSR} */
2376static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7SandyVrCurrentConfig(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2377{
2378 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2379 /** @todo Figure out what MSR_VR_CURRENT_CONFIG & MSR_VR_MISC_CONFIG are. */
2380 *puValue = 0;
2381 return VINF_SUCCESS;
2382}
2383
2384
2385/** @callback_method_impl{FNCPUMWRMSR} */
2386static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7SandyVrCurrentConfig(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2387{
2388 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2389 /** @todo Figure out what MSR_VR_CURRENT_CONFIG & MSR_VR_MISC_CONFIG are. */
2390 return VINF_SUCCESS;
2391}
2392
2393
2394/** @callback_method_impl{FNCPUMRDMSR} */
2395static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7SandyVrMiscConfig(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2396{
2397 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2398 /** @todo Figure out what MSR_VR_CURRENT_CONFIG & MSR_VR_MISC_CONFIG are. */
2399 *puValue = 0;
2400 return VINF_SUCCESS;
2401}
2402
2403
2404/** @callback_method_impl{FNCPUMWRMSR} */
2405static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7SandyVrMiscConfig(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2406{
2407 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2408 /** @todo Figure out what MSR_VR_CURRENT_CONFIG & MSR_VR_MISC_CONFIG are. */
2409 return VINF_SUCCESS;
2410}
2411
2412
2413/** @callback_method_impl{FNCPUMRDMSR} */
2414static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7SandyRaplPowerUnit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2415{
2416 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2417 /** @todo intel RAPL. */
2418 *puValue = pRange->uValue;
2419 return VINF_SUCCESS;
2420}
2421
2422
2423/** @callback_method_impl{FNCPUMWRMSR} */
2424static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7SandyRaplPowerUnit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2425{
2426 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2427 /* Note! This is documented as read only and except for a Silvermont sample has
2428 always been classified as read only. This is just here to make it compile. */
2429 return VINF_SUCCESS;
2430}
2431
2432
2433/** @callback_method_impl{FNCPUMRDMSR} */
2434static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7SandyPkgCnIrtlN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2435{
2436 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2437 /** @todo intel power management. */
2438 *puValue = 0;
2439 return VINF_SUCCESS;
2440}
2441
2442
2443/** @callback_method_impl{FNCPUMWRMSR} */
2444static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7SandyPkgCnIrtlN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2445{
2446 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2447 /** @todo intel power management. */
2448 return VINF_SUCCESS;
2449}
2450
2451
2452/** @callback_method_impl{FNCPUMRDMSR} */
2453static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7SandyPkgC2Residency(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2454{
2455 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2456 /** @todo intel power management. */
2457 *puValue = 0;
2458 return VINF_SUCCESS;
2459}
2460
2461
2462/** @callback_method_impl{FNCPUMWRMSR} */
2463static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7SandyPkgC2Residency(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2464{
2465 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2466 /* Note! This is documented as read only and except for a Silvermont sample has
2467 always been classified as read only. This is just here to make it compile. */
2468 return VINF_SUCCESS;
2469}
2470
2471
2472/** @callback_method_impl{FNCPUMRDMSR} */
2473static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPkgPowerLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2474{
2475 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2476 /** @todo intel RAPL. */
2477 *puValue = 0;
2478 return VINF_SUCCESS;
2479}
2480
2481
2482/** @callback_method_impl{FNCPUMWRMSR} */
2483static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7RaplPkgPowerLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2484{
2485 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2486 /** @todo intel RAPL. */
2487 return VINF_SUCCESS;
2488}
2489
2490
2491/** @callback_method_impl{FNCPUMRDMSR} */
2492static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPkgEnergyStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2493{
2494 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2495 /** @todo intel power management. */
2496 *puValue = 0;
2497 return VINF_SUCCESS;
2498}
2499
2500
2501/** @callback_method_impl{FNCPUMRDMSR} */
2502static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPkgPerfStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2503{
2504 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2505 /** @todo intel power management. */
2506 *puValue = 0;
2507 return VINF_SUCCESS;
2508}
2509
2510
2511/** @callback_method_impl{FNCPUMRDMSR} */
2512static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPkgPowerInfo(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2513{
2514 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2515 /** @todo intel power management. */
2516 *puValue = 0;
2517 return VINF_SUCCESS;
2518}
2519
2520
2521/** @callback_method_impl{FNCPUMRDMSR} */
2522static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplDramPowerLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2523{
2524 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2525 /** @todo intel RAPL. */
2526 *puValue = 0;
2527 return VINF_SUCCESS;
2528}
2529
2530
2531/** @callback_method_impl{FNCPUMWRMSR} */
2532static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7RaplDramPowerLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2533{
2534 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2535 /** @todo intel RAPL. */
2536 return VINF_SUCCESS;
2537}
2538
2539
2540/** @callback_method_impl{FNCPUMRDMSR} */
2541static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplDramEnergyStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2542{
2543 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2544 /** @todo intel power management. */
2545 *puValue = 0;
2546 return VINF_SUCCESS;
2547}
2548
2549
2550/** @callback_method_impl{FNCPUMRDMSR} */
2551static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplDramPerfStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2552{
2553 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2554 /** @todo intel power management. */
2555 *puValue = 0;
2556 return VINF_SUCCESS;
2557}
2558
2559
2560/** @callback_method_impl{FNCPUMRDMSR} */
2561static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplDramPowerInfo(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2562{
2563 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2564 /** @todo intel power management. */
2565 *puValue = 0;
2566 return VINF_SUCCESS;
2567}
2568
2569
2570/** @callback_method_impl{FNCPUMRDMSR} */
2571static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPp0PowerLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2572{
2573 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2574 /** @todo intel RAPL. */
2575 *puValue = 0;
2576 return VINF_SUCCESS;
2577}
2578
2579
2580/** @callback_method_impl{FNCPUMWRMSR} */
2581static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7RaplPp0PowerLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2582{
2583 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2584 /** @todo intel RAPL. */
2585 return VINF_SUCCESS;
2586}
2587
2588
2589/** @callback_method_impl{FNCPUMRDMSR} */
2590static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPp0EnergyStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2591{
2592 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2593 /** @todo intel power management. */
2594 *puValue = 0;
2595 return VINF_SUCCESS;
2596}
2597
2598
2599/** @callback_method_impl{FNCPUMRDMSR} */
2600static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPp0Policy(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2601{
2602 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2603 /** @todo intel RAPL. */
2604 *puValue = 0;
2605 return VINF_SUCCESS;
2606}
2607
2608
2609/** @callback_method_impl{FNCPUMWRMSR} */
2610static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7RaplPp0Policy(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2611{
2612 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2613 /** @todo intel RAPL. */
2614 return VINF_SUCCESS;
2615}
2616
2617
2618/** @callback_method_impl{FNCPUMRDMSR} */
2619static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPp0PerfStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2620{
2621 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2622 /** @todo intel power management. */
2623 *puValue = 0;
2624 return VINF_SUCCESS;
2625}
2626
2627
2628/** @callback_method_impl{FNCPUMRDMSR} */
2629static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPp1PowerLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2630{
2631 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2632 /** @todo intel RAPL. */
2633 *puValue = 0;
2634 return VINF_SUCCESS;
2635}
2636
2637
2638/** @callback_method_impl{FNCPUMWRMSR} */
2639static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7RaplPp1PowerLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2640{
2641 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2642 /** @todo intel RAPL. */
2643 return VINF_SUCCESS;
2644}
2645
2646
2647/** @callback_method_impl{FNCPUMRDMSR} */
2648static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPp1EnergyStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2649{
2650 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2651 /** @todo intel power management. */
2652 *puValue = 0;
2653 return VINF_SUCCESS;
2654}
2655
2656
2657/** @callback_method_impl{FNCPUMRDMSR} */
2658static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7RaplPp1Policy(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2659{
2660 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2661 /** @todo intel RAPL. */
2662 *puValue = 0;
2663 return VINF_SUCCESS;
2664}
2665
2666
2667/** @callback_method_impl{FNCPUMWRMSR} */
2668static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7RaplPp1Policy(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2669{
2670 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2671 /** @todo intel RAPL. */
2672 return VINF_SUCCESS;
2673}
2674
2675
2676/** @callback_method_impl{FNCPUMRDMSR} */
2677static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7IvyConfigTdpNominal(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2678{
2679 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2680 /** @todo intel power management. */
2681 *puValue = pRange->uValue;
2682 return VINF_SUCCESS;
2683}
2684
2685
2686/** @callback_method_impl{FNCPUMRDMSR} */
2687static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7IvyConfigTdpLevel1(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2688{
2689 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2690 /** @todo intel power management. */
2691 *puValue = pRange->uValue;
2692 return VINF_SUCCESS;
2693}
2694
2695
2696/** @callback_method_impl{FNCPUMRDMSR} */
2697static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7IvyConfigTdpLevel2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2698{
2699 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2700 /** @todo intel power management. */
2701 *puValue = pRange->uValue;
2702 return VINF_SUCCESS;
2703}
2704
2705
2706/** @callback_method_impl{FNCPUMRDMSR} */
2707static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7IvyConfigTdpControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2708{
2709 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2710 /** @todo intel power management. */
2711 *puValue = 0;
2712 return VINF_SUCCESS;
2713}
2714
2715
2716/** @callback_method_impl{FNCPUMWRMSR} */
2717static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7IvyConfigTdpControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2718{
2719 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2720 /** @todo intel power management. */
2721 return VINF_SUCCESS;
2722}
2723
2724
2725/** @callback_method_impl{FNCPUMRDMSR} */
2726static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7IvyTurboActivationRatio(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2727{
2728 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2729 /** @todo intel power management. */
2730 *puValue = 0;
2731 return VINF_SUCCESS;
2732}
2733
2734
2735/** @callback_method_impl{FNCPUMWRMSR} */
2736static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7IvyTurboActivationRatio(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2737{
2738 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2739 /** @todo intel power management. */
2740 return VINF_SUCCESS;
2741}
2742
2743
2744/** @callback_method_impl{FNCPUMRDMSR} */
2745static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7UncPerfGlobalCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2746{
2747 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2748 /** @todo uncore msrs. */
2749 *puValue = 0;
2750 return VINF_SUCCESS;
2751}
2752
2753
2754/** @callback_method_impl{FNCPUMWRMSR} */
2755static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7UncPerfGlobalCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2756{
2757 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2758 /** @todo uncore msrs. */
2759 return VINF_SUCCESS;
2760}
2761
2762
2763/** @callback_method_impl{FNCPUMRDMSR} */
2764static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7UncPerfGlobalStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2765{
2766 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2767 /** @todo uncore msrs. */
2768 *puValue = 0;
2769 return VINF_SUCCESS;
2770}
2771
2772
2773/** @callback_method_impl{FNCPUMWRMSR} */
2774static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7UncPerfGlobalStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2775{
2776 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2777 /** @todo uncore msrs. */
2778 return VINF_SUCCESS;
2779}
2780
2781
2782/** @callback_method_impl{FNCPUMRDMSR} */
2783static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7UncPerfGlobalOvfCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2784{
2785 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2786 /** @todo uncore msrs. */
2787 *puValue = 0;
2788 return VINF_SUCCESS;
2789}
2790
2791
2792/** @callback_method_impl{FNCPUMWRMSR} */
2793static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7UncPerfGlobalOvfCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2794{
2795 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2796 /** @todo uncore msrs. */
2797 return VINF_SUCCESS;
2798}
2799
2800
2801/** @callback_method_impl{FNCPUMRDMSR} */
2802static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7UncPerfFixedCtrCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2803{
2804 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2805 /** @todo uncore msrs. */
2806 *puValue = 0;
2807 return VINF_SUCCESS;
2808}
2809
2810
2811/** @callback_method_impl{FNCPUMWRMSR} */
2812static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7UncPerfFixedCtrCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2813{
2814 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2815 /** @todo uncore msrs. */
2816 return VINF_SUCCESS;
2817}
2818
2819
2820/** @callback_method_impl{FNCPUMRDMSR} */
2821static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7UncPerfFixedCtr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2822{
2823 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2824 /** @todo uncore msrs. */
2825 *puValue = 0;
2826 return VINF_SUCCESS;
2827}
2828
2829
2830/** @callback_method_impl{FNCPUMWRMSR} */
2831static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7UncPerfFixedCtr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2832{
2833 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2834 /** @todo uncore msrs. */
2835 return VINF_SUCCESS;
2836}
2837
2838
2839/** @callback_method_impl{FNCPUMRDMSR} */
2840static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7UncCBoxConfig(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2841{
2842 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2843 /** @todo uncore msrs. */
2844 *puValue = 0;
2845 return VINF_SUCCESS;
2846}
2847
2848
2849/** @callback_method_impl{FNCPUMRDMSR} */
2850static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7UncArbPerfCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2851{
2852 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2853 /** @todo uncore msrs. */
2854 *puValue = 0;
2855 return VINF_SUCCESS;
2856}
2857
2858
2859/** @callback_method_impl{FNCPUMWRMSR} */
2860static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7UncArbPerfCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2861{
2862 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2863 /** @todo uncore msrs. */
2864 return VINF_SUCCESS;
2865}
2866
2867
2868/** @callback_method_impl{FNCPUMRDMSR} */
2869static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7UncArbPerfEvtSelN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2870{
2871 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2872 /** @todo uncore msrs. */
2873 *puValue = 0;
2874 return VINF_SUCCESS;
2875}
2876
2877
2878/** @callback_method_impl{FNCPUMWRMSR} */
2879static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelI7UncArbPerfEvtSelN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2880{
2881 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2882 /** @todo uncore msrs. */
2883 return VINF_SUCCESS;
2884}
2885
2886
2887/** @callback_method_impl{FNCPUMRDMSR} */
2888static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelI7SmiCount(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2889{
2890 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2891
2892 /*
2893 * 31:0 is SMI count (read only), 63:32 reserved.
2894 * Since we don't do SMI, the count is always zero.
2895 */
2896 *puValue = 0;
2897 return VINF_SUCCESS;
2898}
2899
2900
2901/** @callback_method_impl{FNCPUMRDMSR} */
2902static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelCore2EmttmCrTablesN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2903{
2904 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2905 /** @todo implement enhanced multi thread termal monitoring? */
2906 *puValue = pRange->uValue;
2907 return VINF_SUCCESS;
2908}
2909
2910
2911/** @callback_method_impl{FNCPUMWRMSR} */
2912static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelCore2EmttmCrTablesN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2913{
2914 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2915 /** @todo implement enhanced multi thread termal monitoring? */
2916 return VINF_SUCCESS;
2917}
2918
2919
2920/** @callback_method_impl{FNCPUMRDMSR} */
2921static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelCore2SmmCStMiscInfo(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2922{
2923 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2924 /** @todo SMM & C-states? */
2925 *puValue = 0;
2926 return VINF_SUCCESS;
2927}
2928
2929
2930/** @callback_method_impl{FNCPUMWRMSR} */
2931static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelCore2SmmCStMiscInfo(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2932{
2933 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2934 /** @todo SMM & C-states? */
2935 return VINF_SUCCESS;
2936}
2937
2938
2939/** @callback_method_impl{FNCPUMRDMSR} */
2940static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelCore1ExtConfig(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2941{
2942 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2943 /** @todo Core1&2 EXT_CONFIG (whatever that is)? */
2944 *puValue = 0;
2945 return VINF_SUCCESS;
2946}
2947
2948
2949/** @callback_method_impl{FNCPUMWRMSR} */
2950static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelCore1ExtConfig(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2951{
2952 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2953 /** @todo Core1&2 EXT_CONFIG (whatever that is)? */
2954 return VINF_SUCCESS;
2955}
2956
2957
2958/** @callback_method_impl{FNCPUMRDMSR} */
2959static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelCore1DtsCalControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2960{
2961 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2962 /** @todo Core1&2(?) DTS_CAL_CTRL (whatever that is)? */
2963 *puValue = 0;
2964 return VINF_SUCCESS;
2965}
2966
2967
2968/** @callback_method_impl{FNCPUMWRMSR} */
2969static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelCore1DtsCalControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2970{
2971 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2972 /** @todo Core1&2(?) DTS_CAL_CTRL (whatever that is)? */
2973 return VINF_SUCCESS;
2974}
2975
2976
2977/** @callback_method_impl{FNCPUMRDMSR} */
2978static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelCore2PeciControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2979{
2980 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
2981 /** @todo Core2+ platform environment control interface control register? */
2982 *puValue = 0;
2983 return VINF_SUCCESS;
2984}
2985
2986
2987/** @callback_method_impl{FNCPUMWRMSR} */
2988static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_IntelCore2PeciControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
2989{
2990 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
2991 /** @todo Core2+ platform environment control interface control register? */
2992 return VINF_SUCCESS;
2993}
2994
2995
2996/** @callback_method_impl{FNCPUMRDMSR} */
2997static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_IntelAtSilvCoreC1Recidency(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
2998{
2999 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3000 *puValue = 0;
3001 return VINF_SUCCESS;
3002}
3003
3004
3005/*
3006 * Multiple vendor P6 MSRs.
3007 * Multiple vendor P6 MSRs.
3008 * Multiple vendor P6 MSRs.
3009 *
3010 * These MSRs were introduced with the P6 but not elevated to architectural
3011 * MSRs, despite other vendors implementing them.
3012 */
3013
3014
3015/** @callback_method_impl{FNCPUMRDMSR} */
3016static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_P6LastBranchFromIp(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3017{
3018 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3019 /* AMD seems to just record RIP, while intel claims to record RIP+CS.BASE
3020 if I read the docs correctly, thus the need for separate functions. */
3021 /** @todo implement last branch records. */
3022 *puValue = 0;
3023 return VINF_SUCCESS;
3024}
3025
3026
3027/** @callback_method_impl{FNCPUMRDMSR} */
3028static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_P6LastBranchToIp(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3029{
3030 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3031 /** @todo implement last branch records. */
3032 *puValue = 0;
3033 return VINF_SUCCESS;
3034}
3035
3036
3037/** @callback_method_impl{FNCPUMRDMSR} */
3038static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_P6LastIntFromIp(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3039{
3040 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3041 /** @todo implement last exception records. */
3042 *puValue = 0;
3043 return VINF_SUCCESS;
3044}
3045
3046
3047/** @callback_method_impl{FNCPUMWRMSR} */
3048static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_P6LastIntFromIp(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3049{
3050 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3051 /** @todo implement last exception records. */
3052 /* Note! On many CPUs, the high bit of the 0x000001dd register is always writable, even when the result is
3053 a non-cannonical address. */
3054 return VINF_SUCCESS;
3055}
3056
3057
3058/** @callback_method_impl{FNCPUMRDMSR} */
3059static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_P6LastIntToIp(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3060{
3061 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3062 /** @todo implement last exception records. */
3063 *puValue = 0;
3064 return VINF_SUCCESS;
3065}
3066
3067
3068/** @callback_method_impl{FNCPUMWRMSR} */
3069static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_P6LastIntToIp(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3070{
3071 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3072 /** @todo implement last exception records. */
3073 return VINF_SUCCESS;
3074}
3075
3076
3077
3078/*
3079 * AMD specific
3080 * AMD specific
3081 * AMD specific
3082 */
3083
3084
3085/** @callback_method_impl{FNCPUMRDMSR} */
3086static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hTscRate(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3087{
3088 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3089 /** @todo Implement TscRateMsr */
3090 *puValue = RT_MAKE_U64(0, 1); /* 1.0 = reset value. */
3091 return VINF_SUCCESS;
3092}
3093
3094
3095/** @callback_method_impl{FNCPUMWRMSR} */
3096static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hTscRate(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3097{
3098 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3099 /** @todo Implement TscRateMsr */
3100 return VINF_SUCCESS;
3101}
3102
3103
3104/** @callback_method_impl{FNCPUMRDMSR} */
3105static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hLwpCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3106{
3107 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3108 /** @todo Implement AMD LWP? (Instructions: LWPINS, LWPVAL, LLWPCB, SLWPCB) */
3109 /* Note: Only listes in BKDG for Family 15H. */
3110 *puValue = 0;
3111 return VINF_SUCCESS;
3112}
3113
3114
3115/** @callback_method_impl{FNCPUMWRMSR} */
3116static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hLwpCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3117{
3118 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3119 /** @todo Implement AMD LWP? (Instructions: LWPINS, LWPVAL, LLWPCB, SLWPCB) */
3120 return VINF_SUCCESS;
3121}
3122
3123
3124/** @callback_method_impl{FNCPUMRDMSR} */
3125static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hLwpCbAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3126{
3127 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3128 /** @todo Implement AMD LWP? (Instructions: LWPINS, LWPVAL, LLWPCB, SLWPCB) */
3129 /* Note: Only listes in BKDG for Family 15H. */
3130 *puValue = 0;
3131 return VINF_SUCCESS;
3132}
3133
3134
3135/** @callback_method_impl{FNCPUMWRMSR} */
3136static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hLwpCbAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3137{
3138 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3139 /** @todo Implement AMD LWP? (Instructions: LWPINS, LWPVAL, LLWPCB, SLWPCB) */
3140 return VINF_SUCCESS;
3141}
3142
3143
3144/** @callback_method_impl{FNCPUMRDMSR} */
3145static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hMc4MiscN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3146{
3147 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3148 /** @todo machine check. */
3149 *puValue = 0;
3150 return VINF_SUCCESS;
3151}
3152
3153
3154/** @callback_method_impl{FNCPUMWRMSR} */
3155static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hMc4MiscN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3156{
3157 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3158 /** @todo machine check. */
3159 return VINF_SUCCESS;
3160}
3161
3162
3163/** @callback_method_impl{FNCPUMRDMSR} */
3164static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8PerfCtlN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3165{
3166 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3167 /** @todo AMD performance events. */
3168 *puValue = 0;
3169 return VINF_SUCCESS;
3170}
3171
3172
3173/** @callback_method_impl{FNCPUMWRMSR} */
3174static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8PerfCtlN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3175{
3176 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3177 /** @todo AMD performance events. */
3178 return VINF_SUCCESS;
3179}
3180
3181
3182/** @callback_method_impl{FNCPUMRDMSR} */
3183static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8PerfCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3184{
3185 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3186 /** @todo AMD performance events. */
3187 *puValue = 0;
3188 return VINF_SUCCESS;
3189}
3190
3191
3192/** @callback_method_impl{FNCPUMWRMSR} */
3193static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8PerfCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3194{
3195 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3196 /** @todo AMD performance events. */
3197 return VINF_SUCCESS;
3198}
3199
3200
3201/** @callback_method_impl{FNCPUMRDMSR} */
3202static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8SysCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3203{
3204 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3205 /** @todo AMD SYS_CFG */
3206 *puValue = pRange->uValue;
3207 return VINF_SUCCESS;
3208}
3209
3210
3211/** @callback_method_impl{FNCPUMWRMSR} */
3212static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8SysCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3213{
3214 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3215 /** @todo AMD SYS_CFG */
3216 return VINF_SUCCESS;
3217}
3218
3219
3220/** @callback_method_impl{FNCPUMRDMSR} */
3221static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8HwCr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3222{
3223 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3224 /** @todo AMD HW_CFG */
3225 *puValue = 0;
3226 return VINF_SUCCESS;
3227}
3228
3229
3230/** @callback_method_impl{FNCPUMWRMSR} */
3231static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8HwCr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3232{
3233 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3234 /** @todo AMD HW_CFG */
3235 return VINF_SUCCESS;
3236}
3237
3238
3239/** @callback_method_impl{FNCPUMRDMSR} */
3240static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8IorrBaseN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3241{
3242 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3243 /** @todo AMD IorrMask/IorrBase */
3244 *puValue = 0;
3245 return VINF_SUCCESS;
3246}
3247
3248
3249/** @callback_method_impl{FNCPUMWRMSR} */
3250static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8IorrBaseN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3251{
3252 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3253 /** @todo AMD IorrMask/IorrBase */
3254 return VINF_SUCCESS;
3255}
3256
3257
3258/** @callback_method_impl{FNCPUMRDMSR} */
3259static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8IorrMaskN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3260{
3261 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3262 /** @todo AMD IorrMask/IorrBase */
3263 *puValue = 0;
3264 return VINF_SUCCESS;
3265}
3266
3267
3268/** @callback_method_impl{FNCPUMWRMSR} */
3269static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8IorrMaskN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3270{
3271 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3272 /** @todo AMD IorrMask/IorrBase */
3273 return VINF_SUCCESS;
3274}
3275
3276
3277/** @callback_method_impl{FNCPUMRDMSR} */
3278static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8TopOfMemN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3279{
3280 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3281 *puValue = 0;
3282 /** @todo return 4GB - RamHoleSize here for TOPMEM. Figure out what to return
3283 * for TOPMEM2. */
3284 //if (pRange->uValue == 0)
3285 // *puValue = _4G - RamHoleSize;
3286 return VINF_SUCCESS;
3287}
3288
3289
3290/** @callback_method_impl{FNCPUMWRMSR} */
3291static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8TopOfMemN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3292{
3293 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3294 /** @todo AMD TOPMEM and TOPMEM2/TOM2. */
3295 return VINF_SUCCESS;
3296}
3297
3298
3299/** @callback_method_impl{FNCPUMRDMSR} */
3300static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8NbCfg1(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3301{
3302 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3303 /** @todo AMD NB_CFG1 */
3304 *puValue = 0;
3305 return VINF_SUCCESS;
3306}
3307
3308
3309/** @callback_method_impl{FNCPUMWRMSR} */
3310static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8NbCfg1(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3311{
3312 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3313 /** @todo AMD NB_CFG1 */
3314 return VINF_SUCCESS;
3315}
3316
3317
3318/** @callback_method_impl{FNCPUMRDMSR} */
3319static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8McXcptRedir(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3320{
3321 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3322 /** @todo machine check. */
3323 *puValue = 0;
3324 return VINF_SUCCESS;
3325}
3326
3327
3328/** @callback_method_impl{FNCPUMWRMSR} */
3329static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8McXcptRedir(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3330{
3331 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3332 /** @todo machine check. */
3333 return VINF_SUCCESS;
3334}
3335
3336
3337/** @callback_method_impl{FNCPUMRDMSR} */
3338static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8CpuNameN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3339{
3340 RT_NOREF_PV(idMsr);
3341 PCPUMCPUIDLEAF pLeaf = cpumCpuIdGetLeaf(pVCpu->CTX_SUFF(pVM), pRange->uValue / 2 + 0x80000001);
3342 if (pLeaf)
3343 {
3344 if (!(pRange->uValue & 1))
3345 *puValue = RT_MAKE_U64(pLeaf->uEax, pLeaf->uEbx);
3346 else
3347 *puValue = RT_MAKE_U64(pLeaf->uEcx, pLeaf->uEdx);
3348 }
3349 else
3350 *puValue = 0;
3351 return VINF_SUCCESS;
3352}
3353
3354
3355/** @callback_method_impl{FNCPUMWRMSR} */
3356static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8CpuNameN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3357{
3358 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3359 /** @todo Remember guest programmed CPU name. */
3360 return VINF_SUCCESS;
3361}
3362
3363
3364/** @callback_method_impl{FNCPUMRDMSR} */
3365static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8HwThermalCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3366{
3367 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3368 /** @todo AMD HTC. */
3369 *puValue = pRange->uValue;
3370 return VINF_SUCCESS;
3371}
3372
3373
3374/** @callback_method_impl{FNCPUMWRMSR} */
3375static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8HwThermalCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3376{
3377 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3378 /** @todo AMD HTC. */
3379 return VINF_SUCCESS;
3380}
3381
3382
3383/** @callback_method_impl{FNCPUMRDMSR} */
3384static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8SwThermalCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3385{
3386 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3387 /** @todo AMD STC. */
3388 *puValue = 0;
3389 return VINF_SUCCESS;
3390}
3391
3392
3393/** @callback_method_impl{FNCPUMWRMSR} */
3394static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8SwThermalCtrl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3395{
3396 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3397 /** @todo AMD STC. */
3398 return VINF_SUCCESS;
3399}
3400
3401
3402/** @callback_method_impl{FNCPUMRDMSR} */
3403static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8FidVidControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3404{
3405 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3406 /** @todo AMD FIDVID_CTL. */
3407 *puValue = pRange->uValue;
3408 return VINF_SUCCESS;
3409}
3410
3411
3412/** @callback_method_impl{FNCPUMWRMSR} */
3413static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8FidVidControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3414{
3415 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3416 /** @todo AMD FIDVID_CTL. */
3417 return VINF_SUCCESS;
3418}
3419
3420
3421/** @callback_method_impl{FNCPUMRDMSR} */
3422static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8FidVidStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3423{
3424 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3425 /** @todo AMD FIDVID_STATUS. */
3426 *puValue = pRange->uValue;
3427 return VINF_SUCCESS;
3428}
3429
3430
3431/** @callback_method_impl{FNCPUMRDMSR} */
3432static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8McCtlMaskN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3433{
3434 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3435 /** @todo AMD MC. */
3436 *puValue = 0;
3437 return VINF_SUCCESS;
3438}
3439
3440
3441/** @callback_method_impl{FNCPUMWRMSR} */
3442static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8McCtlMaskN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3443{
3444 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3445 /** @todo AMD MC. */
3446 return VINF_SUCCESS;
3447}
3448
3449
3450/** @callback_method_impl{FNCPUMRDMSR} */
3451static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8SmiOnIoTrapN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3452{
3453 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3454 /** @todo AMD SMM/SMI and I/O trap. */
3455 *puValue = 0;
3456 return VINF_SUCCESS;
3457}
3458
3459
3460/** @callback_method_impl{FNCPUMWRMSR} */
3461static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8SmiOnIoTrapN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3462{
3463 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3464 /** @todo AMD SMM/SMI and I/O trap. */
3465 return VINF_SUCCESS;
3466}
3467
3468
3469/** @callback_method_impl{FNCPUMRDMSR} */
3470static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8SmiOnIoTrapCtlSts(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3471{
3472 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3473 /** @todo AMD SMM/SMI and I/O trap. */
3474 *puValue = 0;
3475 return VINF_SUCCESS;
3476}
3477
3478
3479/** @callback_method_impl{FNCPUMWRMSR} */
3480static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8SmiOnIoTrapCtlSts(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3481{
3482 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3483 /** @todo AMD SMM/SMI and I/O trap. */
3484 return VINF_SUCCESS;
3485}
3486
3487
3488/** @callback_method_impl{FNCPUMRDMSR} */
3489static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8IntPendingMessage(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3490{
3491 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3492 /** @todo Interrupt pending message. */
3493 *puValue = 0;
3494 return VINF_SUCCESS;
3495}
3496
3497
3498/** @callback_method_impl{FNCPUMWRMSR} */
3499static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8IntPendingMessage(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3500{
3501 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3502 /** @todo Interrupt pending message. */
3503 return VINF_SUCCESS;
3504}
3505
3506
3507/** @callback_method_impl{FNCPUMRDMSR} */
3508static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8SmiTriggerIoCycle(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3509{
3510 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3511 /** @todo AMD SMM/SMI and trigger I/O cycle. */
3512 *puValue = 0;
3513 return VINF_SUCCESS;
3514}
3515
3516
3517/** @callback_method_impl{FNCPUMWRMSR} */
3518static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8SmiTriggerIoCycle(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3519{
3520 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3521 /** @todo AMD SMM/SMI and trigger I/O cycle. */
3522 return VINF_SUCCESS;
3523}
3524
3525
3526/** @callback_method_impl{FNCPUMRDMSR} */
3527static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hMmioCfgBaseAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3528{
3529 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3530 /** @todo AMD MMIO Configuration base address. */
3531 *puValue = 0;
3532 return VINF_SUCCESS;
3533}
3534
3535
3536/** @callback_method_impl{FNCPUMWRMSR} */
3537static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hMmioCfgBaseAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3538{
3539 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3540 /** @todo AMD MMIO Configuration base address. */
3541 return VINF_SUCCESS;
3542}
3543
3544
3545/** @callback_method_impl{FNCPUMRDMSR} */
3546static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hTrapCtlMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3547{
3548 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3549 /** @todo AMD 0xc0010059. */
3550 *puValue = 0;
3551 return VINF_SUCCESS;
3552}
3553
3554
3555/** @callback_method_impl{FNCPUMWRMSR} */
3556static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hTrapCtlMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3557{
3558 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3559 /** @todo AMD 0xc0010059. */
3560 return VINF_SUCCESS;
3561}
3562
3563
3564/** @callback_method_impl{FNCPUMRDMSR} */
3565static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hPStateCurLimit(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3566{
3567 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3568 /** @todo AMD P-states. */
3569 *puValue = pRange->uValue;
3570 return VINF_SUCCESS;
3571}
3572
3573
3574/** @callback_method_impl{FNCPUMRDMSR} */
3575static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hPStateControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3576{
3577 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3578 /** @todo AMD P-states. */
3579 *puValue = pRange->uValue;
3580 return VINF_SUCCESS;
3581}
3582
3583
3584/** @callback_method_impl{FNCPUMWRMSR} */
3585static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hPStateControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3586{
3587 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3588 /** @todo AMD P-states. */
3589 return VINF_SUCCESS;
3590}
3591
3592
3593/** @callback_method_impl{FNCPUMRDMSR} */
3594static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hPStateStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3595{
3596 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3597 /** @todo AMD P-states. */
3598 *puValue = pRange->uValue;
3599 return VINF_SUCCESS;
3600}
3601
3602
3603/** @callback_method_impl{FNCPUMWRMSR} */
3604static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hPStateStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3605{
3606 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3607 /** @todo AMD P-states. */
3608 return VINF_SUCCESS;
3609}
3610
3611
3612/** @callback_method_impl{FNCPUMRDMSR} */
3613static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hPStateN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3614{
3615 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3616 /** @todo AMD P-states. */
3617 *puValue = pRange->uValue;
3618 return VINF_SUCCESS;
3619}
3620
3621
3622/** @callback_method_impl{FNCPUMWRMSR} */
3623static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hPStateN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3624{
3625 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3626 /** @todo AMD P-states. */
3627 return VINF_SUCCESS;
3628}
3629
3630
3631/** @callback_method_impl{FNCPUMRDMSR} */
3632static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hCofVidControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3633{
3634 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3635 /** @todo AMD P-states. */
3636 *puValue = pRange->uValue;
3637 return VINF_SUCCESS;
3638}
3639
3640
3641/** @callback_method_impl{FNCPUMWRMSR} */
3642static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hCofVidControl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3643{
3644 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3645 /** @todo AMD P-states. */
3646 return VINF_SUCCESS;
3647}
3648
3649
3650/** @callback_method_impl{FNCPUMRDMSR} */
3651static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hCofVidStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3652{
3653 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3654 /** @todo AMD P-states. */
3655 *puValue = pRange->uValue;
3656 return VINF_SUCCESS;
3657}
3658
3659
3660/** @callback_method_impl{FNCPUMWRMSR} */
3661static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hCofVidStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3662{
3663 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3664 /* Note! Writing 0 seems to not GP, not sure if it does anything to the value... */
3665 /** @todo AMD P-states. */
3666 return VINF_SUCCESS;
3667}
3668
3669
3670/** @callback_method_impl{FNCPUMRDMSR} */
3671static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hCStateIoBaseAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3672{
3673 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3674 /** @todo AMD C-states. */
3675 *puValue = 0;
3676 return VINF_SUCCESS;
3677}
3678
3679
3680/** @callback_method_impl{FNCPUMWRMSR} */
3681static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hCStateIoBaseAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3682{
3683 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3684 /** @todo AMD C-states. */
3685 return VINF_SUCCESS;
3686}
3687
3688
3689/** @callback_method_impl{FNCPUMRDMSR} */
3690static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hCpuWatchdogTimer(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3691{
3692 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3693 /** @todo AMD machine checks. */
3694 *puValue = 0;
3695 return VINF_SUCCESS;
3696}
3697
3698
3699/** @callback_method_impl{FNCPUMWRMSR} */
3700static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hCpuWatchdogTimer(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3701{
3702 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3703 /** @todo AMD machine checks. */
3704 return VINF_SUCCESS;
3705}
3706
3707
3708/** @callback_method_impl{FNCPUMRDMSR} */
3709static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8SmmBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3710{
3711 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3712 /** @todo AMD SMM. */
3713 *puValue = 0;
3714 return VINF_SUCCESS;
3715}
3716
3717
3718/** @callback_method_impl{FNCPUMWRMSR} */
3719static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8SmmBase(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3720{
3721 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3722 /** @todo AMD SMM. */
3723 return VINF_SUCCESS;
3724}
3725
3726
3727/** @callback_method_impl{FNCPUMRDMSR} */
3728static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8SmmAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3729{
3730 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3731 /** @todo AMD SMM. */
3732 *puValue = 0;
3733 return VINF_SUCCESS;
3734}
3735
3736
3737/** @callback_method_impl{FNCPUMWRMSR} */
3738static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8SmmAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3739{
3740 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3741 /** @todo AMD SMM. */
3742 return VINF_SUCCESS;
3743}
3744
3745
3746
3747/** @callback_method_impl{FNCPUMRDMSR} */
3748static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8SmmMask(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3749{
3750 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3751 /** @todo AMD SMM. */
3752 *puValue = 0;
3753 return VINF_SUCCESS;
3754}
3755
3756
3757/** @callback_method_impl{FNCPUMWRMSR} */
3758static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8SmmMask(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3759{
3760 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3761 /** @todo AMD SMM. */
3762 return VINF_SUCCESS;
3763}
3764
3765
3766/** @callback_method_impl{FNCPUMRDMSR} */
3767static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8VmCr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3768{
3769 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3770 PVM pVM = pVCpu->CTX_SUFF(pVM);
3771 if (pVM->cpum.s.GuestFeatures.fSvm)
3772 *puValue = MSR_K8_VM_CR_LOCK;
3773 else
3774 *puValue = 0;
3775 return VINF_SUCCESS;
3776}
3777
3778
3779/** @callback_method_impl{FNCPUMWRMSR} */
3780static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8VmCr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3781{
3782 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
3783 PVM pVM = pVCpu->CTX_SUFF(pVM);
3784 if (pVM->cpum.s.GuestFeatures.fSvm)
3785 {
3786 /* Silently ignore writes to LOCK and SVM_DISABLE bit when the LOCK bit is set (see cpumMsrRd_AmdK8VmCr). */
3787 if (uValue & (MSR_K8_VM_CR_DPD | MSR_K8_VM_CR_R_INIT | MSR_K8_VM_CR_DIS_A20M))
3788 return VERR_CPUM_RAISE_GP_0;
3789 return VINF_SUCCESS;
3790 }
3791 return VERR_CPUM_RAISE_GP_0;
3792}
3793
3794
3795/** @callback_method_impl{FNCPUMRDMSR} */
3796static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8IgnNe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3797{
3798 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3799 /** @todo AMD IGNNE\# control. */
3800 *puValue = 0;
3801 return VINF_SUCCESS;
3802}
3803
3804
3805/** @callback_method_impl{FNCPUMWRMSR} */
3806static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8IgnNe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3807{
3808 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3809 /** @todo AMD IGNNE\# control. */
3810 return VINF_SUCCESS;
3811}
3812
3813
3814/** @callback_method_impl{FNCPUMRDMSR} */
3815static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8SmmCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3816{
3817 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3818 /** @todo AMD SMM. */
3819 *puValue = 0;
3820 return VINF_SUCCESS;
3821}
3822
3823
3824/** @callback_method_impl{FNCPUMWRMSR} */
3825static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8SmmCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3826{
3827 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3828 /** @todo AMD SMM. */
3829 return VINF_SUCCESS;
3830}
3831
3832
3833/** @callback_method_impl{FNCPUMRDMSR} */
3834static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8VmHSavePa(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3835{
3836 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3837 *puValue = pVCpu->cpum.s.Guest.hwvirt.svm.uMsrHSavePa;
3838 return VINF_SUCCESS;
3839}
3840
3841
3842/** @callback_method_impl{FNCPUMWRMSR} */
3843static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8VmHSavePa(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3844{
3845 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uRawValue);
3846 if (uValue & UINT64_C(0xfff))
3847 {
3848 Log(("CPUM: Invalid setting of low 12 bits set writing host-state save area MSR %#x: %#llx\n", idMsr, uValue));
3849 return VERR_CPUM_RAISE_GP_0;
3850 }
3851
3852 uint64_t fInvPhysMask = ~(RT_BIT_64(pVCpu->CTX_SUFF(pVM)->cpum.s.GuestFeatures.cMaxPhysAddrWidth) - 1U);
3853 if (fInvPhysMask & uValue)
3854 {
3855 Log(("CPUM: Invalid physical address bits set writing host-state save area MSR %#x: %#llx (%#llx)\n",
3856 idMsr, uValue, uValue & fInvPhysMask));
3857 return VERR_CPUM_RAISE_GP_0;
3858 }
3859
3860 pVCpu->cpum.s.Guest.hwvirt.svm.uMsrHSavePa = uValue;
3861 return VINF_SUCCESS;
3862}
3863
3864
3865/** @callback_method_impl{FNCPUMRDMSR} */
3866static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hVmLockKey(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3867{
3868 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3869 /** @todo AMD SVM. */
3870 *puValue = 0; /* RAZ */
3871 return VINF_SUCCESS;
3872}
3873
3874
3875/** @callback_method_impl{FNCPUMWRMSR} */
3876static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hVmLockKey(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3877{
3878 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3879 /** @todo AMD SVM. */
3880 return VINF_SUCCESS;
3881}
3882
3883
3884/** @callback_method_impl{FNCPUMRDMSR} */
3885static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hSmmLockKey(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3886{
3887 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3888 /** @todo AMD SMM. */
3889 *puValue = 0; /* RAZ */
3890 return VINF_SUCCESS;
3891}
3892
3893
3894/** @callback_method_impl{FNCPUMWRMSR} */
3895static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hSmmLockKey(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3896{
3897 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3898 /** @todo AMD SMM. */
3899 return VINF_SUCCESS;
3900}
3901
3902
3903/** @callback_method_impl{FNCPUMRDMSR} */
3904static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hLocalSmiStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3905{
3906 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3907 /** @todo AMD SMM/SMI. */
3908 *puValue = 0;
3909 return VINF_SUCCESS;
3910}
3911
3912
3913/** @callback_method_impl{FNCPUMWRMSR} */
3914static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hLocalSmiStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3915{
3916 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3917 /** @todo AMD SMM/SMI. */
3918 return VINF_SUCCESS;
3919}
3920
3921
3922/** @callback_method_impl{FNCPUMRDMSR} */
3923static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hOsVisWrkIdLength(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3924{
3925 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr);
3926 /** @todo AMD OS visible workaround. */
3927 *puValue = pRange->uValue;
3928 return VINF_SUCCESS;
3929}
3930
3931
3932/** @callback_method_impl{FNCPUMWRMSR} */
3933static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hOsVisWrkIdLength(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3934{
3935 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3936 /** @todo AMD OS visible workaround. */
3937 return VINF_SUCCESS;
3938}
3939
3940
3941/** @callback_method_impl{FNCPUMRDMSR} */
3942static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hOsVisWrkStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3943{
3944 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3945 /** @todo AMD OS visible workaround. */
3946 *puValue = 0;
3947 return VINF_SUCCESS;
3948}
3949
3950
3951/** @callback_method_impl{FNCPUMWRMSR} */
3952static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hOsVisWrkStatus(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3953{
3954 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3955 /** @todo AMD OS visible workaround. */
3956 return VINF_SUCCESS;
3957}
3958
3959
3960/** @callback_method_impl{FNCPUMRDMSR} */
3961static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam16hL2IPerfCtlN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3962{
3963 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3964 /** @todo AMD L2I performance counters. */
3965 *puValue = 0;
3966 return VINF_SUCCESS;
3967}
3968
3969
3970/** @callback_method_impl{FNCPUMWRMSR} */
3971static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam16hL2IPerfCtlN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3972{
3973 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3974 /** @todo AMD L2I performance counters. */
3975 return VINF_SUCCESS;
3976}
3977
3978
3979/** @callback_method_impl{FNCPUMRDMSR} */
3980static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam16hL2IPerfCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
3981{
3982 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
3983 /** @todo AMD L2I performance counters. */
3984 *puValue = 0;
3985 return VINF_SUCCESS;
3986}
3987
3988
3989/** @callback_method_impl{FNCPUMWRMSR} */
3990static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam16hL2IPerfCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
3991{
3992 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
3993 /** @todo AMD L2I performance counters. */
3994 return VINF_SUCCESS;
3995}
3996
3997
3998/** @callback_method_impl{FNCPUMRDMSR} */
3999static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hNorthbridgePerfCtlN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4000{
4001 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4002 /** @todo AMD Northbridge performance counters. */
4003 *puValue = 0;
4004 return VINF_SUCCESS;
4005}
4006
4007
4008/** @callback_method_impl{FNCPUMWRMSR} */
4009static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hNorthbridgePerfCtlN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4010{
4011 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4012 /** @todo AMD Northbridge performance counters. */
4013 return VINF_SUCCESS;
4014}
4015
4016
4017/** @callback_method_impl{FNCPUMRDMSR} */
4018static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hNorthbridgePerfCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4019{
4020 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4021 /** @todo AMD Northbridge performance counters. */
4022 *puValue = 0;
4023 return VINF_SUCCESS;
4024}
4025
4026
4027/** @callback_method_impl{FNCPUMWRMSR} */
4028static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hNorthbridgePerfCtrN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4029{
4030 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4031 /** @todo AMD Northbridge performance counters. */
4032 return VINF_SUCCESS;
4033}
4034
4035
4036/** @callback_method_impl{FNCPUMRDMSR} */
4037static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7MicrocodeCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4038{
4039 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4040 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4041 * cpus. Need to be explored and verify K7 presence. */
4042 /** @todo Undocumented register only seen mentioned in fam15h erratum \#608. */
4043 *puValue = pRange->uValue;
4044 return VINF_SUCCESS;
4045}
4046
4047
4048/** @callback_method_impl{FNCPUMWRMSR} */
4049static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7MicrocodeCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4050{
4051 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4052 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4053 * cpus. Need to be explored and verify K7 presence. */
4054 /** @todo Undocumented register only seen mentioned in fam15h erratum \#608. */
4055 return VINF_SUCCESS;
4056}
4057
4058
4059/** @callback_method_impl{FNCPUMRDMSR} */
4060static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7ClusterIdMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4061{
4062 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4063 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4064 * cpus. Need to be explored and verify K7 presence. */
4065 /** @todo Undocumented register only seen mentioned in fam16h BKDG r3.00 when
4066 * describing EBL_CR_POWERON. */
4067 *puValue = pRange->uValue;
4068 return VINF_SUCCESS;
4069}
4070
4071
4072/** @callback_method_impl{FNCPUMWRMSR} */
4073static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7ClusterIdMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4074{
4075 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4076 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4077 * cpus. Need to be explored and verify K7 presence. */
4078 /** @todo Undocumented register only seen mentioned in fam16h BKDG r3.00 when
4079 * describing EBL_CR_POWERON. */
4080 return VINF_SUCCESS;
4081}
4082
4083
4084/** @callback_method_impl{FNCPUMRDMSR} */
4085static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8CpuIdCtlStd07hEbax(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4086{
4087 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4088 bool fIgnored;
4089 PCPUMCPUIDLEAF pLeaf = cpumCpuIdGetLeafEx(pVCpu->CTX_SUFF(pVM), 0x00000007, 0, &fIgnored);
4090 if (pLeaf)
4091 *puValue = RT_MAKE_U64(pLeaf->uEbx, pLeaf->uEax);
4092 else
4093 *puValue = 0;
4094 return VINF_SUCCESS;
4095}
4096
4097
4098/** @callback_method_impl{FNCPUMWRMSR} */
4099static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8CpuIdCtlStd07hEbax(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4100{
4101 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4102 /** @todo Changing CPUID leaf 7/0. */
4103 return VINF_SUCCESS;
4104}
4105
4106
4107/** @callback_method_impl{FNCPUMRDMSR} */
4108static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8CpuIdCtlStd06hEcx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4109{
4110 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4111 PCPUMCPUIDLEAF pLeaf = cpumCpuIdGetLeaf(pVCpu->CTX_SUFF(pVM), 0x00000006);
4112 if (pLeaf)
4113 *puValue = pLeaf->uEcx;
4114 else
4115 *puValue = 0;
4116 return VINF_SUCCESS;
4117}
4118
4119
4120/** @callback_method_impl{FNCPUMWRMSR} */
4121static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8CpuIdCtlStd06hEcx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4122{
4123 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4124 /** @todo Changing CPUID leaf 6. */
4125 return VINF_SUCCESS;
4126}
4127
4128
4129/** @callback_method_impl{FNCPUMRDMSR} */
4130static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8CpuIdCtlStd01hEdcx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4131{
4132 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4133 PCPUMCPUIDLEAF pLeaf = cpumCpuIdGetLeaf(pVCpu->CTX_SUFF(pVM), 0x00000001);
4134 if (pLeaf)
4135 *puValue = RT_MAKE_U64(pLeaf->uEdx, pLeaf->uEcx);
4136 else
4137 *puValue = 0;
4138 return VINF_SUCCESS;
4139}
4140
4141
4142/** @callback_method_impl{FNCPUMWRMSR} */
4143static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8CpuIdCtlStd01hEdcx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4144{
4145 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4146 /** @todo Changing CPUID leaf 0x80000001. */
4147 return VINF_SUCCESS;
4148}
4149
4150
4151/** @callback_method_impl{FNCPUMRDMSR} */
4152static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8CpuIdCtlExt01hEdcx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4153{
4154 RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4155 PCPUMCPUIDLEAF pLeaf = cpumCpuIdGetLeaf(pVCpu->CTX_SUFF(pVM), 0x80000001);
4156 if (pLeaf)
4157 *puValue = RT_MAKE_U64(pLeaf->uEdx, pLeaf->uEcx);
4158 else
4159 *puValue = 0;
4160 return VINF_SUCCESS;
4161}
4162
4163
4164/** @callback_method_impl{FNCPUMWRMSR} */
4165static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8CpuIdCtlExt01hEdcx(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4166{
4167 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4168 /** @todo Changing CPUID leaf 0x80000001. */
4169 return VINF_SUCCESS;
4170}
4171
4172
4173/** @callback_method_impl{FNCPUMRDMSR} */
4174static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK8PatchLevel(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4175{
4176 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4177 /** @todo Fake AMD microcode patching. */
4178 *puValue = pRange->uValue;
4179 return VINF_SUCCESS;
4180}
4181
4182
4183/** @callback_method_impl{FNCPUMWRMSR} */
4184static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK8PatchLoader(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4185{
4186 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4187 /** @todo Fake AMD microcode patching. */
4188 return VINF_SUCCESS;
4189}
4190
4191
4192/** @callback_method_impl{FNCPUMRDMSR} */
4193static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7DebugStatusMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4194{
4195 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4196 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4197 * cpus. Need to be explored and verify K7 presence. */
4198 /** @todo undocumented */
4199 *puValue = 0;
4200 return VINF_SUCCESS;
4201}
4202
4203
4204/** @callback_method_impl{FNCPUMWRMSR} */
4205static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7DebugStatusMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4206{
4207 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4208 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4209 * cpus. Need to be explored and verify K7 presence. */
4210 /** @todo undocumented */
4211 return VINF_SUCCESS;
4212}
4213
4214
4215/** @callback_method_impl{FNCPUMRDMSR} */
4216static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7BHTraceBaseMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4217{
4218 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4219 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4220 * cpus. Need to be explored and verify K7 presence. */
4221 /** @todo undocumented */
4222 *puValue = 0;
4223 return VINF_SUCCESS;
4224}
4225
4226
4227/** @callback_method_impl{FNCPUMWRMSR} */
4228static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7BHTraceBaseMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4229{
4230 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4231 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4232 * cpus. Need to be explored and verify K7 presence. */
4233 /** @todo undocumented */
4234 return VINF_SUCCESS;
4235}
4236
4237
4238/** @callback_method_impl{FNCPUMRDMSR} */
4239static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7BHTracePtrMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4240{
4241 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4242 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4243 * cpus. Need to be explored and verify K7 presence. */
4244 /** @todo undocumented */
4245 *puValue = 0;
4246 return VINF_SUCCESS;
4247}
4248
4249
4250/** @callback_method_impl{FNCPUMWRMSR} */
4251static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7BHTracePtrMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4252{
4253 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4254 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4255 * cpus. Need to be explored and verify K7 presence. */
4256 /** @todo undocumented */
4257 return VINF_SUCCESS;
4258}
4259
4260
4261/** @callback_method_impl{FNCPUMRDMSR} */
4262static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7BHTraceLimitMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4263{
4264 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4265 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4266 * cpus. Need to be explored and verify K7 presence. */
4267 /** @todo undocumented */
4268 *puValue = 0;
4269 return VINF_SUCCESS;
4270}
4271
4272
4273/** @callback_method_impl{FNCPUMWRMSR} */
4274static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7BHTraceLimitMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4275{
4276 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4277 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4278 * cpus. Need to be explored and verify K7 presence. */
4279 /** @todo undocumented */
4280 return VINF_SUCCESS;
4281}
4282
4283
4284/** @callback_method_impl{FNCPUMRDMSR} */
4285static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7HardwareDebugToolCfgMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4286{
4287 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4288 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4289 * cpus. Need to be explored and verify K7 presence. */
4290 /** @todo undocumented */
4291 *puValue = 0;
4292 return VINF_SUCCESS;
4293}
4294
4295
4296/** @callback_method_impl{FNCPUMWRMSR} */
4297static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7HardwareDebugToolCfgMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4298{
4299 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4300 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4301 * cpus. Need to be explored and verify K7 presence. */
4302 /** @todo undocumented */
4303 return VINF_SUCCESS;
4304}
4305
4306
4307/** @callback_method_impl{FNCPUMRDMSR} */
4308static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7FastFlushCountMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4309{
4310 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4311 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4312 * cpus. Need to be explored and verify K7 presence. */
4313 /** @todo undocumented */
4314 *puValue = 0;
4315 return VINF_SUCCESS;
4316}
4317
4318
4319/** @callback_method_impl{FNCPUMWRMSR} */
4320static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7FastFlushCountMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4321{
4322 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4323 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4324 * cpus. Need to be explored and verify K7 presence. */
4325 /** @todo undocumented */
4326 return VINF_SUCCESS;
4327}
4328
4329
4330/** @callback_method_impl{FNCPUMRDMSR} */
4331static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7NodeId(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4332{
4333 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4334 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4335 * cpus. Need to be explored and verify K7 presence. */
4336 /** @todo AMD node ID and bios scratch. */
4337 *puValue = 0; /* nodeid = 0; nodes-per-cpu = 1 */
4338 return VINF_SUCCESS;
4339}
4340
4341
4342/** @callback_method_impl{FNCPUMWRMSR} */
4343static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7NodeId(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4344{
4345 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4346 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4347 * cpus. Need to be explored and verify K7 presence. */
4348 /** @todo AMD node ID and bios scratch. */
4349 return VINF_SUCCESS;
4350}
4351
4352
4353/** @callback_method_impl{FNCPUMRDMSR} */
4354static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7DrXAddrMaskN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4355{
4356 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4357 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4358 * cpus. Need to be explored and verify K7 presence. */
4359 /** @todo AMD DRx address masking (range breakpoints). */
4360 *puValue = 0;
4361 return VINF_SUCCESS;
4362}
4363
4364
4365/** @callback_method_impl{FNCPUMWRMSR} */
4366static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7DrXAddrMaskN(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4367{
4368 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4369 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4370 * cpus. Need to be explored and verify K7 presence. */
4371 /** @todo AMD DRx address masking (range breakpoints). */
4372 return VINF_SUCCESS;
4373}
4374
4375
4376/** @callback_method_impl{FNCPUMRDMSR} */
4377static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7Dr0DataMatchMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4378{
4379 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4380 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4381 * cpus. Need to be explored and verify K7 presence. */
4382 /** @todo AMD undocument debugging features. */
4383 *puValue = 0;
4384 return VINF_SUCCESS;
4385}
4386
4387
4388/** @callback_method_impl{FNCPUMWRMSR} */
4389static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7Dr0DataMatchMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4390{
4391 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4392 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4393 * cpus. Need to be explored and verify K7 presence. */
4394 /** @todo AMD undocument debugging features. */
4395 return VINF_SUCCESS;
4396}
4397
4398
4399/** @callback_method_impl{FNCPUMRDMSR} */
4400static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7Dr0DataMaskMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4401{
4402 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4403 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4404 * cpus. Need to be explored and verify K7 presence. */
4405 /** @todo AMD undocument debugging features. */
4406 *puValue = 0;
4407 return VINF_SUCCESS;
4408}
4409
4410
4411/** @callback_method_impl{FNCPUMWRMSR} */
4412static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7Dr0DataMaskMaybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4413{
4414 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4415 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4416 * cpus. Need to be explored and verify K7 presence. */
4417 /** @todo AMD undocument debugging features. */
4418 return VINF_SUCCESS;
4419}
4420
4421
4422/** @callback_method_impl{FNCPUMRDMSR} */
4423static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7LoadStoreCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4424{
4425 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4426 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4427 * cpus. Need to be explored and verify K7 presence. */
4428 /** @todo AMD load-store config. */
4429 *puValue = 0;
4430 return VINF_SUCCESS;
4431}
4432
4433
4434/** @callback_method_impl{FNCPUMWRMSR} */
4435static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7LoadStoreCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4436{
4437 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4438 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4439 * cpus. Need to be explored and verify K7 presence. */
4440 /** @todo AMD load-store config. */
4441 return VINF_SUCCESS;
4442}
4443
4444
4445/** @callback_method_impl{FNCPUMRDMSR} */
4446static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7InstrCacheCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4447{
4448 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4449 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4450 * cpus. Need to be explored and verify K7 presence. */
4451 /** @todo AMD instruction cache config. */
4452 *puValue = 0;
4453 return VINF_SUCCESS;
4454}
4455
4456
4457/** @callback_method_impl{FNCPUMWRMSR} */
4458static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7InstrCacheCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4459{
4460 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4461 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4462 * cpus. Need to be explored and verify K7 presence. */
4463 /** @todo AMD instruction cache config. */
4464 return VINF_SUCCESS;
4465}
4466
4467
4468/** @callback_method_impl{FNCPUMRDMSR} */
4469static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7DataCacheCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4470{
4471 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4472 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4473 * cpus. Need to be explored and verify K7 presence. */
4474 /** @todo AMD data cache config. */
4475 *puValue = 0;
4476 return VINF_SUCCESS;
4477}
4478
4479
4480/** @callback_method_impl{FNCPUMWRMSR} */
4481static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7DataCacheCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4482{
4483 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4484 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4485 * cpus. Need to be explored and verify K7 presence. */
4486 /** @todo AMD data cache config. */
4487 return VINF_SUCCESS;
4488}
4489
4490
4491/** @callback_method_impl{FNCPUMRDMSR} */
4492static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7BusUnitCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4493{
4494 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4495 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4496 * cpus. Need to be explored and verify K7 presence. */
4497 /** @todo AMD bus unit config. */
4498 *puValue = 0;
4499 return VINF_SUCCESS;
4500}
4501
4502
4503/** @callback_method_impl{FNCPUMWRMSR} */
4504static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7BusUnitCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4505{
4506 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4507 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4508 * cpus. Need to be explored and verify K7 presence. */
4509 /** @todo AMD bus unit config. */
4510 return VINF_SUCCESS;
4511}
4512
4513
4514/** @callback_method_impl{FNCPUMRDMSR} */
4515static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdK7DebugCtl2Maybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4516{
4517 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4518 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4519 * cpus. Need to be explored and verify K7 presence. */
4520 /** @todo Undocument AMD debug control register \#2. */
4521 *puValue = 0;
4522 return VINF_SUCCESS;
4523}
4524
4525
4526/** @callback_method_impl{FNCPUMWRMSR} */
4527static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdK7DebugCtl2Maybe(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4528{
4529 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4530 /** @todo Allegedly requiring edi=0x9c5a203a when execuing rdmsr/wrmsr on older
4531 * cpus. Need to be explored and verify K7 presence. */
4532 /** @todo Undocument AMD debug control register \#2. */
4533 return VINF_SUCCESS;
4534}
4535
4536
4537/** @callback_method_impl{FNCPUMRDMSR} */
4538static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hFpuCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4539{
4540 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4541 /** @todo AMD FPU config. */
4542 *puValue = 0;
4543 return VINF_SUCCESS;
4544}
4545
4546
4547/** @callback_method_impl{FNCPUMWRMSR} */
4548static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hFpuCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4549{
4550 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4551 /** @todo AMD FPU config. */
4552 return VINF_SUCCESS;
4553}
4554
4555
4556/** @callback_method_impl{FNCPUMRDMSR} */
4557static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hDecoderCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4558{
4559 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4560 /** @todo AMD decoder config. */
4561 *puValue = 0;
4562 return VINF_SUCCESS;
4563}
4564
4565
4566/** @callback_method_impl{FNCPUMWRMSR} */
4567static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hDecoderCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4568{
4569 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4570 /** @todo AMD decoder config. */
4571 return VINF_SUCCESS;
4572}
4573
4574
4575/** @callback_method_impl{FNCPUMRDMSR} */
4576static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hBusUnitCfg2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4577{
4578 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4579 /* Note! 10h and 16h */
4580 /** @todo AMD bus unit config. */
4581 *puValue = 0;
4582 return VINF_SUCCESS;
4583}
4584
4585
4586/** @callback_method_impl{FNCPUMWRMSR} */
4587static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hBusUnitCfg2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4588{
4589 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4590 /* Note! 10h and 16h */
4591 /** @todo AMD bus unit config. */
4592 return VINF_SUCCESS;
4593}
4594
4595
4596/** @callback_method_impl{FNCPUMRDMSR} */
4597static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hCombUnitCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4598{
4599 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4600 /** @todo AMD unit config. */
4601 *puValue = 0;
4602 return VINF_SUCCESS;
4603}
4604
4605
4606/** @callback_method_impl{FNCPUMWRMSR} */
4607static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hCombUnitCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4608{
4609 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4610 /** @todo AMD unit config. */
4611 return VINF_SUCCESS;
4612}
4613
4614
4615/** @callback_method_impl{FNCPUMRDMSR} */
4616static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hCombUnitCfg2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4617{
4618 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4619 /** @todo AMD unit config 2. */
4620 *puValue = 0;
4621 return VINF_SUCCESS;
4622}
4623
4624
4625/** @callback_method_impl{FNCPUMWRMSR} */
4626static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hCombUnitCfg2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4627{
4628 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4629 /** @todo AMD unit config 2. */
4630 return VINF_SUCCESS;
4631}
4632
4633
4634/** @callback_method_impl{FNCPUMRDMSR} */
4635static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hCombUnitCfg3(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4636{
4637 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4638 /** @todo AMD combined unit config 3. */
4639 *puValue = 0;
4640 return VINF_SUCCESS;
4641}
4642
4643
4644/** @callback_method_impl{FNCPUMWRMSR} */
4645static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hCombUnitCfg3(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4646{
4647 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4648 /** @todo AMD combined unit config 3. */
4649 return VINF_SUCCESS;
4650}
4651
4652
4653/** @callback_method_impl{FNCPUMRDMSR} */
4654static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hExecUnitCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4655{
4656 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4657 /** @todo AMD execution unit config. */
4658 *puValue = 0;
4659 return VINF_SUCCESS;
4660}
4661
4662
4663/** @callback_method_impl{FNCPUMWRMSR} */
4664static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hExecUnitCfg(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4665{
4666 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4667 /** @todo AMD execution unit config. */
4668 return VINF_SUCCESS;
4669}
4670
4671
4672/** @callback_method_impl{FNCPUMRDMSR} */
4673static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam15hLoadStoreCfg2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4674{
4675 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4676 /** @todo AMD load-store config 2. */
4677 *puValue = 0;
4678 return VINF_SUCCESS;
4679}
4680
4681
4682/** @callback_method_impl{FNCPUMWRMSR} */
4683static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam15hLoadStoreCfg2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4684{
4685 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4686 /** @todo AMD load-store config 2. */
4687 return VINF_SUCCESS;
4688}
4689
4690
4691/** @callback_method_impl{FNCPUMRDMSR} */
4692static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsFetchCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4693{
4694 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4695 /** @todo AMD IBS. */
4696 *puValue = 0;
4697 return VINF_SUCCESS;
4698}
4699
4700
4701/** @callback_method_impl{FNCPUMWRMSR} */
4702static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsFetchCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4703{
4704 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4705 /** @todo AMD IBS. */
4706 return VINF_SUCCESS;
4707}
4708
4709
4710/** @callback_method_impl{FNCPUMRDMSR} */
4711static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsFetchLinAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4712{
4713 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4714 /** @todo AMD IBS. */
4715 *puValue = 0;
4716 return VINF_SUCCESS;
4717}
4718
4719
4720/** @callback_method_impl{FNCPUMWRMSR} */
4721static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsFetchLinAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4722{
4723 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4724 /** @todo AMD IBS. */
4725 return VINF_SUCCESS;
4726}
4727
4728
4729/** @callback_method_impl{FNCPUMRDMSR} */
4730static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsFetchPhysAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4731{
4732 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4733 /** @todo AMD IBS. */
4734 *puValue = 0;
4735 return VINF_SUCCESS;
4736}
4737
4738
4739/** @callback_method_impl{FNCPUMWRMSR} */
4740static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsFetchPhysAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4741{
4742 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4743 /** @todo AMD IBS. */
4744 return VINF_SUCCESS;
4745}
4746
4747
4748/** @callback_method_impl{FNCPUMRDMSR} */
4749static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsOpExecCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4750{
4751 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4752 /** @todo AMD IBS. */
4753 *puValue = 0;
4754 return VINF_SUCCESS;
4755}
4756
4757
4758/** @callback_method_impl{FNCPUMWRMSR} */
4759static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsOpExecCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4760{
4761 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4762 /** @todo AMD IBS. */
4763 return VINF_SUCCESS;
4764}
4765
4766
4767/** @callback_method_impl{FNCPUMRDMSR} */
4768static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsOpRip(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4769{
4770 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4771 /** @todo AMD IBS. */
4772 *puValue = 0;
4773 return VINF_SUCCESS;
4774}
4775
4776
4777/** @callback_method_impl{FNCPUMWRMSR} */
4778static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsOpRip(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4779{
4780 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4781 /** @todo AMD IBS. */
4782 if (!X86_IS_CANONICAL(uValue))
4783 {
4784 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue));
4785 return VERR_CPUM_RAISE_GP_0;
4786 }
4787 return VINF_SUCCESS;
4788}
4789
4790
4791/** @callback_method_impl{FNCPUMRDMSR} */
4792static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsOpData(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4793{
4794 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4795 /** @todo AMD IBS. */
4796 *puValue = 0;
4797 return VINF_SUCCESS;
4798}
4799
4800
4801/** @callback_method_impl{FNCPUMWRMSR} */
4802static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsOpData(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4803{
4804 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4805 /** @todo AMD IBS. */
4806 return VINF_SUCCESS;
4807}
4808
4809
4810/** @callback_method_impl{FNCPUMRDMSR} */
4811static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsOpData2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4812{
4813 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4814 /** @todo AMD IBS. */
4815 *puValue = 0;
4816 return VINF_SUCCESS;
4817}
4818
4819
4820/** @callback_method_impl{FNCPUMWRMSR} */
4821static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsOpData2(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4822{
4823 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4824 /** @todo AMD IBS. */
4825 return VINF_SUCCESS;
4826}
4827
4828
4829/** @callback_method_impl{FNCPUMRDMSR} */
4830static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsOpData3(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4831{
4832 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4833 /** @todo AMD IBS. */
4834 *puValue = 0;
4835 return VINF_SUCCESS;
4836}
4837
4838
4839/** @callback_method_impl{FNCPUMWRMSR} */
4840static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsOpData3(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4841{
4842 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4843 /** @todo AMD IBS. */
4844 return VINF_SUCCESS;
4845}
4846
4847
4848/** @callback_method_impl{FNCPUMRDMSR} */
4849static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsDcLinAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4850{
4851 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4852 /** @todo AMD IBS. */
4853 *puValue = 0;
4854 return VINF_SUCCESS;
4855}
4856
4857
4858/** @callback_method_impl{FNCPUMWRMSR} */
4859static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsDcLinAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4860{
4861 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4862 /** @todo AMD IBS. */
4863 if (!X86_IS_CANONICAL(uValue))
4864 {
4865 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue));
4866 return VERR_CPUM_RAISE_GP_0;
4867 }
4868 return VINF_SUCCESS;
4869}
4870
4871
4872/** @callback_method_impl{FNCPUMRDMSR} */
4873static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsDcPhysAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4874{
4875 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4876 /** @todo AMD IBS. */
4877 *puValue = 0;
4878 return VINF_SUCCESS;
4879}
4880
4881
4882/** @callback_method_impl{FNCPUMWRMSR} */
4883static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsDcPhysAddr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4884{
4885 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4886 /** @todo AMD IBS. */
4887 return VINF_SUCCESS;
4888}
4889
4890
4891/** @callback_method_impl{FNCPUMRDMSR} */
4892static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam10hIbsCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4893{
4894 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4895 /** @todo AMD IBS. */
4896 *puValue = 0;
4897 return VINF_SUCCESS;
4898}
4899
4900
4901/** @callback_method_impl{FNCPUMWRMSR} */
4902static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam10hIbsCtl(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4903{
4904 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4905 /** @todo AMD IBS. */
4906 return VINF_SUCCESS;
4907}
4908
4909
4910/** @callback_method_impl{FNCPUMRDMSR} */
4911static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_AmdFam14hIbsBrTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4912{
4913 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange);
4914 /** @todo AMD IBS. */
4915 *puValue = 0;
4916 return VINF_SUCCESS;
4917}
4918
4919
4920/** @callback_method_impl{FNCPUMWRMSR} */
4921static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_AmdFam14hIbsBrTarget(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4922{
4923 RT_NOREF_PV(pVCpu); RT_NOREF_PV(idMsr); RT_NOREF_PV(pRange); RT_NOREF_PV(uValue); RT_NOREF_PV(uRawValue);
4924 /** @todo AMD IBS. */
4925 if (!X86_IS_CANONICAL(uValue))
4926 {
4927 Log(("CPUM: wrmsr %s(%#x), %#llx -> #GP - not canonical\n", pRange->szName, idMsr, uValue));
4928 return VERR_CPUM_RAISE_GP_0;
4929 }
4930 return VINF_SUCCESS;
4931}
4932
4933
4934
4935/*
4936 * GIM MSRs.
4937 * GIM MSRs.
4938 * GIM MSRs.
4939 */
4940
4941
4942/** @callback_method_impl{FNCPUMRDMSR} */
4943static DECLCALLBACK(VBOXSTRICTRC) cpumMsrRd_Gim(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
4944{
4945#ifdef VBOX_WITH_NESTED_HWVIRT
4946 /* Raise #GP(0) like a physical CPU would since the nested-hypervisor hasn't intercept these MSRs. */
4947 PCCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
4948 if (CPUMIsGuestInNestedHwVirtMode(pCtx))
4949 return VERR_CPUM_RAISE_GP_0;
4950#endif
4951 return GIMReadMsr(pVCpu, idMsr, pRange, puValue);
4952}
4953
4954
4955/** @callback_method_impl{FNCPUMWRMSR} */
4956static DECLCALLBACK(VBOXSTRICTRC) cpumMsrWr_Gim(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
4957{
4958#ifdef VBOX_WITH_NESTED_HWVIRT
4959 /* Raise #GP(0) like a physical CPU would since the nested-hypervisor hasn't intercept these MSRs. */
4960 PCCPUMCTX pCtx = &pVCpu->cpum.s.Guest;
4961 if (CPUMIsGuestInNestedHwVirtMode(pCtx))
4962 return VERR_CPUM_RAISE_GP_0;
4963#endif
4964 return GIMWriteMsr(pVCpu, idMsr, pRange, uValue, uRawValue);
4965}
4966
4967
4968/**
4969 * MSR read function table.
4970 */
4971static const PFNCPUMRDMSR g_aCpumRdMsrFns[kCpumMsrRdFn_End] =
4972{
4973 NULL, /* Invalid */
4974 cpumMsrRd_FixedValue,
4975 NULL, /* Alias */
4976 cpumMsrRd_WriteOnly,
4977 cpumMsrRd_Ia32P5McAddr,
4978 cpumMsrRd_Ia32P5McType,
4979 cpumMsrRd_Ia32TimestampCounter,
4980 cpumMsrRd_Ia32PlatformId,
4981 cpumMsrRd_Ia32ApicBase,
4982 cpumMsrRd_Ia32FeatureControl,
4983 cpumMsrRd_Ia32BiosSignId,
4984 cpumMsrRd_Ia32SmmMonitorCtl,
4985 cpumMsrRd_Ia32PmcN,
4986 cpumMsrRd_Ia32MonitorFilterLineSize,
4987 cpumMsrRd_Ia32MPerf,
4988 cpumMsrRd_Ia32APerf,
4989 cpumMsrRd_Ia32MtrrCap,
4990 cpumMsrRd_Ia32MtrrPhysBaseN,
4991 cpumMsrRd_Ia32MtrrPhysMaskN,
4992 cpumMsrRd_Ia32MtrrFixed,
4993 cpumMsrRd_Ia32MtrrDefType,
4994 cpumMsrRd_Ia32Pat,
4995 cpumMsrRd_Ia32SysEnterCs,
4996 cpumMsrRd_Ia32SysEnterEsp,
4997 cpumMsrRd_Ia32SysEnterEip,
4998 cpumMsrRd_Ia32McgCap,
4999 cpumMsrRd_Ia32McgStatus,
5000 cpumMsrRd_Ia32McgCtl,
5001 cpumMsrRd_Ia32DebugCtl,
5002 cpumMsrRd_Ia32SmrrPhysBase,
5003 cpumMsrRd_Ia32SmrrPhysMask,
5004 cpumMsrRd_Ia32PlatformDcaCap,
5005 cpumMsrRd_Ia32CpuDcaCap,
5006 cpumMsrRd_Ia32Dca0Cap,
5007 cpumMsrRd_Ia32PerfEvtSelN,
5008 cpumMsrRd_Ia32PerfStatus,
5009 cpumMsrRd_Ia32PerfCtl,
5010 cpumMsrRd_Ia32FixedCtrN,
5011 cpumMsrRd_Ia32PerfCapabilities,
5012 cpumMsrRd_Ia32FixedCtrCtrl,
5013 cpumMsrRd_Ia32PerfGlobalStatus,
5014 cpumMsrRd_Ia32PerfGlobalCtrl,
5015 cpumMsrRd_Ia32PerfGlobalOvfCtrl,
5016 cpumMsrRd_Ia32PebsEnable,
5017 cpumMsrRd_Ia32ClockModulation,
5018 cpumMsrRd_Ia32ThermInterrupt,
5019 cpumMsrRd_Ia32ThermStatus,
5020 cpumMsrRd_Ia32Therm2Ctl,
5021 cpumMsrRd_Ia32MiscEnable,
5022 cpumMsrRd_Ia32McCtlStatusAddrMiscN,
5023 cpumMsrRd_Ia32McNCtl2,
5024 cpumMsrRd_Ia32DsArea,
5025 cpumMsrRd_Ia32TscDeadline,
5026 cpumMsrRd_Ia32X2ApicN,
5027 cpumMsrRd_Ia32DebugInterface,
5028 cpumMsrRd_Ia32VmxBase,
5029 cpumMsrRd_Ia32VmxPinbasedCtls,
5030 cpumMsrRd_Ia32VmxProcbasedCtls,
5031 cpumMsrRd_Ia32VmxExitCtls,
5032 cpumMsrRd_Ia32VmxEntryCtls,
5033 cpumMsrRd_Ia32VmxMisc,
5034 cpumMsrRd_Ia32VmxCr0Fixed0,
5035 cpumMsrRd_Ia32VmxCr0Fixed1,
5036 cpumMsrRd_Ia32VmxCr4Fixed0,
5037 cpumMsrRd_Ia32VmxCr4Fixed1,
5038 cpumMsrRd_Ia32VmxVmcsEnum,
5039 cpumMsrRd_Ia32VmxProcBasedCtls2,
5040 cpumMsrRd_Ia32VmxEptVpidCap,
5041 cpumMsrRd_Ia32VmxTruePinbasedCtls,
5042 cpumMsrRd_Ia32VmxTrueProcbasedCtls,
5043 cpumMsrRd_Ia32VmxTrueExitCtls,
5044 cpumMsrRd_Ia32VmxTrueEntryCtls,
5045 cpumMsrRd_Ia32VmxVmFunc,
5046 cpumMsrRd_Ia32SpecCtrl,
5047 cpumMsrRd_Ia32ArchCapabilities,
5048
5049 cpumMsrRd_Amd64Efer,
5050 cpumMsrRd_Amd64SyscallTarget,
5051 cpumMsrRd_Amd64LongSyscallTarget,
5052 cpumMsrRd_Amd64CompSyscallTarget,
5053 cpumMsrRd_Amd64SyscallFlagMask,
5054 cpumMsrRd_Amd64FsBase,
5055 cpumMsrRd_Amd64GsBase,
5056 cpumMsrRd_Amd64KernelGsBase,
5057 cpumMsrRd_Amd64TscAux,
5058
5059 cpumMsrRd_IntelEblCrPowerOn,
5060 cpumMsrRd_IntelI7CoreThreadCount,
5061 cpumMsrRd_IntelP4EbcHardPowerOn,
5062 cpumMsrRd_IntelP4EbcSoftPowerOn,
5063 cpumMsrRd_IntelP4EbcFrequencyId,
5064 cpumMsrRd_IntelP6FsbFrequency,
5065 cpumMsrRd_IntelPlatformInfo,
5066 cpumMsrRd_IntelFlexRatio,
5067 cpumMsrRd_IntelPkgCStConfigControl,
5068 cpumMsrRd_IntelPmgIoCaptureBase,
5069 cpumMsrRd_IntelLastBranchFromToN,
5070 cpumMsrRd_IntelLastBranchFromN,
5071 cpumMsrRd_IntelLastBranchToN,
5072 cpumMsrRd_IntelLastBranchTos,
5073 cpumMsrRd_IntelBblCrCtl,
5074 cpumMsrRd_IntelBblCrCtl3,
5075 cpumMsrRd_IntelI7TemperatureTarget,
5076 cpumMsrRd_IntelI7MsrOffCoreResponseN,
5077 cpumMsrRd_IntelI7MiscPwrMgmt,
5078 cpumMsrRd_IntelP6CrN,
5079 cpumMsrRd_IntelCpuId1FeatureMaskEcdx,
5080 cpumMsrRd_IntelCpuId1FeatureMaskEax,
5081 cpumMsrRd_IntelCpuId80000001FeatureMaskEcdx,
5082 cpumMsrRd_IntelI7SandyAesNiCtl,
5083 cpumMsrRd_IntelI7TurboRatioLimit,
5084 cpumMsrRd_IntelI7LbrSelect,
5085 cpumMsrRd_IntelI7SandyErrorControl,
5086 cpumMsrRd_IntelI7VirtualLegacyWireCap,
5087 cpumMsrRd_IntelI7PowerCtl,
5088 cpumMsrRd_IntelI7SandyPebsNumAlt,
5089 cpumMsrRd_IntelI7PebsLdLat,
5090 cpumMsrRd_IntelI7PkgCnResidencyN,
5091 cpumMsrRd_IntelI7CoreCnResidencyN,
5092 cpumMsrRd_IntelI7SandyVrCurrentConfig,
5093 cpumMsrRd_IntelI7SandyVrMiscConfig,
5094 cpumMsrRd_IntelI7SandyRaplPowerUnit,
5095 cpumMsrRd_IntelI7SandyPkgCnIrtlN,
5096 cpumMsrRd_IntelI7SandyPkgC2Residency,
5097 cpumMsrRd_IntelI7RaplPkgPowerLimit,
5098 cpumMsrRd_IntelI7RaplPkgEnergyStatus,
5099 cpumMsrRd_IntelI7RaplPkgPerfStatus,
5100 cpumMsrRd_IntelI7RaplPkgPowerInfo,
5101 cpumMsrRd_IntelI7RaplDramPowerLimit,
5102 cpumMsrRd_IntelI7RaplDramEnergyStatus,
5103 cpumMsrRd_IntelI7RaplDramPerfStatus,
5104 cpumMsrRd_IntelI7RaplDramPowerInfo,
5105 cpumMsrRd_IntelI7RaplPp0PowerLimit,
5106 cpumMsrRd_IntelI7RaplPp0EnergyStatus,
5107 cpumMsrRd_IntelI7RaplPp0Policy,
5108 cpumMsrRd_IntelI7RaplPp0PerfStatus,
5109 cpumMsrRd_IntelI7RaplPp1PowerLimit,
5110 cpumMsrRd_IntelI7RaplPp1EnergyStatus,
5111 cpumMsrRd_IntelI7RaplPp1Policy,
5112 cpumMsrRd_IntelI7IvyConfigTdpNominal,
5113 cpumMsrRd_IntelI7IvyConfigTdpLevel1,
5114 cpumMsrRd_IntelI7IvyConfigTdpLevel2,
5115 cpumMsrRd_IntelI7IvyConfigTdpControl,
5116 cpumMsrRd_IntelI7IvyTurboActivationRatio,
5117 cpumMsrRd_IntelI7UncPerfGlobalCtrl,
5118 cpumMsrRd_IntelI7UncPerfGlobalStatus,
5119 cpumMsrRd_IntelI7UncPerfGlobalOvfCtrl,
5120 cpumMsrRd_IntelI7UncPerfFixedCtrCtrl,
5121 cpumMsrRd_IntelI7UncPerfFixedCtr,
5122 cpumMsrRd_IntelI7UncCBoxConfig,
5123 cpumMsrRd_IntelI7UncArbPerfCtrN,
5124 cpumMsrRd_IntelI7UncArbPerfEvtSelN,
5125 cpumMsrRd_IntelI7SmiCount,
5126 cpumMsrRd_IntelCore2EmttmCrTablesN,
5127 cpumMsrRd_IntelCore2SmmCStMiscInfo,
5128 cpumMsrRd_IntelCore1ExtConfig,
5129 cpumMsrRd_IntelCore1DtsCalControl,
5130 cpumMsrRd_IntelCore2PeciControl,
5131 cpumMsrRd_IntelAtSilvCoreC1Recidency,
5132
5133 cpumMsrRd_P6LastBranchFromIp,
5134 cpumMsrRd_P6LastBranchToIp,
5135 cpumMsrRd_P6LastIntFromIp,
5136 cpumMsrRd_P6LastIntToIp,
5137
5138 cpumMsrRd_AmdFam15hTscRate,
5139 cpumMsrRd_AmdFam15hLwpCfg,
5140 cpumMsrRd_AmdFam15hLwpCbAddr,
5141 cpumMsrRd_AmdFam10hMc4MiscN,
5142 cpumMsrRd_AmdK8PerfCtlN,
5143 cpumMsrRd_AmdK8PerfCtrN,
5144 cpumMsrRd_AmdK8SysCfg,
5145 cpumMsrRd_AmdK8HwCr,
5146 cpumMsrRd_AmdK8IorrBaseN,
5147 cpumMsrRd_AmdK8IorrMaskN,
5148 cpumMsrRd_AmdK8TopOfMemN,
5149 cpumMsrRd_AmdK8NbCfg1,
5150 cpumMsrRd_AmdK8McXcptRedir,
5151 cpumMsrRd_AmdK8CpuNameN,
5152 cpumMsrRd_AmdK8HwThermalCtrl,
5153 cpumMsrRd_AmdK8SwThermalCtrl,
5154 cpumMsrRd_AmdK8FidVidControl,
5155 cpumMsrRd_AmdK8FidVidStatus,
5156 cpumMsrRd_AmdK8McCtlMaskN,
5157 cpumMsrRd_AmdK8SmiOnIoTrapN,
5158 cpumMsrRd_AmdK8SmiOnIoTrapCtlSts,
5159 cpumMsrRd_AmdK8IntPendingMessage,
5160 cpumMsrRd_AmdK8SmiTriggerIoCycle,
5161 cpumMsrRd_AmdFam10hMmioCfgBaseAddr,
5162 cpumMsrRd_AmdFam10hTrapCtlMaybe,
5163 cpumMsrRd_AmdFam10hPStateCurLimit,
5164 cpumMsrRd_AmdFam10hPStateControl,
5165 cpumMsrRd_AmdFam10hPStateStatus,
5166 cpumMsrRd_AmdFam10hPStateN,
5167 cpumMsrRd_AmdFam10hCofVidControl,
5168 cpumMsrRd_AmdFam10hCofVidStatus,
5169 cpumMsrRd_AmdFam10hCStateIoBaseAddr,
5170 cpumMsrRd_AmdFam10hCpuWatchdogTimer,
5171 cpumMsrRd_AmdK8SmmBase,
5172 cpumMsrRd_AmdK8SmmAddr,
5173 cpumMsrRd_AmdK8SmmMask,
5174 cpumMsrRd_AmdK8VmCr,
5175 cpumMsrRd_AmdK8IgnNe,
5176 cpumMsrRd_AmdK8SmmCtl,
5177 cpumMsrRd_AmdK8VmHSavePa,
5178 cpumMsrRd_AmdFam10hVmLockKey,
5179 cpumMsrRd_AmdFam10hSmmLockKey,
5180 cpumMsrRd_AmdFam10hLocalSmiStatus,
5181 cpumMsrRd_AmdFam10hOsVisWrkIdLength,
5182 cpumMsrRd_AmdFam10hOsVisWrkStatus,
5183 cpumMsrRd_AmdFam16hL2IPerfCtlN,
5184 cpumMsrRd_AmdFam16hL2IPerfCtrN,
5185 cpumMsrRd_AmdFam15hNorthbridgePerfCtlN,
5186 cpumMsrRd_AmdFam15hNorthbridgePerfCtrN,
5187 cpumMsrRd_AmdK7MicrocodeCtl,
5188 cpumMsrRd_AmdK7ClusterIdMaybe,
5189 cpumMsrRd_AmdK8CpuIdCtlStd07hEbax,
5190 cpumMsrRd_AmdK8CpuIdCtlStd06hEcx,
5191 cpumMsrRd_AmdK8CpuIdCtlStd01hEdcx,
5192 cpumMsrRd_AmdK8CpuIdCtlExt01hEdcx,
5193 cpumMsrRd_AmdK8PatchLevel,
5194 cpumMsrRd_AmdK7DebugStatusMaybe,
5195 cpumMsrRd_AmdK7BHTraceBaseMaybe,
5196 cpumMsrRd_AmdK7BHTracePtrMaybe,
5197 cpumMsrRd_AmdK7BHTraceLimitMaybe,
5198 cpumMsrRd_AmdK7HardwareDebugToolCfgMaybe,
5199 cpumMsrRd_AmdK7FastFlushCountMaybe,
5200 cpumMsrRd_AmdK7NodeId,
5201 cpumMsrRd_AmdK7DrXAddrMaskN,
5202 cpumMsrRd_AmdK7Dr0DataMatchMaybe,
5203 cpumMsrRd_AmdK7Dr0DataMaskMaybe,
5204 cpumMsrRd_AmdK7LoadStoreCfg,
5205 cpumMsrRd_AmdK7InstrCacheCfg,
5206 cpumMsrRd_AmdK7DataCacheCfg,
5207 cpumMsrRd_AmdK7BusUnitCfg,
5208 cpumMsrRd_AmdK7DebugCtl2Maybe,
5209 cpumMsrRd_AmdFam15hFpuCfg,
5210 cpumMsrRd_AmdFam15hDecoderCfg,
5211 cpumMsrRd_AmdFam10hBusUnitCfg2,
5212 cpumMsrRd_AmdFam15hCombUnitCfg,
5213 cpumMsrRd_AmdFam15hCombUnitCfg2,
5214 cpumMsrRd_AmdFam15hCombUnitCfg3,
5215 cpumMsrRd_AmdFam15hExecUnitCfg,
5216 cpumMsrRd_AmdFam15hLoadStoreCfg2,
5217 cpumMsrRd_AmdFam10hIbsFetchCtl,
5218 cpumMsrRd_AmdFam10hIbsFetchLinAddr,
5219 cpumMsrRd_AmdFam10hIbsFetchPhysAddr,
5220 cpumMsrRd_AmdFam10hIbsOpExecCtl,
5221 cpumMsrRd_AmdFam10hIbsOpRip,
5222 cpumMsrRd_AmdFam10hIbsOpData,
5223 cpumMsrRd_AmdFam10hIbsOpData2,
5224 cpumMsrRd_AmdFam10hIbsOpData3,
5225 cpumMsrRd_AmdFam10hIbsDcLinAddr,
5226 cpumMsrRd_AmdFam10hIbsDcPhysAddr,
5227 cpumMsrRd_AmdFam10hIbsCtl,
5228 cpumMsrRd_AmdFam14hIbsBrTarget,
5229
5230 cpumMsrRd_Gim
5231};
5232
5233
5234/**
5235 * MSR write function table.
5236 */
5237static const PFNCPUMWRMSR g_aCpumWrMsrFns[kCpumMsrWrFn_End] =
5238{
5239 NULL, /* Invalid */
5240 cpumMsrWr_IgnoreWrite,
5241 cpumMsrWr_ReadOnly,
5242 NULL, /* Alias */
5243 cpumMsrWr_Ia32P5McAddr,
5244 cpumMsrWr_Ia32P5McType,
5245 cpumMsrWr_Ia32TimestampCounter,
5246 cpumMsrWr_Ia32ApicBase,
5247 cpumMsrWr_Ia32FeatureControl,
5248 cpumMsrWr_Ia32BiosSignId,
5249 cpumMsrWr_Ia32BiosUpdateTrigger,
5250 cpumMsrWr_Ia32SmmMonitorCtl,
5251 cpumMsrWr_Ia32PmcN,
5252 cpumMsrWr_Ia32MonitorFilterLineSize,
5253 cpumMsrWr_Ia32MPerf,
5254 cpumMsrWr_Ia32APerf,
5255 cpumMsrWr_Ia32MtrrPhysBaseN,
5256 cpumMsrWr_Ia32MtrrPhysMaskN,
5257 cpumMsrWr_Ia32MtrrFixed,
5258 cpumMsrWr_Ia32MtrrDefType,
5259 cpumMsrWr_Ia32Pat,
5260 cpumMsrWr_Ia32SysEnterCs,
5261 cpumMsrWr_Ia32SysEnterEsp,
5262 cpumMsrWr_Ia32SysEnterEip,
5263 cpumMsrWr_Ia32McgStatus,
5264 cpumMsrWr_Ia32McgCtl,
5265 cpumMsrWr_Ia32DebugCtl,
5266 cpumMsrWr_Ia32SmrrPhysBase,
5267 cpumMsrWr_Ia32SmrrPhysMask,
5268 cpumMsrWr_Ia32PlatformDcaCap,
5269 cpumMsrWr_Ia32Dca0Cap,
5270 cpumMsrWr_Ia32PerfEvtSelN,
5271 cpumMsrWr_Ia32PerfStatus,
5272 cpumMsrWr_Ia32PerfCtl,
5273 cpumMsrWr_Ia32FixedCtrN,
5274 cpumMsrWr_Ia32PerfCapabilities,
5275 cpumMsrWr_Ia32FixedCtrCtrl,
5276 cpumMsrWr_Ia32PerfGlobalStatus,
5277 cpumMsrWr_Ia32PerfGlobalCtrl,
5278 cpumMsrWr_Ia32PerfGlobalOvfCtrl,
5279 cpumMsrWr_Ia32PebsEnable,
5280 cpumMsrWr_Ia32ClockModulation,
5281 cpumMsrWr_Ia32ThermInterrupt,
5282 cpumMsrWr_Ia32ThermStatus,
5283 cpumMsrWr_Ia32Therm2Ctl,
5284 cpumMsrWr_Ia32MiscEnable,
5285 cpumMsrWr_Ia32McCtlStatusAddrMiscN,
5286 cpumMsrWr_Ia32McNCtl2,
5287 cpumMsrWr_Ia32DsArea,
5288 cpumMsrWr_Ia32TscDeadline,
5289 cpumMsrWr_Ia32X2ApicN,
5290 cpumMsrWr_Ia32DebugInterface,
5291 cpumMsrWr_Ia32SpecCtrl,
5292 cpumMsrWr_Ia32PredCmd,
5293
5294 cpumMsrWr_Amd64Efer,
5295 cpumMsrWr_Amd64SyscallTarget,
5296 cpumMsrWr_Amd64LongSyscallTarget,
5297 cpumMsrWr_Amd64CompSyscallTarget,
5298 cpumMsrWr_Amd64SyscallFlagMask,
5299 cpumMsrWr_Amd64FsBase,
5300 cpumMsrWr_Amd64GsBase,
5301 cpumMsrWr_Amd64KernelGsBase,
5302 cpumMsrWr_Amd64TscAux,
5303
5304 cpumMsrWr_IntelEblCrPowerOn,
5305 cpumMsrWr_IntelP4EbcHardPowerOn,
5306 cpumMsrWr_IntelP4EbcSoftPowerOn,
5307 cpumMsrWr_IntelP4EbcFrequencyId,
5308 cpumMsrWr_IntelFlexRatio,
5309 cpumMsrWr_IntelPkgCStConfigControl,
5310 cpumMsrWr_IntelPmgIoCaptureBase,
5311 cpumMsrWr_IntelLastBranchFromToN,
5312 cpumMsrWr_IntelLastBranchFromN,
5313 cpumMsrWr_IntelLastBranchToN,
5314 cpumMsrWr_IntelLastBranchTos,
5315 cpumMsrWr_IntelBblCrCtl,
5316 cpumMsrWr_IntelBblCrCtl3,
5317 cpumMsrWr_IntelI7TemperatureTarget,
5318 cpumMsrWr_IntelI7MsrOffCoreResponseN,
5319 cpumMsrWr_IntelI7MiscPwrMgmt,
5320 cpumMsrWr_IntelP6CrN,
5321 cpumMsrWr_IntelCpuId1FeatureMaskEcdx,
5322 cpumMsrWr_IntelCpuId1FeatureMaskEax,
5323 cpumMsrWr_IntelCpuId80000001FeatureMaskEcdx,
5324 cpumMsrWr_IntelI7SandyAesNiCtl,
5325 cpumMsrWr_IntelI7TurboRatioLimit,
5326 cpumMsrWr_IntelI7LbrSelect,
5327 cpumMsrWr_IntelI7SandyErrorControl,
5328 cpumMsrWr_IntelI7PowerCtl,
5329 cpumMsrWr_IntelI7SandyPebsNumAlt,
5330 cpumMsrWr_IntelI7PebsLdLat,
5331 cpumMsrWr_IntelI7SandyVrCurrentConfig,
5332 cpumMsrWr_IntelI7SandyVrMiscConfig,
5333 cpumMsrWr_IntelI7SandyRaplPowerUnit,
5334 cpumMsrWr_IntelI7SandyPkgCnIrtlN,
5335 cpumMsrWr_IntelI7SandyPkgC2Residency,
5336 cpumMsrWr_IntelI7RaplPkgPowerLimit,
5337 cpumMsrWr_IntelI7RaplDramPowerLimit,
5338 cpumMsrWr_IntelI7RaplPp0PowerLimit,
5339 cpumMsrWr_IntelI7RaplPp0Policy,
5340 cpumMsrWr_IntelI7RaplPp1PowerLimit,
5341 cpumMsrWr_IntelI7RaplPp1Policy,
5342 cpumMsrWr_IntelI7IvyConfigTdpControl,
5343 cpumMsrWr_IntelI7IvyTurboActivationRatio,
5344 cpumMsrWr_IntelI7UncPerfGlobalCtrl,
5345 cpumMsrWr_IntelI7UncPerfGlobalStatus,
5346 cpumMsrWr_IntelI7UncPerfGlobalOvfCtrl,
5347 cpumMsrWr_IntelI7UncPerfFixedCtrCtrl,
5348 cpumMsrWr_IntelI7UncPerfFixedCtr,
5349 cpumMsrWr_IntelI7UncArbPerfCtrN,
5350 cpumMsrWr_IntelI7UncArbPerfEvtSelN,
5351 cpumMsrWr_IntelCore2EmttmCrTablesN,
5352 cpumMsrWr_IntelCore2SmmCStMiscInfo,
5353 cpumMsrWr_IntelCore1ExtConfig,
5354 cpumMsrWr_IntelCore1DtsCalControl,
5355 cpumMsrWr_IntelCore2PeciControl,
5356
5357 cpumMsrWr_P6LastIntFromIp,
5358 cpumMsrWr_P6LastIntToIp,
5359
5360 cpumMsrWr_AmdFam15hTscRate,
5361 cpumMsrWr_AmdFam15hLwpCfg,
5362 cpumMsrWr_AmdFam15hLwpCbAddr,
5363 cpumMsrWr_AmdFam10hMc4MiscN,
5364 cpumMsrWr_AmdK8PerfCtlN,
5365 cpumMsrWr_AmdK8PerfCtrN,
5366 cpumMsrWr_AmdK8SysCfg,
5367 cpumMsrWr_AmdK8HwCr,
5368 cpumMsrWr_AmdK8IorrBaseN,
5369 cpumMsrWr_AmdK8IorrMaskN,
5370 cpumMsrWr_AmdK8TopOfMemN,
5371 cpumMsrWr_AmdK8NbCfg1,
5372 cpumMsrWr_AmdK8McXcptRedir,
5373 cpumMsrWr_AmdK8CpuNameN,
5374 cpumMsrWr_AmdK8HwThermalCtrl,
5375 cpumMsrWr_AmdK8SwThermalCtrl,
5376 cpumMsrWr_AmdK8FidVidControl,
5377 cpumMsrWr_AmdK8McCtlMaskN,
5378 cpumMsrWr_AmdK8SmiOnIoTrapN,
5379 cpumMsrWr_AmdK8SmiOnIoTrapCtlSts,
5380 cpumMsrWr_AmdK8IntPendingMessage,
5381 cpumMsrWr_AmdK8SmiTriggerIoCycle,
5382 cpumMsrWr_AmdFam10hMmioCfgBaseAddr,
5383 cpumMsrWr_AmdFam10hTrapCtlMaybe,
5384 cpumMsrWr_AmdFam10hPStateControl,
5385 cpumMsrWr_AmdFam10hPStateStatus,
5386 cpumMsrWr_AmdFam10hPStateN,
5387 cpumMsrWr_AmdFam10hCofVidControl,
5388 cpumMsrWr_AmdFam10hCofVidStatus,
5389 cpumMsrWr_AmdFam10hCStateIoBaseAddr,
5390 cpumMsrWr_AmdFam10hCpuWatchdogTimer,
5391 cpumMsrWr_AmdK8SmmBase,
5392 cpumMsrWr_AmdK8SmmAddr,
5393 cpumMsrWr_AmdK8SmmMask,
5394 cpumMsrWr_AmdK8VmCr,
5395 cpumMsrWr_AmdK8IgnNe,
5396 cpumMsrWr_AmdK8SmmCtl,
5397 cpumMsrWr_AmdK8VmHSavePa,
5398 cpumMsrWr_AmdFam10hVmLockKey,
5399 cpumMsrWr_AmdFam10hSmmLockKey,
5400 cpumMsrWr_AmdFam10hLocalSmiStatus,
5401 cpumMsrWr_AmdFam10hOsVisWrkIdLength,
5402 cpumMsrWr_AmdFam10hOsVisWrkStatus,
5403 cpumMsrWr_AmdFam16hL2IPerfCtlN,
5404 cpumMsrWr_AmdFam16hL2IPerfCtrN,
5405 cpumMsrWr_AmdFam15hNorthbridgePerfCtlN,
5406 cpumMsrWr_AmdFam15hNorthbridgePerfCtrN,
5407 cpumMsrWr_AmdK7MicrocodeCtl,
5408 cpumMsrWr_AmdK7ClusterIdMaybe,
5409 cpumMsrWr_AmdK8CpuIdCtlStd07hEbax,
5410 cpumMsrWr_AmdK8CpuIdCtlStd06hEcx,
5411 cpumMsrWr_AmdK8CpuIdCtlStd01hEdcx,
5412 cpumMsrWr_AmdK8CpuIdCtlExt01hEdcx,
5413 cpumMsrWr_AmdK8PatchLoader,
5414 cpumMsrWr_AmdK7DebugStatusMaybe,
5415 cpumMsrWr_AmdK7BHTraceBaseMaybe,
5416 cpumMsrWr_AmdK7BHTracePtrMaybe,
5417 cpumMsrWr_AmdK7BHTraceLimitMaybe,
5418 cpumMsrWr_AmdK7HardwareDebugToolCfgMaybe,
5419 cpumMsrWr_AmdK7FastFlushCountMaybe,
5420 cpumMsrWr_AmdK7NodeId,
5421 cpumMsrWr_AmdK7DrXAddrMaskN,
5422 cpumMsrWr_AmdK7Dr0DataMatchMaybe,
5423 cpumMsrWr_AmdK7Dr0DataMaskMaybe,
5424 cpumMsrWr_AmdK7LoadStoreCfg,
5425 cpumMsrWr_AmdK7InstrCacheCfg,
5426 cpumMsrWr_AmdK7DataCacheCfg,
5427 cpumMsrWr_AmdK7BusUnitCfg,
5428 cpumMsrWr_AmdK7DebugCtl2Maybe,
5429 cpumMsrWr_AmdFam15hFpuCfg,
5430 cpumMsrWr_AmdFam15hDecoderCfg,
5431 cpumMsrWr_AmdFam10hBusUnitCfg2,
5432 cpumMsrWr_AmdFam15hCombUnitCfg,
5433 cpumMsrWr_AmdFam15hCombUnitCfg2,
5434 cpumMsrWr_AmdFam15hCombUnitCfg3,
5435 cpumMsrWr_AmdFam15hExecUnitCfg,
5436 cpumMsrWr_AmdFam15hLoadStoreCfg2,
5437 cpumMsrWr_AmdFam10hIbsFetchCtl,
5438 cpumMsrWr_AmdFam10hIbsFetchLinAddr,
5439 cpumMsrWr_AmdFam10hIbsFetchPhysAddr,
5440 cpumMsrWr_AmdFam10hIbsOpExecCtl,
5441 cpumMsrWr_AmdFam10hIbsOpRip,
5442 cpumMsrWr_AmdFam10hIbsOpData,
5443 cpumMsrWr_AmdFam10hIbsOpData2,
5444 cpumMsrWr_AmdFam10hIbsOpData3,
5445 cpumMsrWr_AmdFam10hIbsDcLinAddr,
5446 cpumMsrWr_AmdFam10hIbsDcPhysAddr,
5447 cpumMsrWr_AmdFam10hIbsCtl,
5448 cpumMsrWr_AmdFam14hIbsBrTarget,
5449
5450 cpumMsrWr_Gim
5451};
5452
5453
5454/**
5455 * Looks up the range for the given MSR.
5456 *
5457 * @returns Pointer to the range if found, NULL if not.
5458 * @param pVM The cross context VM structure.
5459 * @param idMsr The MSR to look up.
5460 */
5461# ifndef IN_RING3
5462static
5463# endif
5464PCPUMMSRRANGE cpumLookupMsrRange(PVM pVM, uint32_t idMsr)
5465{
5466 /*
5467 * Binary lookup.
5468 */
5469 uint32_t cRanges = pVM->cpum.s.GuestInfo.cMsrRanges;
5470 if (!cRanges)
5471 return NULL;
5472 PCPUMMSRRANGE paRanges = pVM->cpum.s.GuestInfo.CTX_SUFF(paMsrRanges);
5473 for (;;)
5474 {
5475 uint32_t i = cRanges / 2;
5476 if (idMsr < paRanges[i].uFirst)
5477 {
5478 if (i == 0)
5479 break;
5480 cRanges = i;
5481 }
5482 else if (idMsr > paRanges[i].uLast)
5483 {
5484 i++;
5485 if (i >= cRanges)
5486 break;
5487 cRanges -= i;
5488 paRanges = &paRanges[i];
5489 }
5490 else
5491 {
5492 if (paRanges[i].enmRdFn == kCpumMsrRdFn_MsrAlias)
5493 return cpumLookupMsrRange(pVM, paRanges[i].uValue);
5494 return &paRanges[i];
5495 }
5496 }
5497
5498# ifdef VBOX_STRICT
5499 /*
5500 * Linear lookup to verify the above binary search.
5501 */
5502 uint32_t cLeft = pVM->cpum.s.GuestInfo.cMsrRanges;
5503 PCPUMMSRRANGE pCur = pVM->cpum.s.GuestInfo.CTX_SUFF(paMsrRanges);
5504 while (cLeft-- > 0)
5505 {
5506 if (idMsr >= pCur->uFirst && idMsr <= pCur->uLast)
5507 {
5508 AssertFailed();
5509 if (pCur->enmRdFn == kCpumMsrRdFn_MsrAlias)
5510 return cpumLookupMsrRange(pVM, pCur->uValue);
5511 return pCur;
5512 }
5513 pCur++;
5514 }
5515# endif
5516 return NULL;
5517}
5518
5519
5520/**
5521 * Query a guest MSR.
5522 *
5523 * The caller is responsible for checking privilege if the call is the result of
5524 * a RDMSR instruction. We'll do the rest.
5525 *
5526 * @retval VINF_SUCCESS on success.
5527 * @retval VINF_CPUM_R3_MSR_READ if the MSR read could not be serviced in the
5528 * current context (raw-mode or ring-0).
5529 * @retval VERR_CPUM_RAISE_GP_0 on failure (invalid MSR), the caller is
5530 * expected to take the appropriate actions. @a *puValue is set to 0.
5531 * @param pVCpu The cross context virtual CPU structure.
5532 * @param idMsr The MSR.
5533 * @param puValue Where to return the value.
5534 *
5535 * @remarks This will always return the right values, even when we're in the
5536 * recompiler.
5537 */
5538VMMDECL(VBOXSTRICTRC) CPUMQueryGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t *puValue)
5539{
5540 *puValue = 0;
5541
5542 VBOXSTRICTRC rcStrict;
5543 PVM pVM = pVCpu->CTX_SUFF(pVM);
5544 PCPUMMSRRANGE pRange = cpumLookupMsrRange(pVM, idMsr);
5545 if (pRange)
5546 {
5547 CPUMMSRRDFN enmRdFn = (CPUMMSRRDFN)pRange->enmRdFn;
5548 AssertReturn(enmRdFn > kCpumMsrRdFn_Invalid && enmRdFn < kCpumMsrRdFn_End, VERR_CPUM_IPE_1);
5549
5550 PFNCPUMRDMSR pfnRdMsr = g_aCpumRdMsrFns[enmRdFn];
5551 AssertReturn(pfnRdMsr, VERR_CPUM_IPE_2);
5552
5553 STAM_COUNTER_INC(&pRange->cReads);
5554 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrReads);
5555
5556 rcStrict = pfnRdMsr(pVCpu, idMsr, pRange, puValue);
5557 if (rcStrict == VINF_SUCCESS)
5558 Log2(("CPUM: RDMSR %#x (%s) -> %#llx\n", idMsr, pRange->szName, *puValue));
5559 else if (rcStrict == VERR_CPUM_RAISE_GP_0)
5560 {
5561 Log(("CPUM: RDMSR %#x (%s) -> #GP(0)\n", idMsr, pRange->szName));
5562 STAM_COUNTER_INC(&pRange->cGps);
5563 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrReadsRaiseGp);
5564 }
5565#ifndef IN_RING3
5566 else if (rcStrict == VINF_CPUM_R3_MSR_READ)
5567 Log(("CPUM: RDMSR %#x (%s) -> ring-3\n", idMsr, pRange->szName));
5568#endif
5569 else
5570 {
5571 Log(("CPUM: RDMSR %#x (%s) -> rcStrict=%Rrc\n", idMsr, pRange->szName, VBOXSTRICTRC_VAL(rcStrict)));
5572 AssertMsgStmt(RT_FAILURE_NP(rcStrict), ("%Rrc idMsr=%#x\n", VBOXSTRICTRC_VAL(rcStrict), idMsr),
5573 rcStrict = VERR_IPE_UNEXPECTED_INFO_STATUS);
5574 Assert(rcStrict != VERR_EM_INTERPRETER);
5575 }
5576 }
5577 else
5578 {
5579 Log(("CPUM: Unknown RDMSR %#x -> #GP(0)\n", idMsr));
5580 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrReads);
5581 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrReadsUnknown);
5582 rcStrict = VERR_CPUM_RAISE_GP_0;
5583 }
5584 return rcStrict;
5585}
5586
5587
5588/**
5589 * Writes to a guest MSR.
5590 *
5591 * The caller is responsible for checking privilege if the call is the result of
5592 * a WRMSR instruction. We'll do the rest.
5593 *
5594 * @retval VINF_SUCCESS on success.
5595 * @retval VINF_CPUM_R3_MSR_WRITE if the MSR write could not be serviced in the
5596 * current context (raw-mode or ring-0).
5597 * @retval VERR_CPUM_RAISE_GP_0 on failure, the caller is expected to take the
5598 * appropriate actions.
5599 *
5600 * @param pVCpu The cross context virtual CPU structure.
5601 * @param idMsr The MSR id.
5602 * @param uValue The value to set.
5603 *
5604 * @remarks Everyone changing MSR values, including the recompiler, shall do it
5605 * by calling this method. This makes sure we have current values and
5606 * that we trigger all the right actions when something changes.
5607 *
5608 * For performance reasons, this actually isn't entirely true for some
5609 * MSRs when in HM mode. The code here and in HM must be aware of
5610 * this.
5611 */
5612VMMDECL(VBOXSTRICTRC) CPUMSetGuestMsr(PVMCPU pVCpu, uint32_t idMsr, uint64_t uValue)
5613{
5614 VBOXSTRICTRC rcStrict;
5615 PVM pVM = pVCpu->CTX_SUFF(pVM);
5616 PCPUMMSRRANGE pRange = cpumLookupMsrRange(pVM, idMsr);
5617 if (pRange)
5618 {
5619 STAM_COUNTER_INC(&pRange->cWrites);
5620 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrWrites);
5621
5622 if (!(uValue & pRange->fWrGpMask))
5623 {
5624 CPUMMSRWRFN enmWrFn = (CPUMMSRWRFN)pRange->enmWrFn;
5625 AssertReturn(enmWrFn > kCpumMsrWrFn_Invalid && enmWrFn < kCpumMsrWrFn_End, VERR_CPUM_IPE_1);
5626
5627 PFNCPUMWRMSR pfnWrMsr = g_aCpumWrMsrFns[enmWrFn];
5628 AssertReturn(pfnWrMsr, VERR_CPUM_IPE_2);
5629
5630 uint64_t uValueAdjusted = uValue & ~pRange->fWrIgnMask;
5631 if (uValueAdjusted != uValue)
5632 {
5633 STAM_COUNTER_INC(&pRange->cIgnoredBits);
5634 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrWritesToIgnoredBits);
5635 }
5636
5637 rcStrict = pfnWrMsr(pVCpu, idMsr, pRange, uValueAdjusted, uValue);
5638 if (rcStrict == VINF_SUCCESS)
5639 Log2(("CPUM: WRMSR %#x (%s), %#llx [%#llx]\n", idMsr, pRange->szName, uValueAdjusted, uValue));
5640 else if (rcStrict == VERR_CPUM_RAISE_GP_0)
5641 {
5642 Log(("CPUM: WRMSR %#x (%s), %#llx [%#llx] -> #GP(0)\n", idMsr, pRange->szName, uValueAdjusted, uValue));
5643 STAM_COUNTER_INC(&pRange->cGps);
5644 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrWritesRaiseGp);
5645 }
5646#ifndef IN_RING3
5647 else if (rcStrict == VINF_CPUM_R3_MSR_WRITE)
5648 Log(("CPUM: WRMSR %#x (%s), %#llx [%#llx] -> ring-3\n", idMsr, pRange->szName, uValueAdjusted, uValue));
5649#endif
5650 else
5651 {
5652 Log(("CPUM: WRMSR %#x (%s), %#llx [%#llx] -> rcStrict=%Rrc\n",
5653 idMsr, pRange->szName, uValueAdjusted, uValue, VBOXSTRICTRC_VAL(rcStrict)));
5654 AssertMsgStmt(RT_FAILURE_NP(rcStrict), ("%Rrc idMsr=%#x\n", VBOXSTRICTRC_VAL(rcStrict), idMsr),
5655 rcStrict = VERR_IPE_UNEXPECTED_INFO_STATUS);
5656 Assert(rcStrict != VERR_EM_INTERPRETER);
5657 }
5658 }
5659 else
5660 {
5661 Log(("CPUM: WRMSR %#x (%s), %#llx -> #GP(0) - invalid bits %#llx\n",
5662 idMsr, pRange->szName, uValue, uValue & pRange->fWrGpMask));
5663 STAM_COUNTER_INC(&pRange->cGps);
5664 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrWritesRaiseGp);
5665 rcStrict = VERR_CPUM_RAISE_GP_0;
5666 }
5667 }
5668 else
5669 {
5670 Log(("CPUM: Unknown WRMSR %#x, %#llx -> #GP(0)\n", idMsr, uValue));
5671 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrWrites);
5672 STAM_REL_COUNTER_INC(&pVM->cpum.s.cMsrWritesUnknown);
5673 rcStrict = VERR_CPUM_RAISE_GP_0;
5674 }
5675 return rcStrict;
5676}
5677
5678
5679#if defined(VBOX_STRICT) && defined(IN_RING3)
5680/**
5681 * Performs some checks on the static data related to MSRs.
5682 *
5683 * @returns VINF_SUCCESS on success, error on failure.
5684 */
5685int cpumR3MsrStrictInitChecks(void)
5686{
5687#define CPUM_ASSERT_RD_MSR_FN(a_Register) \
5688 AssertReturn(g_aCpumRdMsrFns[kCpumMsrRdFn_##a_Register] == cpumMsrRd_##a_Register, VERR_CPUM_IPE_2);
5689#define CPUM_ASSERT_WR_MSR_FN(a_Register) \
5690 AssertReturn(g_aCpumWrMsrFns[kCpumMsrWrFn_##a_Register] == cpumMsrWr_##a_Register, VERR_CPUM_IPE_2);
5691
5692 AssertReturn(g_aCpumRdMsrFns[kCpumMsrRdFn_Invalid] == NULL, VERR_CPUM_IPE_2);
5693 CPUM_ASSERT_RD_MSR_FN(FixedValue);
5694 CPUM_ASSERT_RD_MSR_FN(WriteOnly);
5695 CPUM_ASSERT_RD_MSR_FN(Ia32P5McAddr);
5696 CPUM_ASSERT_RD_MSR_FN(Ia32P5McType);
5697 CPUM_ASSERT_RD_MSR_FN(Ia32TimestampCounter);
5698 CPUM_ASSERT_RD_MSR_FN(Ia32PlatformId);
5699 CPUM_ASSERT_RD_MSR_FN(Ia32ApicBase);
5700 CPUM_ASSERT_RD_MSR_FN(Ia32FeatureControl);
5701 CPUM_ASSERT_RD_MSR_FN(Ia32BiosSignId);
5702 CPUM_ASSERT_RD_MSR_FN(Ia32SmmMonitorCtl);
5703 CPUM_ASSERT_RD_MSR_FN(Ia32PmcN);
5704 CPUM_ASSERT_RD_MSR_FN(Ia32MonitorFilterLineSize);
5705 CPUM_ASSERT_RD_MSR_FN(Ia32MPerf);
5706 CPUM_ASSERT_RD_MSR_FN(Ia32APerf);
5707 CPUM_ASSERT_RD_MSR_FN(Ia32MtrrCap);
5708 CPUM_ASSERT_RD_MSR_FN(Ia32MtrrPhysBaseN);
5709 CPUM_ASSERT_RD_MSR_FN(Ia32MtrrPhysMaskN);
5710 CPUM_ASSERT_RD_MSR_FN(Ia32MtrrFixed);
5711 CPUM_ASSERT_RD_MSR_FN(Ia32MtrrDefType);
5712 CPUM_ASSERT_RD_MSR_FN(Ia32Pat);
5713 CPUM_ASSERT_RD_MSR_FN(Ia32SysEnterCs);
5714 CPUM_ASSERT_RD_MSR_FN(Ia32SysEnterEsp);
5715 CPUM_ASSERT_RD_MSR_FN(Ia32SysEnterEip);
5716 CPUM_ASSERT_RD_MSR_FN(Ia32McgCap);
5717 CPUM_ASSERT_RD_MSR_FN(Ia32McgStatus);
5718 CPUM_ASSERT_RD_MSR_FN(Ia32McgCtl);
5719 CPUM_ASSERT_RD_MSR_FN(Ia32DebugCtl);
5720 CPUM_ASSERT_RD_MSR_FN(Ia32SmrrPhysBase);
5721 CPUM_ASSERT_RD_MSR_FN(Ia32SmrrPhysMask);
5722 CPUM_ASSERT_RD_MSR_FN(Ia32PlatformDcaCap);
5723 CPUM_ASSERT_RD_MSR_FN(Ia32CpuDcaCap);
5724 CPUM_ASSERT_RD_MSR_FN(Ia32Dca0Cap);
5725 CPUM_ASSERT_RD_MSR_FN(Ia32PerfEvtSelN);
5726 CPUM_ASSERT_RD_MSR_FN(Ia32PerfStatus);
5727 CPUM_ASSERT_RD_MSR_FN(Ia32PerfCtl);
5728 CPUM_ASSERT_RD_MSR_FN(Ia32FixedCtrN);
5729 CPUM_ASSERT_RD_MSR_FN(Ia32PerfCapabilities);
5730 CPUM_ASSERT_RD_MSR_FN(Ia32FixedCtrCtrl);
5731 CPUM_ASSERT_RD_MSR_FN(Ia32PerfGlobalStatus);
5732 CPUM_ASSERT_RD_MSR_FN(Ia32PerfGlobalCtrl);
5733 CPUM_ASSERT_RD_MSR_FN(Ia32PerfGlobalOvfCtrl);
5734 CPUM_ASSERT_RD_MSR_FN(Ia32PebsEnable);
5735 CPUM_ASSERT_RD_MSR_FN(Ia32ClockModulation);
5736 CPUM_ASSERT_RD_MSR_FN(Ia32ThermInterrupt);
5737 CPUM_ASSERT_RD_MSR_FN(Ia32ThermStatus);
5738 CPUM_ASSERT_RD_MSR_FN(Ia32MiscEnable);
5739 CPUM_ASSERT_RD_MSR_FN(Ia32McCtlStatusAddrMiscN);
5740 CPUM_ASSERT_RD_MSR_FN(Ia32McNCtl2);
5741 CPUM_ASSERT_RD_MSR_FN(Ia32DsArea);
5742 CPUM_ASSERT_RD_MSR_FN(Ia32TscDeadline);
5743 CPUM_ASSERT_RD_MSR_FN(Ia32X2ApicN);
5744 CPUM_ASSERT_RD_MSR_FN(Ia32DebugInterface);
5745 CPUM_ASSERT_RD_MSR_FN(Ia32VmxBase);
5746 CPUM_ASSERT_RD_MSR_FN(Ia32VmxPinbasedCtls);
5747 CPUM_ASSERT_RD_MSR_FN(Ia32VmxProcbasedCtls);
5748 CPUM_ASSERT_RD_MSR_FN(Ia32VmxExitCtls);
5749 CPUM_ASSERT_RD_MSR_FN(Ia32VmxEntryCtls);
5750 CPUM_ASSERT_RD_MSR_FN(Ia32VmxMisc);
5751 CPUM_ASSERT_RD_MSR_FN(Ia32VmxCr0Fixed0);
5752 CPUM_ASSERT_RD_MSR_FN(Ia32VmxCr0Fixed1);
5753 CPUM_ASSERT_RD_MSR_FN(Ia32VmxCr4Fixed0);
5754 CPUM_ASSERT_RD_MSR_FN(Ia32VmxCr4Fixed1);
5755 CPUM_ASSERT_RD_MSR_FN(Ia32VmxVmcsEnum);
5756 CPUM_ASSERT_RD_MSR_FN(Ia32VmxProcBasedCtls2);
5757 CPUM_ASSERT_RD_MSR_FN(Ia32VmxEptVpidCap);
5758 CPUM_ASSERT_RD_MSR_FN(Ia32VmxTruePinbasedCtls);
5759 CPUM_ASSERT_RD_MSR_FN(Ia32VmxTrueProcbasedCtls);
5760 CPUM_ASSERT_RD_MSR_FN(Ia32VmxTrueExitCtls);
5761 CPUM_ASSERT_RD_MSR_FN(Ia32VmxTrueEntryCtls);
5762 CPUM_ASSERT_RD_MSR_FN(Ia32VmxVmFunc);
5763 CPUM_ASSERT_RD_MSR_FN(Ia32SpecCtrl);
5764 CPUM_ASSERT_RD_MSR_FN(Ia32ArchCapabilities);
5765
5766 CPUM_ASSERT_RD_MSR_FN(Amd64Efer);
5767 CPUM_ASSERT_RD_MSR_FN(Amd64SyscallTarget);
5768 CPUM_ASSERT_RD_MSR_FN(Amd64LongSyscallTarget);
5769 CPUM_ASSERT_RD_MSR_FN(Amd64CompSyscallTarget);
5770 CPUM_ASSERT_RD_MSR_FN(Amd64SyscallFlagMask);
5771 CPUM_ASSERT_RD_MSR_FN(Amd64FsBase);
5772 CPUM_ASSERT_RD_MSR_FN(Amd64GsBase);
5773 CPUM_ASSERT_RD_MSR_FN(Amd64KernelGsBase);
5774 CPUM_ASSERT_RD_MSR_FN(Amd64TscAux);
5775
5776 CPUM_ASSERT_RD_MSR_FN(IntelEblCrPowerOn);
5777 CPUM_ASSERT_RD_MSR_FN(IntelI7CoreThreadCount);
5778 CPUM_ASSERT_RD_MSR_FN(IntelP4EbcHardPowerOn);
5779 CPUM_ASSERT_RD_MSR_FN(IntelP4EbcSoftPowerOn);
5780 CPUM_ASSERT_RD_MSR_FN(IntelP4EbcFrequencyId);
5781 CPUM_ASSERT_RD_MSR_FN(IntelP6FsbFrequency);
5782 CPUM_ASSERT_RD_MSR_FN(IntelPlatformInfo);
5783 CPUM_ASSERT_RD_MSR_FN(IntelFlexRatio);
5784 CPUM_ASSERT_RD_MSR_FN(IntelPkgCStConfigControl);
5785 CPUM_ASSERT_RD_MSR_FN(IntelPmgIoCaptureBase);
5786 CPUM_ASSERT_RD_MSR_FN(IntelLastBranchFromToN);
5787 CPUM_ASSERT_RD_MSR_FN(IntelLastBranchFromN);
5788 CPUM_ASSERT_RD_MSR_FN(IntelLastBranchToN);
5789 CPUM_ASSERT_RD_MSR_FN(IntelLastBranchTos);
5790 CPUM_ASSERT_RD_MSR_FN(IntelBblCrCtl);
5791 CPUM_ASSERT_RD_MSR_FN(IntelBblCrCtl3);
5792 CPUM_ASSERT_RD_MSR_FN(IntelI7TemperatureTarget);
5793 CPUM_ASSERT_RD_MSR_FN(IntelI7MsrOffCoreResponseN);
5794 CPUM_ASSERT_RD_MSR_FN(IntelI7MiscPwrMgmt);
5795 CPUM_ASSERT_RD_MSR_FN(IntelP6CrN);
5796 CPUM_ASSERT_RD_MSR_FN(IntelCpuId1FeatureMaskEcdx);
5797 CPUM_ASSERT_RD_MSR_FN(IntelCpuId1FeatureMaskEax);
5798 CPUM_ASSERT_RD_MSR_FN(IntelCpuId80000001FeatureMaskEcdx);
5799 CPUM_ASSERT_RD_MSR_FN(IntelI7SandyAesNiCtl);
5800 CPUM_ASSERT_RD_MSR_FN(IntelI7TurboRatioLimit);
5801 CPUM_ASSERT_RD_MSR_FN(IntelI7LbrSelect);
5802 CPUM_ASSERT_RD_MSR_FN(IntelI7SandyErrorControl);
5803 CPUM_ASSERT_RD_MSR_FN(IntelI7VirtualLegacyWireCap);
5804 CPUM_ASSERT_RD_MSR_FN(IntelI7PowerCtl);
5805 CPUM_ASSERT_RD_MSR_FN(IntelI7SandyPebsNumAlt);
5806 CPUM_ASSERT_RD_MSR_FN(IntelI7PebsLdLat);
5807 CPUM_ASSERT_RD_MSR_FN(IntelI7PkgCnResidencyN);
5808 CPUM_ASSERT_RD_MSR_FN(IntelI7CoreCnResidencyN);
5809 CPUM_ASSERT_RD_MSR_FN(IntelI7SandyVrCurrentConfig);
5810 CPUM_ASSERT_RD_MSR_FN(IntelI7SandyVrMiscConfig);
5811 CPUM_ASSERT_RD_MSR_FN(IntelI7SandyRaplPowerUnit);
5812 CPUM_ASSERT_RD_MSR_FN(IntelI7SandyPkgCnIrtlN);
5813 CPUM_ASSERT_RD_MSR_FN(IntelI7SandyPkgC2Residency);
5814 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPkgPowerLimit);
5815 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPkgEnergyStatus);
5816 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPkgPerfStatus);
5817 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPkgPowerInfo);
5818 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplDramPowerLimit);
5819 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplDramEnergyStatus);
5820 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplDramPerfStatus);
5821 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplDramPowerInfo);
5822 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPp0PowerLimit);
5823 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPp0EnergyStatus);
5824 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPp0Policy);
5825 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPp0PerfStatus);
5826 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPp1PowerLimit);
5827 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPp1EnergyStatus);
5828 CPUM_ASSERT_RD_MSR_FN(IntelI7RaplPp1Policy);
5829 CPUM_ASSERT_RD_MSR_FN(IntelI7IvyConfigTdpNominal);
5830 CPUM_ASSERT_RD_MSR_FN(IntelI7IvyConfigTdpLevel1);
5831 CPUM_ASSERT_RD_MSR_FN(IntelI7IvyConfigTdpLevel2);
5832 CPUM_ASSERT_RD_MSR_FN(IntelI7IvyConfigTdpControl);
5833 CPUM_ASSERT_RD_MSR_FN(IntelI7IvyTurboActivationRatio);
5834 CPUM_ASSERT_RD_MSR_FN(IntelI7UncPerfGlobalCtrl);
5835 CPUM_ASSERT_RD_MSR_FN(IntelI7UncPerfGlobalStatus);
5836 CPUM_ASSERT_RD_MSR_FN(IntelI7UncPerfGlobalOvfCtrl);
5837 CPUM_ASSERT_RD_MSR_FN(IntelI7UncPerfFixedCtrCtrl);
5838 CPUM_ASSERT_RD_MSR_FN(IntelI7UncPerfFixedCtr);
5839 CPUM_ASSERT_RD_MSR_FN(IntelI7UncCBoxConfig);
5840 CPUM_ASSERT_RD_MSR_FN(IntelI7UncArbPerfCtrN);
5841 CPUM_ASSERT_RD_MSR_FN(IntelI7UncArbPerfEvtSelN);
5842 CPUM_ASSERT_RD_MSR_FN(IntelI7SmiCount);
5843 CPUM_ASSERT_RD_MSR_FN(IntelCore2EmttmCrTablesN);
5844 CPUM_ASSERT_RD_MSR_FN(IntelCore2SmmCStMiscInfo);
5845 CPUM_ASSERT_RD_MSR_FN(IntelCore1ExtConfig);
5846 CPUM_ASSERT_RD_MSR_FN(IntelCore1DtsCalControl);
5847 CPUM_ASSERT_RD_MSR_FN(IntelCore2PeciControl);
5848 CPUM_ASSERT_RD_MSR_FN(IntelAtSilvCoreC1Recidency);
5849
5850 CPUM_ASSERT_RD_MSR_FN(P6LastBranchFromIp);
5851 CPUM_ASSERT_RD_MSR_FN(P6LastBranchToIp);
5852 CPUM_ASSERT_RD_MSR_FN(P6LastIntFromIp);
5853 CPUM_ASSERT_RD_MSR_FN(P6LastIntToIp);
5854
5855 CPUM_ASSERT_RD_MSR_FN(AmdFam15hTscRate);
5856 CPUM_ASSERT_RD_MSR_FN(AmdFam15hLwpCfg);
5857 CPUM_ASSERT_RD_MSR_FN(AmdFam15hLwpCbAddr);
5858 CPUM_ASSERT_RD_MSR_FN(AmdFam10hMc4MiscN);
5859 CPUM_ASSERT_RD_MSR_FN(AmdK8PerfCtlN);
5860 CPUM_ASSERT_RD_MSR_FN(AmdK8PerfCtrN);
5861 CPUM_ASSERT_RD_MSR_FN(AmdK8SysCfg);
5862 CPUM_ASSERT_RD_MSR_FN(AmdK8HwCr);
5863 CPUM_ASSERT_RD_MSR_FN(AmdK8IorrBaseN);
5864 CPUM_ASSERT_RD_MSR_FN(AmdK8IorrMaskN);
5865 CPUM_ASSERT_RD_MSR_FN(AmdK8TopOfMemN);
5866 CPUM_ASSERT_RD_MSR_FN(AmdK8NbCfg1);
5867 CPUM_ASSERT_RD_MSR_FN(AmdK8McXcptRedir);
5868 CPUM_ASSERT_RD_MSR_FN(AmdK8CpuNameN);
5869 CPUM_ASSERT_RD_MSR_FN(AmdK8HwThermalCtrl);
5870 CPUM_ASSERT_RD_MSR_FN(AmdK8SwThermalCtrl);
5871 CPUM_ASSERT_RD_MSR_FN(AmdK8FidVidControl);
5872 CPUM_ASSERT_RD_MSR_FN(AmdK8FidVidStatus);
5873 CPUM_ASSERT_RD_MSR_FN(AmdK8McCtlMaskN);
5874 CPUM_ASSERT_RD_MSR_FN(AmdK8SmiOnIoTrapN);
5875 CPUM_ASSERT_RD_MSR_FN(AmdK8SmiOnIoTrapCtlSts);
5876 CPUM_ASSERT_RD_MSR_FN(AmdK8IntPendingMessage);
5877 CPUM_ASSERT_RD_MSR_FN(AmdK8SmiTriggerIoCycle);
5878 CPUM_ASSERT_RD_MSR_FN(AmdFam10hMmioCfgBaseAddr);
5879 CPUM_ASSERT_RD_MSR_FN(AmdFam10hTrapCtlMaybe);
5880 CPUM_ASSERT_RD_MSR_FN(AmdFam10hPStateCurLimit);
5881 CPUM_ASSERT_RD_MSR_FN(AmdFam10hPStateControl);
5882 CPUM_ASSERT_RD_MSR_FN(AmdFam10hPStateStatus);
5883 CPUM_ASSERT_RD_MSR_FN(AmdFam10hPStateN);
5884 CPUM_ASSERT_RD_MSR_FN(AmdFam10hCofVidControl);
5885 CPUM_ASSERT_RD_MSR_FN(AmdFam10hCofVidStatus);
5886 CPUM_ASSERT_RD_MSR_FN(AmdFam10hCStateIoBaseAddr);
5887 CPUM_ASSERT_RD_MSR_FN(AmdFam10hCpuWatchdogTimer);
5888 CPUM_ASSERT_RD_MSR_FN(AmdK8SmmBase);
5889 CPUM_ASSERT_RD_MSR_FN(AmdK8SmmAddr);
5890 CPUM_ASSERT_RD_MSR_FN(AmdK8SmmMask);
5891 CPUM_ASSERT_RD_MSR_FN(AmdK8VmCr);
5892 CPUM_ASSERT_RD_MSR_FN(AmdK8IgnNe);
5893 CPUM_ASSERT_RD_MSR_FN(AmdK8SmmCtl);
5894 CPUM_ASSERT_RD_MSR_FN(AmdK8VmHSavePa);
5895 CPUM_ASSERT_RD_MSR_FN(AmdFam10hVmLockKey);
5896 CPUM_ASSERT_RD_MSR_FN(AmdFam10hSmmLockKey);
5897 CPUM_ASSERT_RD_MSR_FN(AmdFam10hLocalSmiStatus);
5898 CPUM_ASSERT_RD_MSR_FN(AmdFam10hOsVisWrkIdLength);
5899 CPUM_ASSERT_RD_MSR_FN(AmdFam10hOsVisWrkStatus);
5900 CPUM_ASSERT_RD_MSR_FN(AmdFam16hL2IPerfCtlN);
5901 CPUM_ASSERT_RD_MSR_FN(AmdFam16hL2IPerfCtrN);
5902 CPUM_ASSERT_RD_MSR_FN(AmdFam15hNorthbridgePerfCtlN);
5903 CPUM_ASSERT_RD_MSR_FN(AmdFam15hNorthbridgePerfCtrN);
5904 CPUM_ASSERT_RD_MSR_FN(AmdK7MicrocodeCtl);
5905 CPUM_ASSERT_RD_MSR_FN(AmdK7ClusterIdMaybe);
5906 CPUM_ASSERT_RD_MSR_FN(AmdK8CpuIdCtlStd07hEbax);
5907 CPUM_ASSERT_RD_MSR_FN(AmdK8CpuIdCtlStd06hEcx);
5908 CPUM_ASSERT_RD_MSR_FN(AmdK8CpuIdCtlStd01hEdcx);
5909 CPUM_ASSERT_RD_MSR_FN(AmdK8CpuIdCtlExt01hEdcx);
5910 CPUM_ASSERT_RD_MSR_FN(AmdK8PatchLevel);
5911 CPUM_ASSERT_RD_MSR_FN(AmdK7DebugStatusMaybe);
5912 CPUM_ASSERT_RD_MSR_FN(AmdK7BHTraceBaseMaybe);
5913 CPUM_ASSERT_RD_MSR_FN(AmdK7BHTracePtrMaybe);
5914 CPUM_ASSERT_RD_MSR_FN(AmdK7BHTraceLimitMaybe);
5915 CPUM_ASSERT_RD_MSR_FN(AmdK7HardwareDebugToolCfgMaybe);
5916 CPUM_ASSERT_RD_MSR_FN(AmdK7FastFlushCountMaybe);
5917 CPUM_ASSERT_RD_MSR_FN(AmdK7NodeId);
5918 CPUM_ASSERT_RD_MSR_FN(AmdK7DrXAddrMaskN);
5919 CPUM_ASSERT_RD_MSR_FN(AmdK7Dr0DataMatchMaybe);
5920 CPUM_ASSERT_RD_MSR_FN(AmdK7Dr0DataMaskMaybe);
5921 CPUM_ASSERT_RD_MSR_FN(AmdK7LoadStoreCfg);
5922 CPUM_ASSERT_RD_MSR_FN(AmdK7InstrCacheCfg);
5923 CPUM_ASSERT_RD_MSR_FN(AmdK7DataCacheCfg);
5924 CPUM_ASSERT_RD_MSR_FN(AmdK7BusUnitCfg);
5925 CPUM_ASSERT_RD_MSR_FN(AmdK7DebugCtl2Maybe);
5926 CPUM_ASSERT_RD_MSR_FN(AmdFam15hFpuCfg);
5927 CPUM_ASSERT_RD_MSR_FN(AmdFam15hDecoderCfg);
5928 CPUM_ASSERT_RD_MSR_FN(AmdFam10hBusUnitCfg2);
5929 CPUM_ASSERT_RD_MSR_FN(AmdFam15hCombUnitCfg);
5930 CPUM_ASSERT_RD_MSR_FN(AmdFam15hCombUnitCfg2);
5931 CPUM_ASSERT_RD_MSR_FN(AmdFam15hCombUnitCfg3);
5932 CPUM_ASSERT_RD_MSR_FN(AmdFam15hExecUnitCfg);
5933 CPUM_ASSERT_RD_MSR_FN(AmdFam15hLoadStoreCfg2);
5934 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsFetchCtl);
5935 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsFetchLinAddr);
5936 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsFetchPhysAddr);
5937 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsOpExecCtl);
5938 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsOpRip);
5939 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsOpData);
5940 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsOpData2);
5941 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsOpData3);
5942 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsDcLinAddr);
5943 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsDcPhysAddr);
5944 CPUM_ASSERT_RD_MSR_FN(AmdFam10hIbsCtl);
5945 CPUM_ASSERT_RD_MSR_FN(AmdFam14hIbsBrTarget);
5946
5947 CPUM_ASSERT_RD_MSR_FN(Gim)
5948
5949 AssertReturn(g_aCpumWrMsrFns[kCpumMsrWrFn_Invalid] == NULL, VERR_CPUM_IPE_2);
5950 CPUM_ASSERT_WR_MSR_FN(Ia32P5McAddr);
5951 CPUM_ASSERT_WR_MSR_FN(Ia32P5McType);
5952 CPUM_ASSERT_WR_MSR_FN(Ia32TimestampCounter);
5953 CPUM_ASSERT_WR_MSR_FN(Ia32ApicBase);
5954 CPUM_ASSERT_WR_MSR_FN(Ia32FeatureControl);
5955 CPUM_ASSERT_WR_MSR_FN(Ia32BiosSignId);
5956 CPUM_ASSERT_WR_MSR_FN(Ia32BiosUpdateTrigger);
5957 CPUM_ASSERT_WR_MSR_FN(Ia32SmmMonitorCtl);
5958 CPUM_ASSERT_WR_MSR_FN(Ia32PmcN);
5959 CPUM_ASSERT_WR_MSR_FN(Ia32MonitorFilterLineSize);
5960 CPUM_ASSERT_WR_MSR_FN(Ia32MPerf);
5961 CPUM_ASSERT_WR_MSR_FN(Ia32APerf);
5962 CPUM_ASSERT_WR_MSR_FN(Ia32MtrrPhysBaseN);
5963 CPUM_ASSERT_WR_MSR_FN(Ia32MtrrPhysMaskN);
5964 CPUM_ASSERT_WR_MSR_FN(Ia32MtrrFixed);
5965 CPUM_ASSERT_WR_MSR_FN(Ia32MtrrDefType);
5966 CPUM_ASSERT_WR_MSR_FN(Ia32Pat);
5967 CPUM_ASSERT_WR_MSR_FN(Ia32SysEnterCs);
5968 CPUM_ASSERT_WR_MSR_FN(Ia32SysEnterEsp);
5969 CPUM_ASSERT_WR_MSR_FN(Ia32SysEnterEip);
5970 CPUM_ASSERT_WR_MSR_FN(Ia32McgStatus);
5971 CPUM_ASSERT_WR_MSR_FN(Ia32McgCtl);
5972 CPUM_ASSERT_WR_MSR_FN(Ia32DebugCtl);
5973 CPUM_ASSERT_WR_MSR_FN(Ia32SmrrPhysBase);
5974 CPUM_ASSERT_WR_MSR_FN(Ia32SmrrPhysMask);
5975 CPUM_ASSERT_WR_MSR_FN(Ia32PlatformDcaCap);
5976 CPUM_ASSERT_WR_MSR_FN(Ia32Dca0Cap);
5977 CPUM_ASSERT_WR_MSR_FN(Ia32PerfEvtSelN);
5978 CPUM_ASSERT_WR_MSR_FN(Ia32PerfStatus);
5979 CPUM_ASSERT_WR_MSR_FN(Ia32PerfCtl);
5980 CPUM_ASSERT_WR_MSR_FN(Ia32FixedCtrN);
5981 CPUM_ASSERT_WR_MSR_FN(Ia32PerfCapabilities);
5982 CPUM_ASSERT_WR_MSR_FN(Ia32FixedCtrCtrl);
5983 CPUM_ASSERT_WR_MSR_FN(Ia32PerfGlobalStatus);
5984 CPUM_ASSERT_WR_MSR_FN(Ia32PerfGlobalCtrl);
5985 CPUM_ASSERT_WR_MSR_FN(Ia32PerfGlobalOvfCtrl);
5986 CPUM_ASSERT_WR_MSR_FN(Ia32PebsEnable);
5987 CPUM_ASSERT_WR_MSR_FN(Ia32ClockModulation);
5988 CPUM_ASSERT_WR_MSR_FN(Ia32ThermInterrupt);
5989 CPUM_ASSERT_WR_MSR_FN(Ia32ThermStatus);
5990 CPUM_ASSERT_WR_MSR_FN(Ia32MiscEnable);
5991 CPUM_ASSERT_WR_MSR_FN(Ia32McCtlStatusAddrMiscN);
5992 CPUM_ASSERT_WR_MSR_FN(Ia32McNCtl2);
5993 CPUM_ASSERT_WR_MSR_FN(Ia32DsArea);
5994 CPUM_ASSERT_WR_MSR_FN(Ia32TscDeadline);
5995 CPUM_ASSERT_WR_MSR_FN(Ia32X2ApicN);
5996 CPUM_ASSERT_WR_MSR_FN(Ia32DebugInterface);
5997 CPUM_ASSERT_WR_MSR_FN(Ia32SpecCtrl);
5998 CPUM_ASSERT_WR_MSR_FN(Ia32PredCmd);
5999
6000 CPUM_ASSERT_WR_MSR_FN(Amd64Efer);
6001 CPUM_ASSERT_WR_MSR_FN(Amd64SyscallTarget);
6002 CPUM_ASSERT_WR_MSR_FN(Amd64LongSyscallTarget);
6003 CPUM_ASSERT_WR_MSR_FN(Amd64CompSyscallTarget);
6004 CPUM_ASSERT_WR_MSR_FN(Amd64SyscallFlagMask);
6005 CPUM_ASSERT_WR_MSR_FN(Amd64FsBase);
6006 CPUM_ASSERT_WR_MSR_FN(Amd64GsBase);
6007 CPUM_ASSERT_WR_MSR_FN(Amd64KernelGsBase);
6008 CPUM_ASSERT_WR_MSR_FN(Amd64TscAux);
6009
6010 CPUM_ASSERT_WR_MSR_FN(IntelEblCrPowerOn);
6011 CPUM_ASSERT_WR_MSR_FN(IntelP4EbcHardPowerOn);
6012 CPUM_ASSERT_WR_MSR_FN(IntelP4EbcSoftPowerOn);
6013 CPUM_ASSERT_WR_MSR_FN(IntelP4EbcFrequencyId);
6014 CPUM_ASSERT_WR_MSR_FN(IntelFlexRatio);
6015 CPUM_ASSERT_WR_MSR_FN(IntelPkgCStConfigControl);
6016 CPUM_ASSERT_WR_MSR_FN(IntelPmgIoCaptureBase);
6017 CPUM_ASSERT_WR_MSR_FN(IntelLastBranchFromToN);
6018 CPUM_ASSERT_WR_MSR_FN(IntelLastBranchFromN);
6019 CPUM_ASSERT_WR_MSR_FN(IntelLastBranchToN);
6020 CPUM_ASSERT_WR_MSR_FN(IntelLastBranchTos);
6021 CPUM_ASSERT_WR_MSR_FN(IntelBblCrCtl);
6022 CPUM_ASSERT_WR_MSR_FN(IntelBblCrCtl3);
6023 CPUM_ASSERT_WR_MSR_FN(IntelI7TemperatureTarget);
6024 CPUM_ASSERT_WR_MSR_FN(IntelI7MsrOffCoreResponseN);
6025 CPUM_ASSERT_WR_MSR_FN(IntelI7MiscPwrMgmt);
6026 CPUM_ASSERT_WR_MSR_FN(IntelP6CrN);
6027 CPUM_ASSERT_WR_MSR_FN(IntelCpuId1FeatureMaskEcdx);
6028 CPUM_ASSERT_WR_MSR_FN(IntelCpuId1FeatureMaskEax);
6029 CPUM_ASSERT_WR_MSR_FN(IntelCpuId80000001FeatureMaskEcdx);
6030 CPUM_ASSERT_WR_MSR_FN(IntelI7SandyAesNiCtl);
6031 CPUM_ASSERT_WR_MSR_FN(IntelI7TurboRatioLimit);
6032 CPUM_ASSERT_WR_MSR_FN(IntelI7LbrSelect);
6033 CPUM_ASSERT_WR_MSR_FN(IntelI7SandyErrorControl);
6034 CPUM_ASSERT_WR_MSR_FN(IntelI7PowerCtl);
6035 CPUM_ASSERT_WR_MSR_FN(IntelI7SandyPebsNumAlt);
6036 CPUM_ASSERT_WR_MSR_FN(IntelI7PebsLdLat);
6037 CPUM_ASSERT_WR_MSR_FN(IntelI7SandyVrCurrentConfig);
6038 CPUM_ASSERT_WR_MSR_FN(IntelI7SandyVrMiscConfig);
6039 CPUM_ASSERT_WR_MSR_FN(IntelI7SandyPkgCnIrtlN);
6040 CPUM_ASSERT_WR_MSR_FN(IntelI7SandyPkgC2Residency);
6041 CPUM_ASSERT_WR_MSR_FN(IntelI7RaplPkgPowerLimit);
6042 CPUM_ASSERT_WR_MSR_FN(IntelI7RaplDramPowerLimit);
6043 CPUM_ASSERT_WR_MSR_FN(IntelI7RaplPp0PowerLimit);
6044 CPUM_ASSERT_WR_MSR_FN(IntelI7RaplPp0Policy);
6045 CPUM_ASSERT_WR_MSR_FN(IntelI7RaplPp1PowerLimit);
6046 CPUM_ASSERT_WR_MSR_FN(IntelI7RaplPp1Policy);
6047 CPUM_ASSERT_WR_MSR_FN(IntelI7IvyConfigTdpControl);
6048 CPUM_ASSERT_WR_MSR_FN(IntelI7IvyTurboActivationRatio);
6049 CPUM_ASSERT_WR_MSR_FN(IntelI7UncPerfGlobalCtrl);
6050 CPUM_ASSERT_WR_MSR_FN(IntelI7UncPerfGlobalStatus);
6051 CPUM_ASSERT_WR_MSR_FN(IntelI7UncPerfGlobalOvfCtrl);
6052 CPUM_ASSERT_WR_MSR_FN(IntelI7UncPerfFixedCtrCtrl);
6053 CPUM_ASSERT_WR_MSR_FN(IntelI7UncPerfFixedCtr);
6054 CPUM_ASSERT_WR_MSR_FN(IntelI7UncArbPerfCtrN);
6055 CPUM_ASSERT_WR_MSR_FN(IntelI7UncArbPerfEvtSelN);
6056 CPUM_ASSERT_WR_MSR_FN(IntelCore2EmttmCrTablesN);
6057 CPUM_ASSERT_WR_MSR_FN(IntelCore2SmmCStMiscInfo);
6058 CPUM_ASSERT_WR_MSR_FN(IntelCore1ExtConfig);
6059 CPUM_ASSERT_WR_MSR_FN(IntelCore1DtsCalControl);
6060 CPUM_ASSERT_WR_MSR_FN(IntelCore2PeciControl);
6061
6062 CPUM_ASSERT_WR_MSR_FN(P6LastIntFromIp);
6063 CPUM_ASSERT_WR_MSR_FN(P6LastIntToIp);
6064
6065 CPUM_ASSERT_WR_MSR_FN(AmdFam15hTscRate);
6066 CPUM_ASSERT_WR_MSR_FN(AmdFam15hLwpCfg);
6067 CPUM_ASSERT_WR_MSR_FN(AmdFam15hLwpCbAddr);
6068 CPUM_ASSERT_WR_MSR_FN(AmdFam10hMc4MiscN);
6069 CPUM_ASSERT_WR_MSR_FN(AmdK8PerfCtlN);
6070 CPUM_ASSERT_WR_MSR_FN(AmdK8PerfCtrN);
6071 CPUM_ASSERT_WR_MSR_FN(AmdK8SysCfg);
6072 CPUM_ASSERT_WR_MSR_FN(AmdK8HwCr);
6073 CPUM_ASSERT_WR_MSR_FN(AmdK8IorrBaseN);
6074 CPUM_ASSERT_WR_MSR_FN(AmdK8IorrMaskN);
6075 CPUM_ASSERT_WR_MSR_FN(AmdK8TopOfMemN);
6076 CPUM_ASSERT_WR_MSR_FN(AmdK8NbCfg1);
6077 CPUM_ASSERT_WR_MSR_FN(AmdK8McXcptRedir);
6078 CPUM_ASSERT_WR_MSR_FN(AmdK8CpuNameN);
6079 CPUM_ASSERT_WR_MSR_FN(AmdK8HwThermalCtrl);
6080 CPUM_ASSERT_WR_MSR_FN(AmdK8SwThermalCtrl);
6081 CPUM_ASSERT_WR_MSR_FN(AmdK8FidVidControl);
6082 CPUM_ASSERT_WR_MSR_FN(AmdK8McCtlMaskN);
6083 CPUM_ASSERT_WR_MSR_FN(AmdK8SmiOnIoTrapN);
6084 CPUM_ASSERT_WR_MSR_FN(AmdK8SmiOnIoTrapCtlSts);
6085 CPUM_ASSERT_WR_MSR_FN(AmdK8IntPendingMessage);
6086 CPUM_ASSERT_WR_MSR_FN(AmdK8SmiTriggerIoCycle);
6087 CPUM_ASSERT_WR_MSR_FN(AmdFam10hMmioCfgBaseAddr);
6088 CPUM_ASSERT_WR_MSR_FN(AmdFam10hTrapCtlMaybe);
6089 CPUM_ASSERT_WR_MSR_FN(AmdFam10hPStateControl);
6090 CPUM_ASSERT_WR_MSR_FN(AmdFam10hPStateStatus);
6091 CPUM_ASSERT_WR_MSR_FN(AmdFam10hPStateN);
6092 CPUM_ASSERT_WR_MSR_FN(AmdFam10hCofVidControl);
6093 CPUM_ASSERT_WR_MSR_FN(AmdFam10hCofVidStatus);
6094 CPUM_ASSERT_WR_MSR_FN(AmdFam10hCStateIoBaseAddr);
6095 CPUM_ASSERT_WR_MSR_FN(AmdFam10hCpuWatchdogTimer);
6096 CPUM_ASSERT_WR_MSR_FN(AmdK8SmmBase);
6097 CPUM_ASSERT_WR_MSR_FN(AmdK8SmmAddr);
6098 CPUM_ASSERT_WR_MSR_FN(AmdK8SmmMask);
6099 CPUM_ASSERT_WR_MSR_FN(AmdK8VmCr);
6100 CPUM_ASSERT_WR_MSR_FN(AmdK8IgnNe);
6101 CPUM_ASSERT_WR_MSR_FN(AmdK8SmmCtl);
6102 CPUM_ASSERT_WR_MSR_FN(AmdK8VmHSavePa);
6103 CPUM_ASSERT_WR_MSR_FN(AmdFam10hVmLockKey);
6104 CPUM_ASSERT_WR_MSR_FN(AmdFam10hSmmLockKey);
6105 CPUM_ASSERT_WR_MSR_FN(AmdFam10hLocalSmiStatus);
6106 CPUM_ASSERT_WR_MSR_FN(AmdFam10hOsVisWrkIdLength);
6107 CPUM_ASSERT_WR_MSR_FN(AmdFam10hOsVisWrkStatus);
6108 CPUM_ASSERT_WR_MSR_FN(AmdFam16hL2IPerfCtlN);
6109 CPUM_ASSERT_WR_MSR_FN(AmdFam16hL2IPerfCtrN);
6110 CPUM_ASSERT_WR_MSR_FN(AmdFam15hNorthbridgePerfCtlN);
6111 CPUM_ASSERT_WR_MSR_FN(AmdFam15hNorthbridgePerfCtrN);
6112 CPUM_ASSERT_WR_MSR_FN(AmdK7MicrocodeCtl);
6113 CPUM_ASSERT_WR_MSR_FN(AmdK7ClusterIdMaybe);
6114 CPUM_ASSERT_WR_MSR_FN(AmdK8CpuIdCtlStd07hEbax);
6115 CPUM_ASSERT_WR_MSR_FN(AmdK8CpuIdCtlStd06hEcx);
6116 CPUM_ASSERT_WR_MSR_FN(AmdK8CpuIdCtlStd01hEdcx);
6117 CPUM_ASSERT_WR_MSR_FN(AmdK8CpuIdCtlExt01hEdcx);
6118 CPUM_ASSERT_WR_MSR_FN(AmdK8PatchLoader);
6119 CPUM_ASSERT_WR_MSR_FN(AmdK7DebugStatusMaybe);
6120 CPUM_ASSERT_WR_MSR_FN(AmdK7BHTraceBaseMaybe);
6121 CPUM_ASSERT_WR_MSR_FN(AmdK7BHTracePtrMaybe);
6122 CPUM_ASSERT_WR_MSR_FN(AmdK7BHTraceLimitMaybe);
6123 CPUM_ASSERT_WR_MSR_FN(AmdK7HardwareDebugToolCfgMaybe);
6124 CPUM_ASSERT_WR_MSR_FN(AmdK7FastFlushCountMaybe);
6125 CPUM_ASSERT_WR_MSR_FN(AmdK7NodeId);
6126 CPUM_ASSERT_WR_MSR_FN(AmdK7DrXAddrMaskN);
6127 CPUM_ASSERT_WR_MSR_FN(AmdK7Dr0DataMatchMaybe);
6128 CPUM_ASSERT_WR_MSR_FN(AmdK7Dr0DataMaskMaybe);
6129 CPUM_ASSERT_WR_MSR_FN(AmdK7LoadStoreCfg);
6130 CPUM_ASSERT_WR_MSR_FN(AmdK7InstrCacheCfg);
6131 CPUM_ASSERT_WR_MSR_FN(AmdK7DataCacheCfg);
6132 CPUM_ASSERT_WR_MSR_FN(AmdK7BusUnitCfg);
6133 CPUM_ASSERT_WR_MSR_FN(AmdK7DebugCtl2Maybe);
6134 CPUM_ASSERT_WR_MSR_FN(AmdFam15hFpuCfg);
6135 CPUM_ASSERT_WR_MSR_FN(AmdFam15hDecoderCfg);
6136 CPUM_ASSERT_WR_MSR_FN(AmdFam10hBusUnitCfg2);
6137 CPUM_ASSERT_WR_MSR_FN(AmdFam15hCombUnitCfg);
6138 CPUM_ASSERT_WR_MSR_FN(AmdFam15hCombUnitCfg2);
6139 CPUM_ASSERT_WR_MSR_FN(AmdFam15hCombUnitCfg3);
6140 CPUM_ASSERT_WR_MSR_FN(AmdFam15hExecUnitCfg);
6141 CPUM_ASSERT_WR_MSR_FN(AmdFam15hLoadStoreCfg2);
6142 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsFetchCtl);
6143 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsFetchLinAddr);
6144 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsFetchPhysAddr);
6145 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsOpExecCtl);
6146 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsOpRip);
6147 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsOpData);
6148 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsOpData2);
6149 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsOpData3);
6150 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsDcLinAddr);
6151 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsDcPhysAddr);
6152 CPUM_ASSERT_WR_MSR_FN(AmdFam10hIbsCtl);
6153 CPUM_ASSERT_WR_MSR_FN(AmdFam14hIbsBrTarget);
6154
6155 CPUM_ASSERT_WR_MSR_FN(Gim);
6156
6157 return VINF_SUCCESS;
6158}
6159#endif /* VBOX_STRICT && IN_RING3 */
6160
6161
6162/**
6163 * Gets the scalable bus frequency.
6164 *
6165 * The bus frequency is used as a base in several MSRs that gives the CPU and
6166 * other frequency ratios.
6167 *
6168 * @returns Scalable bus frequency in Hz. Will not return CPUM_SBUSFREQ_UNKNOWN.
6169 * @param pVM The cross context VM structure.
6170 */
6171VMMDECL(uint64_t) CPUMGetGuestScalableBusFrequency(PVM pVM)
6172{
6173 uint64_t uFreq = pVM->cpum.s.GuestInfo.uScalableBusFreq;
6174 if (uFreq == CPUM_SBUSFREQ_UNKNOWN)
6175 uFreq = CPUM_SBUSFREQ_100MHZ;
6176 return uFreq;
6177}
6178
6179
6180/**
6181 * Sets the guest EFER MSR without performing any additional checks.
6182 *
6183 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
6184 * @param uOldEfer The previous EFER MSR value.
6185 * @param uValidEfer The new, validated EFER MSR value.
6186 *
6187 * @remarks One would normally call CPUMQueryValidatedGuestEfer before calling this
6188 * function to change the EFER in order to perform an EFER transition.
6189 */
6190VMMDECL(void) CPUMSetGuestMsrEferNoCheck(PVMCPU pVCpu, uint64_t uOldEfer, uint64_t uValidEfer)
6191{
6192 pVCpu->cpum.s.Guest.msrEFER = uValidEfer;
6193
6194 /* AMD64 Architecture Programmer's Manual: 15.15 TLB Control; flush the TLB
6195 if MSR_K6_EFER_NXE, MSR_K6_EFER_LME or MSR_K6_EFER_LMA are changed. */
6196 if ( (uOldEfer & (MSR_K6_EFER_NXE | MSR_K6_EFER_LME | MSR_K6_EFER_LMA))
6197 != (pVCpu->cpum.s.Guest.msrEFER & (MSR_K6_EFER_NXE | MSR_K6_EFER_LME | MSR_K6_EFER_LMA)))
6198 {
6199 /// @todo PGMFlushTLB(pVCpu, cr3, true /*fGlobal*/);
6200 HMFlushTLB(pVCpu);
6201
6202 /* Notify PGM about NXE changes. */
6203 if ( (uOldEfer & MSR_K6_EFER_NXE)
6204 != (pVCpu->cpum.s.Guest.msrEFER & MSR_K6_EFER_NXE))
6205 PGMNotifyNxeChanged(pVCpu, !(uOldEfer & MSR_K6_EFER_NXE));
6206 }
6207}
6208
6209
6210/**
6211 * Validates an EFER MSR write.
6212 *
6213 * @returns VBox status code.
6214 * @param pVM The cross context VM structure.
6215 * @param uCr0 The CR0 of the CPU corresponding to the EFER MSR.
6216 * @param uOldEfer Value of the previous EFER MSR on the CPU if any.
6217 * @param uNewEfer The new EFER MSR value being written.
6218 * @param puValidEfer Where to store the validated EFER (only updated if
6219 * this function returns VINF_SUCCESS).
6220 */
6221VMMDECL(int) CPUMQueryValidatedGuestEfer(PVM pVM, uint64_t uCr0, uint64_t uOldEfer, uint64_t uNewEfer, uint64_t *puValidEfer)
6222{
6223 uint32_t const fExtFeatures = pVM->cpum.s.aGuestCpuIdPatmExt[0].uEax >= 0x80000001
6224 ? pVM->cpum.s.aGuestCpuIdPatmExt[1].uEdx
6225 : 0;
6226 uint64_t fMask = 0;
6227 uint64_t const fIgnoreMask = MSR_K6_EFER_LMA;
6228
6229 /* Filter out those bits the guest is allowed to change. (e.g. LMA is read-only) */
6230 if (fExtFeatures & X86_CPUID_EXT_FEATURE_EDX_NX)
6231 fMask |= MSR_K6_EFER_NXE;
6232 if (fExtFeatures & X86_CPUID_EXT_FEATURE_EDX_LONG_MODE)
6233 fMask |= MSR_K6_EFER_LME;
6234 if (fExtFeatures & X86_CPUID_EXT_FEATURE_EDX_SYSCALL)
6235 fMask |= MSR_K6_EFER_SCE;
6236 if (fExtFeatures & X86_CPUID_AMD_FEATURE_EDX_FFXSR)
6237 fMask |= MSR_K6_EFER_FFXSR;
6238 if (pVM->cpum.s.GuestFeatures.fSvm)
6239 fMask |= MSR_K6_EFER_SVME;
6240
6241 /* #GP(0) If anything outside the allowed bits is set. */
6242 if (uNewEfer & ~(fIgnoreMask | fMask))
6243 {
6244 Log(("CPUM: Settings disallowed EFER bit. uNewEfer=%#RX64 fAllowed=%#RX64 -> #GP(0)\n", uNewEfer, fMask));
6245 return VERR_CPUM_RAISE_GP_0;
6246 }
6247
6248 /* Check for illegal MSR_K6_EFER_LME transitions: not allowed to change LME if
6249 paging is enabled. (AMD Arch. Programmer's Manual Volume 2: Table 14-5) */
6250 if ( (uOldEfer & MSR_K6_EFER_LME) != (uNewEfer & fMask & MSR_K6_EFER_LME)
6251 && (uCr0 & X86_CR0_PG))
6252 {
6253 Log(("CPUM: Illegal MSR_K6_EFER_LME change: paging is enabled!!\n"));
6254 return VERR_CPUM_RAISE_GP_0;
6255 }
6256
6257 /* There are a few more: e.g. MSR_K6_EFER_LMSLE */
6258 AssertMsg(!(uNewEfer & ~( MSR_K6_EFER_NXE
6259 | MSR_K6_EFER_LME
6260 | MSR_K6_EFER_LMA /* ignored anyway */
6261 | MSR_K6_EFER_SCE
6262 | MSR_K6_EFER_FFXSR
6263 | MSR_K6_EFER_SVME)),
6264 ("Unexpected value %#RX64\n", uNewEfer));
6265
6266 *puValidEfer = (uOldEfer & ~fMask) | (uNewEfer & fMask);
6267 return VINF_SUCCESS;
6268}
6269
6270#ifdef IN_RING0
6271
6272/**
6273 * Fast way for HM to access the MSR_K8_TSC_AUX register.
6274 *
6275 * @returns The register value.
6276 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
6277 * @thread EMT(pVCpu)
6278 */
6279VMMR0_INT_DECL(uint64_t) CPUMR0GetGuestTscAux(PVMCPU pVCpu)
6280{
6281 return pVCpu->cpum.s.GuestMsrs.msr.TscAux;
6282}
6283
6284
6285/**
6286 * Fast way for HM to access the MSR_K8_TSC_AUX register.
6287 *
6288 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
6289 * @param uValue The new value.
6290 * @thread EMT(pVCpu)
6291 */
6292VMMR0_INT_DECL(void) CPUMR0SetGuestTscAux(PVMCPU pVCpu, uint64_t uValue)
6293{
6294 pVCpu->cpum.s.GuestMsrs.msr.TscAux = uValue;
6295}
6296
6297/**
6298 * Fast way for HM to access the IA32_SPEC_CTRL register.
6299 *
6300 * @returns The register value.
6301 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
6302 * @thread EMT(pVCpu)
6303 */
6304VMMR0_INT_DECL(uint64_t) CPUMR0GetGuestSpecCtrl(PVMCPU pVCpu)
6305{
6306 return pVCpu->cpum.s.GuestMsrs.msr.SpecCtrl;
6307}
6308
6309
6310/**
6311 * Fast way for HM to access the IA32_SPEC_CTRL register.
6312 *
6313 * @param pVCpu The cross context virtual CPU structure of the calling EMT.
6314 * @param uValue The new value.
6315 * @thread EMT(pVCpu)
6316 */
6317VMMR0_INT_DECL(void) CPUMR0SetGuestSpecCtrl(PVMCPU pVCpu, uint64_t uValue)
6318{
6319 pVCpu->cpum.s.GuestMsrs.msr.SpecCtrl = uValue;
6320}
6321
6322#endif /* IN_RING0 */
6323
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