提交 a3cd8c33 编写于 作者: Y Yang Jihong 提交者: Zheng Zengkai

livepatch: Adapt livepatch-sample for stop_machine model

hulk inclusion
category: feature
bugzilla: 182230 https://gitee.com/openeuler/kernel/issues/I4EFWX

--------------------------------

1. Adapt interfaces in module_init & module_exit
2. Add load_hook & unload_hook test
Reviewed-by: NKuohai Xu <xukuohai@huawei.com>
Signed-off-by: NYang Jihong <yangjihong1@huawei.com>
Reviewed-by: NKuohai Xu <xukuohai@huawei.com>
Signed-off-by: NChen Jun <chenjun102@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 99081abf
......@@ -33,6 +33,31 @@
*/
#include <linux/seq_file.h>
#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
void load_hook(void)
{
pr_info("load_hook\n");
}
void unload_hook(void)
{
pr_info("unload_hook\n");
}
static struct klp_hook hooks_load[] = {
{
.hook = load_hook
}, { }
};
static struct klp_hook hooks_unload[] = {
{
.hook = unload_hook
}, { }
};
#endif
static int livepatch_cmdline_proc_show(struct seq_file *m, void *v)
{
seq_printf(m, "%s\n", "this has been live patched");
......@@ -54,6 +79,10 @@ static struct klp_object objs[] = {
{
/* name being NULL means vmlinux */
.funcs = funcs,
#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
.hooks_load = hooks_load,
.hooks_unload = hooks_unload,
#endif
}, { }
};
......@@ -68,11 +97,19 @@ static int livepatch_init(void)
patch.objs[0].funcs[0].new_func =
(void *)ppc_function_entry((void *)livepatch_cmdline_proc_show);
#endif
#ifdef CONFIG_LIVEPATCH_PER_TASK_CONSISTENCY
return klp_enable_patch(&patch);
#elif defined(CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY)
return klp_register_patch(&patch);
#endif
}
static void livepatch_exit(void)
{
#ifdef CONFIG_LIVEPATCH_STOP_MACHINE_CONSISTENCY
WARN_ON(klp_unregister_patch(&patch));
#endif
}
module_init(livepatch_init);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册