David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2013 Huawei Ltd. |
| 4 | * Author: Jiang Liu <liuj97@gmail.com> |
| 5 | * |
| 6 | * Based on arch/arm/kernel/jump_label.c |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 7 | */ |
| 8 | #include <linux/kernel.h> |
| 9 | #include <linux/jump_label.h> |
| 10 | #include <asm/insn.h> |
| 11 | |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 12 | void arch_jump_label_transform(struct jump_entry *entry, |
| 13 | enum jump_label_type type) |
| 14 | { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 15 | void *addr = (void *)jump_entry_code(entry); |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 16 | u32 insn; |
| 17 | |
| 18 | if (type == JUMP_LABEL_JMP) { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame^] | 19 | insn = aarch64_insn_gen_branch_imm(jump_entry_code(entry), |
| 20 | jump_entry_target(entry), |
Andrew Scull | b4b6d4a | 2019-01-02 15:54:55 +0000 | [diff] [blame] | 21 | AARCH64_INSN_BRANCH_NOLINK); |
| 22 | } else { |
| 23 | insn = aarch64_insn_gen_nop(); |
| 24 | } |
| 25 | |
| 26 | aarch64_insn_patch_text_nosync(addr, insn); |
| 27 | } |
| 28 | |
| 29 | void arch_jump_label_transform_static(struct jump_entry *entry, |
| 30 | enum jump_label_type type) |
| 31 | { |
| 32 | /* |
| 33 | * We use the architected A64 NOP in arch_static_branch, so there's no |
| 34 | * need to patch an identical A64 NOP over the top of it here. The core |
| 35 | * will call arch_jump_label_transform from a module notifier if the |
| 36 | * NOP needs to be replaced by a branch. |
| 37 | */ |
| 38 | } |