github FEX-Emu/FEX FEX-2509
FEX Release FEX-2509

latest releases: FEX-2609, FEX-2608, FEX-2607...
12 months ago

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

After last month's enormous improvements, this release will look quite tame in comparison. Although we still did a bunch of work, so let's dive in.

More JIT improvements

Not quite as striking, but we still did work on the JIT this last month as usual. As usual too many to go over individually so here's a list.

  • Move Arm64EC EC entrypoint check to L1 branch target lookup
  • Fix 32-bit zero-extend semantics on CMPXCHG
  • Fix 16-bit operand ENTER/LEAVE instructions
  • Implement support for JMPF/CALLF/RETF with operating mode switch
    • Mode switch will still cause crashes until remaining implementation details are sorted
  • Optimize x87 FTW calculation
  • Fix IEEE 754 unordered comparison in x87
  • Various JIT execution time improvements to reduce stutters
  • Recheck TF flag after POPF instruction to ensure correct behaviour
  • Fix some OOB reads for specific float instructions
  • Always explore fallthrough conditional branches

Mono specific performance hacks for ARM64EC/WOW64

Mono's JIT has consistently been a pain for us where it's use of self-modifying code causes
significant code invalidation and stutters due to how we interact with each other. When JITs get stacked in emulation it is almost always a bad time.
We now detect Mono on Arm64EC/WOW64 and will do some very specific optimizations. I won't go in to the details since it's fairly complex, but when
Mono is detected, we will end up having less stutter, more performance, and less likely to crash when TSO memory model emulation is disabled.

Disable 3DNow! by default on Wine WOW64 binary

We found out this month that Fallout: New Vegas will only render a black screen when 3DNow! is enabled. This is seemingly due to specific optimized
code routines that the D3D9X support library uses for various things. We are currently assuming that this is due to how we implemented the 3DNow!
reciprocal instructions, where they behave like the Geode implementation rather than "typical" AMD
3DNow! versions. This could mean that these games also render black screens on Geodes, but getting an OLPC XO-1 today to
try the game seems a bit excessive. Instead we have built a Phenom system to ensure the game renders fine on a real Phenom and to confirm our
suspicions. It renders fine on real hardware, so until we have a soft-float implementation of these instructions we won't have complete proof but
something to work towards.

Until then, we are going to disable 3DNow! in this configuration, which causes this d3d9x support library to use
SSE2 codepaths instead; Resolving the black screen rendering in the process.

Fix BRK size calculation

When emulating a Linux application, we need to setup a small amount of memory higher in the address space for the "program
break"
. This is a bit of legacy memory allocation that tends to get used early in a program's
life-cycle and then everything ends up using mmap later. Our original size calculation for this was actually incorrect which was causing part of our
ELF loading to overlap this range. Usually not a problem because it usually meant some overlap with a BSS segment of the ELF that was aligned to some
larger page size and didn't do any harm.

The bigger problem is that we could have inadvertently allowed 32-bit applications to allocate memory in to the low pages of 64-bit memory space which
could result in emulation bugs. Additionally we were always reserving a full 8MB of virtual memory space, which while it isn't a lot, there are late
generation 32-bit games that run in to Virtual Address space exhaustion, so giving back as much of that 8MB as possible means they are less likely to
OOM themselves.

It's a little thing, but nice to see fixed.

Force WOW64 allocations outside of the 32-bit memory space

Turns out FEX was accidentally allocating some memory in the 32-bit address space when running in WOW64 Wine emulation mode. Oops! We have now fixed
this which similar to the last point, means 32-bit games are less likely to OOM.

Updates to downstream FEX packages

We have news for users of the FEX packages included in certain Linux distributions:

Apple Silicon users running Fedora Asahi Remix (and others that use muvm) may have seen
an issue where FEX failed to start after customizing its configuration. The issue was that
our graphical FEXConfig tool overrode muvm's internal RootFS setup, so
we fixed the problem by no longer touching
settings managed by the microVM. With the new FEX release, you can use FEXConfig like on any other
distribution: To configure logging, to change TSO configuration, to enable library forwarding,
and more.

Speaking of library forwarding: This feature provides significant speed-ups by omitting
costly emulation and instead directly calling into native ARM64 libraries. Unfortunately
only few distributions have so far been able to provide this feature in their FEX packages:
Our Ubuntu PPA includes it out of the box, and Fedora users can install fex-emu-thunks from
the official repositories. Joining these ranks this month is NixOS thanks to our
nixpkgs pull request being merged.
This support is somewhat preliminary since there are open questions around the unique approach
to dynamic linking taken in Nix/NixOS, but nixpkgs community members are already looking into
this problem. Hopefully it won't be long until enjoyers of reproducible builds will have the
same fluent experience as Fedora and Ubuntu users!

Raw Changes

