jump_label.h 997 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef _ASM_SPARC_JUMP_LABEL_H
  2. #define _ASM_SPARC_JUMP_LABEL_H
  3. #ifndef __ASSEMBLY__
  4. #include <linux/types.h>
  5. #define JUMP_LABEL_NOP_SIZE 4
  6. static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
  7. {
  8. asm_volatile_goto("1:\n\t"
  9. "nop\n\t"
  10. "nop\n\t"
  11. ".pushsection __jump_table, \"aw\"\n\t"
  12. ".align 4\n\t"
  13. ".word 1b, %l[l_yes], %c0\n\t"
  14. ".popsection \n\t"
  15. : : "i" (&((char *)key)[branch]) : : l_yes);
  16. return false;
  17. l_yes:
  18. return true;
  19. }
  20. static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
  21. {
  22. asm_volatile_goto("1:\n\t"
  23. "b %l[l_yes]\n\t"
  24. "nop\n\t"
  25. ".pushsection __jump_table, \"aw\"\n\t"
  26. ".align 4\n\t"
  27. ".word 1b, %l[l_yes], %c0\n\t"
  28. ".popsection \n\t"
  29. : : "i" (&((char *)key)[branch]) : : l_yes);
  30. return false;
  31. l_yes:
  32. return true;
  33. }
  34. typedef u32 jump_label_t;
  35. struct jump_entry {
  36. jump_label_t code;
  37. jump_label_t target;
  38. jump_label_t key;
  39. };
  40. #endif /* __ASSEMBLY__ */
  41. #endif