jump_label.h 970 B

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