jump_label.c 794 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. #include <asm/cacheflush.h>
  8. #ifdef HAVE_JUMP_LABEL
  9. void arch_jump_label_transform(struct jump_entry *entry,
  10. enum jump_label_type type)
  11. {
  12. u32 val;
  13. u32 *insn = (u32 *) (unsigned long) entry->code;
  14. if (type == JUMP_LABEL_ENABLE) {
  15. s32 off = (s32)entry->target - (s32)entry->code;
  16. #ifdef CONFIG_SPARC64
  17. /* ba,pt %xcc, . + (off << 2) */
  18. val = 0x10680000 | ((u32) off >> 2);
  19. #else
  20. /* ba . + (off << 2) */
  21. val = 0x10800000 | ((u32) off >> 2);
  22. #endif
  23. } else {
  24. val = 0x01000000;
  25. }
  26. get_online_cpus();
  27. mutex_lock(&text_mutex);
  28. *insn = val;
  29. flushi(insn);
  30. mutex_unlock(&text_mutex);
  31. put_online_cpus();
  32. }
  33. #endif