github FEX-Emu/FEX FEX-2608
FEX Release FEX-2608

3 hours ago

Read the blog post at FEX-Emu's Site!

After what felt like a very quick month, it's time for another FEX release. We're busy writing improvements for next month's release already, so let's
not distract for too long and smash through these changes!

Removal of deprecated FEXInterpreter binary

Back in the FEX-2510 release we completely removed a FEXLoader binary with a deprecation of the FEXInterpreter binary, renaming it to
just FEX. We kept the FEXInterpreter binary around for a while because downstream projects had hardcoded the binary in their scripts and we wanted to give
some time for them to migrate. After nearly a year we're hoping that everyone has migrated to the new binary name. If your project is still using the
old binary name then we recommend fix them!

The typical JIT improvements

As typical there are a bunch of JIT changes this month. Let's breakdown what was fixed.

  • Use SVE XAR for SHA1 emulation as a minor optimization.
  • Fix JIT telemetry value unconstrained predictable problem on ARMv8.0
    • Would only cause some missed telemetry on ARMv8.0 platforms, very minor.
  • Optimize VMOVMASKPD/PS instructions.
    • Cutting from 11/10 instructions down to 7.
  • Fix incorrect emulation of BFP store instruction
  • Fixes crash if ProcessorID IR op was encountered on WINE
    • Silly little assert check that crashed.
  • A bunch more improvements to hardware with 256-bit SVE
  • Actually a ton of little bug fixes and edge cases getting patched up.

Fix VirtualProtect on win32

This change is fairly spicy because it means some of our memory protections were silently failing under WINE. With this fixed, it should fix some
weird edge case crashes that weren't able to be explained.

Fix overwriting memory region in allocation tracking

This is a bit of a weird case where FEX's memory allocations on 48-bit VA systems were silently only ever using one allocation region. It was
accidentally overwriting all regions with whatever the smallest allocation happened to be. Luckily on 48-bit systems, the smallest region would still
be very large and unlikely to run out, but a bug fix is a bug fix.

Fix inactive JIT guard pages not being ignored

A funny little quirk of our JIT is that we rely on SIGSEGV to handle memory overflows safely. Where we try to calculate a size of code memory that
gets generated from IR through a heuristic and if the size is calculated incorrectly we safely fault and longjump to try again. The times in which the
heuristic is incorrect isn't very frequent so the performance win of not range checking as heavily is a big win.

One problem is we forgot to turn off the JIT guard page checking when outside of the JIT, so if an application happens to access from [0, 4096), we
would long jump back in to our JIT and hilarious crashes would occur. Oops!

Fixes AVX signal state saving and restoring

While signals are fairly rare, we implementing saving the AVX state incorrectly, which could cause us the fail to restore it if the application jumps
to a new location. This is now fixed which should probably resolve a few crashes.

Spinloop using WFE on WINE

On WINE we had some spinloops that are required when an application is in the process of suspending a thread. We now spin using the WFE instruction
which puts the ARM CPU in lower-power state while waiting on an atomic. This can shave off watts of power in this edge case, so it's worth supporting!

Fix untracked thread handling

When a process creates a new thread using the Clone syscall API, there's a lot of tricky edge cases to support. In one of those paths we were
accidentally losing tracking of a thread in our frontend. Usually this is pretty benign but it could result in some broken TLS tracking due to a new
thread data structure actually pointing to the parent thread. Oops!

Raw Changes

