VirtualBox

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

Last change on this file since 71833 was 71755, checked in by vboxsync, 7 years ago

VMM: Nested Hw.virt: Fix overriding SVM nested-guest PAT MSR while executing with nested-guest w/ shadow paging.
Also fixes loading, validating and restoring the PAT MSR when nested-paging is used by the nested-hypervisor.

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