1 #ifndef _ASMARM_THREAD_INFO_H_ 2 #define _ASMARM_THREAD_INFO_H_ 3 /* 4 * Adapted from arch/arm64/include/asm/thread_info.h 5 * 6 * Copyright (C) 2017, Red Hat Inc, Andrew Jones <drjones@redhat.com> 7 * 8 * This work is licensed under the terms of the GNU GPL, version 2. 9 */ 10 #include <asm/page.h> 11 12 #define MIN_THREAD_SHIFT 14 /* THREAD_SIZE == 16K */ 13 #if PAGE_SHIFT > MIN_THREAD_SHIFT 14 #define THREAD_SHIFT PAGE_SHIFT 15 #define THREAD_SIZE PAGE_SIZE 16 #define THREAD_MASK PAGE_MASK 17 #else 18 #define THREAD_SHIFT MIN_THREAD_SHIFT 19 #define THREAD_SIZE (_AC(1,UL) << THREAD_SHIFT) 20 #define THREAD_MASK (~(THREAD_SIZE-1)) 21 #endif 22 23 #ifndef __ASSEMBLY__ 24 #include <asm/processor.h> 25 #include <alloc.h> 26 27 #ifdef __arm__ 28 #include <asm/ptrace.h> 29 /* 30 * arm needs room left at the top for the exception stacks, 31 * and the stack needs to be 8-byte aligned 32 */ 33 #define THREAD_START_SP \ 34 ((THREAD_SIZE - (sizeof(struct pt_regs) * 8)) & ~7) 35 #else 36 #define THREAD_START_SP (THREAD_SIZE - 16) 37 #endif 38 39 static inline void *thread_stack_alloc(void) 40 { 41 void *sp = memalign(PAGE_SIZE, THREAD_SIZE); 42 return sp + THREAD_START_SP; 43 } 44 45 #define TIF_USER_MODE (1U << 0) 46 47 struct thread_info { 48 int cpu; 49 unsigned int flags; 50 void *pgtable; 51 #ifdef __arm__ 52 exception_fn exception_handlers[EXCPTN_MAX]; 53 #else 54 vector_fn vector_handlers[VECTOR_MAX]; 55 exception_fn exception_handlers[VECTOR_MAX][EC_MAX]; 56 #endif 57 char ext[0]; /* allow unit tests to add extended info */ 58 }; 59 60 static inline struct thread_info *thread_info_sp(unsigned long sp) 61 { 62 return (struct thread_info *)(sp & ~(THREAD_SIZE - 1)); 63 } 64 65 register unsigned long current_stack_pointer asm("sp"); 66 67 static inline struct thread_info *current_thread_info(void) 68 { 69 return thread_info_sp(current_stack_pointer); 70 } 71 72 extern void thread_info_init(struct thread_info *ti, unsigned int flags); 73 74 #endif /* !__ASSEMBLY__ */ 75 #endif /* _ASMARM_THREAD_INFO_H_ */ 76