Skip to content

Commit

Permalink
ARM64EC: Process pending cross-process work on syscalls and exceptions
Browse files Browse the repository at this point in the history
This is used to notify the JIT of e.g. memory writes by a debugger.
  • Loading branch information
bylaws committed Dec 12, 2024
1 parent af1d2d6 commit d080180
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Source/Windows/ARM64EC/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,8 @@ class ECSyscallHandler : public FEXCore::HLE::SyscallHandler, public FEXCore::Al
}

uint64_t HandleSyscall(FEXCore::Core::CpuStateFrame* Frame, FEXCore::HLE::SyscallArguments* Args) override {
ProcessPendingCrossProcessEmulatorWork();

// Manually raise an exeption with the current JIT state packed into a native context, ntdll handles this and
// reenters the JIT (see dlls/ntdll/signal_arm64ec.c in wine).
uint64_t FPCR, FPSR;
Expand Down Expand Up @@ -505,6 +507,7 @@ class ECSyscallHandler : public FEXCore::HLE::SyscallHandler, public FEXCore::Al
} // namespace Exception

extern "C" void SyncThreadContext(CONTEXT* Context) {
ProcessPendingCrossProcessEmulatorWork();
auto* Thread = GetCPUArea().ThreadState();
// All other EFlags bits are lost when converting to/from an ARM64EC context, so merge them in from the current JIT state.
// This is advisable over dropping their values as thread suspend/resume uses this function, and that can happen at any point in guest code.
Expand Down

0 comments on commit d080180

Please sign in to comment.