VirtualBox

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


Ignore:
Timestamp:
Nov 25, 2008 6:16:51 PM (16 years ago)
Author:
vboxsync
Message:

VMM,SUPLib: Updated SUPLib API spec, turned out we don't get zero-filled memory from ring-0. Switched the heap to use the new api.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/MMHyper.cpp

    r14543 r14589  
    783783    const uint32_t  cbAligned = RT_ALIGN_32(cb, PAGE_SIZE);
    784784    AssertReturn(cbAligned >= cb, VERR_INVALID_PARAMETER);
     785    uint32_t const  cPages = cb >> PAGE_SHIFT;
    785786    int             rc;
    786787    void           *pv;
    787     RTR0PTR         pvR0;
    788 #if 1
     788    RTR0PTR         pvR0 = NIL_RTR0PTR;
     789#if 0
     790    PSUPPAGE        paPages = NULL;
    789791    rc = SUPPageAlloc(cbAligned >> PAGE_SHIFT, &pv); /** @todo #1865: heap allocation must be changed for osx (only). */
    790     pvR0 = (uintptr_t)pv;
    791792#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     }
     793    PSUPPAGE        paPages = (PSUPPAGE)MMR3HeapAlloc(pVM, MM_TAG_MM, cPages * sizeof(paPages[0]));
     794    if (!paPages)
     795        return VERR_NO_MEMORY;
     796    rc = SUPR3PageAllocEx(cPages,
     797                          0 /*fFlags*/,
     798                          &pv,
     799                          VMMIsHwVirtExtForced(pVM) ? &pvR0 : NULL,
     800                          paPages);
    799801#endif
    800802    if (RT_SUCCESS(rc))
    801803    {
     804        if (!VMMIsHwVirtExtForced(pVM))
     805            pvR0 = (uintptr_t)pv;
     806        memset(pv, 0, cbAligned);
     807
    802808        /*
    803809         * Initialize the heap and first free chunk.
     
    806812        pHeap->u32Magic             = MMHYPERHEAP_MAGIC;
    807813        pHeap->pbHeapR3             = (uint8_t *)pHeap + MMYPERHEAP_HDR_SIZE;
    808         pHeap->pbHeapR0             = (uintptr_t)pHeap->pbHeapR3; /** @todo #1865: Map heap into ring-0 on darwin. */
    809         //pHeap->pbHeapGC           = 0; // set by mmR3HyperHeapMap()
     814        pHeap->pbHeapR0             = pvR0             + MMYPERHEAP_HDR_SIZE;
     815        //pHeap->pbHeapRC           = 0; // set by mmR3HyperHeapMap()
    810816        pHeap->pVMR3                = pVM;
    811817        pHeap->pVMR0                = pVM->pVMR0;
     
    817823        pHeap->offPageAligned       = pHeap->cbHeap;
    818824        //pHeap->HyperHeapStatTree  = 0;
     825        pHeap->paPages              = paPages;
    819826
    820827        PMMHYPERCHUNKFREE pFree = (PMMHYPERCHUNKFREE)pHeap->pbHeapR3;
     
    844851static int mmR3HyperHeapMap(PVM pVM, PMMHYPERHEAP pHeap, PRTGCPTR ppHeapGC)
    845852{
    846     int rc = MMR3HyperMapHCRam(pVM, pHeap, pHeap->cbHeap + MMYPERHEAP_HDR_SIZE, true, "Heap", ppHeapGC);
     853    Assert(RT_ALIGN_Z(pHeap->cbHeap + MMYPERHEAP_HDR_SIZE, PAGE_SIZE) == pHeap->cbHeap + MMYPERHEAP_HDR_SIZE);
     854    Assert(pHeap->paPages);
     855    int rc = MMR3HyperMapPages(pVM,
     856                               pHeap,
     857                               pHeap->pbHeapR0 - MMYPERHEAP_HDR_SIZE,
     858                               (pHeap->cbHeap + MMYPERHEAP_HDR_SIZE) >> PAGE_SHIFT,
     859                               pHeap->paPages,
     860                               "Heap", ppHeapGC);
    847861    if (RT_SUCCESS(rc))
    848862    {
     
    851865        /* Reserve a page for fencing. */
    852866        MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
     867
     868        /* We won't need these any more. */
     869        MMR3HeapFree(pHeap->paPages);
     870        pHeap->paPages = NULL;
    853871    }
    854872    return rc;
  • trunk/src/VBox/VMM/MMInternal.h

    r14155 r14589  
    281281    uint32_t                u32Padding0;
    282282#endif
     283    /** The heap physical pages. */
     284    R3PTRTYPE(PSUPPAGE)     paPages;
     285#if HC_ARCH_BITS == 32
     286    /** Padding the structure to a 64-bit aligned size. */
     287    uint32_t                u32Padding1;
     288#endif
    283289} MMHYPERHEAP;
    284290/** Pointer to the hypervisor heap. */
  • trunk/src/VBox/VMM/MMPagePool.cpp

    r14157 r14589  
    6868     *        ring-0. Need to change the wasy we allocate it... */
    6969    AssertReleaseReturn(sizeof(*pVM->mm.s.pPagePoolR3) + sizeof(*pVM->mm.s.pPagePoolLowR3) < PAGE_SIZE, VERR_INTERNAL_ERROR);
    70     int rc = SUPPageAllocLocked(1, (void **)&pVM->mm.s.pPagePoolR3);
     70    int rc = SUPPageAllocLockedEx(1, (void **)&pVM->mm.s.pPagePoolR3, NULL);
    7171    if (RT_FAILURE(rc))
    7272        return rc;
  • trunk/src/VBox/VMM/PGMPhys.cpp

    r14075 r14589  
    677677    if (RT_SUCCESS(rc))
    678678    {
     679        memset(pvPages, 0, cPages * PAGE_SIZE);
     680
    679681        /*
    680682         * Create the MMIO2 range record for it.
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