]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/mach/arm/thread_status.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / mach / arm / thread_status.h
index 30f2f097d3984faf39686c29c74dc00c63396c2f..a52b770aacacff5202b509c9ed39ebbee0ab9ae8 100644 (file)
 //      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
@@ -143,6 +147,9 @@ typedef _STRUCT_ARM_THREAD_STATE64 arm_thread_state64_t;
 /* 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) */
@@ -357,13 +364,13 @@ get_saved_state_pc(const arm_saved_state_t *iss)
 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
@@ -393,7 +400,7 @@ set_saved_state_fp(arm_saved_state_t *iss, register_t fp)
 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
@@ -502,6 +509,21 @@ struct arm_saved_state {
 
 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)
 
@@ -632,14 +654,14 @@ const_saved_state64(const arm_saved_state_t *iss)
 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)
@@ -650,7 +672,7 @@ add_saved_state_pc(arm_saved_state_t *iss, int diff)
                    [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) */
        }
 }
@@ -668,7 +690,7 @@ set_saved_state_pc(arm_saved_state_t *iss, register_t pc)
                    [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) */
        }
 }
@@ -676,7 +698,7 @@ set_saved_state_pc(arm_saved_state_t *iss, register_t pc)
 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
@@ -685,14 +707,14 @@ set_saved_state_sp(arm_saved_state_t *iss, register_t sp)
        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
@@ -708,7 +730,7 @@ set_saved_state_lr(arm_saved_state_t *iss, register_t lr)
                    [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) */
        }
 }
@@ -716,7 +738,7 @@ set_saved_state_lr(arm_saved_state_t *iss, register_t lr)
 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
@@ -725,7 +747,7 @@ set_saved_state_fp(arm_saved_state_t *iss, register_t fp)
        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;
        }
 }
 
@@ -742,7 +764,7 @@ get_saved_state_reg(const arm_saved_state_t *iss, unsigned reg)
                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
@@ -774,10 +796,11 @@ set_saved_state_reg(arm_saved_state_t *iss, unsigned reg, register_t value)
                        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)
 {
@@ -829,7 +852,7 @@ set_saved_state_cpsr(arm_saved_state_t *iss, uint32_t cpsr)
 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
@@ -838,7 +861,7 @@ set_saved_state_far(arm_saved_state_t *iss, register_t far)
        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;
        }
 }
 
@@ -943,6 +966,12 @@ typedef struct arm_neon_saved_state arm_neon_saved_state_t;
 #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)
 {
@@ -978,6 +1007,12 @@ struct arm_context {
 };
 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*);