jump_label.c 561 B

12345678910111213141516171819202122
  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/inst.h>
  10. void arch_jump_label_transform(struct jump_entry *entry, enum jump_label_type type)
  11. {
  12. u32 insn;
  13. void *addr = (void *)jump_entry_code(entry);
  14. if (type == JUMP_LABEL_JMP)
  15. insn = larch_insn_gen_b(jump_entry_code(entry), jump_entry_target(entry));
  16. else
  17. insn = larch_insn_gen_nop();
  18. larch_insn_patch_text(addr, insn);
  19. }