VirtualBox

Ignore:
Timestamp:
Mar 13, 2025 5:47:45 PM (2 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
167951
Message:

Runtime/common/efi,Main: Fix creating NVRAM files for ARM VMs, the previous ones where incompatible to what the UEFI firmware expected causing a hang during boot under certain circumstances, bugref:10872

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-all/NvramStoreImpl.cpp

    r107849 r108554  
    471471    }
    472472
     473    PlatformArchitecture_T const enmArch = m->pParent->i_getPlatform()->i_getArchitecture();
    473474    if (SUCCEEDED(hrc))
    474475    {
     
    485486            {
    486487                /** @todo The size is hardcoded to match what the firmware image uses right now which is a gross hack... */
    487                 uint64_t cbUefi = m->pParent->i_getPlatform()->i_getArchitecture() == PlatformArchitecture_ARM ? 786432 : 540672;
     488                uint64_t cbUefi = enmArch == PlatformArchitecture_ARM ? 3 * _256K : 132 * _4K;
    488489                vrc = RTVfsFileSetSize(hVfsUefiVarStore, cbUefi, RTVFSFILE_SIZE_F_NORMAL);
    489490                if (RT_SUCCESS(vrc))
     
    495496
    496497        if (RT_SUCCESS(vrc))
    497         {
    498             vrc = RTEfiVarStoreCreate(hVfsUefiVarStore, 0 /*offStore*/, 0 /*cbStore*/, RTEFIVARSTORE_CREATE_F_DEFAULT, 0 /*cbBlock*/,
     498        {   /* We want to create NVRAM files matching the default QEMU_VARS.fd for now, see https://github.com/tianocore/edk2/commit/bf57a42a0e2cf1c68e9db2f61c82ce93c806ab07. */
     499            static const RTEFIVARSTORECFG s_EfiNvramCfgArm = {   3 * _256K /*cbFv*/, _256K /*cbBlock*/, _256K /*cbVarStore*/,    0 /*cbNvEventLog*/,  2 * _256K /*cbFtw*/, 0x3ffe0 /*cbWriteQueue*/};
     500            /* We want to create NVRAM files matching the default OVMF_VARS.fd for now, see https://github.com/tianocore/edk2/commit/b24fca05751f8222acf264853709012e0ab7bf49. */
     501            static const RTEFIVARSTORECFG s_EfiNvramCfgX86 = { 132 * _4K   /*cbFv*/,   _4K /*cbBlock*/, _256K /*cbVarStore*/,  _4K /*cbNvEventLog*/, 67 *   _4K /*cbFtw*/, 0x00fe0 /*cbWriteQueue*/};
     502
     503            vrc = RTEfiVarStoreCreate(hVfsUefiVarStore, 0 /*offStore*/, enmArch == PlatformArchitecture_ARM ? &s_EfiNvramCfgArm : &s_EfiNvramCfgX86,
    499504                                      NULL /*pErrInfo*/);
    500505            if (RT_FAILURE(vrc))
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette