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