xref: /openbmc/linux/arch/powerpc/include/asm/jump_label.h (revision cc1adb5f32557f10f48e8febbef7278a2db9d593)
1ac5f89c7SMichael Ellerman #ifndef _ASM_POWERPC_JUMP_LABEL_H
2ac5f89c7SMichael Ellerman #define _ASM_POWERPC_JUMP_LABEL_H
3ac5f89c7SMichael Ellerman 
4ac5f89c7SMichael Ellerman /*
5ac5f89c7SMichael Ellerman  * Copyright 2010 Michael Ellerman, IBM Corp.
6ac5f89c7SMichael Ellerman  *
7ac5f89c7SMichael Ellerman  * This program is free software; you can redistribute it and/or
8ac5f89c7SMichael Ellerman  * modify it under the terms of the GNU General Public License
9ac5f89c7SMichael Ellerman  * as published by the Free Software Foundation; either version
10ac5f89c7SMichael Ellerman  * 2 of the License, or (at your option) any later version.
11ac5f89c7SMichael Ellerman  */
12ac5f89c7SMichael Ellerman 
13*cc1adb5fSAnton Blanchard #ifndef __ASSEMBLY__
14ac5f89c7SMichael Ellerman #include <linux/types.h>
15ac5f89c7SMichael Ellerman 
16ac5f89c7SMichael Ellerman #include <asm/feature-fixups.h>
17ac5f89c7SMichael Ellerman 
18ac5f89c7SMichael Ellerman #define JUMP_ENTRY_TYPE		stringify_in_c(FTR_ENTRY_LONG)
19ac5f89c7SMichael Ellerman #define JUMP_LABEL_NOP_SIZE	4
20ac5f89c7SMichael Ellerman 
21c5905afbSIngo Molnar static __always_inline bool arch_static_branch(struct static_key *key)
22ac5f89c7SMichael Ellerman {
233f0116c3SIngo Molnar 	asm_volatile_goto("1:\n\t"
24ac5f89c7SMichael Ellerman 		 "nop\n\t"
25ac5f89c7SMichael Ellerman 		 ".pushsection __jump_table,  \"aw\"\n\t"
26ac5f89c7SMichael Ellerman 		 JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
27ac5f89c7SMichael Ellerman 		 ".popsection \n\t"
28ac5f89c7SMichael Ellerman 		 : :  "i" (key) : : l_yes);
29ac5f89c7SMichael Ellerman 	return false;
30ac5f89c7SMichael Ellerman l_yes:
31ac5f89c7SMichael Ellerman 	return true;
32ac5f89c7SMichael Ellerman }
33ac5f89c7SMichael Ellerman 
34ac5f89c7SMichael Ellerman #ifdef CONFIG_PPC64
35ac5f89c7SMichael Ellerman typedef u64 jump_label_t;
36ac5f89c7SMichael Ellerman #else
37ac5f89c7SMichael Ellerman typedef u32 jump_label_t;
38ac5f89c7SMichael Ellerman #endif
39ac5f89c7SMichael Ellerman 
40ac5f89c7SMichael Ellerman struct jump_entry {
41ac5f89c7SMichael Ellerman 	jump_label_t code;
42ac5f89c7SMichael Ellerman 	jump_label_t target;
43ac5f89c7SMichael Ellerman 	jump_label_t key;
44ac5f89c7SMichael Ellerman };
45ac5f89c7SMichael Ellerman 
46*cc1adb5fSAnton Blanchard #else
47*cc1adb5fSAnton Blanchard #define ARCH_STATIC_BRANCH(LABEL, KEY)		\
48*cc1adb5fSAnton Blanchard 1098:	nop;					\
49*cc1adb5fSAnton Blanchard 	.pushsection __jump_table, "aw";	\
50*cc1adb5fSAnton Blanchard 	FTR_ENTRY_LONG 1098b, LABEL, KEY;	\
51*cc1adb5fSAnton Blanchard 	.popsection
52*cc1adb5fSAnton Blanchard #endif
53*cc1adb5fSAnton Blanchard 
54ac5f89c7SMichael Ellerman #endif /* _ASM_POWERPC_JUMP_LABEL_H */
55