// ARM_THREAD_STATE_LAST 8 /* legacy */
#define ARM_THREAD_STATE32 9
+#ifdef XNU_KERNEL_PRIVATE
+#define X86_THREAD_STATE_NONE 13 /* i386/thread_status.h THREAD_STATE_NONE */
+#endif /* XNU_KERNEL_PRIVATE */
+
/* API */
#define ARM_DEBUG_STATE32 14
#define ARM_DEBUG_STATE64 15
/* Set fp field of arm_thread_state64_t to a data pointer value */
#define arm_thread_state64_set_fp(ts, ptr) \
__darwin_arm_thread_state64_set_fp(ts, ptr)
+/* Strip ptr auth bits from pc, lr, sp and fp field of arm_thread_state64_t */
+#define arm_thread_state64_ptrauth_strip(ts) \
+ __darwin_arm_thread_state64_ptrauth_strip(ts)
#endif /* __DARWIN_C_LEVEL >= __DARWIN_C_FULL && defined(__arm64__) */
#endif /* !defined(KERNEL) */
static inline void
add_saved_state_pc(arm_saved_state_t *iss, int diff)
{
- iss->pc += diff;
+ iss->pc += (unsigned int)diff;
}
static inline void
set_saved_state_pc(arm_saved_state_t *iss, register_t pc)
{
- iss->pc = pc;
+ iss->pc = (typeof(iss->pc))pc;
}
static inline register_t
static inline register_t
get_saved_state_lr(const arm_saved_state_t *iss)
{
- return iss->lr;
+ return (register_t)iss->lr;
}
static inline void
typedef struct arm_saved_state arm_saved_state_t;
+struct arm_kernel_saved_state {
+ uint64_t x[12]; /* General purpose registers x16-x28 */
+ uint64_t fp; /* Frame pointer x29 */
+ uint64_t lr; /* Link register x30 */
+ uint64_t sp; /* Stack pointer x31 */
+ uint64_t pc; /* Program counter */
+ uint32_t cpsr; /* Current program status register */
+ uint32_t reserved; /* Reserved padding */
+#if defined(HAS_APPLE_PAC)
+ uint64_t jophash;
+#endif /* defined(HAS_APPLE_PAC) */
+} __attribute__((aligned(16)));
+
+typedef struct arm_kernel_saved_state arm_kernel_saved_state_t;
+
#if defined(XNU_KERNEL_PRIVATE)
#if defined(HAS_APPLE_PAC)
static inline register_t
get_saved_state_pc(const arm_saved_state_t *iss)
{
- return is_saved_state32(iss) ? const_saved_state32(iss)->pc : const_saved_state64(iss)->pc;
+ return (register_t)(is_saved_state32(iss) ? const_saved_state32(iss)->pc : const_saved_state64(iss)->pc);
}
static inline void
add_saved_state_pc(arm_saved_state_t *iss, int diff)
{
if (is_saved_state32(iss)) {
- uint64_t pc = saved_state32(iss)->pc + diff;
+ uint64_t pc = saved_state32(iss)->pc + (uint32_t)diff;
saved_state32(iss)->pc = CAST_ASSERT_SAFE(uint32_t, pc);
} else {
#if defined(XNU_KERNEL_PRIVATE) && defined(HAS_APPLE_PAC)
[diff] "r"(diff)
);
#else
- saved_state64(iss)->pc += diff;
+ saved_state64(iss)->pc += (unsigned long)diff;
#endif /* defined(XNU_KERNEL_PRIVATE) && defined(HAS_APPLE_PAC) */
}
}
[pc] "r"(pc)
);
#else
- saved_state64(iss)->pc = pc;
+ saved_state64(iss)->pc = (unsigned long)pc;
#endif /* defined(XNU_KERNEL_PRIVATE) && defined(HAS_APPLE_PAC) */
}
}
static inline register_t
get_saved_state_sp(const arm_saved_state_t *iss)
{
- return is_saved_state32(iss) ? const_saved_state32(iss)->sp : const_saved_state64(iss)->sp;
+ return (register_t)(is_saved_state32(iss) ? const_saved_state32(iss)->sp : const_saved_state64(iss)->sp);
}
static inline void
if (is_saved_state32(iss)) {
saved_state32(iss)->sp = CAST_ASSERT_SAFE(uint32_t, sp);
} else {
- saved_state64(iss)->sp = sp;
+ saved_state64(iss)->sp = (uint64_t)sp;
}
}
static inline register_t
get_saved_state_lr(const arm_saved_state_t *iss)
{
- return is_saved_state32(iss) ? const_saved_state32(iss)->lr : const_saved_state64(iss)->lr;
+ return (register_t)(is_saved_state32(iss) ? const_saved_state32(iss)->lr : const_saved_state64(iss)->lr);
}
static inline void
[lr] "r"(lr)
);
#else
- saved_state64(iss)->lr = lr;
+ saved_state64(iss)->lr = (unsigned long)lr;
#endif /* defined(XNU_KERNEL_PRIVATE) && defined(HAS_APPLE_PAC) */
}
}
static inline register_t
get_saved_state_fp(const arm_saved_state_t *iss)
{
- return is_saved_state32(iss) ? const_saved_state32(iss)->r[7] : const_saved_state64(iss)->fp;
+ return (register_t)(is_saved_state32(iss) ? const_saved_state32(iss)->r[7] : const_saved_state64(iss)->fp);
}
static inline void
if (is_saved_state32(iss)) {
saved_state32(iss)->r[7] = CAST_ASSERT_SAFE(uint32_t, fp);
} else {
- saved_state64(iss)->fp = fp;
+ saved_state64(iss)->fp = (uint64_t)fp;
}
}
return 0;
}
- return is_saved_state32(iss) ? (const_saved_state32(iss)->r[reg]) : (const_saved_state64(iss)->x[reg]);
+ return (register_t)(is_saved_state32(iss) ? (const_saved_state32(iss)->r[reg]) : (const_saved_state64(iss)->x[reg]));
}
static inline void
return;
}
#endif
- saved_state64(iss)->x[reg] = value;
+ saved_state64(iss)->x[reg] = (uint64_t)value;
}
}
+
static inline uint32_t
get_saved_state_cpsr(const arm_saved_state_t *iss)
{
static inline register_t
get_saved_state_far(const arm_saved_state_t *iss)
{
- return is_saved_state32(iss) ? const_saved_state32(iss)->far : const_saved_state64(iss)->far;
+ return (register_t)(is_saved_state32(iss) ? const_saved_state32(iss)->far : const_saved_state64(iss)->far);
}
static inline void
if (is_saved_state32(iss)) {
saved_state32(iss)->far = CAST_ASSERT_SAFE(uint32_t, far);
} else {
- saved_state64(iss)->far = far;
+ saved_state64(iss)->far = (uint64_t)far;
}
}
#define ns_32 uns.ns_32
#define ns_64 uns.ns_64
+struct arm_kernel_neon_saved_state {
+ uint64_t d[8];
+ uint32_t fpcr;
+};
+typedef struct arm_kernel_neon_saved_state arm_kernel_neon_saved_state_t;
+
static inline boolean_t
is_neon_saved_state32(const arm_neon_saved_state_t *state)
{
};
typedef struct arm_context arm_context_t;
+struct arm_kernel_context {
+ struct arm_kernel_saved_state ss;
+ struct arm_kernel_neon_saved_state ns;
+};
+typedef struct arm_kernel_context arm_kernel_context_t;
+
extern void saved_state_to_thread_state64(const arm_saved_state_t*, arm_thread_state64_t*);
extern void thread_state64_to_saved_state(const arm_thread_state64_t*, arm_saved_state_t*);