hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/I8MGE6
---------------------------
The previous sample use case did not consider the APC and function descriptors of PPC64
Signed-off-by: Cheng Jian cj.chengjian@huawei.com Signed-off-by: Dong Kai dongkai11@huawei.com Signed-off-by: Ye Weihua yeweihua4@huawei.com Signed-off-by: Zheng Yejian zhengyejian1@huawei.com --- samples/livepatch/livepatch-sample.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
diff --git a/samples/livepatch/livepatch-sample.c b/samples/livepatch/livepatch-sample.c index 4a99769086b2..333d040b66a7 100644 --- a/samples/livepatch/livepatch-sample.c +++ b/samples/livepatch/livepatch-sample.c @@ -10,6 +10,9 @@ #include <linux/module.h> #include <linux/kernel.h> #include <linux/livepatch.h> +#if defined(CONFIG_LIVEPATCH_WO_FTRACE) && defined(CONFIG_PPC64) +#include <asm/code-patching.h> +#endif
/* * This (dumb) live patch overrides the function that prints the @@ -63,7 +66,11 @@ static int livepatch_cmdline_proc_show(struct seq_file *m, void *v)
static struct klp_func funcs[] = { { +#if defined(CONFIG_LIVEPATCH_WO_FTRACE) && defined(CONFIG_PPC64) + .old_name = ".cmdline_proc_show", +#else .old_name = "cmdline_proc_show", +#endif .new_func = livepatch_cmdline_proc_show, }, { } }; @@ -87,6 +94,10 @@ static struct klp_patch patch = { static int livepatch_init(void) { #ifdef CONFIG_LIVEPATCH_WO_FTRACE +#ifdef CONFIG_PPC64 + patch.objs[0].funcs[0].new_func = + (void *)ppc_function_entry((void *)livepatch_cmdline_proc_show); +#endif /* CONFIG_PPC64 */ return klp_register_patch(&patch); #else return klp_enable_patch(&patch);