Skip to content
/ linux Public
forked from torvalds/linux

Commit

Permalink
livepatch: Remove klp_arch_set_pc() and asm/livepatch.h
Browse files Browse the repository at this point in the history
All three versions of klp_arch_set_pc() do exactly the same: they
call ftrace_instruction_pointer_set().

Call ftrace_instruction_pointer_set() directly and remove
klp_arch_set_pc().

As klp_arch_set_pc() was the only thing remaining in asm/livepatch.h
on x86 and s390, remove asm/livepatch.h

livepatch.h remains on powerpc but its content is exclusively used
by powerpc specific code.

Signed-off-by: Christophe Leroy <[email protected]>
Acked-by: Petr Mladek <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Acked-by: Miroslav Benes <[email protected]>
Signed-off-by: Petr Mladek <[email protected]>
  • Loading branch information
chleroy authored and pmladek committed May 24, 2022
1 parent d111c9f commit 5d7c854
Show file tree
Hide file tree
Showing 8 changed files with 3 additions and 58 deletions.
2 changes: 0 additions & 2 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -11338,8 +11338,6 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/livepatching/livepatching.g
F: Documentation/ABI/testing/sysfs-kernel-livepatch
F: Documentation/livepatch/
F: arch/powerpc/include/asm/livepatch.h
F: arch/s390/include/asm/livepatch.h
F: arch/x86/include/asm/livepatch.h
F: include/linux/livepatch.h
F: kernel/livepatch/
F: lib/livepatch/
Expand Down
10 changes: 1 addition & 9 deletions arch/powerpc/include/asm/livepatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@
#ifndef _ASM_POWERPC_LIVEPATCH_H
#define _ASM_POWERPC_LIVEPATCH_H

#include <linux/module.h>
#include <linux/ftrace.h>
#include <linux/sched.h>
#include <linux/sched/task_stack.h>

#ifdef CONFIG_LIVEPATCH
static inline void klp_arch_set_pc(struct ftrace_regs *fregs, unsigned long ip)
{
ftrace_instruction_pointer_set(fregs, ip);
}
#endif /* CONFIG_LIVEPATCH */

#ifdef CONFIG_LIVEPATCH_64
static inline void klp_init_thread_info(struct task_struct *p)
{
Expand Down
1 change: 0 additions & 1 deletion arch/powerpc/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
#include <asm/machdep.h>
#include <asm/udbg.h>
#include <asm/smp.h>
#include <asm/livepatch.h>
#include <asm/hw_irq.h>
#include <asm/softirq_stack.h>

Expand Down
2 changes: 1 addition & 1 deletion arch/powerpc/kernel/setup_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#include <asm/udbg.h>
#include <asm/kexec.h>
#include <asm/code-patching.h>
#include <asm/livepatch.h>
#include <asm/ftrace.h>
#include <asm/opal.h>
#include <asm/cputhreads.h>
#include <asm/hw_irq.h>
Expand Down
22 changes: 0 additions & 22 deletions arch/s390/include/asm/livepatch.h

This file was deleted.

20 changes: 0 additions & 20 deletions arch/x86/include/asm/livepatch.h

This file was deleted.

2 changes: 0 additions & 2 deletions include/linux/livepatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

#if IS_ENABLED(CONFIG_LIVEPATCH)

#include <asm/livepatch.h>

/* task patch states */
#define KLP_UNDEFINED -1
#define KLP_UNPATCHED 0
Expand Down
2 changes: 1 addition & 1 deletion kernel/livepatch/patch.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static void notrace klp_ftrace_handler(unsigned long ip,
if (func->nop)
goto unlock;

klp_arch_set_pc(fregs, (unsigned long)func->new_func);
ftrace_instruction_pointer_set(fregs, (unsigned long)func->new_func);

unlock:
ftrace_test_recursion_unlock(bit);
Expand Down

0 comments on commit 5d7c854

Please sign in to comment.