diff --git a/src/util/page_fault_handler.cpp b/src/util/page_fault_handler.cpp index c4a1bd5e9..2df1a95c0 100644 --- a/src/util/page_fault_handler.cpp +++ b/src/util/page_fault_handler.cpp @@ -31,6 +31,8 @@ #endif #if defined(CPU_ARCH_ARM64) +static constexpr u64 ARM64_ESR_ISS_DA_WNR = (1u << 6); + [[maybe_unused]] static bool IsStoreInstruction(const void* ptr) { u32 bits; @@ -280,9 +282,10 @@ void PageFaultHandler::SignalHandler(int sig, siginfo_t* info, void* ctx) void* const exception_pc = reinterpret_cast(static_cast(ctx)->uc_mcontext->__ss.__rip); const bool is_write = (static_cast(ctx)->uc_mcontext->__es.__err & 2) != 0; #elif defined(CPU_ARCH_ARM64) - void* const exception_address = reinterpret_cast(static_cast(ctx)->uc_mcontext->__es.__far); - void* const exception_pc = reinterpret_cast(static_cast(ctx)->uc_mcontext->__ss.__pc); - const bool is_write = IsStoreInstruction(exception_pc); + ucontext_t* const context = static_cast(ctx); + void* const exception_address = reinterpret_cast(context->uc_mcontext->__es.__far); + void* const exception_pc = reinterpret_cast(context->uc_mcontext->__ss.__pc); + const bool is_write = (context->uc_mcontext->__es.__esr & ARM64_ESR_ISS_DA_WNR) != 0; #else void* const exception_address = reinterpret_cast(info->si_addr); void* const exception_pc = nullptr;