jump_label.c 912 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #include <linux/kernel.h>
  2. #include <linux/types.h>
  3. #include <linux/mutex.h>
  4. #include <linux/cpu.h>
  5. #include <linux/jump_label.h>
  6. #include <linux/memory.h>
  7. #ifdef HAVE_JUMP_LABEL
  8. void arch_jump_label_transform(struct jump_entry *entry,
  9. enum jump_label_type type)
  10. {
  11. u32 val;
  12. u32 *insn = (u32 *) (unsigned long) entry->code;
  13. if (type == JUMP_LABEL_ENABLE) {
  14. s32 off = (s32)entry->target - (s32)entry->code;
  15. #ifdef CONFIG_SPARC64
  16. /* ba,pt %xcc, . + (off << 2) */
  17. val = 0x10680000 | ((u32) off >> 2);
  18. #else
  19. /* ba . + (off << 2) */
  20. val = 0x10800000 | ((u32) off >> 2);
  21. #endif
  22. } else {
  23. val = 0x01000000;
  24. }
  25. get_online_cpus();
  26. mutex_lock(&text_mutex);
  27. *insn = val;
  28. flushi(insn);
  29. mutex_unlock(&text_mutex);
  30. put_online_cpus();
  31. }
  32. void arch_jump_label_text_poke_early(jump_label_t addr)
  33. {
  34. u32 *insn_p = (u32 *) (unsigned long) addr;
  35. *insn_p = 0x01000000;
  36. flushi(insn_p);
  37. }
  38. #endif