jump_label.h 1.1 KB

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