VirtualBox

Ignore:
Timestamp:
Aug 4, 2019 2:39:54 AM (5 years ago)
Author:
vboxsync
Message:

VMM: Kicking out raw-mode and 32-bit hosts - MM, PGM, ++. bugref:9517 bugref:9511

File:
1 edited

Legend:

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

    r76553 r80118  
    3838*   Internal Functions                                                                                                           *
    3939*********************************************************************************************************************************/
     40#ifndef PGM_WITHOUT_MAPPINGS
    4041static DECLCALLBACK(bool) mmR3HyperRelocateCallback(PVM pVM, RTGCPTR GCPtrOld, RTGCPTR GCPtrNew, PGMRELOCATECALL enmMode,
    4142                                                    void *pvUser);
     43#endif
    4244static int mmR3HyperMap(PVM pVM, const size_t cb, const char *pszDesc, PRTGCPTR pGCPtr, PMMLOOKUPHYPER *ppLookup);
    4345static int mmR3HyperHeapCreate(PVM pVM, const size_t cb, PMMHYPERHEAP *ppHeap, PRTR0PTR pR0PtrHeap);
     
    5456static uint32_t mmR3HyperComputeHeapSize(PVM pVM)
    5557{
     58    /** @todo Redo after moving allocations off the hyper heap. */
     59
    5660    /*
    5761     * Gather parameters.
    5862     */
    59     bool        fCanUseLargerHeap;
    60     int rc = CFGMR3QueryBoolDef(CFGMR3GetChild(CFGMR3GetRoot(pVM), "MM"), "CanUseLargerHeap", &fCanUseLargerHeap, false);
    61     AssertStmt(RT_SUCCESS(rc), fCanUseLargerHeap = false);
     63    bool        fCanUseLargerHeap = true;
     64    //bool        fCanUseLargerHeap;
     65    //int rc = CFGMR3QueryBoolDef(CFGMR3GetChild(CFGMR3GetRoot(pVM), "MM"), "CanUseLargerHeap", &fCanUseLargerHeap, false);
     66    //AssertStmt(RT_SUCCESS(rc), fCanUseLargerHeap = false);
    6267
    6368    uint64_t    cbRam;
    64     rc = CFGMR3QueryU64(CFGMR3GetRoot(pVM), "RamSize", &cbRam);
     69    int rc = CFGMR3QueryU64(CFGMR3GetRoot(pVM), "RamSize", &cbRam);
    6570    AssertStmt(RT_SUCCESS(rc), cbRam = _1G);
    6671
     
    142147         * Make a small head fence to fend of accidental sequential access.
    143148         */
    144         MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
     149        MMR3HyperReserveFence(pVM);
    145150
    146151        /*
     
    158163
    159164            /* Reserve a page for fencing. */
    160             MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
     165            MMR3HyperReserveFence(pVM);
    161166
    162167            /*
     
    218223    AssertRC(rc);
    219224
     225#ifndef PGM_WITHOUT_MAPPINGS
    220226    /*
    221227     * Adjust and create the HMA mapping.
     
    227233    if (RT_FAILURE(rc))
    228234        return rc;
     235#endif
    229236    pVM->mm.s.fPGMInitialized = true;
    230237
     238#ifndef PGM_WITHOUT_MAPPINGS
    231239    /*
    232240     * Do all the delayed mappings.
     
    309317        pLookup = (PMMLOOKUPHYPER)((uintptr_t)pLookup + pLookup->offNext);
    310318    }
     319#endif /* !PGM_WITHOUT_MAPPINGS */
    311320
    312321    LogFlow(("MMR3HyperInitFinalize: returns VINF_SUCCESS\n"));
     
    315324
    316325
     326#ifndef PGM_WITHOUT_MAPPINGS
    317327/**
    318328 * Callback function which will be called when PGM is trying to find a new
     
    385395    return false;
    386396}
     397#endif /* !PGM_WITHOUT_MAPPINGS */
     398
    387399
    388400/**
     
    400412    return rc;
    401413}
     414
     415
     416#ifndef PGM_WITHOUT_MAPPINGS
    402417
    403418/**
     
    607622}
    608623
     624#endif /* !PGM_WITHOUT_MAPPINGS */
    609625
    610626/**
     
    662678            }
    663679
     680#ifndef PGM_WITHOUT_MAPPINGS
    664681            if (pVM->mm.s.fPGMInitialized)
    665682            {
     
    670687                }
    671688            }
     689#endif
    672690            if (RT_SUCCESS(rc))
    673691            {
     
    689707
    690708
     709#ifndef PGM_WITHOUT_MAPPINGS
    691710/**
    692711 * Reserves a hypervisor memory area.
     
    729748    }
    730749    return rc;
     750}
     751#endif /* !PGM_WITHOUT_MAPPINGS */
     752
     753
     754/**
     755 * Reserves an electric fence page.
     756 *
     757 * @returns VBox status code.
     758 * @param   pVM         The cross context VM structure.
     759 */
     760VMMR3DECL(int) MMR3HyperReserveFence(PVM pVM)
     761{
     762#ifndef PGM_WITHOUT_MAPPINGS
     763    return MMR3HyperReserve(pVM, cb, "fence", NULL);
     764#else
     765    RT_NOREF(pVM);
     766    return VINF_SUCCESS;
     767#endif
    731768}
    732769
     
    818855                              0 /*fFlags*/,
    819856                              &pv,
    820 #if defined(VBOX_WITH_2X_4GB_ADDR_SPACE) || defined(VBOX_WITH_MORE_RING0_MEM_MAPPINGS)
    821857                              &pvR0,
    822 #else
    823                               NULL,
    824 #endif
    825858                              paPages);
    826859    if (RT_SUCCESS(rc))
    827860    {
    828 #if !defined(VBOX_WITH_2X_4GB_ADDR_SPACE) && !defined(VBOX_WITH_MORE_RING0_MEM_MAPPINGS)
    829         pvR0 = (uintptr_t)pv;
    830 #endif
     861        Assert(pvR0 != NIL_RTR0PTR && !(PAGE_OFFSET_MASK & pvR0));
    831862        memset(pv, 0, cbAligned);
    832863
     
    837868        pHeap->u32Magic             = MMHYPERHEAP_MAGIC;
    838869        pHeap->pbHeapR3             = (uint8_t *)pHeap + MMYPERHEAP_HDR_SIZE;
    839         pHeap->pbHeapR0             = pvR0 != NIL_RTR0PTR ? pvR0 + MMYPERHEAP_HDR_SIZE : NIL_RTR0PTR;
     870        pHeap->pbHeapR0             = pvR0 + MMYPERHEAP_HDR_SIZE;
    840871        //pHeap->pbHeapRC           = 0; // set by mmR3HyperHeapMap()
    841872        pHeap->pVMR3                = pVM;
     
    871902}
    872903
     904
    873905/**
    874906 * Allocates a new heap.
     
    877909{
    878910    Assert(RT_ALIGN_Z(pHeap->cbHeap + MMYPERHEAP_HDR_SIZE, PAGE_SIZE) == pHeap->cbHeap + MMYPERHEAP_HDR_SIZE);
     911    Assert(pHeap->pbHeapR0);
    879912    Assert(pHeap->paPages);
    880913    int rc = MMR3HyperMapPages(pVM,
    881914                               pHeap,
    882                                pHeap->pbHeapR0 != NIL_RTR0PTR ? pHeap->pbHeapR0 - MMYPERHEAP_HDR_SIZE : NIL_RTR0PTR,
     915                               pHeap->pbHeapR0 - MMYPERHEAP_HDR_SIZE,
    883916                               (pHeap->cbHeap + MMYPERHEAP_HDR_SIZE) >> PAGE_SHIFT,
    884917                               pHeap->paPages,
     
    889922        pHeap->pbHeapRC = *ppHeapGC + MMYPERHEAP_HDR_SIZE;
    890923        /* Reserve a page for fencing. */
    891         MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
     924        MMR3HyperReserveFence(pVM);
    892925
    893926        /* We won't need these any more. */
     
    10141047                              0 /*fFlags*/,
    10151048                              &pvPages,
    1016 #ifdef VBOX_WITH_MORE_RING0_MEM_MAPPINGS
    10171049                              &pvR0,
    1018 #else
    1019                               fFlags & MMHYPER_AONR_FLAGS_KERNEL_MAPPING ? &pvR0 : NULL,
    1020 #endif
    10211050                              paPages);
    10221051    if (RT_SUCCESS(rc))
    10231052    {
    1024 #ifdef VBOX_WITH_MORE_RING0_MEM_MAPPINGS
    10251053        Assert(pvR0 != NIL_RTR0PTR);
    1026 #else
    1027         if (!(fFlags & MMHYPER_AONR_FLAGS_KERNEL_MAPPING))
    1028 # ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    1029             pvR0 = NIL_RTR0PTR;
    1030 # else
    1031             pvR0 = (RTR0PTR)pvPages;
    1032 # endif
    1033 #endif
    1034 
    10351054        memset(pvPages, 0, cbAligned);
    10361055
     
    10501069            Log2(("MMR3HyperAllocOnceNoRel: cbAligned=%#x uAlignment=%#x returns VINF_SUCCESS and *ppv=%p\n",
    10511070                  cbAligned, uAlignment, *ppv));
    1052             MMR3HyperReserve(pVM, PAGE_SIZE, "fence", NULL);
     1071            MMR3HyperReserveFence(pVM);
    10531072            return rc;
    10541073        }
     
    11651184    if (fSet)
    11661185    {
     1186#ifndef PGM_WITHOUT_MAPPINGS
    11671187        rc = PGMMapSetPage(pVM, MMHyperR3ToRC(pVM, pvStart), cb, 0);
     1188#else
     1189        rc = VINF_SUCCESS;
     1190#endif
    11681191        SUPR3PageProtect(pbR3, R0Ptr, off, (uint32_t)cb, RTMEM_PROT_NONE);
    11691192    }
    11701193    else
    11711194    {
     1195#ifndef PGM_WITHOUT_MAPPINGS
    11721196        rc = PGMMapSetPage(pVM, MMHyperR3ToRC(pVM, pvStart), cb, X86_PTE_P | X86_PTE_A | X86_PTE_D | X86_PTE_RW);
     1197#else
     1198        rc = VINF_SUCCESS;
     1199#endif
    11731200        SUPR3PageProtect(pbR3, R0Ptr, off, (uint32_t)cb, RTMEM_PROT_READ | RTMEM_PROT_WRITE);
    11741201    }
     
    12281255}
    12291256
     1257#ifndef PGM_WITHOUT_MAPPINGS
    12301258
    12311259/**
     
    13141342
    13151343
    1316 #if 0 /* unused, not implemented */
    1317 /**
    1318  * Convert hypervisor HC physical address to HC virtual address.
    1319  *
    1320  * @returns HC virtual address.
    1321  * @param   pVM         The cross context VM structure.
    1322  * @param   HCPhys      Host context physical address.
    1323  */
    1324 VMMR3DECL(void *) MMR3HyperHCPhys2HCVirt(PVM pVM, RTHCPHYS HCPhys)
    1325 {
    1326     void *pv;
    1327     int rc = MMR3HyperHCPhys2HCVirtEx(pVM, HCPhys, &pv);
    1328     if (RT_SUCCESS(rc))
    1329         return pv;
    1330     AssertMsgFailed(("Invalid address HCPhys=%x rc=%d\n", HCPhys, rc));
    1331     return NULL;
    1332 }
    1333 
    1334 
    1335 /**
    1336  * Convert hypervisor HC physical address to HC virtual address.
    1337  *
    1338  * @returns VBox status code.
    1339  * @param   pVM         The cross context VM structure.
    1340  * @param   HCPhys      Host context physical address.
    1341  * @param   ppv         Where to store the HC virtual address.
    1342  */
    1343 VMMR3DECL(int)   MMR3HyperHCPhys2HCVirtEx(PVM pVM, RTHCPHYS HCPhys, void **ppv)
    1344 {
    1345     /*
    1346      * Linear search.
    1347      */
    1348     /** @todo implement when actually used. */
    1349     return VERR_INVALID_POINTER;
    1350 }
    1351 #endif /* unused, not implemented */
    1352 
    1353 
    13541344/**
    13551345 * Read hypervisor memory from GC virtual address.
     
    13701360}
    13711361
     1362#endif /* !PGM_WITHOUT_MAPPINGS */
    13721363
    13731364/**
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