jump_label.h 695 B

12345678910111213141516171819202122232425262728293031323334353637
  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. #define JUMP_LABEL_NOP_SIZE 5
  7. # define JUMP_LABEL_INITIAL_NOP ".byte 0xe9 \n\t .long 0\n\t"
  8. # define JUMP_LABEL(key, label) \
  9. do { \
  10. asm goto("1:" \
  11. JUMP_LABEL_INITIAL_NOP \
  12. ".pushsection __jump_table, \"aw\" \n\t"\
  13. _ASM_PTR "1b, %l[" #label "], %c0 \n\t" \
  14. ".popsection \n\t" \
  15. : : "i" (key) : : label); \
  16. } while (0)
  17. #endif /* __KERNEL__ */
  18. #ifdef CONFIG_X86_64
  19. typedef u64 jump_label_t;
  20. #else
  21. typedef u32 jump_label_t;
  22. #endif
  23. struct jump_entry {
  24. jump_label_t code;
  25. jump_label_t target;
  26. jump_label_t key;
  27. };
  28. #endif