jump_label.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. #ifndef _ASM_POWERPC_JUMP_LABEL_H
  3. #define _ASM_POWERPC_JUMP_LABEL_H
  4. /*
  5. * Copyright 2010 Michael Ellerman, IBM Corp.
  6. */
  7. #ifndef __ASSEMBLY__
  8. #include <linux/types.h>
  9. #include <asm/feature-fixups.h>
  10. #include <asm/asm-const.h>
  11. #define JUMP_ENTRY_TYPE stringify_in_c(FTR_ENTRY_LONG)
  12. #define JUMP_LABEL_NOP_SIZE 4
  13. static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
  14. {
  15. asm_volatile_goto("1:\n\t"
  16. "nop # arch_static_branch\n\t"
  17. ".pushsection __jump_table, \"aw\"\n\t"
  18. ".long 1b - ., %l[l_yes] - .\n\t"
  19. JUMP_ENTRY_TYPE "%c0 - .\n\t"
  20. ".popsection \n\t"
  21. : : "i" (&((char *)key)[branch]) : : l_yes);
  22. return false;
  23. l_yes:
  24. return true;
  25. }
  26. static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
  27. {
  28. asm_volatile_goto("1:\n\t"
  29. "b %l[l_yes] # arch_static_branch_jump\n\t"
  30. ".pushsection __jump_table, \"aw\"\n\t"
  31. ".long 1b - ., %l[l_yes] - .\n\t"
  32. JUMP_ENTRY_TYPE "%c0 - .\n\t"
  33. ".popsection \n\t"
  34. : : "i" (&((char *)key)[branch]) : : l_yes);
  35. return false;
  36. l_yes:
  37. return true;
  38. }
  39. #else
  40. #define ARCH_STATIC_BRANCH(LABEL, KEY) \
  41. 1098: nop; \
  42. .pushsection __jump_table, "aw"; \
  43. .long 1098b - ., LABEL - .; \
  44. FTR_ENTRY_LONG KEY - .; \
  45. .popsection
  46. #endif
  47. #endif /* _ASM_POWERPC_JUMP_LABEL_H */