VirtualBox

Changeset 51981 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jul 11, 2014 6:16:19 AM (10 years ago)
Author:
vboxsync
Message:

VMM/GIM, VMM/HM: Add support for Hyper-V hypervisor capabilities reporting through CPUID. Updated saved states as well, will break old states.

Location:
trunk/src/VBox/VMM
Files:
4 edited

Legend:

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

    r51560 r51981  
    274274
    275275/**
    276  * Checks if nested paging is enabled
    277  *
    278  * @returns boolean
     276 * Checks if nested paging is enabled.
     277 *
     278 * @returns true if nested paging is active, false otherwise.
    279279 * @param   pVM         Pointer to the VM.
    280280 */
     
    283283    return HMIsEnabled(pVM) && pVM->hm.s.fNestedPaging;
    284284}
     285
     286
     287/**
     288 * Checks if MSR bitmaps are available. It is assumed that when it's available
     289 * it will be used as well.
     290 *
     291 * @returns true if MSR bitmaps are available, false otherwise.
     292 * @param   pVM         Pointer to the VM.
     293 */
     294VMM_INT_DECL(bool) HMAreMsrBitmapsAvailable(PVM pVM)
     295{
     296    if (HMIsEnabled(pVM))
     297    {
     298        if (pVM->hm.s.svm.fSupported)
     299            return true;
     300
     301        if (   pVM->hm.s.vmx.fSupported
     302            && (pVM->hm.s.vmx.Msrs.VmxProcCtls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_USE_MSR_BITMAPS))
     303        {
     304            return true;
     305        }
     306    }
     307    return false;
     308}
     309
    285310
    286311/**
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r51961 r51981  
    976976        }
    977977
    978         /* Allocate the MSR-bitmap if supported by the CPU. The MSR-bitmap is for transparent accesses of specific MSRs. */
     978        /*
     979         * Allocate the MSR-bitmap if supported by the CPU. The MSR-bitmap is for
     980         * transparent accesses of specific MSRs.
     981         *
     982         * If the condition for enabling MSR bitmaps changes here, don't forget to
     983         * update HMIsMsrBitmapsAvailable().
     984         */
    979985        if (pVM->hm.s.vmx.Msrs.VmxProcCtls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_USE_MSR_BITMAPS)
    980986        {
  • trunk/src/VBox/VMM/VMMR3/GIMHv.cpp

    r51980 r51981  
    8888    if (!pVM->gim.s.u32Version)
    8989    {
     90        /* Basic features. */
    9091        pHv->uBaseFeat = 0
    9192                       //| GIM_HV_BASE_FEAT_VP_RUNTIME_MSR
     
    104105                       ;
    105106
     107        /* Miscellaneous features. */
    106108        pHv->uMiscFeat = GIM_HV_MISC_FEAT_TIMER_FREQ;
    107109
     110        /* Hypervisor recommendations to the guest. */
    108111        pHv->uHyperHints = GIM_HV_HINT_MSR_FOR_SYS_RESET;
     112
     113        /* Hypervisor capabilities; features used by the hypervisor. */
     114        pHv->uHyperCaps  = HMIsNestedPagingActive(pVM)   ? GIM_HV_HOST_FEAT_NESTED_PAGING : 0;
     115        pHv->uHyperCaps |= HMAreMsrBitmapsAvailable(pVM) ? GIM_HV_HOST_FEAT_MSR_BITMAP : 0;
    109116    }
    110117
     
    161168    RT_ZERO(HyperLeaf);
    162169    HyperLeaf.uLeaf        = UINT32_C(0x40000000);
    163     HyperLeaf.uEax         = UINT32_C(0x40000005); /* Minimum value for Hyper-V */
     170    HyperLeaf.uEax         = UINT32_C(0x40000006); /* Minimum value for Hyper-V is 0x40000005. */
    164171    HyperLeaf.uEbx         = 0x7263694D;           /* 'Micr' */
    165172    HyperLeaf.uEcx         = 0x666F736F;           /* 'osof' */
     
    203210    AssertLogRelRCReturn(rc, rc);
    204211
     212    HyperLeaf.uLeaf        = UINT32_C(0x40000006);
     213    HyperLeaf.uEax         = pHv->uHyperCaps;
     214    HyperLeaf.uEbx         = 0;
     215    HyperLeaf.uEcx         = 0;
     216    HyperLeaf.uEdx         = 0;
     217    rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
     218    AssertLogRelRCReturn(rc, rc);
     219
    205220    /*
    206221     * Insert all MSR ranges of Hyper-V.
     
    321336    rc = SSMR3PutU32(pSSM, pcHv->uMiscFeat);                AssertRCReturn(rc, rc);
    322337    rc = SSMR3PutU32(pSSM, pcHv->uHyperHints);              AssertRCReturn(rc, rc);
     338    rc = SSMR3PutU32(pSSM, pcHv->uHyperCaps);               AssertRCReturn(rc, rc);
    323339
    324340    /*
     
    384400    rc = SSMR3GetU32(pSSM, &pHv->uMiscFeat);                AssertRCReturn(rc, rc);
    385401    rc = SSMR3GetU32(pSSM, &pHv->uHyperHints);              AssertRCReturn(rc, rc);
     402    rc = SSMR3GetU32(pSSM, &pHv->uHyperCaps);               AssertRCReturn(rc, rc);
    386403
    387404    /*
  • trunk/src/VBox/VMM/include/GIMHvInternal.h

    r51961 r51981  
    471471    /** Miscellaneous features. */
    472472    uint32_t                    uMiscFeat;
    473     /** Hypervisor hints. */
     473    /** Hypervisor hints to the guest. */
    474474    uint32_t                    uHyperHints;
    475     /** Alignment padding. */
    476     uint32_t                    u32Alignment0;
     475    /** Hypervisor capabilities. */
     476    uint32_t                    uHyperCaps;
    477477
    478478    /** Per-VM R0 Spinlock for protecting EMT writes to the TSC page. */
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