VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/GIMR0.cpp@ 57062

Last change on this file since 57062 was 56791, checked in by vboxsync, 9 years ago

VMM/GIM: Try passing identical TSC and NanoTS pairs to all VCPUs for KVM guests.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1/* $Id: GIMR0.cpp 56791 2015-07-03 16:19:59Z vboxsync $ */
2/** @file
3 * Guest Interface Manager (GIM) - Host Context Ring-0.
4 */
5
6/*
7 * Copyright (C) 2014-2015 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 */
35VMMR0_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 case GIMPROVIDERID_KVM:
46 return gimR0KvmInitVM(pVM);
47
48 default:
49 break;
50 }
51 return VINF_SUCCESS;
52}
53
54
55/**
56 * Does ring-0 per-VM GIM termination.
57 *
58 * @returns VBox status code.
59 * @param pVM Pointer to the VM.
60 */
61VMMR0_INT_DECL(int) GIMR0TermVM(PVM pVM)
62{
63 if (!GIMIsEnabled(pVM))
64 return VINF_SUCCESS;
65
66 switch (pVM->gim.s.enmProviderId)
67 {
68 case GIMPROVIDERID_HYPERV:
69 return gimR0HvTermVM(pVM);
70
71 case GIMPROVIDERID_KVM:
72 return gimR0KvmTermVM(pVM);
73
74 default:
75 break;
76 }
77 return VINF_SUCCESS;
78}
79
80
81/**
82 * Updates the paravirtualized TSC supported by the GIM provider.
83 *
84 * @returns VBox status code.
85 * @retval VINF_SUCCESS if the paravirt. TSC is setup and in use.
86 * @retval VERR_GIM_NOT_ENABLED if no GIM provider is configured for this VM.
87 * @retval VERR_GIM_PVTSC_NOT_AVAILABLE if the GIM provider does not support any
88 * paravirt. TSC.
89 * @retval VERR_GIM_PVTSC_NOT_IN_USE if the GIM provider supports paravirt. TSC
90 * but the guest isn't currently using it.
91 *
92 * @param pVM Pointer to the VM.
93 * @param u64Offset The computed TSC offset.
94 *
95 * @thread EMT(pVCpu)
96 */
97VMMR0_INT_DECL(int) GIMR0UpdateParavirtTsc(PVM pVM, uint64_t u64Offset)
98{
99 switch (pVM->gim.s.enmProviderId)
100 {
101 case GIMPROVIDERID_HYPERV:
102 return gimR0HvUpdateParavirtTsc(pVM, u64Offset);
103
104 case GIMPROVIDERID_KVM:
105 return VINF_SUCCESS;
106
107 case GIMPROVIDERID_NONE:
108 return VERR_GIM_NOT_ENABLED;
109
110 default:
111 break;
112 }
113 return VERR_GIM_PVTSC_NOT_AVAILABLE;
114}
115
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