jump_label: move 'asm goto' support test to Kconfig
[linux-2.6-block.git] / arch / arm64 / kernel / jump_label.c
CommitLineData
9732cafd
JL
1/*
2 * Copyright (C) 2013 Huawei Ltd.
3 * Author: Jiang Liu <liuj97@gmail.com>
4 *
5 * Based on arch/arm/kernel/jump_label.c
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#include <linux/kernel.h>
20#include <linux/jump_label.h>
21#include <asm/insn.h>
22
6ddae418
MR
23void arch_jump_label_transform(struct jump_entry *entry,
24 enum jump_label_type type)
9732cafd 25{
c296146c 26 void *addr = (void *)jump_entry_code(entry);
9732cafd
JL
27 u32 insn;
28
76b235c6 29 if (type == JUMP_LABEL_JMP) {
c296146c
AB
30 insn = aarch64_insn_gen_branch_imm(jump_entry_code(entry),
31 jump_entry_target(entry),
9732cafd
JL
32 AARCH64_INSN_BRANCH_NOLINK);
33 } else {
34 insn = aarch64_insn_gen_nop();
35 }
36
f6cc0c50 37 aarch64_insn_patch_text_nosync(addr, insn);
9732cafd
JL
38}
39
40void arch_jump_label_transform_static(struct jump_entry *entry,
41 enum jump_label_type type)
42{
6ddae418
MR
43 /*
44 * We use the architected A64 NOP in arch_static_branch, so there's no
45 * need to patch an identical A64 NOP over the top of it here. The core
46 * will call arch_jump_label_transform from a module notifier if the
47 * NOP needs to be replaced by a branch.
48 */
9732cafd 49}