FEX Release FEX-2608

  • 64BitAllocator

    • Removes unused additional size argument (192e363)
    • Avoid madvising more than necessary in InitializeVMARegionsUsed() (4fa539f)
    • Remove duplicate headers (3e6b3c8)
    • Avoid overwriting Region[0] in Create64BitAllocatorWithRegions (76b35df)
  • ALUOps

  • AVX128

    • Optimize 256-bit vmovmaskpd as well (aa26a78)
  • Allocator

    • fix the caching of host va size (5b91642)
  • AllocatorHooks

    • Amend VirtualProtect for Windows (12baceb)
  • Arm64Emitter

    • Fix incorrect condition for constant NOP padding (83f4c9d)
    • Pull FillSpecialRegs bools into a struct (e24f232)
    • Wire up conditional FPR spilling in SpillForPreserveAllABICall (650f5b7)
  • AtomicOps

    • Avoid constrained unpredictable case in TelemetrySetValue() (12e8cf0)
  • BPFEmitter

    • Amend instruction class checking in HandleStore() (480f45f)
  • CI

    • Disable ranges-v3 from trying to build native (68740b3)
  • CPUBackend

    • Remove unnecessary reinterpret_casts (58c247b)
  • CodeCache

    • Use maximal code buffer size when generating code caches, too (0467d52)

    • Mark executable memory as EC code on ARM64EC (aff3fcf)

    • WoA

      • Support mixed WoW64/ARM64EC processing (4a091df)
  • Common

    • Async

      • Handle fd closing a little better (b750d67)
    • BitSet

      • Amend byte size retrieval (356d461)
    • Bitset

  • Config

    • Minor cleanup (61d033f)
    • Fixes AppOverrides with FEX_APP_CONFIG (7a6f0de)
  • Context

    • Add support for single-step RIP ranges (1bd3945)
  • ConversionOps

    • Remove redundant code in Vector_FToS (c8dd9ee)
  • Core

    • Remove unnecessary bounds check in GenerateIR() (f374b47)
    • Fix dereference of invalid iterator (444c37f)
  • Crypto

    • Clarify zero vector size in SHA1RNDS4Op() (46ec279)
    • Make use of XAR in SHA1NEXTE when available (850ef70)
  • Dispatcher

    • Avoid loading unnecessary reg in vixl single step (fb4d8a6)
  • Externals

  • FEX

    • Remove FEXInterpreter binary (37265b1)
  • FEXCore

    • Ignore inactive JIT guard ranges (464ec9d)
    • Isolate multiblock error state per block (7469fdb)
    • Split out CodeBuffer management to its own file (a652a58)
    • Resolve missing prototype warnings (2ac95f4)
    • Fixes a crash with multiblock if ProcessorID IR op is encountered (6cd2a48)
  • FEXGetConfig

    • Add convenience option for dumping system/tso info (31c2449)
  • FEXOfflineCompiler

    • Fix improper syscall ABI on WoA (5a0bf1b)
  • FEXServer

    • Fix some missing declaration warnings (7bb380a)
  • Filesystem

    • Fix Absolute() on Windows (4518d58)
  • FlexBitSet

    • Simplify MemClear/MemSet (7ce172a)
  • Frontend

    • Prioritize instruction fetch faults (27315e3)
  • Github

  • HostFeatures

    • Pull MMFR3 identification register (ba762a9)
    • Amend SSBS2 signifying (b193a0c)
  • HostRunner

  • IR

    • Enclose straggler Desc comments in brackets (3cbcc7b)
    • Use begin block type in operator-- (d5572e3)
    • Remove unused VUShraI (77467ea)
    • Remove need to specify element size for vector bitwise ops (e508b6d)
  • IRDumper

    • stringstream -> ostringstream (d6b38b6)
  • IREmitter

    • Mark some helpers as const (1cffa00)
  • IRValidation

  • JIT

    • Remove JIT detection string (2464633)

    • Rename temporary CPU buffer allocator (15e76e8)

    • ALUOps

      • Fix operand overlapping bug for pdep (21a968b)
  • LinuxAllocator

    • Reduce MemAllocator32Bit size by 16 bytes (941f0fb)
  • LinuxEmulation

    • Resolve missing prototype warnings (b58be2c)
  • MemoryOps

    • Avoid double application of base offset in {Load,Store}ContextIndexed case (6c57b2f)
    • Make use of current working reg for cache operations (5d846c3)
  • MiscOps

    • Fix round mode clearing for RP/RM modes in PushRoundingMode (821dfe5)
  • OpcodeDispatcher

    • Fix 32bit cmpxchg zero extension with eax as first operand (8a8827c)
    • Remove asterisk from BMI source args (b90c983)
  • PassManager

    • Simplify initialization interface (eb7e02e)
  • RedundantFlagCalculationElimination

  • RegisterAllocationPass

    • Ensure pair reg invariant (0f2463d)
    • Function cleanup (ce27754)
    • Amend type cast in DecodeSRANode() (0662508)
  • SharedCodeBufferManager

  • SignalDelegator

    • Remove unused Required parameter in handler setting (d295d9f)
    • Group members together (ec95330)
    • Remove odd double negation in GuestSigProcMask (6e0c9d1)
  • Signals

    • Preprocessor disable intentional dead code (a135325)
  • Socket

    • Pass size by reference in getsockopt (8a844f9)
  • StringUtils

    • Handle strings entirely composed of whitespace in trims (76c4ebb)
  • Thread

    • Amend new thread handling in HandleNewClone() (341a519)
    • Amend pidfd_open check (c6f823f)
  • ThreadManager

    • Fix error return values in FrontendAllocateSlots() (99b8df4)
  • Utils

    • File
      • Handle dual read/write case (7ff0466)
  • Vector

    • Indicate 128-bit zero vector in DefaultX87State() (7efc3ec)
    • Use unary handler for scalar unary insertions (3781411)
    • LoadSourceGPR -> LoadSourceFPR for MASKMOVOp (1417888)
    • Trim one instruction off insertq (d0f03cb)
  • VectorOps

    • Make use of unpredicated shifts (921ce59)
    • Add trivial case handling in VSQXTN2 (a7627ba)
    • Simplify 256-bit VAddV (5ec8526)
    • Simplify SVE 256-bit VOrn with BSL2N (28cdae4)
    • Make SVE shift==0 case symmetric with ASIMD (bd15023)
    • Join identical branches in VFMLS/VFNMLS (92a171c)
  • WinAPI

    • IO
      • Fix handling of end of file offset in SetFilePointerEx (bc16f90)
  • Windows

    • Fixes around using Unicode functions (cfa3dfa)

    • ImageTracker

      • Adapt code cache loading logic to FEXOfflineCompiler (db9414a)
      • Wire up LoadCache and EnableLoadedSection (57ca49d)
    • UnixLib

      • Fix enabling TSO through legacy Proton codepath (ebe7342)
  • Wow64

    • Spin loop on atomic with WFE (71d4e2c)
  • Misc

  • gitlab

  • unittests

    • Add stress tests for VBLEND{PD, PS} (ec2aa40)
    • Add stress tests for VSHUF{PD, PS} (dddad1c)
    • Add stress tests for VPERMIL{PD, PS} (3f98202)
    • Add stress test for vperm2f128/vperm2i128 (91017db)
  • x32

    • FD

      • Combine offset halves directly (f2b679f)
      • Make use of SanitizeIOCount for vector construction in vmsplice (b9d97df)
      • Fix readahead upper offset type (48ce5bf)
      • Correct total word calculation in select() variants (617a518)
      • Ensure sendfile updates offset if set (94ccfef)
    • Info

      • Only modify output in getrlimit/ugetrlimit if successful (00826d3)
    • Msg

      • Fix result comparison in mq_getsetattr (5dd0477)
    • Semaphore

      • Fix storing of message type in msgrcv (9ff322e)
    • Thread

      • Move writability check around in waitpid (0bdf159)
      • Fix off-by-one in get_thread_area (2af7c24)
    • Time

      • Correct sizeof expression in utimensat (8fbde84)
  • x64

    • Thread
      • Amend faulting copy handling related to LDTs (0e8b01c)
  • x87StackOptimizationPass

    • Minor cleanup (0589d9b)
    • Make use of std::array for FixedSizeStack (6846f10)
    • Remove shadowing variable in PUSHSTACK case (30f2a7b)

Don't miss a new FEX release

NewReleases is sending notifications on new releases.