VirtualBox

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

Last change on this file since 107631 was 107570, checked in by vboxsync, 10 days ago

VMM/CPUM: Report the host CPU microcode revision number to the guest when on an amd64 host. jiraref:VBP-947

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