xref: /openbmc/linux/arch/csky/include/asm/jump_label.h (revision aaff74d8)
14e8bb4baSGuo Ren /* SPDX-License-Identifier: GPL-2.0-only */
24e8bb4baSGuo Ren 
34e8bb4baSGuo Ren #ifndef __ASM_CSKY_JUMP_LABEL_H
44e8bb4baSGuo Ren #define __ASM_CSKY_JUMP_LABEL_H
54e8bb4baSGuo Ren 
64e8bb4baSGuo Ren #ifndef __ASSEMBLY__
74e8bb4baSGuo Ren 
84e8bb4baSGuo Ren #include <linux/types.h>
94e8bb4baSGuo Ren 
104e8bb4baSGuo Ren #define JUMP_LABEL_NOP_SIZE 4
114e8bb4baSGuo Ren 
arch_static_branch(struct static_key * key,bool branch)124e8bb4baSGuo Ren static __always_inline bool arch_static_branch(struct static_key *key,
134e8bb4baSGuo Ren 					       bool branch)
144e8bb4baSGuo Ren {
15*aaff74d8SLinus Torvalds 	asm goto(
164e8bb4baSGuo Ren 		"1:	nop32					\n"
174e8bb4baSGuo Ren 		"	.pushsection	__jump_table, \"aw\"	\n"
184e8bb4baSGuo Ren 		"	.align		2			\n"
194e8bb4baSGuo Ren 		"	.long		1b - ., %l[label] - .	\n"
204e8bb4baSGuo Ren 		"	.long		%0 - .			\n"
214e8bb4baSGuo Ren 		"	.popsection				\n"
224e8bb4baSGuo Ren 		:  :  "i"(&((char *)key)[branch]) :  : label);
234e8bb4baSGuo Ren 
244e8bb4baSGuo Ren 	return false;
254e8bb4baSGuo Ren label:
264e8bb4baSGuo Ren 	return true;
274e8bb4baSGuo Ren }
284e8bb4baSGuo Ren 
arch_static_branch_jump(struct static_key * key,bool branch)294e8bb4baSGuo Ren static __always_inline bool arch_static_branch_jump(struct static_key *key,
304e8bb4baSGuo Ren 						    bool branch)
314e8bb4baSGuo Ren {
32*aaff74d8SLinus Torvalds 	asm goto(
334e8bb4baSGuo Ren 		"1:	bsr32		%l[label]		\n"
344e8bb4baSGuo Ren 		"	.pushsection	__jump_table, \"aw\"	\n"
354e8bb4baSGuo Ren 		"	.align		2			\n"
364e8bb4baSGuo Ren 		"	.long		1b - ., %l[label] - .	\n"
374e8bb4baSGuo Ren 		"	.long		%0 - .			\n"
384e8bb4baSGuo Ren 		"	.popsection				\n"
394e8bb4baSGuo Ren 		:  :  "i"(&((char *)key)[branch]) :  : label);
404e8bb4baSGuo Ren 
414e8bb4baSGuo Ren 	return false;
424e8bb4baSGuo Ren label:
434e8bb4baSGuo Ren 	return true;
444e8bb4baSGuo Ren }
454e8bb4baSGuo Ren 
46060d7997SArnd Bergmann enum jump_label_type;
47060d7997SArnd Bergmann void arch_jump_label_transform_static(struct jump_entry *entry,
48060d7997SArnd Bergmann 				      enum jump_label_type type);
49060d7997SArnd Bergmann #define arch_jump_label_transform_static arch_jump_label_transform_static
50060d7997SArnd Bergmann 
514e8bb4baSGuo Ren #endif  /* __ASSEMBLY__ */
524e8bb4baSGuo Ren #endif	/* __ASM_CSKY_JUMP_LABEL_H */
53