]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
livepatch: move x86 specific ftrace handler code to arch/x86
authorLi Bin <huawei.libin@huawei.com>
Fri, 19 Dec 2014 06:11:17 +0000 (14:11 +0800)
committerJiri Kosina <jkosina@suse.cz>
Mon, 22 Dec 2014 14:40:49 +0000 (15:40 +0100)
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: Li Bin <huawei.libin@huawei.com>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
arch/x86/include/asm/livepatch.h
kernel/livepatch/core.c

index d529db1b1edf95b3a0aceab68fee9aa3b682d75a..b5608d7757fdf4a5d90902b08c5f45ff9c32fcbc 100644 (file)
@@ -22,6 +22,7 @@
 #define _ASM_X86_LIVEPATCH_H
 
 #include <linux/module.h>
+#include <linux/ftrace.h>
 
 #ifdef CONFIG_LIVE_PATCHING
 #ifndef CC_USING_FENTRY
 extern int klp_write_module_reloc(struct module *mod, unsigned long type,
                                  unsigned long loc, unsigned long value);
 
+static inline void klp_arch_set_pc(struct pt_regs *regs, unsigned long ip)
+{
+       regs->ip = ip;
+}
 #else
 #error Live patching support is disabled; check CONFIG_LIVE_PATCHING
 #endif
index f99fe189d596eaf2f002bdf2ea64b56cf1e7d630..07a2db9d01e6d51aec90a8789b5b3a8b9dc90226 100644 (file)
@@ -272,7 +272,7 @@ static void notrace klp_ftrace_handler(unsigned long ip,
 {
        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)