1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun #ifndef _ASMARM_UCONTEXT_H 3*4882a593Smuzhiyun #define _ASMARM_UCONTEXT_H 4*4882a593Smuzhiyun 5*4882a593Smuzhiyun #include <asm/fpstate.h> 6*4882a593Smuzhiyun #include <asm/user.h> 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun /* 9*4882a593Smuzhiyun * struct sigcontext only has room for the basic registers, but struct 10*4882a593Smuzhiyun * ucontext now has room for all registers which need to be saved and 11*4882a593Smuzhiyun * restored. Coprocessor registers are stored in uc_regspace. Each 12*4882a593Smuzhiyun * coprocessor's saved state should start with a documented 32-bit magic 13*4882a593Smuzhiyun * number, followed by a 32-bit word giving the coproccesor's saved size. 14*4882a593Smuzhiyun * uc_regspace may be expanded if necessary, although this takes some 15*4882a593Smuzhiyun * coordination with glibc. 16*4882a593Smuzhiyun */ 17*4882a593Smuzhiyun 18*4882a593Smuzhiyun struct ucontext { 19*4882a593Smuzhiyun unsigned long uc_flags; 20*4882a593Smuzhiyun struct ucontext *uc_link; 21*4882a593Smuzhiyun stack_t uc_stack; 22*4882a593Smuzhiyun struct sigcontext uc_mcontext; 23*4882a593Smuzhiyun sigset_t uc_sigmask; 24*4882a593Smuzhiyun /* Allow for uc_sigmask growth. Glibc uses a 1024-bit sigset_t. */ 25*4882a593Smuzhiyun int __unused[32 - (sizeof (sigset_t) / sizeof (int))]; 26*4882a593Smuzhiyun /* Last for extensibility. Eight byte aligned because some 27*4882a593Smuzhiyun coprocessors require eight byte alignment. */ 28*4882a593Smuzhiyun unsigned long uc_regspace[128] __attribute__((__aligned__(8))); 29*4882a593Smuzhiyun }; 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun #ifdef __KERNEL__ 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun /* 34*4882a593Smuzhiyun * Coprocessor save state. The magic values and specific 35*4882a593Smuzhiyun * coprocessor's layouts are part of the userspace ABI. Each one of 36*4882a593Smuzhiyun * these should be a multiple of eight bytes and aligned to eight 37*4882a593Smuzhiyun * bytes, to prevent unpredictable padding in the signal frame. 38*4882a593Smuzhiyun */ 39*4882a593Smuzhiyun 40*4882a593Smuzhiyun /* 41*4882a593Smuzhiyun * Dummy padding block: if this magic is encountered, the block should 42*4882a593Smuzhiyun * be skipped using the corresponding size field. 43*4882a593Smuzhiyun */ 44*4882a593Smuzhiyun #define DUMMY_MAGIC 0xb0d9ed01 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun #ifdef CONFIG_CRUNCH 47*4882a593Smuzhiyun #define CRUNCH_MAGIC 0x5065cf03 48*4882a593Smuzhiyun #define CRUNCH_STORAGE_SIZE (CRUNCH_SIZE + 8) 49*4882a593Smuzhiyun 50*4882a593Smuzhiyun struct crunch_sigframe { 51*4882a593Smuzhiyun unsigned long magic; 52*4882a593Smuzhiyun unsigned long size; 53*4882a593Smuzhiyun struct crunch_state storage; 54*4882a593Smuzhiyun } __attribute__((__aligned__(8))); 55*4882a593Smuzhiyun #endif 56*4882a593Smuzhiyun 57*4882a593Smuzhiyun #ifdef CONFIG_IWMMXT 58*4882a593Smuzhiyun /* iwmmxt_area is 0x98 bytes long, preceded by 8 bytes of signature */ 59*4882a593Smuzhiyun #define IWMMXT_MAGIC 0x12ef842a 60*4882a593Smuzhiyun #define IWMMXT_STORAGE_SIZE (IWMMXT_SIZE + 8) 61*4882a593Smuzhiyun 62*4882a593Smuzhiyun struct iwmmxt_sigframe { 63*4882a593Smuzhiyun unsigned long magic; 64*4882a593Smuzhiyun unsigned long size; 65*4882a593Smuzhiyun struct iwmmxt_struct storage; 66*4882a593Smuzhiyun } __attribute__((__aligned__(8))); 67*4882a593Smuzhiyun #endif /* CONFIG_IWMMXT */ 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun #ifdef CONFIG_VFP 70*4882a593Smuzhiyun #define VFP_MAGIC 0x56465001 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun struct vfp_sigframe 73*4882a593Smuzhiyun { 74*4882a593Smuzhiyun unsigned long magic; 75*4882a593Smuzhiyun unsigned long size; 76*4882a593Smuzhiyun struct user_vfp ufp; 77*4882a593Smuzhiyun struct user_vfp_exc ufp_exc; 78*4882a593Smuzhiyun } __attribute__((__aligned__(8))); 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun /* 81*4882a593Smuzhiyun * 8 byte for magic and size, 264 byte for ufp, 12 bytes for ufp_exc, 82*4882a593Smuzhiyun * 4 bytes padding. 83*4882a593Smuzhiyun */ 84*4882a593Smuzhiyun #define VFP_STORAGE_SIZE sizeof(struct vfp_sigframe) 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun #endif /* CONFIG_VFP */ 87*4882a593Smuzhiyun 88*4882a593Smuzhiyun /* 89*4882a593Smuzhiyun * Auxiliary signal frame. This saves stuff like FP state. 90*4882a593Smuzhiyun * The layout of this structure is not part of the user ABI, 91*4882a593Smuzhiyun * because the config options aren't. uc_regspace is really 92*4882a593Smuzhiyun * one of these. 93*4882a593Smuzhiyun */ 94*4882a593Smuzhiyun struct aux_sigframe { 95*4882a593Smuzhiyun #ifdef CONFIG_CRUNCH 96*4882a593Smuzhiyun struct crunch_sigframe crunch; 97*4882a593Smuzhiyun #endif 98*4882a593Smuzhiyun #ifdef CONFIG_IWMMXT 99*4882a593Smuzhiyun struct iwmmxt_sigframe iwmmxt; 100*4882a593Smuzhiyun #endif 101*4882a593Smuzhiyun #ifdef CONFIG_VFP 102*4882a593Smuzhiyun struct vfp_sigframe vfp; 103*4882a593Smuzhiyun #endif 104*4882a593Smuzhiyun /* Something that isn't a valid magic number for any coprocessor. */ 105*4882a593Smuzhiyun unsigned long end_magic; 106*4882a593Smuzhiyun } __attribute__((__aligned__(8))); 107*4882a593Smuzhiyun 108*4882a593Smuzhiyun #endif 109*4882a593Smuzhiyun 110*4882a593Smuzhiyun #endif /* !_ASMARM_UCONTEXT_H */ 111