blob: ae098c438f009eb0e312fc8b78a6ce07f4311cc6 [file] [log] [blame]
Michael Ellermanac5f89c2011-06-29 19:16:59 +00001#ifndef _ASM_POWERPC_JUMP_LABEL_H
2#define _ASM_POWERPC_JUMP_LABEL_H
3
4/*
5 * Copyright 2010 Michael Ellerman, IBM Corp.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12
13#include <linux/types.h>
14
15#include <asm/feature-fixups.h>
16
17#define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG)
18#define JUMP_LABEL_NOP_SIZE 4
19
Ingo Molnarc5905af2012-02-24 08:31:31 +010020static __always_inline bool arch_static_branch(struct static_key *key)
Michael Ellermanac5f89c2011-06-29 19:16:59 +000021{
22 asm goto("1:\n\t"
23 "nop\n\t"
24 ".pushsection __jump_table, \"aw\"\n\t"
Michael Ellermanac5f89c2011-06-29 19:16:59 +000025 JUMP_ENTRY_TYPE "1b, %l[l_yes], %c0\n\t"
26 ".popsection \n\t"
27 : : "i" (key) : : l_yes);
28 return false;
29l_yes:
30 return true;
31}
32
33#ifdef CONFIG_PPC64
34typedef u64 jump_label_t;
35#else
36typedef u32 jump_label_t;
37#endif
38
39struct jump_entry {
40 jump_label_t code;
41 jump_label_t target;
42 jump_label_t key;
Michael Ellermanac5f89c2011-06-29 19:16:59 +000043};
44
45#endif /* _ASM_POWERPC_JUMP_LABEL_H */