提交 ec571063 编写于 作者: Z Zheng Yejian 提交者: Zheng Zengkai

livepatch/arm64: Uniform 'old_func' field in struct klp_func_node

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I4UAQ1

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

'struct klp_func_node' is used to save codes of a function which is then
be live-patched. Currently this structure is respectively defined in
x86/arm32/arm64/ppc32/ppc64.

The definitions of field which save old function address are different:
  In x86/arm32/ppc32/ppc64: void *old_func;
  In arm64: unsigned long old_addr;

Minority subordinates to majority, uniform them as 'void *old_func'.

Preparatory only, no functional change.
Signed-off-by: NZheng Yejian <zhengyejian1@huawei.com>
Reviewed-by: NKuohai Xu <xukuohai@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 4d6bd7d6
...@@ -56,7 +56,7 @@ static inline bool offset_in_range(unsigned long pc, unsigned long addr, ...@@ -56,7 +56,7 @@ static inline bool offset_in_range(unsigned long pc, unsigned long addr,
struct klp_func_node { struct klp_func_node {
struct list_head node; struct list_head node;
struct list_head func_stack; struct list_head func_stack;
unsigned long old_addr; void *old_func;
#ifdef CONFIG_ARM64_MODULE_PLTS #ifdef CONFIG_ARM64_MODULE_PLTS
u32 old_insns[LJMP_INSN_SIZE]; u32 old_insns[LJMP_INSN_SIZE];
#else #else
...@@ -66,12 +66,12 @@ struct klp_func_node { ...@@ -66,12 +66,12 @@ struct klp_func_node {
static LIST_HEAD(klp_func_list); static LIST_HEAD(klp_func_list);
static struct klp_func_node *klp_find_func_node(unsigned long old_addr) static struct klp_func_node *klp_find_func_node(void *old_func)
{ {
struct klp_func_node *func_node; struct klp_func_node *func_node;
list_for_each_entry(func_node, &klp_func_list, node) { list_for_each_entry(func_node, &klp_func_list, node) {
if (func_node->old_addr == old_addr) if (func_node->old_func == old_func)
return func_node; return func_node;
} }
...@@ -180,7 +180,7 @@ static int klp_check_activeness_func(struct klp_patch *patch, int enable, ...@@ -180,7 +180,7 @@ static int klp_check_activeness_func(struct klp_patch *patch, int enable,
* When enable, checking the currently * When enable, checking the currently
* active functions. * active functions.
*/ */
func_node = klp_find_func_node((unsigned long)func->old_func); func_node = klp_find_func_node(func->old_func);
if (!func_node || if (!func_node ||
list_empty(&func_node->func_stack)) { list_empty(&func_node->func_stack)) {
func_addr = (unsigned long)func->old_func; func_addr = (unsigned long)func->old_func;
...@@ -221,7 +221,7 @@ static int klp_check_activeness_func(struct klp_patch *patch, int enable, ...@@ -221,7 +221,7 @@ static int klp_check_activeness_func(struct klp_patch *patch, int enable,
* patched function and the function itself * patched function and the function itself
* which to be unpatched. * which to be unpatched.
*/ */
func_node = klp_find_func_node((unsigned long)func->old_func); func_node = klp_find_func_node(func->old_func);
if (!func_node) { if (!func_node) {
return -EINVAL; return -EINVAL;
} }
...@@ -370,7 +370,7 @@ int arch_klp_patch_func(struct klp_func *func) ...@@ -370,7 +370,7 @@ int arch_klp_patch_func(struct klp_func *func)
#endif #endif
int ret = 0; int ret = 0;
func_node = klp_find_func_node((unsigned long)func->old_func); func_node = klp_find_func_node(func->old_func);
if (!func_node) { if (!func_node) {
func_node = func->func_node; func_node = func->func_node;
if (!func_node) if (!func_node)
...@@ -378,7 +378,7 @@ int arch_klp_patch_func(struct klp_func *func) ...@@ -378,7 +378,7 @@ int arch_klp_patch_func(struct klp_func *func)
memory_flag = 1; memory_flag = 1;
INIT_LIST_HEAD(&func_node->func_stack); INIT_LIST_HEAD(&func_node->func_stack);
func_node->old_addr = (unsigned long)func->old_func; func_node->old_func = func->old_func;
#ifdef CONFIG_ARM64_MODULE_PLTS #ifdef CONFIG_ARM64_MODULE_PLTS
for (i = 0; i < LJMP_INSN_SIZE; i++) { for (i = 0; i < LJMP_INSN_SIZE; i++) {
...@@ -447,11 +447,11 @@ void arch_klp_unpatch_func(struct klp_func *func) ...@@ -447,11 +447,11 @@ void arch_klp_unpatch_func(struct klp_func *func)
int i; int i;
u32 insns[LJMP_INSN_SIZE]; u32 insns[LJMP_INSN_SIZE];
#endif #endif
func_node = klp_find_func_node((unsigned long)func->old_func); func_node = klp_find_func_node(func->old_func);
if (WARN_ON(!func_node)) if (WARN_ON(!func_node))
return; return;
pc = func_node->old_addr; pc = (unsigned long)func_node->old_func;
if (list_is_singular(&func_node->func_stack)) { if (list_is_singular(&func_node->func_stack)) {
#ifdef CONFIG_ARM64_MODULE_PLTS #ifdef CONFIG_ARM64_MODULE_PLTS
for (i = 0; i < LJMP_INSN_SIZE; i++) for (i = 0; i < LJMP_INSN_SIZE; i++)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册