VirtualBox

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

Last change on this file since 73009 was 72866, checked in by vboxsync, 7 years ago

IEM,CPUM: Can use LogRel in ring-0 too now and have it go to VBox.log.

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