Commit b5bfc517 authored by Li Bin's avatar Li Bin Committed by Jiri Kosina

livepatch: move x86 specific ftrace handler code to arch/x86

The execution flow redirection related implemention in the livepatch
ftrace handler is depended on the specific architecture. This patch
introduces klp_arch_set_pc(like kgdb_arch_set_pc) interface to change
the pt_regs.
Signed-off-by: default avatarLi Bin <huawei.libin@huawei.com>
Acked-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
parent 13d1cf7e
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#define _ASM_X86_LIVEPATCH_H #define _ASM_X86_LIVEPATCH_H
#include <linux/module.h> #include <linux/module.h>
#include <linux/ftrace.h>
#ifdef CONFIG_LIVE_PATCHING #ifdef CONFIG_LIVE_PATCHING
#ifndef CC_USING_FENTRY #ifndef CC_USING_FENTRY
...@@ -30,6 +31,10 @@ ...@@ -30,6 +31,10 @@
extern int klp_write_module_reloc(struct module *mod, unsigned long type, extern int klp_write_module_reloc(struct module *mod, unsigned long type,
unsigned long loc, unsigned long value); unsigned long loc, unsigned long value);
static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
{
regs->ip = ip;
}
#else #else
#error Live patching support is disabled; check CONFIG_LIVE_PATCHING #error Live patching support is disabled; check CONFIG_LIVE_PATCHING
#endif #endif
......
...@@ -272,7 +272,7 @@ static void notrace klp_ftrace_handler(unsigned long ip, ...@@ -272,7 +272,7 @@ static void notrace klp_ftrace_handler(unsigned long ip,
{ {
struct klp_func *func = ops->private; struct klp_func *func = ops->private;
regs->ip = (unsigned long)func->new_func; klp_arch_set_pc(regs, (unsigned long)func->new_func);
} }
static int klp_disable_func(struct klp_func *func) static int klp_disable_func(struct klp_func *func)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment