aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/livepatch.h
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@redhat.com>2017-02-13 20:42:35 -0500
committerJiri Kosina <jkosina@suse.cz>2017-03-08 03:23:16 -0500
commit0dade9f374f1c15f9b43ab01ab75a3b459bba5f6 (patch)
tree2ce5e295256b7be0a39df16284d8800baacac1bb /include/linux/livepatch.h
parent2f09ca60a56dd9c217d32d68340e1b08cbbe1ace (diff)
livepatch: separate enabled and patched states
Once we have a consistency model, patches and their objects will be enabled and disabled at different times. For example, when a patch is disabled, its loaded objects' funcs can remain registered with ftrace indefinitely until the unpatching operation is complete and they're no longer in use. It's less confusing if we give them different names: patches can be enabled or disabled; objects (and their funcs) can be patched or unpatched: - Enabled means that a patch is logically enabled (but not necessarily fully applied). - Patched means that an object's funcs are registered with ftrace and added to the klp_ops func stack. Also, since these states are binary, represent them with booleans instead of ints. Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com> Acked-by: Miroslav Benes <mbenes@suse.cz> Reviewed-by: Petr Mladek <pmladek@suse.com> Reviewed-by: Kamalesh Babulal <kamalesh@linux.vnet.ibm.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'include/linux/livepatch.h')
-rw-r--r--include/linux/livepatch.h17
1 files changed, 6 insertions, 11 deletions
diff --git a/include/linux/livepatch.h b/include/linux/livepatch.h
index 5cc20e588a22..9787a63b57ac 100644
--- a/include/linux/livepatch.h
+++ b/include/linux/livepatch.h
@@ -28,11 +28,6 @@
28 28
29#include <asm/livepatch.h> 29#include <asm/livepatch.h>
30 30
31enum klp_state {
32 KLP_DISABLED,
33 KLP_ENABLED
34};
35
36/** 31/**
37 * struct klp_func - function structure for live patching 32 * struct klp_func - function structure for live patching
38 * @old_name: name of the function to be patched 33 * @old_name: name of the function to be patched
@@ -41,8 +36,8 @@ enum klp_state {
41 * can be found (optional) 36 * can be found (optional)
42 * @old_addr: the address of the function being patched 37 * @old_addr: the address of the function being patched
43 * @kobj: kobject for sysfs resources 38 * @kobj: kobject for sysfs resources
44 * @state: tracks function-level patch application state
45 * @stack_node: list node for klp_ops func_stack list 39 * @stack_node: list node for klp_ops func_stack list
40 * @patched: the func has been added to the klp_ops list
46 */ 41 */
47struct klp_func { 42struct klp_func {
48 /* external */ 43 /* external */
@@ -60,8 +55,8 @@ struct klp_func {
60 /* internal */ 55 /* internal */
61 unsigned long old_addr; 56 unsigned long old_addr;
62 struct kobject kobj; 57 struct kobject kobj;
63 enum klp_state state;
64 struct list_head stack_node; 58 struct list_head stack_node;
59 bool patched;
65}; 60};
66 61
67/** 62/**
@@ -71,7 +66,7 @@ struct klp_func {
71 * @kobj: kobject for sysfs resources 66 * @kobj: kobject for sysfs resources
72 * @mod: kernel module associated with the patched object 67 * @mod: kernel module associated with the patched object
73 * (NULL for vmlinux) 68 * (NULL for vmlinux)
74 * @state: tracks object-level patch application state 69 * @patched: the object's funcs have been added to the klp_ops list
75 */ 70 */
76struct klp_object { 71struct klp_object {
77 /* external */ 72 /* external */
@@ -81,7 +76,7 @@ struct klp_object {
81 /* internal */ 76 /* internal */
82 struct kobject kobj; 77 struct kobject kobj;
83 struct module *mod; 78 struct module *mod;
84 enum klp_state state; 79 bool patched;
85}; 80};
86 81
87/** 82/**
@@ -90,7 +85,7 @@ struct klp_object {
90 * @objs: object entries for kernel objects to be patched 85 * @objs: object entries for kernel objects to be patched
91 * @list: list node for global list of registered patches 86 * @list: list node for global list of registered patches
92 * @kobj: kobject for sysfs resources 87 * @kobj: kobject for sysfs resources
93 * @state: tracks patch-level application state 88 * @enabled: the patch is enabled (but operation may be incomplete)
94 */ 89 */
95struct klp_patch { 90struct klp_patch {
96 /* external */ 91 /* external */
@@ -100,7 +95,7 @@ struct klp_patch {
100 /* internal */ 95 /* internal */
101 struct list_head list; 96 struct list_head list;
102 struct kobject kobj; 97 struct kobject kobj;
103 enum klp_state state; 98 bool enabled;
104}; 99};
105 100
106#define klp_for_each_object(patch, obj) \ 101#define klp_for_each_object(patch, obj) \