^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #include <linux/jump_label.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) #include <asm/patch.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <asm/insn.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) static void __arch_jump_label_transform(struct jump_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) enum jump_label_type type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) bool is_static)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) void *addr = (void *)entry->code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) unsigned int insn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) if (type == JUMP_LABEL_JMP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) insn = arm_gen_branch(entry->code, entry->target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) insn = arm_gen_nop();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) if (is_static)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) __patch_text_early(addr, insn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) patch_text(addr, insn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) void arch_jump_label_transform(struct jump_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) enum jump_label_type type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) __arch_jump_label_transform(entry, type, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) void arch_jump_label_transform_static(struct jump_entry *entry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) enum jump_label_type type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) __arch_jump_label_transform(entry, type, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) }