X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/2d21ac55c334faf3a56e5634905ed6987fc787d4..04b8595b18b1b41ac7a206e4b3d51a635f8413d7:/osfmk/mach/i386/thread_status.h diff --git a/osfmk/mach/i386/thread_status.h b/osfmk/mach/i386/thread_status.h index d8c38843f..9c682ee72 100644 --- a/osfmk/mach/i386/thread_status.h +++ b/osfmk/mach/i386/thread_status.h @@ -110,6 +110,11 @@ #define x86_DEBUG_STATE64 11 #define x86_DEBUG_STATE 12 #define THREAD_STATE_NONE 13 +/* 14 and 15 are used for the internal x86_SAVED_STATE flavours */ +#define x86_AVX_STATE32 16 +#define x86_AVX_STATE64 17 +#define x86_AVX_STATE 18 + /* * Largest state on this machine: @@ -136,6 +141,9 @@ (x == x86_FLOAT_STATE) || \ (x == x86_EXCEPTION_STATE) || \ (x == x86_DEBUG_STATE) || \ + (x == x86_AVX_STATE32) || \ + (x == x86_AVX_STATE64) || \ + (x == x86_AVX_STATE) || \ (x == THREAD_STATE_NONE)) struct x86_state_hdr { @@ -175,6 +183,10 @@ typedef _STRUCT_X86_FLOAT_STATE32 x86_float_state32_t; #define x86_FLOAT_STATE32_COUNT ((mach_msg_type_number_t) \ (sizeof(x86_float_state32_t)/sizeof(unsigned int))) +typedef _STRUCT_X86_AVX_STATE32 x86_avx_state32_t; +#define x86_AVX_STATE32_COUNT ((mach_msg_type_number_t) \ + (sizeof(x86_avx_state32_t)/sizeof(unsigned int))) + /* * to be deprecated in the future */ @@ -201,7 +213,11 @@ typedef _STRUCT_X86_THREAD_STATE64 x86_thread_state64_t; typedef _STRUCT_X86_FLOAT_STATE64 x86_float_state64_t; #define x86_FLOAT_STATE64_COUNT ((mach_msg_type_number_t) \ (sizeof(x86_float_state64_t)/sizeof(unsigned int))) - + +typedef _STRUCT_X86_AVX_STATE64 x86_avx_state64_t; +#define x86_AVX_STATE64_COUNT ((mach_msg_type_number_t) \ + (sizeof(x86_avx_state64_t)/sizeof(unsigned int))) + typedef _STRUCT_X86_EXCEPTION_STATE64 x86_exception_state64_t; #define x86_EXCEPTION_STATE64_COUNT ((mach_msg_type_number_t) \ ( sizeof (x86_exception_state64_t) / sizeof (int) )) @@ -249,6 +265,14 @@ struct x86_debug_state { } uds; }; +struct x86_avx_state { + x86_state_hdr_t ash; + union { + x86_avx_state32_t as32; + x86_avx_state64_t as64; + } ufs; +}; + typedef struct x86_thread_state x86_thread_state_t; #define x86_THREAD_STATE_COUNT ((mach_msg_type_number_t) \ ( sizeof (x86_thread_state_t) / sizeof (int) )) @@ -265,6 +289,10 @@ typedef struct x86_debug_state x86_debug_state_t; #define x86_DEBUG_STATE_COUNT ((mach_msg_type_number_t) \ (sizeof(x86_debug_state_t)/sizeof(unsigned int))) +typedef struct x86_avx_state x86_avx_state_t; +#define x86_AVX_STATE_COUNT ((mach_msg_type_number_t) \ + (sizeof(x86_avx_state_t)/sizeof(unsigned int))) + /* * Machine-independent way for servers and Mach's exception mechanism to * choose the most efficient state flavor for exception RPC's: @@ -272,116 +300,54 @@ typedef struct x86_debug_state x86_debug_state_t; #define MACHINE_THREAD_STATE x86_THREAD_STATE #define MACHINE_THREAD_STATE_COUNT x86_THREAD_STATE_COUNT -/* - * when reloading the segment registers on - * a return out of the kernel, we may take - * a GeneralProtection or SegmentNotPresent - * fault if one or more of the segment - * registers in the saved state was improperly - * specified via an x86_THREAD_STATE32 call - * the frame we push on top of the existing - * save area looks like this... we need to - * carry this as part of the save area - * in case we get hit so that we have a big - * enough stack - */ -struct x86_seg_load_fault32 { - unsigned int trapno; - unsigned int err; - unsigned int eip; - unsigned int cs; - unsigned int efl; -}; - #ifdef XNU_KERNEL_PRIVATE #define x86_SAVED_STATE32 THREAD_STATE_NONE + 1 #define x86_SAVED_STATE64 THREAD_STATE_NONE + 2 -/* - * Subset of saved state stored by processor on kernel-to-kernel - * trap. (Used by ddb to examine state guaranteed to be present - * on all traps into debugger.) - */ -struct x86_saved_state32_from_kernel { - unsigned int gs; - unsigned int fs; - unsigned int es; - unsigned int ds; - unsigned int edi; - unsigned int esi; - unsigned int ebp; - unsigned int cr2; /* kernel esp stored by pusha - we save cr2 here later */ - unsigned int ebx; - unsigned int edx; - unsigned int ecx; - unsigned int eax; - unsigned int trapno; - unsigned int err; - unsigned int eip; - unsigned int cs; - unsigned int efl; -}; - /* * The format in which thread state is saved by Mach on this machine. This * state flavor is most efficient for exception RPC's to kernel-loaded * servers, because copying can be avoided: */ struct x86_saved_state32 { - unsigned int gs; - unsigned int fs; - unsigned int es; - unsigned int ds; - unsigned int edi; - unsigned int esi; - unsigned int ebp; - unsigned int cr2; /* kernel esp stored by pusha - we save cr2 here later */ - unsigned int ebx; - unsigned int edx; - unsigned int ecx; - unsigned int eax; - unsigned int trapno; - unsigned int err; - unsigned int eip; - unsigned int cs; - unsigned int efl; - unsigned int uesp; - unsigned int ss; + uint32_t gs; + uint32_t fs; + uint32_t es; + uint32_t ds; + uint32_t edi; + uint32_t esi; + uint32_t ebp; + uint32_t cr2; /* kernel esp stored by pusha - we save cr2 here later */ + uint32_t ebx; + uint32_t edx; + uint32_t ecx; + uint32_t eax; + uint16_t trapno; + uint16_t cpu; + uint32_t err; + uint32_t eip; + uint32_t cs; + uint32_t efl; + uint32_t uesp; + uint32_t ss; }; typedef struct x86_saved_state32 x86_saved_state32_t; #define x86_SAVED_STATE32_COUNT ((mach_msg_type_number_t) \ (sizeof (x86_saved_state32_t)/sizeof(unsigned int))) -struct x86_saved_state32_tagged { - uint32_t tag; - struct x86_saved_state32 state; -}; -typedef struct x86_saved_state32_tagged x86_saved_state32_tagged_t; - -struct x86_sframe32 { -/* - * in case we throw a fault reloading - * segment registers on a return out of - * the kernel... the 'slf' state is only kept - * long enough to rejigger (i.e. restore - * the save area to its original state) - * the save area and throw the appropriate - * kernel trap pointing to the 'ssf' state - */ - struct x86_seg_load_fault32 slf; - struct x86_saved_state32_tagged ssf; -}; -typedef struct x86_sframe32 x86_sframe32_t; +#pragma pack(4) /* * This is the state pushed onto the 64-bit interrupt stack * on any exception/trap/interrupt. */ struct x86_64_intr_stack_frame { - uint32_t trapno; - uint32_t trapfn; + uint16_t trapno; + uint16_t cpu; + uint32_t _pad; + uint64_t trapfn; uint64_t err; uint64_t rip; uint64_t cs; @@ -390,26 +356,7 @@ struct x86_64_intr_stack_frame { uint64_t ss; }; typedef struct x86_64_intr_stack_frame x86_64_intr_stack_frame_t; - -/* - * This defines the state saved before entry into compatibility mode. - * The machine state is pushed automatically and the compat state is - * synthethized in the exception handling code. - */ -struct x86_saved_state_compat32 { - struct x86_saved_state32_tagged iss32; - uint32_t pad_for_16byte_alignment[2]; - struct x86_64_intr_stack_frame isf64; -}; -typedef struct x86_saved_state_compat32 x86_saved_state_compat32_t; - -struct x86_sframe_compat32 { - struct x86_64_intr_stack_frame slf; - uint32_t pad_for_16byte_alignment[2]; - struct x86_saved_state_compat32 ssf; - uint32_t empty[4]; -}; -typedef struct x86_sframe_compat32 x86_sframe_compat32_t; +/* Note: sizeof(x86_64_intr_stack_frame_t) must be a multiple of 16 bytes */ /* * thread state format for task running in 64bit long mode @@ -418,28 +365,12 @@ typedef struct x86_sframe_compat32 x86_sframe_compat32_t; * is no need for an x86_saved_state64_from_kernel variant */ struct x86_saved_state64 { - /* - * saved state organized to reflect the - * system call ABI register convention - * so that we can just pass a pointer - * to the saved state when calling through - * to the actual system call functions - * the ABI limits us to 6 args passed in - * registers... I've add v_arg6 - v_arg8 - * to accomodate our most 'greedy' system - * calls (both BSD and MACH)... the individual - * system call handlers will fill these in - * via copyin if needed... - */ - uint64_t rdi; /* arg0 for system call */ + uint64_t rdi; /* arg0 for system call */ uint64_t rsi; uint64_t rdx; - uint64_t r10; - uint64_t r8; - uint64_t r9; /* arg5 for system call */ - uint64_t v_arg6; - uint64_t v_arg7; - uint64_t v_arg8; + uint64_t r10; /* R10 := RCX prior to syscall trap */ + uint64_t r8; + uint64_t r9; /* arg5 for system call */ uint64_t cr2; uint64_t r15; @@ -454,25 +385,15 @@ struct x86_saved_state64 { uint32_t gs; uint32_t fs; + + uint64_t _pad; + struct x86_64_intr_stack_frame isf; }; typedef struct x86_saved_state64 x86_saved_state64_t; #define x86_SAVED_STATE64_COUNT ((mach_msg_type_number_t) \ (sizeof (struct x86_saved_state64)/sizeof(unsigned int))) -struct x86_saved_state64_tagged { - uint32_t tag; - x86_saved_state64_t state; -}; -typedef struct x86_saved_state64_tagged x86_saved_state64_tagged_t; - -struct x86_sframe64 { - struct x86_64_intr_stack_frame slf; - uint32_t pad_for_16byte_alignment[3]; - struct x86_saved_state64_tagged ssf; -}; -typedef struct x86_sframe64 x86_sframe64_t; - extern uint32_t get_eflags_exportmask(void); /* @@ -480,6 +401,7 @@ extern uint32_t get_eflags_exportmask(void); */ typedef struct { uint32_t flavor; + uint32_t _pad_for_16byte_alignment[3]; union { x86_saved_state32_t ss_32; x86_saved_state64_t ss_64; @@ -487,6 +409,7 @@ typedef struct { } x86_saved_state_t; #define ss_32 uss.ss_32 #define ss_64 uss.ss_64 +#pragma pack() static inline boolean_t is_saved_state64(x86_saved_state_t *iss)