blob: 303b3ab87f7e892a4607055eae136582372745cf [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001// SPDX-License-Identifier: GPL-2.0
Rabin Vincent09f05d82012-02-18 17:52:41 +01002#include <linux/kernel.h>
3#include <linux/jump_label.h>
Wang Nanfca08f32015-01-09 10:19:49 +08004#include <asm/patch.h>
Wang Nan0dc016d2015-01-09 14:37:36 +08005#include <asm/insn.h>
Rabin Vincent09f05d82012-02-18 17:52:41 +01006
Rabin Vincent09f05d82012-02-18 17:52:41 +01007static void __arch_jump_label_transform(struct jump_entry *entry,
8 enum jump_label_type type,
9 bool is_static)
10{
11 void *addr = (void *)entry->code;
12 unsigned int insn;
13
Peter Zijlstra76b235c2015-07-24 14:45:44 +020014 if (type == JUMP_LABEL_JMP)
Rabin Vincent09f05d82012-02-18 17:52:41 +010015 insn = arm_gen_branch(entry->code, entry->target);
16 else
17 insn = arm_gen_nop();
18
19 if (is_static)
Rabin Vincentab0615e2014-04-24 23:28:57 +020020 __patch_text_early(addr, insn);
Rabin Vincent09f05d82012-02-18 17:52:41 +010021 else
22 patch_text(addr, insn);
23}
24
25void arch_jump_label_transform(struct jump_entry *entry,
26 enum jump_label_type type)
27{
28 __arch_jump_label_transform(entry, type, false);
29}
30
31void arch_jump_label_transform_static(struct jump_entry *entry,
32 enum jump_label_type type)
33{
34 __arch_jump_label_transform(entry, type, true);
35}