jump_label.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef _ASM_S390_JUMP_LABEL_H
  3. #define _ASM_S390_JUMP_LABEL_H
  4. #define HAVE_JUMP_LABEL_BATCH
  5. #ifndef __ASSEMBLY__
  6. #include <linux/types.h>
  7. #include <linux/stringify.h>
  8. #define JUMP_LABEL_NOP_SIZE 6
  9. #ifdef CONFIG_CC_IS_CLANG
  10. #define JUMP_LABEL_STATIC_KEY_CONSTRAINT "i"
  11. #elif __GNUC__ < 9
  12. #define JUMP_LABEL_STATIC_KEY_CONSTRAINT "X"
  13. #else
  14. #define JUMP_LABEL_STATIC_KEY_CONSTRAINT "jdd"
  15. #endif
  16. /*
  17. * We use a brcl 0,<offset> instruction for jump labels so it
  18. * can be easily distinguished from a hotpatch generated instruction.
  19. */
  20. static __always_inline bool arch_static_branch(struct static_key *key, bool branch)
  21. {
  22. asm_volatile_goto("0: brcl 0,%l[label]\n"
  23. ".pushsection __jump_table,\"aw\"\n"
  24. ".balign 8\n"
  25. ".long 0b-.,%l[label]-.\n"
  26. ".quad %0+%1-.\n"
  27. ".popsection\n"
  28. : : JUMP_LABEL_STATIC_KEY_CONSTRAINT (key), "i" (branch) : : label);
  29. return false;
  30. label:
  31. return true;
  32. }
  33. static __always_inline bool arch_static_branch_jump(struct static_key *key, bool branch)
  34. {
  35. asm_volatile_goto("0: brcl 15,%l[label]\n"
  36. ".pushsection __jump_table,\"aw\"\n"
  37. ".balign 8\n"
  38. ".long 0b-.,%l[label]-.\n"
  39. ".quad %0+%1-.\n"
  40. ".popsection\n"
  41. : : JUMP_LABEL_STATIC_KEY_CONSTRAINT (key), "i" (branch) : : label);
  42. return false;
  43. label:
  44. return true;
  45. }
  46. #endif /* __ASSEMBLY__ */
  47. #endif