Commit 2ea69fe7 authored by Zheng Yejian's avatar Zheng Yejian
Browse files

livepatch/ppc64: Sample testcase fix ppc64

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: default avatarCheng Jian <cj.chengjian@huawei.com>
Signed-off-by: default avatarDong Kai <dongkai11@huawei.com>
Signed-off-by: default avatarYe Weihua <yeweihua4@huawei.com>
Signed-off-by: default avatarZheng Yejian <zhengyejian1@huawei.com>
parent eabc33c6
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -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);