VirtualBox

Changeset 14543 in vbox


Ignore:
Timestamp:
Nov 24, 2008 7:36:37 PM (16 years ago)
Author:
vboxsync
Message:

#1865/VT-x: Attacking the heap allocation, introducing VMMIsHwVirtExtForced which will only return true on darwin (for now at least).

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vm.h

    r14411 r14543  
    537537     * This is placed here for performance reasons. */
    538538    bool                fCSAMEnabled;
    539 
    540539    /** Hardware VM support is available and enabled.
    541540     * This is placed here for performance reasons. */
    542541    bool                fHWACCMEnabled;
    543 
     542    /** Hardware VM support is required and non-optional.
     543     * This is initialized together with the rest of the VM structure. */
     544    bool                fHwVirtExtForced;
    544545    /** PARAV enabled flag. */
    545546    bool                fPARAVEnabled;
  • trunk/include/VBox/vm.mac

    r13960 r14543  
    7272    .fPATMEnabled       resb 1
    7373    .fCSAMEnabled       resb 1
    74     .fHWACCMEnabled     resb 3
     74    .fHWACCMEnabled     resb 1
     75    .fHwVirtExtForced   resb 1
     76    .fPARAVEnabled      resb 1
    7577
    7678    alignb 8
  • trunk/include/VBox/vmm.h

    r14167 r14543  
    118118VMMDECL(uint32_t)   VMMGetSvnRev(void);
    119119
     120/** @def VMMIsHwVirtExtForced
     121 * Checks if forced to use the hardware assisted virtualization extensions.
     122 *
     123 * This is intended for making setup decisions where we can save resources when
     124 * using hardware assisted virtualization.
     125 *
     126 * @returns true / false.
     127 * @param   pVM     Pointer to the shared VM structure. */
     128#define VMMIsHwVirtExtForced(pVM)   ((pVM)->fHwVirtExtForced)
     129
    120130
    121131#ifdef IN_RING3
  • trunk/src/VBox/Main/ConsoleImpl2.cpp

    r14525 r14543  
    205205    else
    206206        fHWVirtExEnabled = (hwVirtExEnabled == TSBool_True);
    207 #ifndef RT_OS_DARWIN /** @todo Implement HWVirtExt on darwin. See #1865. */
     207#ifdef RT_OS_DARWIN
     208    rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced",      fHWVirtExEnabled);      RC_CHECK();
     209#else
     210    rc = CFGMR3InsertInteger(pRoot, "HwVirtExtForced",      0);                     RC_CHECK();
     211#endif
    208212    if (fHWVirtExEnabled)
    209213    {
    210214        PCFGMNODE pHWVirtExt;
    211215        rc = CFGMR3InsertNode(pRoot, "HWVirtExt", &pHWVirtExt);                     RC_CHECK();
    212         rc = CFGMR3InsertInteger(pHWVirtExt, "Enabled", 1);                         RC_CHECK();
    213     }
    214 #endif
     216        rc = CFGMR3InsertInteger(pHWVirtExt, "Enabled",     1);                     RC_CHECK();
     217    }
    215218
    216219    /* Nested paging (VT-x/AMD-V) */
  • trunk/src/VBox/VMM/MMHyper.cpp

    r14071 r14543  
    781781     * Allocate the hypervisor heap.
    782782     */
    783     const uint32_t cbAligned = RT_ALIGN_32(cb, PAGE_SIZE);
     783    const uint32_t  cbAligned = RT_ALIGN_32(cb, PAGE_SIZE);
    784784    AssertReturn(cbAligned >= cb, VERR_INVALID_PARAMETER);
    785     void *pv;
    786     int rc = SUPPageAlloc(cbAligned >> PAGE_SHIFT, &pv); /** @todo #1865: heap allocation must be changed for osx (only). */
     785    int             rc;
     786    void           *pv;
     787    RTR0PTR         pvR0;
     788#if 1
     789    rc = SUPPageAlloc(cbAligned >> PAGE_SHIFT, &pv); /** @todo #1865: heap allocation must be changed for osx (only). */
     790    pvR0 = (uintptr_t)pv;
     791#else /**@todo resume here. */
     792    if (VMMIsHwVirtExtForced(pVM))
     793        rc = SUPPageAllocKernel((cbAligned >> PAGE_SHIFT, &pv, &pvR0, paPages);
     794    else
     795    {
     796        rc = SUPPageAllocLocked((cbAligned >> PAGE_SHIFT, &pv, paPages);
     797        pvR0 = (uintptr_t)pv;
     798    }
     799#endif
    787800    if (RT_SUCCESS(rc))
    788801    {
  • trunk/src/VBox/VMM/VM.cpp

    r13858 r14543  
    526526        if (RT_SUCCESS(rc))
    527527        {
     528            rc = CFGMR3QueryBoolDef(CFGMR3GetRoot(pVM), "fHwVirtExtForced", &pVM->fHwVirtExtForced, false);
     529            if (RT_SUCCESS(rc) && pVM->fHwVirtExtForced)
     530                pVM->fHWACCMEnabled = true;
     531
    528532            /*
    529533             * If executing in fake suplib mode disable RR3 and RR0 in the config.
     
    541545             * Make sure the CPU count in the config data matches.
    542546             */
    543             uint32_t cCPUsCfg;
    544             rc = CFGMR3QueryU32Def(CFGMR3GetRoot(pVM), "NumCPUs", &cCPUsCfg, 1);
    545             AssertLogRelMsgRC(rc, ("Configuration error: Querying \"NumCPUs\" as integer failed, rc=%Rrc\n", rc));
    546             if (RT_SUCCESS(rc) && cCPUsCfg != cCPUs)
     547            if (RT_SUCCESS(rc))
    547548            {
    548                 AssertLogRelMsgFailed(("Configuration error: \"NumCPUs\"=%RU32 and VMR3CreateVM::cCPUs=%RU32 does not match!\n",
    549                                        cCPUsCfg, cCPUs));
    550                 rc = VERR_INVALID_PARAMETER;
     549                uint32_t cCPUsCfg;
     550                rc = CFGMR3QueryU32Def(CFGMR3GetRoot(pVM), "NumCPUs", &cCPUsCfg, 1);
     551                AssertLogRelMsgRC(rc, ("Configuration error: Querying \"NumCPUs\" as integer failed, rc=%Rrc\n", rc));
     552                if (RT_SUCCESS(rc) && cCPUsCfg != cCPUs)
     553                {
     554                    AssertLogRelMsgFailed(("Configuration error: \"NumCPUs\"=%RU32 and VMR3CreateVM::cCPUs=%RU32 does not match!\n",
     555                                           cCPUsCfg, cCPUs));
     556                    rc = VERR_INVALID_PARAMETER;
     557                }
    551558            }
    552559            if (RT_SUCCESS(rc))
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