text-patching.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef _ASM_X86_TEXT_PATCHING_H
  2. #define _ASM_X86_TEXT_PATCHING_H
  3. #include <linux/types.h>
  4. #include <linux/stddef.h>
  5. #include <asm/ptrace.h>
  6. struct paravirt_patch_site;
  7. #ifdef CONFIG_PARAVIRT
  8. void apply_paravirt(struct paravirt_patch_site *start,
  9. struct paravirt_patch_site *end);
  10. #else
  11. static inline void apply_paravirt(struct paravirt_patch_site *start,
  12. struct paravirt_patch_site *end)
  13. {}
  14. #define __parainstructions NULL
  15. #define __parainstructions_end NULL
  16. #endif
  17. extern void *text_poke_early(void *addr, const void *opcode, size_t len);
  18. /*
  19. * Clear and restore the kernel write-protection flag on the local CPU.
  20. * Allows the kernel to edit read-only pages.
  21. * Side-effect: any interrupt handler running between save and restore will have
  22. * the ability to write to read-only pages.
  23. *
  24. * Warning:
  25. * Code patching in the UP case is safe if NMIs and MCE handlers are stopped and
  26. * no thread can be preempted in the instructions being modified (no iret to an
  27. * invalid instruction possible) or if the instructions are changed from a
  28. * consistent state to another consistent state atomically.
  29. * On the local CPU you need to be protected again NMI or MCE handlers seeing an
  30. * inconsistent instruction while you patch.
  31. */
  32. extern void *text_poke(void *addr, const void *opcode, size_t len);
  33. extern int poke_int3_handler(struct pt_regs *regs);
  34. extern void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler);
  35. #endif /* _ASM_X86_TEXT_PATCHING_H */