VirtualBox

Changeset 107123 in vbox


Ignore:
Timestamp:
Nov 22, 2024 3:46:26 PM (8 weeks ago)
Author:
vboxsync
Message:

Main: Fix running VMs with less than 2GiB of RAM (r165896 regression)

Having too little RAM caused the pci-mmio region to be created below 4GiB,
which made queryMmioRegion return 0 and the page table setup code in the UEFI
fail because it would get confused by the entry having a 0 address and size and
leaving the page tables in a broken state.
Fixing that however doesn't work as the PCI MMIO space needs to be above 4GiB, so
ensure that the region will always be above 4GiB.

Location:
trunk/src/VBox/Main
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/include/ResourceAssignmentManager.h

    r106957 r107123  
    6464    HRESULT assignMmioRegion(const char *pszName, RTGCPHYS cbRegion, PRTGCPHYS pGCPhysStart, PRTGCPHYS pcbRegion);
    6565    HRESULT assignMmio32Region(const char *pszName, RTGCPHYS cbRegion, PRTGCPHYS pGCPhysStart, PRTGCPHYS pcbRegion);
     66    HRESULT assignMmio64Region(const char *pszName, RTGCPHYS cbRegion, PRTGCPHYS pGCPhysStart, PRTGCPHYS pcbRegion);
    6667
    6768    HRESULT assignInterrupts(const char *pszName, uint32_t cInterrupts, uint32_t *piInterruptFirst);
  • trunk/src/VBox/Main/src-client/ConsoleImplConfigArmV8.cpp

    r106960 r107123  
    785785        hrc = pResMgr->assignMmioRegionAligned("pci-pio",    _64K, _64K, &GCPhysMmioStart,   &cbMmio, false /*fOnly32Bit*/); H();
    786786        hrc = pResMgr->assignMmioRegion(       "pci-ecam",   16 * _1M,   &GCPhysPciMmioEcam, &cbPciMmioEcam);              H();
    787         hrc = pResMgr->assignMmioRegion(       "pci-mmio",   _2G,        &GCPhysPciMmio,     &cbPciMmio);                  H();
     787        hrc = pResMgr->assignMmio64Region(     "pci-mmio",   _2G,        &GCPhysPciMmio,     &cbPciMmio);                  H();
    788788        hrc = pResMgr->assignMmio32Region(     "pci-mmio32", _256M,      &GCPhysPciMmio32,   &cbPciMmio32);                H();
    789789
  • trunk/src/VBox/Main/src-client/ResourceAssignmentManager.cpp

    r106966 r107123  
    128128                   RTGCPHYS GCPhysStart, RTGCPHYS GCPhysEnd);
    129129    HRESULT addAddrRange(const char *pszName, RESOURCEREGIONTYPE enmType, RTGCPHYS GCPhysStart, RTGCPHYS GCPhysEnd);
    130     HRESULT findNextFreeAddrRange(RTGCPHYS cbRegion, RTGCPHYS cbAlignment, RTGCPHYS GCPhysMax, RTGCPHYS GCPhysHint,
     130    HRESULT findNextFreeAddrRange(RTGCPHYS cbRegion, RTGCPHYS cbAlignment, RTGCPHYS GCPhysMin, RTGCPHYS GCPhysMax, RTGCPHYS GCPhysHint,
    131131                                  PRTGCPHYS pGCPhysStart, PRTGCPHYS pcbRegion);
    132132
     
    256256
    257257
    258 HRESULT ResourceAssignmentManager::State::findNextFreeAddrRange(RTGCPHYS cbRegion, RTGCPHYS cbAlignment, RTGCPHYS GCPhysMax,
     258HRESULT ResourceAssignmentManager::State::findNextFreeAddrRange(RTGCPHYS cbRegion, RTGCPHYS cbAlignment, RTGCPHYS GCPhysMin, RTGCPHYS GCPhysMax,
    259259                                                                RTGCPHYS GCPhysHint, PRTGCPHYS pGCPhysStart, PRTGCPHYS pcbRegion)
    260260{
     
    275275            if (   pRegion->enmType == kResourceRegionType_Free
    276276                && GCPhysHint >= pRegion->GCPhysEnd
     277                && GCPhysMin <= pRegion->GCPhysStart
    277278                && GCPhysMax >= pRegion->GCPhysEnd
    278279                && GCPhysStartAligned >= pRegion->GCPhysStart
     
    287288        }
    288289    }
     290
     291    while (   iRegion < m_cRegions
     292           && GCPhysMin > m_paRegions[iRegion].GCPhysStart)
     293        iRegion++;
    289294
    290295    /* Find a free region which satisfies or requirements. */
     
    395400    RTGCPHYS GCPhysRegionStart;
    396401    RTGCPHYS cbRegionFinal;
    397     HRESULT hrc = m_pState->findNextFreeAddrRange(cbRegion, cbAlignment, fOnly32Bit ? _4G : RTGCPHYS_MAX,
     402    HRESULT hrc = m_pState->findNextFreeAddrRange(cbRegion, cbAlignment, 0 /*GCPhysMin*/, fOnly32Bit ? _4G : RTGCPHYS_MAX,
    398403                                                  m_GCPhysMmioHint, &GCPhysRegionStart, &cbRegionFinal);
    399404    if (SUCCEEDED(hrc))
     
    417422{
    418423    return assignMmioRegionAligned(pszName, cbRegion, _4K, pGCPhysStart, pcbRegion, true /*fOnly32Bit*/);
     424}
     425
     426
     427HRESULT ResourceAssignmentManager::assignMmio64Region(const char *pszName, RTGCPHYS cbRegion, PRTGCPHYS pGCPhysStart, PRTGCPHYS pcbRegion)
     428{
     429    RTGCPHYS GCPhysRegionStart;
     430    RTGCPHYS cbRegionFinal;
     431    HRESULT hrc = m_pState->findNextFreeAddrRange(cbRegion, _4K, _4G /*GCPhysMin*/, RTGCPHYS_MAX,
     432                                                  m_GCPhysMmioHint, &GCPhysRegionStart, &cbRegionFinal);
     433    if (SUCCEEDED(hrc))
     434    {
     435        *pGCPhysStart = GCPhysRegionStart;
     436        *pcbRegion    = cbRegionFinal;
     437        return assignFixedMmioRegion(pszName, GCPhysRegionStart, cbRegion);
     438    }
     439
     440    return hrc;
    419441}
    420442
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