jump_label.c 684 B

12345678910111213141516171819202122232425262728
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Copyright (C) 2013 Huawei Ltd.
  4. * Author: Jiang Liu <[email protected]>
  5. *
  6. * Based on arch/arm/kernel/jump_label.c
  7. */
  8. #include <linux/kernel.h>
  9. #include <linux/jump_label.h>
  10. #include <asm/insn.h>
  11. #include <asm/patching.h>
  12. void arch_jump_label_transform(struct jump_entry *entry,
  13. enum jump_label_type type)
  14. {
  15. void *addr = (void *)jump_entry_code(entry);
  16. u32 insn;
  17. if (type == JUMP_LABEL_JMP) {
  18. insn = aarch64_insn_gen_branch_imm(jump_entry_code(entry),
  19. jump_entry_target(entry),
  20. AARCH64_INSN_BRANCH_NOLINK);
  21. } else {
  22. insn = aarch64_insn_gen_nop();
  23. }
  24. aarch64_insn_patch_text_nosync(addr, insn);
  25. }