VirtualBox

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


Ignore:
Timestamp:
Sep 25, 2023 12:54:00 AM (15 months ago)
Author:
vboxsync
Message:

VMM/IEM: Fixed EXC_BAD_INSTRUCTION issue. bugref:10370

File:
1 edited

Legend:

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

    r101249 r101250  
    7272# include <iprt/formats/dwarf.h>
    7373# if defined(RT_OS_DARWIN)
     74#  include <libkern/OSCacheControl.h>
    7475#  define IEMNATIVE_USE_LIBUNWIND
    7576extern "C" void  __register_frame(const void *pvFde);
     
    284285     * expect the caller to call iemExecMemAllocatorReadyForUse when done
    285286     * writing to the allocation.
     287     *
     288     * See also https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon
     289     * for details.
    286290     */
    287291    /** @todo detect if this is necessary... it wasn't required on 10.15 or
     
    445449#ifdef RT_OS_DARWIN
    446450    /* See iemExecMemAllocatorAllocTailCode for the explanation. */
    447 # if 0 /** @todo getting weird EXC_BAD_INSTRUCTION exceptions, trying to figure out / work around why... */
    448     int rc2 = RTMemProtect(pv, cb, RTMEM_PROT_NONE);
    449     AssertRC(rc2); RT_NOREF(pVCpu);
    450 # endif
    451451    int rc = RTMemProtect(pv, cb, RTMEM_PROT_EXEC | RTMEM_PROT_READ);
    452452    AssertRC(rc); RT_NOREF(pVCpu);
    453 # if 0 /** @todo getting weird EXC_BAD_INSTRUCTION exceptions, trying to figure out / work around why... */
    454     ASMProbeReadBuffer(pv, cb);
    455 #  ifdef RT_ARCH_ARM64
    456     __asm__ __volatile__("dmb sy\n\t"
    457                          "dsb sy\n\t"
    458                          "isb\n\t"
    459                          ::: "memory");
    460 #  endif
    461 # endif
     453
     454    /*
     455     * Flush the instruction cache:
     456     *      https://developer.apple.com/documentation/apple-silicon/porting-just-in-time-compilers-to-apple-silicon
     457     */
     458    /* sys_dcache_flush(pv, cb); - not necessary */
     459    sys_icache_invalidate(pv, cb);
    462460#else
    463461    RT_NOREF(pVCpu, pv, cb);
     
    837835
    838836    /* Allocate a chunk. */
    839 #ifdef RT_OS_DARWIN /** @todo oh carp! This isn't going to work very well with the unpredictability of the simple heap... */
     837#ifdef RT_OS_DARWIN
    840838    void *pvChunk = RTMemPageAllocEx(pExecMemAllocator->cbChunk, 0);
    841839#else
     
    18391837        iemTbAllocatorProcessDelayedFrees(pVCpu, pVCpu->iem.s.pTbAllocatorR3);
    18401838
    1841 #if 1 /** @todo getting weird EXC_BAD_INSTRUCTION exceptions, trying to figure out / work around why... */
    18421839    PIEMNATIVEINSTR const paFinalInstrBuf = (PIEMNATIVEINSTR)iemExecMemAllocatorAlloc(pVCpu, off * sizeof(IEMNATIVEINSTR));
    18431840    AssertReturn(paFinalInstrBuf, pTb);
    18441841    memcpy(paFinalInstrBuf, pReNative->pInstrBuf, off * sizeof(paFinalInstrBuf[0]));
    1845 #else
    1846     IEMNATIVEINSTR volatile * const paFinalInstrBuf
    1847         = (IEMNATIVEINSTR volatile *)iemExecMemAllocatorAlloc(pVCpu, off * sizeof(IEMNATIVEINSTR));
    1848     AssertReturn(paFinalInstrBuf, pTb);
    1849     for (uint32_t i = 0; i < off; i++)
    1850         paFinalInstrBuf[i] = pReNative->pInstrBuf[i];
    1851     __asm__ __volatile__("dmb sy\n\t" ::: "memory");
    1852 #endif
    18531842
    18541843    /*
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