VirtualBox

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


Ignore:
Timestamp:
Oct 27, 2024 1:07:47 AM (4 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
165607
Message:

VMM/IEM: Unwind info for win.arm64 (attempt at it, anyway). jiraref:1253

Location:
trunk/src/VBox/VMM/VMMAll
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veExecMem.cpp

    r106465 r106724  
    13151315    RT_NOREF(pVCpu);
    13161316
     1317#  ifdef RT_AMD64
    13171318    /*
    13181319     * The AMD64 unwind opcodes.
     
    13611362    AssertCompile((-IEMNATIVE_FP_OFF_LAST_PUSH & 0xf) == 8);
    13621363
     1364#  elif defined(RT_ARCH_ARM64)
     1365    /*
     1366     * The ARM64 unwind codes.
     1367     * 
     1368     * See https://learn.microsoft.com/en-us/cpp/build/arm64-exception-handling?view=msvc-170
     1369     */
     1370    static const uint8_t s_abOpcodes[] =
     1371    {
     1372        /* Prolog: None. */
     1373        0xe5,                                   /* end_c */
     1374        /* Epilog / unwind info: */
     1375        IEMNATIVE_FRAME_VAR_SIZE / 16,          /* alloc_s */
     1376        0xc8, 0x00,                             /* save_regp x19, x20, [sp + #0] */
     1377        0xc8, 0x82,                             /* save_regp x21, x22, [sp + #2*8] */
     1378        0xc9, 0x04,                             /* save_regp x23, x24, [sp + #4*8] */
     1379        0xc9, 0x86,                             /* save_regp x25, x26, [sp + #6*8] */
     1380        0xca, 0x08,                             /* save_regp x27, x28, [sp + #8*8] */
     1381        0x4a,                                   /* save_fplr x29, x30, [sp + #10*8] */
     1382        12*8 / 16,                              /* alloc_s  */
     1383        0xc4,                                   /* end */
     1384        0xc5                                    /* nop */
     1385    };
     1386    AssertCompile(!(sizeof(s_abOpcodes) & 3));
     1387    AssertCompile(!(IEMNATIVE_FRAME_VAR_SIZE & 15) && IEMNATIVE_FRAME_VAR_SIZE < 512);
     1388
     1389#  else
     1390#   error "Port me!"
     1391#  endif
     1392
    13631393    /*
    13641394     * Calc how much space we need and allocate it off the exec heap.
    13651395     */
     1396#  ifdef RT_ARCH_ARM64
     1397    unsigned const cbPerEntry       = _1M - 4;
     1398    unsigned const cFunctionEntries = (pExecMemAllocator->cbChunk + cbPerEntry - 1) / cbPerEntry;
     1399    unsigned const cbUnwindInfo     = (sizeof(uint32_t) * 2 + sizeof(s_abOpcodes)) * cFunctionEntries;
     1400#  else
     1401    unsigned const cbUnwindInfo     = sizeof(s_aOpcodes) + RT_UOFFSETOF(IMAGE_UNWIND_INFO, aOpcodes);
    13661402    unsigned const cFunctionEntries = 1;
    1367     unsigned const cbUnwindInfo     = sizeof(s_aOpcodes) + RT_UOFFSETOF(IMAGE_UNWIND_INFO, aOpcodes);
     1403#  endif
    13681404    unsigned const cbNeeded         = sizeof(IMAGE_RUNTIME_FUNCTION_ENTRY) * cFunctionEntries + cbUnwindInfo;
    13691405    PIMAGE_RUNTIME_FUNCTION_ENTRY const paFunctions
     
    13751411     * Initialize the structures.
    13761412     */
     1413#  ifdef RT_AMD64
    13771414    PIMAGE_UNWIND_INFO const pInfo = (PIMAGE_UNWIND_INFO)&paFunctions[cFunctionEntries];
    13781415
     
    13841421    memcpy(&pInfo->aOpcodes[0], s_aOpcodes, sizeof(s_aOpcodes));
    13851422
    1386     /*
    1387      * Register it.
     1423#  elif defined(RT_ARCH_ARM64)
     1424
     1425    PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA pInfo = (PIMAGE_ARM64_RUNTIME_FUNCTION_ENTRY_XDATA)&paFunctions[cFunctionEntries];
     1426    for (uint32_t i = 0, off = 0; i < cFunctionEntries; i++)
     1427    {
     1428        paFunctions[i].BeginAddress = off;
     1429        paFunctions[i].UnwindData   = (uint32_t)((uintptr_t)pInfo - (uintptr_t)pvChunk) | PdataRefToFullXdata;
     1430
     1431        uint32_t const cFunctionLengthInWords = RT_MAX(cbPerEntry, pExecMemAllocator->cbChunk - off) / 4;
     1432        pInfo[0].FunctionLength               = cFunctionLengthInWords;
     1433        pInfo[0].Version                      = 0;
     1434        pInfo[0].ExceptionDataPresent         = 0;
     1435        pInfo[0].EpilogInHeader               = 0;
     1436        pInfo[0].EpilogCount                  = 1;
     1437        pInfo[0].CodeWords                    = sizeof(s_abOpcodes) / sizeof(uint32_t);
     1438
     1439        pInfo[1].EpilogInfo.EpilogStartOffset = cFunctionLengthInWords;
     1440        pInfo[1].EpilogInfo.Reserved          = 0;
     1441        pInfo[1].EpilogInfo.EpilogStartIndex  = 1;
     1442        pInfo += 2;
     1443
     1444        memcpy(pInfo, s_abOpcodes, sizeof(s_abOpcodes));
     1445        pInfo += sizeof(s_abOpcodes) / sizeof(*pInfo);
     1446    }
     1447
     1448#  else
     1449#   error "Port me!"
     1450#  endif
     1451
     1452    /*
     1453     * Register them.
    13881454     */
    13891455    uint8_t fRet = RtlAddFunctionTable(paFunctions, cFunctionEntries, (uintptr_t)pvChunk);
  • trunk/src/VBox/VMM/VMMAll/IEMAllN8veRecompiler.cpp

    r106622 r106724  
    67136713     * Load the parameters.
    67146714     */
    6715 #if defined(RT_OS_WINDOWS) && defined(VBOXSTRICTRC_STRICT_ENABLED)
     6715#if defined(RT_OS_WINDOWS) && defined(VBOXSTRICTRC_STRICT_ENABLED) && defined(RT_ARCH_AMD64)
    67166716    /* Special code the hidden VBOXSTRICTRC pointer. */
    67176717    off = iemNativeEmitLoadGprFromGpr(  pReNative, off, IEMNATIVE_CALL_ARG1_GREG, IEMNATIVE_REG_FIXED_PVMCPU);
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