1 | /* $Id: VBoxCpuReportMsrSup.cpp 69654 2017-11-10 19:22:45Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * MsrSup - SupDrv-specific MSR access.
|
---|
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 | #include "VBoxCpuReport.h"
|
---|
23 | #include <iprt/x86.h>
|
---|
24 |
|
---|
25 |
|
---|
26 | int VbCpuRepMsrProberInitSupDrv(PVBCPUREPMSRACCESSORS pMsrFunctions)
|
---|
27 | {
|
---|
28 | int rc = SUPR3Init(NULL);
|
---|
29 | if (RT_SUCCESS(rc))
|
---|
30 | {
|
---|
31 | /* Test if the MSR prober is available, since the interface is optional. The TSC MSR will exist on any supported CPU. */
|
---|
32 | uint64_t uValue;
|
---|
33 | bool fGp;
|
---|
34 | rc = SUPR3MsrProberRead(MSR_IA32_TSC, NIL_RTCPUID, &uValue, &fGp);
|
---|
35 | if ( rc != VERR_NOT_IMPLEMENTED
|
---|
36 | && rc != VERR_INVALID_FUNCTION)
|
---|
37 | {
|
---|
38 | pMsrFunctions->fAtomic = true;
|
---|
39 | pMsrFunctions->pfnMsrProberRead = SUPR3MsrProberRead;
|
---|
40 | pMsrFunctions->pfnMsrProberWrite = SUPR3MsrProberWrite;
|
---|
41 | pMsrFunctions->pfnMsrProberModify = SUPR3MsrProberModify;
|
---|
42 |
|
---|
43 | pMsrFunctions->pfnTerm = NULL;
|
---|
44 | return VINF_SUCCESS;
|
---|
45 |
|
---|
46 | }
|
---|
47 | vbCpuRepDebug("warning: MSR probing not supported by the support driver (%Rrc).\n", rc);
|
---|
48 | }
|
---|
49 | else
|
---|
50 | vbCpuRepDebug("warning: Unable to initialize the support library (%Rrc).\n", rc);
|
---|
51 | return rc;
|
---|
52 | }
|
---|
53 |
|
---|