patch.h 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. #ifndef _LIVEPATCH_PATCH_H
  2. #define _LIVEPATCH_PATCH_H
  3. #include <linux/livepatch.h>
  4. #include <linux/list.h>
  5. #include <linux/ftrace.h>
  6. /**
  7. * struct klp_ops - structure for tracking registered ftrace ops structs
  8. *
  9. * A single ftrace_ops is shared between all enabled replacement functions
  10. * (klp_func structs) which have the same old_addr. This allows the switch
  11. * between function versions to happen instantaneously by updating the klp_ops
  12. * struct's func_stack list. The winner is the klp_func at the top of the
  13. * func_stack (front of the list).
  14. *
  15. * @node: node for the global klp_ops list
  16. * @func_stack: list head for the stack of klp_func's (active func is on top)
  17. * @fops: registered ftrace ops struct
  18. */
  19. struct klp_ops {
  20. struct list_head node;
  21. struct list_head func_stack;
  22. struct ftrace_ops fops;
  23. };
  24. struct klp_ops *klp_find_ops(unsigned long old_addr);
  25. int klp_patch_object(struct klp_object *obj);
  26. void klp_unpatch_object(struct klp_object *obj);
  27. void klp_unpatch_objects(struct klp_patch *patch);
  28. #endif /* _LIVEPATCH_PATCH_H */