aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/livepatch/core.h
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/livepatch/core.h')
-rw-r--r--kernel/livepatch/core.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/kernel/livepatch/core.h b/kernel/livepatch/core.h
index c74f24c47837..cc3aa708e0b4 100644
--- a/kernel/livepatch/core.h
+++ b/kernel/livepatch/core.h
@@ -1,6 +1,46 @@
1#ifndef _LIVEPATCH_CORE_H 1#ifndef _LIVEPATCH_CORE_H
2#define _LIVEPATCH_CORE_H 2#define _LIVEPATCH_CORE_H
3 3
4#include <linux/livepatch.h>
5
4extern struct mutex klp_mutex; 6extern struct mutex klp_mutex;
5 7
8static inline bool klp_is_object_loaded(struct klp_object *obj)
9{
10 return !obj->name || obj->mod;
11}
12
13static inline int klp_pre_patch_callback(struct klp_object *obj)
14{
15 int ret = 0;
16
17 if (obj->callbacks.pre_patch)
18 ret = (*obj->callbacks.pre_patch)(obj);
19
20 obj->callbacks.post_unpatch_enabled = !ret;
21
22 return ret;
23}
24
25static inline void klp_post_patch_callback(struct klp_object *obj)
26{
27 if (obj->callbacks.post_patch)
28 (*obj->callbacks.post_patch)(obj);
29}
30
31static inline void klp_pre_unpatch_callback(struct klp_object *obj)
32{
33 if (obj->callbacks.pre_unpatch)
34 (*obj->callbacks.pre_unpatch)(obj);
35}
36
37static inline void klp_post_unpatch_callback(struct klp_object *obj)
38{
39 if (obj->callbacks.post_unpatch_enabled &&
40 obj->callbacks.post_unpatch)
41 (*obj->callbacks.post_unpatch)(obj);
42
43 obj->callbacks.post_unpatch_enabled = false;
44}
45
6#endif /* _LIVEPATCH_CORE_H */ 46#endif /* _LIVEPATCH_CORE_H */