jump_label.h 1009 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_ARM_JUMP_LABEL_H
  3. #define _ASM_ARM_JUMP_LABEL_H
  4. #ifndef __ASSEMBLY__
  5. #include <linux/types.h>
  6. #include <asm/unified.h>
  7. #define JUMP_LABEL_NOP_SIZE 4
  8. static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
  9. {
  10. asm_volatile_goto("1:\n\t"
  11. WASM(nop) "\n\t"
  12. ".pushsection __jump_table, \"aw\"\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. WASM(b) " %l[l_yes]\n\t"
  24. ".pushsection __jump_table, \"aw\"\n\t"
  25. ".word 1b, %l[l_yes], %c0\n\t"
  26. ".popsection\n\t"
  27. : : "i" (&((char *)key)[branch]) : : l_yes);
  28. return false;
  29. l_yes:
  30. return true;
  31. }
  32. typedef u32 jump_label_t;
  33. struct jump_entry {
  34. jump_label_t code;
  35. jump_label_t target;
  36. jump_label_t key;
  37. };
  38. #endif /* __ASSEMBLY__ */
  39. #endif