jump_label.h 1010 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. #ifndef __ASM_CSKY_JUMP_LABEL_H
  3. #define __ASM_CSKY_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,
  8. bool branch)
  9. {
  10. asm_volatile_goto(
  11. "1: nop32 \n"
  12. " .pushsection __jump_table, \"aw\" \n"
  13. " .align 2 \n"
  14. " .long 1b - ., %l[label] - . \n"
  15. " .long %0 - . \n"
  16. " .popsection \n"
  17. : : "i"(&((char *)key)[branch]) : : label);
  18. return false;
  19. label:
  20. return true;
  21. }
  22. static __always_inline bool arch_static_branch_jump(struct static_key *key,
  23. bool branch)
  24. {
  25. asm_volatile_goto(
  26. "1: bsr32 %l[label] \n"
  27. " .pushsection __jump_table, \"aw\" \n"
  28. " .align 2 \n"
  29. " .long 1b - ., %l[label] - . \n"
  30. " .long %0 - . \n"
  31. " .popsection \n"
  32. : : "i"(&((char *)key)[branch]) : : label);
  33. return false;
  34. label:
  35. return true;
  36. }
  37. #endif /* __ASSEMBLY__ */
  38. #endif /* __ASM_CSKY_JUMP_LABEL_H */