VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/GIMAll.cpp@ 51425

Last change on this file since 51425 was 51367, checked in by vboxsync, 11 years ago

VMM/GIM: Hyper-V provider, work-in-progress.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
Line 
1/* $Id: GIMAll.cpp 51367 2014-05-23 07:45:35Z vboxsync $ */
2/** @file
3 * GIM - Guest Interface Manager - 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 "GIMInternal.h"
24#include <VBox/err.h>
25#include <VBox/vmm/vm.h>
26
27/* Include all the providers. */
28#include "GIMHvInternal.h"
29#include "GIMMinimalInternal.h"
30
31
32/**
33 * Checks whether GIM is being used by this VM.
34 *
35 * @retval @c true if used.
36 * @retval @c false if no GIM provider ("none") is used.
37 *
38 * @param pVM Pointer to the VM.
39 * @internal
40 */
41VMMDECL(bool) GIMIsEnabled(PVM pVM)
42{
43 return pVM->gim.s.fEnabled;
44}
45
46
47/**
48 * Implements a GIM hypercall with the provider configured for the VM.
49 *
50 * @returns VBox status code.
51 * @param pVCpu Pointer to the VMCPU.
52 * @param pCtx Pointer to the guest-CPU context.
53 */
54VMM_INT_DECL(int) GIMHypercall(PVMCPU pVCpu, PCPUMCTX pCtx)
55{
56 PVM pVM = pVCpu->CTX_SUFF(pVM);
57 Assert(GIMIsEnabled(pVM));
58 VMCPU_ASSERT_EMT(pVCpu);
59
60 switch (pVM->gim.s.enmProviderId)
61 {
62 case GIMPROVIDERID_HYPERV:
63 return GIMHvHypercall(pVCpu, pCtx);
64
65 default:
66 AssertMsgFailed(("GIMHypercall: for unknown provider %u\n", pVM->gim.s.enmProviderId));
67 return VERR_INTERNAL_ERROR_5; /** @todo Define and use VERR_GIM_HYPERCALL_UNEXPECTED */;
68 }
69}
70
71
72/**
73 * Invokes the read-MSR handler for the GIM provider configured for the VM.
74 *
75 * @returns VBox status code.
76 * @param pVCpu Pointer to the VMCPU.
77 * @param idMsr The MSR to read.
78 * @param pRange The range this MSR belongs to.
79 * @param puValue Where to store the MSR value read.
80 */
81VMM_INT_DECL(int) GIMReadMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
82{
83 Assert(pVCpu);
84 PVM pVM = pVCpu->CTX_SUFF(pVM);
85 Assert(GIMIsEnabled(pVM));
86 VMCPU_ASSERT_EMT(pVCpu);
87
88 switch (pVM->gim.s.enmProviderId)
89 {
90 case GIMPROVIDERID_HYPERV:
91 return GIMHvReadMsr(pVCpu, idMsr, pRange, puValue);
92
93 default:
94 AssertMsgFailed(("GIMReadMsr: for unknown provider %u idMsr=%#RX32 -> #GP(0)", pVM->gim.s.enmProviderId, idMsr));
95 return VERR_CPUM_RAISE_GP_0;
96 }
97}
98
99
100/**
101 * Invokes the write-MSR handler for the GIM provider configured for the VM.
102 *
103 * @returns VBox status code.
104 * @param pVCpu Pointer to the VMCPU.
105 * @param idMsr The MSR to write.
106 * @param pRange The range this MSR belongs to.
107 * @param uValue The value to set, ignored bits masked.
108 * @param uRawValue The raw value with the ignored bits not masked.
109 */
110VMM_INT_DECL(int) GIMWriteMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
111{
112 Assert(pVCpu);
113 PVM pVM = pVCpu->CTX_SUFF(pVM);
114 Assert(GIMIsEnabled(pVM));
115 VMCPU_ASSERT_EMT(pVCpu);
116
117 switch (pVM->gim.s.enmProviderId)
118 {
119 case GIMPROVIDERID_HYPERV:
120 return GIMHvWriteMsr(pVCpu, idMsr, pRange, uValue, uRawValue);
121
122 default:
123 AssertMsgFailed(("GIMWriteMsr: for unknown provider %u idMsr=%#RX32 -> #GP(0)", pVM->gim.s.enmProviderId, idMsr));
124 return VERR_CPUM_RAISE_GP_0;
125 }
126}
127
Note: See TracBrowser for help on using the repository browser.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette