xref: /openbmc/linux/arch/powerpc/include/asm/jump_label.h (revision 3f0116c3238a96bc18ad4b4acefe4e7be32fa861)
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 
13ac5f89c7SMichael Ellerman #include <linux/types.h>
14ac5f89c7SMichael Ellerman 
15ac5f89c7SMichael Ellerman #include <asm/feature-fixups.h>
16ac5f89c7SMichael Ellerman 
17ac5f89c7SMichael Ellerman #define JUMP_ENTRY_TYPE		stringify_in_c(FTR_ENTRY_LONG)
18ac5f89c7SMichael Ellerman #define JUMP_LABEL_NOP_SIZE	4
19ac5f89c7SMichael Ellerman 
20c5905afbSIngo Molnar static __always_inline bool arch_static_branch(struct static_key *key)
21ac5f89c7SMichael Ellerman {
22*3f0116c3SIngo Molnar 	asm_volatile_goto("1:\n\t"
23ac5f89c7SMichael Ellerman 		 "nop\n\t"
24ac5f89c7SMichael Ellerman 		 ".pushsection __jump_table,  \"aw\"\n\t"
25ac5f89c7SMichael Ellerman 		 JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
26ac5f89c7SMichael Ellerman 		 ".popsection \n\t"
27ac5f89c7SMichael Ellerman 		 : :  "i" (key) : : l_yes);
28ac5f89c7SMichael Ellerman 	return false;
29ac5f89c7SMichael Ellerman l_yes:
30ac5f89c7SMichael Ellerman 	return true;
31ac5f89c7SMichael Ellerman }
32ac5f89c7SMichael Ellerman 
33ac5f89c7SMichael Ellerman #ifdef CONFIG_PPC64
34ac5f89c7SMichael Ellerman typedef u64 jump_label_t;
35ac5f89c7SMichael Ellerman #else
36ac5f89c7SMichael Ellerman typedef u32 jump_label_t;
37ac5f89c7SMichael Ellerman #endif
38ac5f89c7SMichael Ellerman 
39ac5f89c7SMichael Ellerman struct jump_entry {
40ac5f89c7SMichael Ellerman 	jump_label_t code;
41ac5f89c7SMichael Ellerman 	jump_label_t target;
42ac5f89c7SMichael Ellerman 	jump_label_t key;
43ac5f89c7SMichael Ellerman };
44ac5f89c7SMichael Ellerman 
45ac5f89c7SMichael Ellerman #endif /* _ASM_POWERPC_JUMP_LABEL_H */
46