VirtualBox

Changeset 92192 in vbox


Ignore:
Timestamp:
Nov 3, 2021 2:44:45 PM (3 years ago)
Author:
vboxsync
Message:

VMM/MM,DevPcArch: Split the base RAM allocation into conventional (< 640KB) and extended (>= 1MB) ranges, leaving the UMA w/o RAM range backing. This will fit better with NEM, esp. on linux. bugref:10122

Location:
trunk/src/VBox
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevPcArch.cpp

    r91920 r92192  
    215215    RT_NOREF(pDevIns, pvUser, off);
    216216    memset(pv, 0xff, cb);
    217     return VINF_SUCCESS;
    218 }
    219 
    220 
    221 /**
    222  * @interface_method_impl{PDMDEVREG,pfnInitComplete,
    223  *      Turn RAM pages between 0xa0000 and 0xfffff into reserved memory.}
    224  */
    225 static DECLCALLBACK(int) pcarchInitComplete(PPDMDEVINS pDevIns)
    226 {
    227     int             iRegion   = 0;
    228     RTGCPHYS const  GCPhysEnd = 0x100000;
    229     RTGCPHYS        GCPhysCur = 0x0a0000;
    230     do
    231     {
    232         if (!PDMDevHlpPhysIsGCPhysNormal(pDevIns, GCPhysCur))
    233             GCPhysCur += X86_PAGE_SIZE;
    234         else
    235         {
    236             RTGCPHYS const GCPhysStart = GCPhysCur;
    237             do
    238                 GCPhysCur += X86_PAGE_SIZE;
    239             while (GCPhysCur < GCPhysEnd && PDMDevHlpPhysIsGCPhysNormal(pDevIns, GCPhysCur));
    240 
    241             IOMMMIOHANDLE hMmioRegion;
    242             int rc = PDMDevHlpMmioCreateAndMap(pDevIns, GCPhysStart, GCPhysCur - GCPhysStart,
    243                                                pcarchReservedMemoryWrite, pcarchReservedMemoryRead,
    244                                                IOMMMIO_FLAGS_READ_PASSTHRU | IOMMMIO_FLAGS_WRITE_PASSTHRU | IOMMMIO_FLAGS_ABS,
    245                                                PDMDevHlpMMHeapAPrintf(pDevIns, MM_TAG_PGM_PHYS /* bad bird*/, "PC Arch Reserved #%u", iRegion),
    246                                                &hMmioRegion);
    247             AssertLogRelRCReturn(rc, rc);
    248             iRegion++;
    249         }
    250     } while (GCPhysCur < GCPhysEnd);
    251 
    252217    return VINF_SUCCESS;
    253218}
     
    324289    /* .pfnDetach = */              NULL,
    325290    /* .pfnQueryInterface = */      NULL,
    326     /* .pfnInitComplete = */        pcarchInitComplete,
     291    /* .pfnInitComplete = */        NULL,
    327292    /* .pfnPowerOff = */            NULL,
    328293    /* .pfnSoftReset = */           NULL,
  • trunk/src/VBox/VMM/VMMR3/MM.cpp

    r91018 r92192  
    377377     * Make the initial memory reservation with GMM.
    378378     */
    379     uint64_t cBasePages = (cbRam >> PAGE_SHIFT) + pVM->mm.s.cBasePages;
     379    uint32_t const cbUma      = _1M - 640*_1K;
     380    uint64_t       cBasePages = ((cbRam - cbUma) >> PAGE_SHIFT) + pVM->mm.s.cBasePages;
    380381    rc = GMMR3InitialReservation(pVM,
    381382                                 RT_MAX(cBasePages + pVM->mm.s.cHandyPages, 1),
     
    407408     */
    408409    pVM->mm.s.cbRamHole = cbRamHole;
    409     if (cbRam > offRamHole)
    410     {
    411         pVM->mm.s.cbRamBelow4GB = offRamHole;
    412         rc = PGMR3PhysRegisterRam(pVM, 0, offRamHole, "Base RAM");
    413         if (RT_SUCCESS(rc))
     410
     411    /* First the conventional memory: */
     412    rc = PGMR3PhysRegisterRam(pVM, 0, RT_MIN(cbRam, 640*_1K), "Conventional RAM");
     413    if (RT_SUCCESS(rc))
     414    {
     415        /* The extended memory from 1MiB up to 4GiB: */
     416        if (cbRam > offRamHole)
    414417        {
    415             pVM->mm.s.cbRamAbove4GB = cbRam - offRamHole;
    416             rc = PGMR3PhysRegisterRam(pVM, _4G, cbRam - offRamHole, "Above 4GB Base RAM");
     418            pVM->mm.s.cbRamBelow4GB = offRamHole;
     419            rc = PGMR3PhysRegisterRam(pVM, _1M, offRamHole - _1M, "Extended RAM");
     420            if (RT_SUCCESS(rc))
     421            {
     422                /* Then all the memory above 4GiB: */
     423                pVM->mm.s.cbRamAbove4GB = cbRam - offRamHole;
     424                rc = PGMR3PhysRegisterRam(pVM, _4G, cbRam - offRamHole, "Above 4GB Base RAM");
     425            }
    417426        }
    418     }
    419     else
    420     {
    421         pVM->mm.s.cbRamBelow4GB = cbRam;
    422         pVM->mm.s.cbRamAbove4GB = 0;
    423         rc = PGMR3PhysRegisterRam(pVM, 0, cbRam, "Base RAM");
     427        else
     428        {
     429            pVM->mm.s.cbRamBelow4GB = cbRam;
     430            pVM->mm.s.cbRamAbove4GB = 0;
     431            if (cbRam > _1M)
     432                rc = PGMR3PhysRegisterRam(pVM, _1M, cbRam - _1M, "Extended RAM");
     433        }
    424434    }
    425435
     
    608618    uint64_t cOld = pVM->mm.s.cBasePages;
    609619    pVM->mm.s.cBasePages += cAddBasePages;
    610     LogFlow(("MMR3IncreaseBaseReservation: +%RU64 (%RU64 -> %RU64\n", cAddBasePages, cOld, pVM->mm.s.cBasePages));
     620    LogFlow(("MMR3IncreaseBaseReservation: +%RU64 (%RU64 -> %RU64)\n", cAddBasePages, cOld, pVM->mm.s.cBasePages));
    611621    int rc = mmR3UpdateReservation(pVM);
    612622    if (RT_FAILURE(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