jump_label.h 758 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 STATIC_KEY_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
  9. static __always_inline bool arch_static_branch(struct static_key *key)
  10. {
  11. asm_volatile_goto("1:"
  12. STATIC_KEY_INITIAL_NOP
  13. ".pushsection __jump_table, \"aw\" \n\t"
  14. _ASM_ALIGN "\n\t"
  15. _ASM_PTR "1b, %l[l_yes], %c0 \n\t"
  16. ".popsection \n\t"
  17. : : "i" (key) : : l_yes);
  18. return false;
  19. l_yes:
  20. return true;
  21. }
  22. #endif /* __KERNEL__ */
  23. #ifdef CONFIG_X86_64
  24. typedef u64 jump_label_t;
  25. #else
  26. typedef u32 jump_label_t;
  27. #endif
  28. struct jump_entry {
  29. jump_label_t code;
  30. jump_label_t target;
  31. jump_label_t key;
  32. };
  33. #endif