mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
aarch64 - Support for apple exceptions
This commit is contained in:
parent
4da30e9eca
commit
470f8674df
@ -1932,9 +1932,8 @@ static void signal_handler(int /*sig*/, siginfo_t* info, void* uct) noexcept
|
|||||||
const bool is_writing = err & 0x2;
|
const bool is_writing = err & 0x2;
|
||||||
#elif defined(ARCH_ARM64)
|
#elif defined(ARCH_ARM64)
|
||||||
const bool is_executing = uptr(info->si_addr) == uptr(RIP(context));
|
const bool is_executing = uptr(info->si_addr) == uptr(RIP(context));
|
||||||
const u32 insn = is_executing ? 0 : *reinterpret_cast<u32*>(RIP(context));
|
|
||||||
|
|
||||||
#ifdef __linux__
|
#if defined(__linux__) || defined(__APPLE__)
|
||||||
// Current CPU state decoder is reverse-engineered from the linux kernel and may not work on other platforms.
|
// Current CPU state decoder is reverse-engineered from the linux kernel and may not work on other platforms.
|
||||||
const auto decoded_reason = aarch64::decode_fault_reason(context);
|
const auto decoded_reason = aarch64::decode_fault_reason(context);
|
||||||
const bool is_writing = (decoded_reason == aarch64::fault_reason::data_write);
|
const bool is_writing = (decoded_reason == aarch64::fault_reason::data_write);
|
||||||
@ -1947,6 +1946,7 @@ static void signal_handler(int /*sig*/, siginfo_t* info, void* uct) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
const u32 insn = is_executing ? 0 : *reinterpret_cast<u32*>(RIP(context));
|
||||||
const bool is_writing =
|
const bool is_writing =
|
||||||
(insn & 0xbfff0000) == 0x0c000000 || // STR <Wt>, [<Xn>, #<imm>] (store word with immediate offset)
|
(insn & 0xbfff0000) == 0x0c000000 || // STR <Wt>, [<Xn>, #<imm>] (store word with immediate offset)
|
||||||
(insn & 0xbfe00000) == 0x0c800000 || // STP <Wt1>, <Wt2>, [<Xn>, #<imm>] (store pair of registers with immediate offset)
|
(insn & 0xbfe00000) == 0x0c800000 || // STP <Wt1>, <Wt2>, [<Xn>, #<imm>] (store pair of registers with immediate offset)
|
||||||
|
@ -53,6 +53,13 @@ namespace aarch64
|
|||||||
auto esr_ctx = find_EL1_esr_context(uctx);
|
auto esr_ctx = find_EL1_esr_context(uctx);
|
||||||
return esr_ctx ? esr_ctx->esr : 0;
|
return esr_ctx ? esr_ctx->esr : 0;
|
||||||
}
|
}
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
u64 _read_ESR_EL1(const ucontext_t* uctx)
|
||||||
|
{
|
||||||
|
// Easy to read from mcontext
|
||||||
|
const auto darwin_ctx = reinterpret_cast<aarch64_darwin_mcontext64*>(uctx->uc_mcontext);
|
||||||
|
return darwin_ctx->es.ESR;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
u64 _read_ESR_EL1(const ucontext_t*)
|
u64 _read_ESR_EL1(const ucontext_t*)
|
||||||
{
|
{
|
||||||
|
@ -8,6 +8,7 @@ namespace aarch64
|
|||||||
// Some renamed kernel definitions, we don't need to include kernel headers directly
|
// Some renamed kernel definitions, we don't need to include kernel headers directly
|
||||||
#pragma pack(push, 1)
|
#pragma pack(push, 1)
|
||||||
|
|
||||||
|
#if defined(__linux__)
|
||||||
struct aarch64_cpu_ctx_block
|
struct aarch64_cpu_ctx_block
|
||||||
{
|
{
|
||||||
u32 magic;
|
u32 magic;
|
||||||
@ -19,6 +20,20 @@ namespace aarch64
|
|||||||
aarch64_cpu_ctx_block head;
|
aarch64_cpu_ctx_block head;
|
||||||
u64 esr; // Exception syndrome register
|
u64 esr; // Exception syndrome register
|
||||||
};
|
};
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
struct aarch64_exception_state
|
||||||
|
{
|
||||||
|
u64 FAR; // Fault address reg
|
||||||
|
u32 ESR; // Exception syndrome reg (ESR_EL1)
|
||||||
|
u32 exception_id;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct aarch64_darwin_mcontext64
|
||||||
|
{
|
||||||
|
aarch64_exception_state es;
|
||||||
|
// Other states we don't care about follow this field
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user