VirtualBox

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

Last change on this file since 95085 was 93294, checked in by vboxsync, 3 years ago

VMM: Nested VMX: bugref:10092 Fixed the missed cpumMsrRd_Ia32VmxCr0Fixed0 in r149358.

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