xref: /OK3568_Linux_fs/kernel/arch/arm64/include/asm/current.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun #ifndef __ASM_CURRENT_H
3*4882a593Smuzhiyun #define __ASM_CURRENT_H
4*4882a593Smuzhiyun 
5*4882a593Smuzhiyun #include <linux/compiler.h>
6*4882a593Smuzhiyun 
7*4882a593Smuzhiyun #ifndef __ASSEMBLY__
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun struct task_struct;
10*4882a593Smuzhiyun 
11*4882a593Smuzhiyun /*
12*4882a593Smuzhiyun  * We don't use read_sysreg() as we want the compiler to cache the value where
13*4882a593Smuzhiyun  * possible.
14*4882a593Smuzhiyun  */
get_current(void)15*4882a593Smuzhiyun static __always_inline struct task_struct *get_current(void)
16*4882a593Smuzhiyun {
17*4882a593Smuzhiyun 	unsigned long sp_el0;
18*4882a593Smuzhiyun 
19*4882a593Smuzhiyun 	asm ("mrs %0, sp_el0" : "=r" (sp_el0));
20*4882a593Smuzhiyun 
21*4882a593Smuzhiyun 	return (struct task_struct *)sp_el0;
22*4882a593Smuzhiyun }
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun #define current get_current()
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun #endif /* __ASSEMBLY__ */
27*4882a593Smuzhiyun 
28*4882a593Smuzhiyun #endif /* __ASM_CURRENT_H */
29*4882a593Smuzhiyun 
30