jump_label.h 1.0 KB

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