FEX Release FEX-2509

  • ARM64EC

    • Cooperatively suspend if needed when leaving the JIT (4f84c28)
  • AsyncNet

    • Simplify declaration of ancillary buffer (f1016e8)
  • AtomicOps

    • Reimplement AtomicNeg using 8.1 CAS atomics (8009f4a)
  • CPUBackend

    • Remove unused variable in CheckCodeBufferUpdate (a804cb5)
  • CodeCache

    • Remove legacy interfaces (b98acdf)
  • CodeLoader

  • Common

    • Remove duplicated StringUtil functionality (3f71517)
    • Remove EnvironmentLoader.cpp/.h (f565939)
  • Config

    • Remove unused Context.h include (09793d2)
  • ConstProp

  • Core

    • Thunks
      • Remove unused IR header/forward declarations (e76af56)
  • Dispatcher

    • Move the EC entrypoint check prior to the L1 lookup (5e467c7)
    • Reduce header dependencies (06c5135)
    • Centralize SignalDelegator config creation (839e3ac)
    • Most minor of optimizations for f64 x87 (2472aee)
  • ELFCodeLoader

    • Fixes BRK allocation with non-PT_DYN ELF files (a156752)
  • F80Fallbacks

    • Remove unnecessary memset (5e19202)
  • FEXConfig

    • Fix RootFS override in muvm-based setups (ac20880)
  • FEXCore

    • Move most instruction tables to be constexpr (f09db0c)

    • Move LDT/GDT management to the frontend (83e4496)

    • Split GDT and LDT prep work (c881055)

    • Fixes 32-bit zero-extend semantics on cmpxchg (b3d1aad)

    • Fixes 16-bit operand size Enter and Leave instructions (6811406)

    • Allocator

  • FileLoading

    • Add missing self-header (80c199c)
  • FileManagement

    • Minor interface cleanup (ae90040)
  • Frontend

    • Force acq/rel semantics for known Unity ringbuffer offsets (bd0cae9)

    • Fix tailcall handling when mono hacks are enabled (6ae9458)

    • Always explore fallthrough branches with multiblock (c6ccc68)

    • Remove log about VEX map_select (63a910d)

    • OpcodeDispatcher

  • General

    • std::alignment_of -> alignof (b7173a3)
    • Replace usages of .at(0) with .data() where applicable (e126cec)
  • Github

    • Force FEX portable config (6ba32da)
  • HostFeatures

    • Fix insufficient documentation to reproduce 3DNow! bug (63ae262)
  • HostRunner

    • Fixes bug with saving CSFSGS (61d3d5b)
  • IR

    • Remove unnecessary forward declarations/headers (317f92f)
    • Remove some unimplemented prototypes (fbf982f)
  • IRDumper

    • Add missing PrintArg for IndexNamedVectorConstant (3df3999)
    • Clean up formatting using fmt (67e9b40)
  • InternalThreadState

    • Remove unused includes (e9f8c01)
    • Make bool operator explicit (71d42d7)
  • IntrusiveIRList

    • RegisterAllocationData
  • InvalidationTracker

    • Disable mono hacks when multiblock is disabled (5a7ff47)
  • LinuxEmulation

    • add basic supports for v4l2 driver of wine32. (e235395)
  • LinuxSyscalls

    • Support modify_ldt on x64 (714856f)
    • Save and restore segment registers on signal (9072571)
  • LogManager

    • Evaluate non-predicate arguments for assertions lazily (993d917)
  • OpDispatcher

    • Force a recheck of TF after POPF (343a529)
  • OpcodeDispatcher

    • Simplify CALLOp return addr calc (2f930b2)
    • Implement support for CALLF/RETF (2825ac2)
    • Implement support for far jump (1e1c4e0)
    • optimize SetX87FTW (5db6a64)
  • RegisterAllocationPass

    • simplify next-use logic (7897b6a)
  • Scripts

    • Fix use of removed helper script (3b32fd5)
  • Syscalls

  • Utils

  • VixlUtils

    • Use std::countl_zero where applicable (e34de22)
  • VolatileMetadata

    • Clean up implementation using ranges::views::split (7df1ed2)
  • WinAPI

    • Force WOW64 allocations to start >4GB (0ca438e)
  • Windows

    • Support EnvLoader via _environ (26b4195)
    • Misc race and correctness fixes (b71879e)
    • Ignore MEM_RESET(_UNDO) allocation protection notifications (7d818e1)
  • X86Tables

    • Convert AVX tables to constexpr (9566910)
  • Misc

    • VDSO_Emulator: Cull unnecessary includes (dd34471)
    • Fix mapping for VS and VC condition codes (1988b43)
    • Common Utils: Remove unused/unnecessary inclusions from headers (ea8ae2b)
    • config_generator: Remove superfluous format arguments (694bc33)
    • json_ir_generator: Clean up generated assertion statements (1ca6443)
    • gvisor_tests: Update expectations for kernel 6.16 (5a73134)
    • Fix IEEE 754 unordered comparison detection in x87 floating-point operations (4a71edf)
    • Remove visibility on functions that is no longer necessary (f866ad5)
    • More BRK fixes (7431495)
    • Reduce use of maybe_unused attributes (62b8090)
    • Do not use diff_from_common_commit (2a76066)
    • Implement support for additional provided volatile metadata (6310c20)
    • Clear IE flag on fninit (bc2e959)
    • Implementation of FCNLEX to clear IE flag (2a4bfe4)
    • Local JIT translation time wins (297677c)
    • Avoid OOB reads for mem sources in some float conversion ops (a47c947)
    • Drop ConstProp (2f925ae)
    • Implement mono specific hacks (aa979e4)
    • Disable 3DNow by default on WOW64 FEX (baddc56)
    • asm_tests: Tests for fninit (4dbfa2f)
  • unittests

    • Adds missing movsxd edge case (7aeb478)

    • 3DNow

    • ASM

      • Adds support for classifying more requirements (3db1f1e)

Don't miss a new FEX release

NewReleases is sending notifications on new releases.