Skip to content

Commit

Permalink
Merge pull request #4269 from bylaws/jumpext
Browse files Browse the repository at this point in the history
JIT: Avoid OOB EC bitmap checks in ExitFunction
  • Loading branch information
alyssarosenzweig authored Jan 14, 2025
2 parents f635a12 + c852a58 commit 8c02bd4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions FEXCore/Source/Interface/Core/ArchHelpers/Arm64Emitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ constexpr size_t PEB_EC_CODE_BITMAP_OFFSET = 0x368;
constexpr size_t CPU_AREA_IN_SYSCALL_CALLBACK_OFFSET = 0x1;
constexpr size_t CPU_AREA_EMULATOR_STACK_BASE_OFFSET = 0x8;
constexpr size_t CPU_AREA_EMULATOR_DATA_OFFSET = 0x30;

constexpr uint64_t EC_CODE_BITMAP_MAX_ADDRESS = 1ULL << 47;
#endif

// Will force one single instruction block to be generated first if set when entering the JIT filling SRA.
Expand Down
2 changes: 1 addition & 1 deletion FEXCore/Source/Interface/Core/JIT/BranchOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ DEF_OP(ExitFunction) {

if (IsInlineConstant(Op->NewRIP, &NewRIP) || IsInlineEntrypointOffset(Op->NewRIP, &NewRIP)) {
#ifdef _M_ARM_64EC
if (RtlIsEcCode(NewRIP)) {
if (NewRIP < EC_CODE_BITMAP_MAX_ADDRESS && RtlIsEcCode(NewRIP)) {
add(ARMEmitter::Size::i64Bit, ARMEmitter::Reg::rsp, StaticRegisters[X86State::REG_RSP], 0);
LoadConstant(ARMEmitter::Size::i64Bit, EC_CALL_CHECKER_PC_REG, NewRIP);
ldr(TMP2, STATE_PTR(CpuStateFrame, Pointers.Common.ExitFunctionEC));
Expand Down

0 comments on commit 8c02bd4

Please sign in to comment.