VirtualBox

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

Last change on this file since 69222 was 69216, checked in by vboxsync, 7 years ago

CPUM: Reject invalid MTRR/PAT types.

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