jump_label.h 733 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #ifndef _ASM_X86_JUMP_LABEL_H
  2. #define _ASM_X86_JUMP_LABEL_H
  3. #ifdef __KERNEL__
  4. #include <linux/types.h>
  5. #include <asm/nops.h>
  6. #include <asm/asm.h>
  7. #define JUMP_LABEL_NOP_SIZE 5
  8. #define JUMP_LABEL_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
  9. static __always_inline bool arch_static_branch(struct jump_label_key *key)
  10. {
  11. asm goto("1:"
  12. JUMP_LABEL_INITIAL_NOP
  13. ".pushsection __jump_table, \"aw\" \n\t"
  14. _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
  15. ".popsection \n\t"
  16. : : "i" (key) : : l_yes);
  17. return false;
  18. l_yes:
  19. return true;
  20. }
  21. #endif /* __KERNEL__ */
  22. #ifdef CONFIG_X86_64
  23. typedef u64 jump_label_t;
  24. #else
  25. typedef u32 jump_label_t;
  26. #endif
  27. struct jump_entry {
  28. jump_label_t code;
  29. jump_label_t target;
  30. jump_label_t key;
  31. };
  32. #endif