Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/*
2 * Copyright (C) 2013 Huawei Ltd.
3 * Author: Jiang Liu <liuj97@gmail.com>
4 *
5 * Based on arch/arm/include/asm/jump_label.h
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef __ASM_JUMP_LABEL_H
20#define __ASM_JUMP_LABEL_H
21
22#ifndef __ASSEMBLY__
23
24#include <linux/types.h>
25#include <asm/insn.h>
26
27#define JUMP_LABEL_NOP_SIZE AARCH64_INSN_SIZE
28
29static __always_inline bool arch_static_branch(struct static_key *key,
30 bool branch)
31{
32 asm_volatile_goto(
33 "1: nop \n\t"
34 " .pushsection __jump_table, \"aw\" \n\t"
35 " .align 3 \n\t"
36 " .long 1b - ., %l[l_yes] - . \n\t"
37 " .quad %c0 - . \n\t"
38 " .popsection \n\t"
39 : : "i"(&((char *)key)[branch]) : : l_yes);
40
41 return false;
42l_yes:
43 return true;
44}
45
46static __always_inline bool arch_static_branch_jump(struct static_key *key,
47 bool branch)
48{
49 asm_volatile_goto(
50 "1: b %l[l_yes] \n\t"
51 " .pushsection __jump_table, \"aw\" \n\t"
52 " .align 3 \n\t"
53 " .long 1b - ., %l[l_yes] - . \n\t"
54 " .quad %c0 - . \n\t"
55 " .popsection \n\t"
56 : : "i"(&((char *)key)[branch]) : : l_yes);
57
58 return false;
59l_yes:
60 return true;
61}
62
63#endif /* __ASSEMBLY__ */
64#endif /* __ASM_JUMP_LABEL_H */