Linux Audio

Check our new training course

Yocto distribution development and maintenance

Need a Yocto distribution for your embedded project?
Loading...
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef _ASM_X86_JUMP_LABEL_H
 3#define _ASM_X86_JUMP_LABEL_H
 4
 5#define HAVE_JUMP_LABEL_BATCH
 6
 
 
 
 
 
 
 
 
 7#include <asm/asm.h>
 8#include <asm/nops.h>
 9
10#ifndef __ASSEMBLY__
11
12#include <linux/stringify.h>
13#include <linux/types.h>
14
15#define JUMP_TABLE_ENTRY				\
16	".pushsection __jump_table,  \"aw\" \n\t"	\
17	_ASM_ALIGN "\n\t"				\
18	".long 1b - . \n\t"				\
19	".long %l[l_yes] - . \n\t"			\
20	_ASM_PTR "%c0 + %c1 - .\n\t"			\
21	".popsection \n\t"
22
23#ifdef CONFIG_HAVE_JUMP_LABEL_HACK
24
25static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
26{
27	asm goto("1:"
28		"jmp %l[l_yes] # objtool NOPs this \n\t"
29		JUMP_TABLE_ENTRY
30		: :  "i" (key), "i" (2 | branch) : : l_yes);
31
32	return false;
33l_yes:
34	return true;
35}
36
37#else /* !CONFIG_HAVE_JUMP_LABEL_HACK */
38
39static __always_inline bool arch_static_branch(struct static_key * const key, const bool branch)
40{
41	asm goto("1:"
42		".byte " __stringify(BYTES_NOP5) "\n\t"
43		JUMP_TABLE_ENTRY
44		: :  "i" (key), "i" (branch) : : l_yes);
45
46	return false;
47l_yes:
48	return true;
49}
50
51#endif /* CONFIG_HAVE_JUMP_LABEL_HACK */
52
53static __always_inline bool arch_static_branch_jump(struct static_key * const key, const bool branch)
54{
55	asm goto("1:"
56		"jmp %l[l_yes]\n\t"
57		JUMP_TABLE_ENTRY
 
 
 
 
 
58		: :  "i" (key), "i" (branch) : : l_yes);
59
60	return false;
61l_yes:
62	return true;
63}
64
65extern int arch_jump_entry_size(struct jump_entry *entry);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
67#endif	/* __ASSEMBLY__ */
68
69#endif
 1/* SPDX-License-Identifier: GPL-2.0 */
 2#ifndef _ASM_X86_JUMP_LABEL_H
 3#define _ASM_X86_JUMP_LABEL_H
 4
 5#define HAVE_JUMP_LABEL_BATCH
 6
 7#define JUMP_LABEL_NOP_SIZE 5
 8
 9#ifdef CONFIG_X86_64
10# define STATIC_KEY_INIT_NOP P6_NOP5_ATOMIC
11#else
12# define STATIC_KEY_INIT_NOP GENERIC_NOP5_ATOMIC
13#endif
14
15#include <asm/asm.h>
16#include <asm/nops.h>
17
18#ifndef __ASSEMBLY__
19
20#include <linux/stringify.h>
21#include <linux/types.h>
22
 
 
 
 
 
 
 
 
 
 
23static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
24{
25	asm_volatile_goto("1:"
26		".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t"
27		".pushsection __jump_table,  \"aw\" \n\t"
28		_ASM_ALIGN "\n\t"
29		".long 1b - ., %l[l_yes] - . \n\t"
30		_ASM_PTR "%c0 + %c1 - .\n\t"
31		".popsection \n\t"
 
 
 
 
 
 
 
 
 
 
32		: :  "i" (key), "i" (branch) : : l_yes);
33
34	return false;
35l_yes:
36	return true;
37}
38
39static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
 
 
40{
41	asm_volatile_goto("1:"
42		".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t"
43		"2:\n\t"
44		".pushsection __jump_table,  \"aw\" \n\t"
45		_ASM_ALIGN "\n\t"
46		".long 1b - ., %l[l_yes] - . \n\t"
47		_ASM_PTR "%c0 + %c1 - .\n\t"
48		".popsection \n\t"
49		: :  "i" (key), "i" (branch) : : l_yes);
50
51	return false;
52l_yes:
53	return true;
54}
55
56#else	/* __ASSEMBLY__ */
57
58.macro STATIC_JUMP_IF_TRUE target, key, def
59.Lstatic_jump_\@:
60	.if \def
61	/* Equivalent to "jmp.d32 \target" */
62	.byte		0xe9
63	.long		\target - .Lstatic_jump_after_\@
64.Lstatic_jump_after_\@:
65	.else
66	.byte		STATIC_KEY_INIT_NOP
67	.endif
68	.pushsection __jump_table, "aw"
69	_ASM_ALIGN
70	.long		.Lstatic_jump_\@ - ., \target - .
71	_ASM_PTR	\key - .
72	.popsection
73.endm
74
75.macro STATIC_JUMP_IF_FALSE target, key, def
76.Lstatic_jump_\@:
77	.if \def
78	.byte		STATIC_KEY_INIT_NOP
79	.else
80	/* Equivalent to "jmp.d32 \target" */
81	.byte		0xe9
82	.long		\target - .Lstatic_jump_after_\@
83.Lstatic_jump_after_\@:
84	.endif
85	.pushsection __jump_table, "aw"
86	_ASM_ALIGN
87	.long		.Lstatic_jump_\@ - ., \target - .
88	_ASM_PTR	\key + 1 - .
89	.popsection
90.endm
91
92#endif	/* __ASSEMBLY__ */
93
94#endif