1 | /* $Id: GIMR0.cpp 52767 2014-09-16 16:51:51Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * Guest Interface Manager (GIM) - Host Context Ring-0.
|
---|
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 | * Header Files *
|
---|
20 | *******************************************************************************/
|
---|
21 | #define LOG_GROUP LOG_GROUP_GIM
|
---|
22 | #include "GIMInternal.h"
|
---|
23 | #include "GIMHvInternal.h"
|
---|
24 |
|
---|
25 | #include <VBox/err.h>
|
---|
26 | #include <VBox/vmm/vm.h>
|
---|
27 |
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Does ring-0 per-VM GIM initialization.
|
---|
31 | *
|
---|
32 | * @returns VBox status code.
|
---|
33 | * @param pVM Pointer to the VM.
|
---|
34 | */
|
---|
35 | VMMR0_INT_DECL(int) GIMR0InitVM(PVM pVM)
|
---|
36 | {
|
---|
37 | if (!GIMIsEnabled(pVM))
|
---|
38 | return VINF_SUCCESS;
|
---|
39 |
|
---|
40 | switch (pVM->gim.s.enmProviderId)
|
---|
41 | {
|
---|
42 | case GIMPROVIDERID_HYPERV:
|
---|
43 | return GIMR0HvInitVM(pVM);
|
---|
44 |
|
---|
45 | default:
|
---|
46 | break;
|
---|
47 | }
|
---|
48 | return VINF_SUCCESS;
|
---|
49 | }
|
---|
50 |
|
---|
51 |
|
---|
52 | /**
|
---|
53 | * Does ring-0 per-VM GIM termination.
|
---|
54 | *
|
---|
55 | * @returns VBox status code.
|
---|
56 | * @param pVM Pointer to the VM.
|
---|
57 | */
|
---|
58 | VMMR0_INT_DECL(int) GIMR0TermVM(PVM pVM)
|
---|
59 | {
|
---|
60 | if (!GIMIsEnabled(pVM))
|
---|
61 | return VINF_SUCCESS;
|
---|
62 |
|
---|
63 | switch (pVM->gim.s.enmProviderId)
|
---|
64 | {
|
---|
65 | case GIMPROVIDERID_HYPERV:
|
---|
66 | return GIMR0HvTermVM(pVM);
|
---|
67 |
|
---|
68 | default:
|
---|
69 | break;
|
---|
70 | }
|
---|
71 | return VINF_SUCCESS;
|
---|
72 | }
|
---|
73 |
|
---|
74 | /**
|
---|
75 | * Updates the paravirtualized TSC supported by the GIM provider.
|
---|
76 | *
|
---|
77 | * @returns VBox status code.
|
---|
78 | * @retval VINF_SUCCESS if the paravirt. TSC is setup and in use.
|
---|
79 | * @retval VERR_GIM_NOT_ENABLED if no GIM provider is configured for this VM.
|
---|
80 | * @retval VERR_GIM_PVTSC_NOT_AVAILABLE if the GIM provider does not support any
|
---|
81 | * paravirt. TSC.
|
---|
82 | * @retval VERR_GIM_PVTSC_NOT_IN_USE if the GIM provider supports paravirt. TSC
|
---|
83 | * but the guest isn't currently using it.
|
---|
84 | *
|
---|
85 | * @param pVM Pointer to the VM.
|
---|
86 | * @param u64Offset The computed TSC offset.
|
---|
87 | *
|
---|
88 | * @thread EMT(pVCpu)
|
---|
89 | */
|
---|
90 | VMMR0_INT_DECL(int) GIMR0UpdateParavirtTsc(PVM pVM, uint64_t u64Offset)
|
---|
91 | {
|
---|
92 | switch (pVM->gim.s.enmProviderId)
|
---|
93 | {
|
---|
94 | case GIMPROVIDERID_HYPERV:
|
---|
95 | return GIMR0HvUpdateParavirtTsc(pVM, u64Offset);
|
---|
96 |
|
---|
97 | case GIMPROVIDERID_NONE:
|
---|
98 | return VERR_GIM_NOT_ENABLED;
|
---|
99 |
|
---|
100 | default:
|
---|
101 | break;
|
---|
102 | }
|
---|
103 | return VERR_GIM_PVTSC_NOT_AVAILABLE;
|
---|
104 | }
|
---|
105 |
|
---|