VirtualBox

Changeset 52699 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Sep 11, 2014 1:31:23 PM (10 years ago)
Author:
vboxsync
Message:

VMM/GIM: Fix initialization of Hyper-V bits that rely on HM initialization to be completed.

Location:
trunk/src/VBox/VMM/VMMR3
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/GIM.cpp

    r52675 r52699  
    149149
    150150
    151 VMMR3_INT_DECL(int) GIMR3InitFinalize(PVM pVM)
    152 {
    153     LogFlow(("GIMR3InitFinalize\n"));
    154 
     151/**
     152 * Initializes the remaining bits of the GIM provider.
     153 * This is called after initializing HM and most other VMM components.
     154 *
     155 * @returns VBox status code.
     156 * @param   pVM                 Pointer to the VM.
     157 * @param   enmWhat             What has been completed.
     158 * @thread  EMT(0)
     159 */
     160VMMR3_INT_DECL(int) GIMR3InitCompleted(PVM pVM)
     161{
    155162    if (!pVM->gim.s.fEnabled)
    156163        return VINF_SUCCESS;
    157164
    158     int rc = VINF_SUCCESS;
    159165    switch (pVM->gim.s.enmProviderId)
    160166    {
    161167        case GIMPROVIDERID_MINIMAL:
    162         {
    163             rc = GIMR3MinimalInitFinalize(pVM);
    164             break;
    165         }
     168            return GIMR3MinimalInitCompleted(pVM);
     169
     170        case GIMPROVIDERID_HYPERV:
     171            return GIMR3HvInitCompleted(pVM);
    166172
    167173        default:
    168174            break;
    169175    }
    170     return rc;
     176    return VINF_SUCCESS;
    171177}
    172178
  • trunk/src/VBox/VMM/VMMR3/GIMHv.cpp

    r52685 r52699  
    111111        pHv->uHyperHints = GIM_HV_HINT_MSR_FOR_SYS_RESET
    112112                         | GIM_HV_HINT_RELAX_TIME_CHECKS;
    113 
    114         /* Hypervisor capabilities; features used by the hypervisor. */
    115         /** @todo This is currently busted as it's too early. See @bugref{7270}
    116          *        comment 130. */
    117         pHv->uHyperCaps  = HMIsNestedPagingActive(pVM)   ? GIM_HV_HOST_FEAT_NESTED_PAGING : 0;
    118         pHv->uHyperCaps |= HMAreMsrBitmapsAvailable(pVM) ? GIM_HV_HOST_FEAT_MSR_BITMAP : 0;
    119113    }
    120114
     
    213207    AssertLogRelRCReturn(rc, rc);
    214208
     209    /*
     210     * Insert all MSR ranges of Hyper-V.
     211     */
     212    for (unsigned i = 0; i < RT_ELEMENTS(g_aMsrRanges_HyperV); i++)
     213    {
     214        rc = CPUMR3MsrRangesInsert(pVM, &g_aMsrRanges_HyperV[i]);
     215        AssertLogRelRCReturn(rc, rc);
     216    }
     217
     218    return VINF_SUCCESS;
     219}
     220
     221
     222/**
     223 * Initializes remaining bits of the Hyper-V provider.
     224 * This is called after initializing HM and almost all other VMM components.
     225 *
     226 * @returns VBox status code.
     227 * @param   pVM     Pointer to the VM.
     228 */
     229VMMR3_INT_DECL(int) GIMR3HvInitCompleted(PVM pVM)
     230{
     231    PGIMHV pHv = &pVM->gim.s.u.Hv;
     232
     233    /*
     234     * Determine interface capabilities based on the version.
     235     */
     236    if (!pVM->gim.s.u32Version)
     237    {
     238        /* Hypervisor capabilities; features used by the hypervisor. */
     239        pHv->uHyperCaps  = HMIsNestedPagingActive(pVM)   ? GIM_HV_HOST_FEAT_NESTED_PAGING : 0;
     240        pHv->uHyperCaps |= HMAreMsrBitmapsAvailable(pVM) ? GIM_HV_HOST_FEAT_MSR_BITMAP : 0;
     241    }
     242
     243    CPUMCPUIDLEAF HyperLeaf;
     244    RT_ZERO(HyperLeaf);
    215245    HyperLeaf.uLeaf        = UINT32_C(0x40000006);
    216246    HyperLeaf.uEax         = pHv->uHyperCaps;
     
    218248    HyperLeaf.uEcx         = 0;
    219249    HyperLeaf.uEdx         = 0;
    220     rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
     250    int rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
    221251    AssertLogRelRCReturn(rc, rc);
    222252
    223     /*
    224      * Insert all MSR ranges of Hyper-V.
    225      */
    226     for (unsigned i = 0; i < RT_ELEMENTS(g_aMsrRanges_HyperV); i++)
    227     {
    228         rc = CPUMR3MsrRangesInsert(pVM, &g_aMsrRanges_HyperV[i]);
    229         AssertLogRelRCReturn(rc, rc);
    230     }
    231 
    232     return VINF_SUCCESS;
     253    return rc;
    233254}
    234255
  • trunk/src/VBox/VMM/VMMR3/GIMMinimal.cpp

    r52676 r52699  
    3636*******************************************************************************/
    3737
     38/**
     39 * Initializes the Minimal provider.
     40 *
     41 * @returns VBox status code.
     42 * @param   pVM     Pointer to the VM.
     43 */
    3844VMMR3_INT_DECL(int) GIMR3MinimalInit(PVM pVM)
    3945{
     
    5056
    5157
    52 VMMR3_INT_DECL(int) GIMR3MinimalInitFinalize(PVM pVM)
     58/**
     59 * Initializes remaining bits of the Minimal provider.
     60 * This is called after initializing HM and almost all other VMM components.
     61 *
     62 * @returns VBox status code.
     63 * @param   pVM     Pointer to the VM.
     64 */
     65VMMR3_INT_DECL(int) GIMR3MinimalInitCompleted(PVM pVM)
    5366{
    5467    /*
     
    92105}
    93106
     107
     108/**
     109 * Applies relocations to data and code managed by this component. This function
     110 * will be called at init and whenever the VMM need to relocate itself inside
     111 * the GC.
     112 *
     113 * @param   pVM         Pointer to the VM.
     114 * @param   offDelta    Relocation delta relative to old location.
     115 */
    94116VMMR3_INT_DECL(void) GIMR3MinimalRelocate(PVM pVM, RTGCINTPTR offDelta)
    95117{
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r52675 r52699  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    10121012#endif
    10131013                                                                            if (RT_SUCCESS(rc))
    1014                                                                                 rc = GIMR3InitFinalize(pVM);
    1015                                                                             if (RT_SUCCESS(rc))
    10161014                                                                            {
    10171015                                                                                PGMR3MemSetup(pVM, false /*fAtReset*/);
     
    11761174        rc = HMR3InitCompleted(pVM, enmWhat);
    11771175    if (RT_SUCCESS(rc))
    1178         rc = PGMR3InitCompleted(pVM, enmWhat);
     1176        rc = PGMR3InitCompleted(pVM, enmWhat);  /** @todo Why is this not inside VMMR3InitCompleted()? */
    11791177#ifndef VBOX_WITH_RAW_MODE
    11801178    if (enmWhat == VMINITCOMPLETED_RING3)
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r52081 r52699  
    55
    66/*
    7  * Copyright (C) 2006-2013 Oracle Corporation
     7 * Copyright (C) 2006-2014 Oracle Corporation
    88 *
    99 * This file is part of VirtualBox Open Source Edition (OSE), as
     
    8484#include <VBox/vmm/pdmapi.h>
    8585#include <VBox/vmm/cpum.h>
     86#include <VBox/vmm/gim.h>
    8687#include <VBox/vmm/mm.h>
    8788#include <VBox/vmm/iom.h>
     
    708709
    709710            /*
     711             * Last chance for GIM to update its CPUID leafs if it requires knowledge/information
     712             * from HM initialization.
     713             */
     714            rc = GIMR3InitCompleted(pVM);
     715            AssertRCReturn(rc, rc);
     716
     717            /*
    710718             * CPUM's post-initialization (print CPUIDs).
    711719             */
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