patch.h 1.1 KB

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