xref: /linux/arch/loongarch/kernel/jump_label.c (revision 53597deca0e38c30e6cd4ba2114fa42d2bcd85bb)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2023 Loongson Technology Corporation Limited
4  *
5  * Based on arch/arm64/kernel/jump_label.c
6  */
7 #include <linux/kernel.h>
8 #include <linux/jump_label.h>
9 #include <asm/cacheflush.h>
10 #include <asm/inst.h>
11 
12 bool arch_jump_label_transform_queue(struct jump_entry *entry, enum jump_label_type type)
13 {
14 	u32 insn;
15 	void *addr = (void *)jump_entry_code(entry);
16 
17 	if (type == JUMP_LABEL_JMP)
18 		insn = larch_insn_gen_b(jump_entry_code(entry), jump_entry_target(entry));
19 	else
20 		insn = larch_insn_gen_nop();
21 
22 	larch_insn_write(addr, insn);
23 
24 	return true;
25 }
26 
27 void arch_jump_label_transform_apply(void)
28 {
29 	flush_icache_all();
30 }
31