mirror of
https://gitee.com/open-loongarch/linux-5.10.git
synced 2026-10-28 22:17:12 +08:00
41 lines
930 B
C
41 lines
930 B
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
* for more details.
|
|
*
|
|
* Copyright (C) 2020 Loongson Technology Co., Ltd.
|
|
*/
|
|
|
|
#include <linux/jump_label.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/memory.h>
|
|
#include <linux/mutex.h>
|
|
#include <linux/types.h>
|
|
#include <linux/cpu.h>
|
|
|
|
#include <asm/cacheflush.h>
|
|
#include <asm/inst.h>
|
|
|
|
void arch_jump_label_transform(struct jump_entry *e,
|
|
enum jump_label_type type)
|
|
{
|
|
|
|
u32 insn, *insn_p;
|
|
|
|
insn_p = (u32 *)e->code;
|
|
|
|
if (type == JUMP_LABEL_JMP)
|
|
insn = larch_insn_gen_b((unsigned long)e->code, (unsigned long)e->target);
|
|
else
|
|
insn = larch_insn_gen_nop();
|
|
|
|
mutex_lock(&text_mutex);
|
|
*insn_p = insn;
|
|
|
|
flush_icache_range((unsigned long)insn_p,
|
|
(unsigned long)insn_p + sizeof(*insn_p));
|
|
|
|
mutex_unlock(&text_mutex);
|
|
}
|