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