VirtualBox

Changeset 51333 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
May 22, 2014 4:42:22 AM (11 years ago)
Author:
vboxsync
Message:

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

Location:
trunk/src/VBox/VMM/VMMAll
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/CPUMAllMsrs.cpp

    r51301 r51333  
    2424#include <VBox/vmm/hm.h>
    2525#include <VBox/vmm/tm.h>
     26#include <VBox/vmm/gim.h>
    2627#include "CPUMInternal.h"
    2728#include <VBox/vmm/vm.h>
     
    43884389}
    43894390
     4391
     4392
     4393/*
     4394 * GIM MSRs.
     4395 * GIM MSRs.
     4396 * GIM MSRs.
     4397 */
     4398
     4399
     4400/** @callback_method_impl{FNCPUMRDMSR} */
     4401static DECLCALLBACK(int) cpumMsrRd_Gim(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
     4402{
     4403    return GIMReadMsr(pVCpu, idMsr, pRange, puValue);
     4404}
     4405
     4406
     4407/** @callback_method_impl{FNCPUMWRMSR} */
     4408static DECLCALLBACK(int) cpumMsrWr_Gim(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
     4409{
     4410    return GIMWriteMsr(pVCpu, idMsr, pRange, uValue, uRawValue);
     4411}
    43904412
    43914413
     
    46464668    cpumMsrRd_AmdFam10hIbsCtl,
    46474669    cpumMsrRd_AmdFam14hIbsBrTarget,
     4670
     4671    cpumMsrRd_Gim
    46484672};
    46494673
     
    48604884    cpumMsrWr_AmdFam10hIbsCtl,
    48614885    cpumMsrWr_AmdFam14hIbsBrTarget,
     4886
     4887    cpumMsrWr_Gim
    48624888};
    48634889
  • trunk/src/VBox/VMM/VMMAll/GIMAll.cpp

    r50953 r51333  
    2222#define LOG_GROUP LOG_GROUP_GIM
    2323#include "GIMInternal.h"
     24#include <VBox/err.h>
    2425#include <VBox/vmm/vm.h>
    2526
     27/* Include all the providers. */
     28#include "GIMHvInternal.h"
     29#include "GIMMinimalInternal.h"
    2630
     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 */
    2741VMMDECL(bool) GIMIsEnabled(PVM pVM)
    2842{
     
    3145
    3246
     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 */
    3354VMM_INT_DECL(int) GIMHypercall(PVMCPU pVCpu, PCPUMCTX pCtx)
    3455{
     
    3758    VMCPU_ASSERT_EMT(pVCpu);
    3859
    39     return pVM->gim.s.CTX_SUFF(pfnHypercall)(pVCpu, pCtx);
     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    }
    4069}
    4170
     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    PVM pVM = pVCpu->CTX_SUFF(pVM);
     84    Assert(GIMIsEnabled(pVM));
     85    VMCPU_ASSERT_EMT(pVCpu);
     86
     87    switch (pVM->gim.s.enmProviderId)
     88    {
     89        case GIMPROVIDERID_HYPERV:
     90            return GIMHvReadMsr(pVCpu, idMsr, pRange, puValue);
     91
     92        default:
     93            AssertMsgFailed(("GIMReadMsr: for unknown provider %u idMsr=%#RX32 -> #GP(0)", pVM->gim.s.enmProviderId, idMsr));
     94            return VERR_CPUM_RAISE_GP_0;
     95    }
     96}
     97
     98
     99/**
     100 * Invokes the write-MSR handler for the GIM provider configured for the VM.
     101 *
     102 * @returns VBox status code.
     103 * @param   pVCpu       Pointer to the VMCPU.
     104 * @param   idMsr       The MSR to write.
     105 * @param   pRange      The range this MSR belongs to.
     106 * @param   uValue      The value to set, ignored bits masked.
     107 * @param   uRawValue   The raw value with the ignored bits not masked.
     108 */
     109VMM_INT_DECL(int) GIMWriteMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
     110{
     111    PVM pVM = pVCpu->CTX_SUFF(pVM);
     112    Assert(GIMIsEnabled(pVM));
     113    VMCPU_ASSERT_EMT(pVCpu);
     114
     115    switch (pVM->gim.s.enmProviderId)
     116    {
     117        case GIMPROVIDERID_HYPERV:
     118            return GIMHvWriteMsr(pVCpu, idMsr, pRange, uValue, uRawValue);
     119
     120        default:
     121            AssertMsgFailed(("GIMWriteMsr: for unknown provider %u idMsr=%#RX32 -> #GP(0)", pVM->gim.s.enmProviderId, idMsr));
     122            return VERR_CPUM_RAISE_GP_0;
     123    }
     124}
     125
  • trunk/src/VBox/VMM/VMMAll/GIMAllHv.cpp

    r50953 r51333  
    3030}
    3131
     32
     33DECLEXPORT(int) GIMHvReadMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t *puValue)
     34{
     35    return VINF_SUCCESS;
     36}
     37
     38
     39DECLEXPORT(int) GIMHvWriteMsr(PVMCPU pVCpu, uint32_t idMsr, PCCPUMMSRRANGE pRange, uint64_t uValue, uint64_t uRawValue)
     40{
     41    return VINF_SUCCESS;
     42}
     43
Note: See TracChangeset for help on using the changeset viewer.

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