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