livepatch: Use the default ftrace_ops instead of REGS when ARGS is available
When CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS is available, the ftrace call will be able to set the ip of the calling function. This will improve the performance of live kernel patching where it does not need all the regs to be stored just to change the instruction pointer. If all archs that support live kernel patching also support HAVE_DYNAMIC_FTRACE_WITH_ARGS, then the architecture specific function klp_arch_set_pc() could be made generic. It is possible that an arch can support HAVE_DYNAMIC_FTRACE_WITH_ARGS but not HAVE_DYNAMIC_FTRACE_WITH_REGS and then have access to live patching. Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Jiri Kosina <jikos@kernel.org> Cc: live-patching@vger.kernel.org Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org> Acked-by: Miroslav Benes <mbenes@suse.cz> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
This commit is contained in:
parent
02a474ca26
commit
2860cd8a23
8 changed files with 29 additions and 9 deletions
|
|
@ -6,7 +6,7 @@ config HAVE_LIVEPATCH
|
|||
|
||||
config LIVEPATCH
|
||||
bool "Kernel Live Patching"
|
||||
depends on DYNAMIC_FTRACE_WITH_REGS
|
||||
depends on DYNAMIC_FTRACE_WITH_REGS || DYNAMIC_FTRACE_WITH_ARGS
|
||||
depends on MODULES
|
||||
depends on SYSFS
|
||||
depends on KALLSYMS_ALL
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ static void notrace klp_ftrace_handler(unsigned long ip,
|
|||
struct ftrace_ops *fops,
|
||||
struct ftrace_regs *fregs)
|
||||
{
|
||||
struct pt_regs *regs = ftrace_get_regs(fregs);
|
||||
struct klp_ops *ops;
|
||||
struct klp_func *func;
|
||||
int patch_state;
|
||||
|
|
@ -118,7 +117,7 @@ static void notrace klp_ftrace_handler(unsigned long ip,
|
|||
if (func->nop)
|
||||
goto unlock;
|
||||
|
||||
klp_arch_set_pc(regs, (unsigned long)func->new_func);
|
||||
klp_arch_set_pc(fregs, (unsigned long)func->new_func);
|
||||
|
||||
unlock:
|
||||
preempt_enable_notrace();
|
||||
|
|
@ -200,8 +199,10 @@ static int klp_patch_func(struct klp_func *func)
|
|||
return -ENOMEM;
|
||||
|
||||
ops->fops.func = klp_ftrace_handler;
|
||||
ops->fops.flags = FTRACE_OPS_FL_SAVE_REGS |
|
||||
FTRACE_OPS_FL_DYNAMIC |
|
||||
ops->fops.flags = FTRACE_OPS_FL_DYNAMIC |
|
||||
#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_WITH_ARGS
|
||||
FTRACE_OPS_FL_SAVE_REGS |
|
||||
#endif
|
||||
FTRACE_OPS_FL_IPMODIFY |
|
||||
FTRACE_OPS_FL_PERMANENT;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue