VirtualBox

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

Last change on this file since 103583 was 100935, checked in by vboxsync, 15 months ago

VMM: bugref:10498 bugref:10318: Implemented basic MTRR reporting and storage, primarily to make progress with nested Hyper-V.

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