1 | /* $Id: GIMAllHv.cpp 51367 2014-05-23 07:45:35Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * GIM - Guest Interface Manager, Microsoft Hyper-V, All Contexts.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2014 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_GIM
|
---|
23 | #include "GIMHvInternal.h"
|
---|
24 |
|
---|
25 | #include <VBox/err.h>
|
---|
26 | #include <VBox/vmm/tm.h>
|
---|
27 | #include <VBox/vmm/vm.h>
|
---|
28 |
|
---|
29 | DECLEXPORT(int) GIMHvHypercall(PVMCPU pVCpu, PCPUMCTX pCtx)
|
---|
30 | {
|
---|
31 | return VINF_SUCCESS;
|
---|
32 | }
|
---|
33 |
|
---|
34 |
|
---|
35 | DECLEXPORT(int) GIMHvReadMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
|
---|
36 | {
|
---|
37 | NOREF(pRange);
|
---|
38 | switch (idMsr)
|
---|
39 | {
|
---|
40 | case MSR_GIM_HV_TIME_REF_COUNT:
|
---|
41 | {
|
---|
42 | /* Hyper-V reports the time in 100ns units. */
|
---|
43 | uint64_t u64Tsc = TMCpuTickGet(pVCpu);
|
---|
44 | uint64_t u64TscHz = TMCpuTicksPerSecond(pVCpu->CTX_SUFF(pVM));
|
---|
45 | uint64_t u64Tsc100Ns = u64TscHz / UINT64_C(10000000); /* 100 ns */
|
---|
46 | *puValue = (u64Tsc / u64Tsc100Ns);
|
---|
47 | return VINF_SUCCESS;
|
---|
48 | }
|
---|
49 |
|
---|
50 | case MSR_GIM_HV_VP_INDEX:
|
---|
51 | *puValue = pVCpu->idCpu;
|
---|
52 | return VINF_SUCCESS;
|
---|
53 |
|
---|
54 | default:
|
---|
55 | break;
|
---|
56 | }
|
---|
57 |
|
---|
58 | LogRel(("GIMHvReadMsr: Unknown/invalid RdMsr %#RX32 -> #GP(0)\n", idMsr));
|
---|
59 | return VERR_CPUM_RAISE_GP_0;
|
---|
60 | }
|
---|
61 |
|
---|
62 |
|
---|
63 | DECLEXPORT(int) GIMHvWriteMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
|
---|
64 | {
|
---|
65 | LogRel(("GIMHvWriteMsr: Unknown/invalid WrMsr %#RX32 -> #GP(0)\n", idMsr));
|
---|
66 | return VERR_CPUM_RAISE_GP_0;
|
---|
67 | }
|
---|
68 |
|
---|