VirtualBox

Changeset 62591 in vbox for trunk


Ignore:
Timestamp:
Jul 27, 2016 1:19:55 PM (8 years ago)
Author:
vboxsync
Message:

VMM/GIM, CPUM: Retire "EnableHVP" CFGM option and the unconditional insertion of hypervisor-specific CPUID leaves. Rather, this
is now tied to the HVP (Hypervisor Present) bit through the "Minimal" GIM provider. The other GIM providers (HyperV, KVM) already
do their own insertion and setting of the HVP bit as necessary.

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

Legend:

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

    r62478 r62591  
    22392239
    22402240/**
    2241  * Insert hypervisor identification leaves.
    2242  *
    2243  * We only return minimal information, primarily ensuring that the
    2244  * 0x40000000 function returns 0x40000001 and identifying ourselves.
    2245  * Hypervisor-specific interface is supported through GIM which will
    2246  * modify these leaves if required depending on the GIM provider.
    2247  *
    2248  * @returns VBox status code.
    2249  * @param   pCpum       The CPUM instance data.
    2250  * @param   pConfig     The CPUID configuration we've read from CFGM.
    2251  */
    2252 static int cpumR3CpuIdPlantHypervisorLeaves(PCPUM pCpum, PCPUMCPUIDCONFIG pConfig)
    2253 {
    2254     CPUMCPUIDLEAF NewLeaf;
    2255     NewLeaf.uLeaf        = UINT32_C(0x40000000);
    2256     NewLeaf.uSubLeaf     = 0;
    2257     NewLeaf.fSubLeafMask = 0;
    2258     NewLeaf.uEax         = UINT32_C(0x40000001);
    2259     NewLeaf.uEbx         = 0x786f4256 /* 'VBox' */;
    2260     NewLeaf.uEcx         = 0x786f4256 /* 'VBox' */;
    2261     NewLeaf.uEdx         = 0x786f4256 /* 'VBox' */;
    2262     NewLeaf.fFlags       = 0;
    2263     int rc = cpumR3CpuIdInsert(NULL /* pVM */, &pCpum->GuestInfo.paCpuIdLeavesR3, &pCpum->GuestInfo.cCpuIdLeaves, &NewLeaf);
    2264     AssertLogRelRCReturn(rc, rc);
    2265 
    2266     NewLeaf.uLeaf        = UINT32_C(0x40000001);
    2267     NewLeaf.uEax         = 0x656e6f6e;                            /* 'none' */
    2268     NewLeaf.uEbx         = 0;
    2269     NewLeaf.uEcx         = 0;
    2270     NewLeaf.uEdx         = 0;
    2271     NewLeaf.fFlags       = 0;
    2272     rc = cpumR3CpuIdInsert(NULL /* pVM */, &pCpum->GuestInfo.paCpuIdLeavesR3, &pCpum->GuestInfo.cCpuIdLeaves, &NewLeaf);
    2273     AssertLogRelRCReturn(rc, rc);
    2274 
    2275     return VINF_SUCCESS;
    2276 }
    2277 
    2278 
    2279 /**
    22802241 * Mini CPU selection support for making Mac OS X happy.
    22812242 *
     
    40333994
    40343995    /*
    4035      * Plant our own hypervisor CPUID leaves.
    4036      */
    4037     if (RT_SUCCESS(rc))
    4038         rc = cpumR3CpuIdPlantHypervisorLeaves(pCpum, &Config);
    4039 
    4040     /*
    40413996     * MSR fudging.
    40423997     */
     
    40954050        if (fEnable)
    40964051            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
    4097 
    4098         /* We don't enable the Hypervisor Present bit by default, but it may be needed by some guests. */
    4099         rc = CFGMR3QueryBoolDef(pCpumCfg, "EnableHVP", &fEnable, false);
    4100         AssertRCReturn(rc, rc);
    4101         if (fEnable)
    4102             CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
    41034052
    41044053        return VINF_SUCCESS;
  • trunk/src/VBox/VMM/VMMR3/GIMMinimal.cpp

    r62478 r62591  
    5050
    5151    /*
    52      * Enable the Hypervisor Present.
     52     * Expose HVP (Hypervisor Present) bit to the guest.
    5353     */
    5454    CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_HVP);
    5555
    56     return VINF_SUCCESS;
     56    /*
     57     * Insert the hypervisor leaf range.
     58     */
     59    CPUMCPUIDLEAF HyperLeaf;
     60    RT_ZERO(HyperLeaf);
     61    HyperLeaf.uLeaf = UINT32_C(0x40000000);
     62    HyperLeaf.uEax  = UINT32_C(0x40000010); /* Maximum leaf we implement. */
     63    int rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
     64    if (RT_SUCCESS(rc))
     65    {
     66        /*
     67         * Insert missing zero leaves (you never know what missing leaves are
     68         * going to return when read).
     69         */
     70        RT_ZERO(HyperLeaf);
     71        for (uint32_t uLeaf = UINT32_C(0x40000001); uLeaf <= UINT32_C(0x40000010); uLeaf++)
     72        {
     73            HyperLeaf.uLeaf = uLeaf;
     74            rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
     75            AssertLogRelRCReturn(rc, rc);
     76        }
     77    }
     78    else
     79        LogRel(("GIM: Minimal: Failed to insert hypervisor leaf %#RX32. rc=%Rrc\n", HyperLeaf.uLeaf, rc));
     80
     81    return rc;
    5782}
    5883
     
    78103    if (RT_SUCCESS(rc))
    79104    {
    80         HyperLeaf.uEax         = UINT32_C(0x40000010);  /* Maximum leaf we implement. */
    81         rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
    82         AssertLogRelRCReturn(rc, rc);
    83 
    84         /*
    85          * Insert missing zero leaves (you never know what missing leaves are
    86          * going to return when read).
    87          */
    88         for (uint32_t uLeaf = UINT32_C(0x40000001); uLeaf < UINT32_C(0x40000010); uLeaf++)
    89         {
    90             rc = CPUMR3CpuIdGetLeaf(pVM, &HyperLeaf, uLeaf, 0 /* uSubLeaf */);
    91             if (RT_FAILURE(rc))
    92             {
    93                 RT_ZERO(HyperLeaf);
    94                 HyperLeaf.uLeaf = uLeaf;
    95                 rc = CPUMR3CpuIdInsert(pVM, &HyperLeaf);
    96                 AssertLogRelRCReturn(rc, rc);
    97             }
    98         }
     105        Assert(HyperLeaf.uEax >= 0x40000010);
    99106
    100107        /*
     
    118125    }
    119126    else
    120         LogRel(("GIM: Minimal: failed to get hypervisor leaf 0x40000000.\n"));
     127        LogRel(("GIM: Minimal: failed to get hypervisor leaf 0x40000000. rc=%Rrc\n", rc));
    121128
    122129    return VINF_SUCCESS;
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