VirtualBox

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

Last change on this file since 96686 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

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