jump_label.c 848 B

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