jump_label.h 1.2 KB

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