OSDN Git Service

Revert "powerpc: Add rethook support"
authorAlexei Starovoitov <ast@kernel.org>
Tue, 22 Mar 2022 04:40:49 +0000 (21:40 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 22 Mar 2022 18:09:13 +0000 (11:09 -0700)
This reverts commit 02752bd99dc2daae05c12f7063bf0632e22b4c1c.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/powerpc/Kconfig
arch/powerpc/kernel/Makefile
arch/powerpc/kernel/rethook.c [deleted file]

index 5feaa24..b779603 100644 (file)
@@ -229,7 +229,6 @@ config PPC
        select HAVE_PERF_EVENTS_NMI             if PPC64
        select HAVE_PERF_REGS
        select HAVE_PERF_USER_STACK_DUMP
-       select HAVE_RETHOOK                     if KPROBES
        select HAVE_REGS_AND_STACK_ACCESS_API
        select HAVE_RELIABLE_STACKTRACE
        select HAVE_RSEQ
index feb24ea..4d78293 100644 (file)
@@ -115,7 +115,6 @@ obj-$(CONFIG_SMP)           += smp.o
 obj-$(CONFIG_KPROBES)          += kprobes.o
 obj-$(CONFIG_OPTPROBES)                += optprobes.o optprobes_head.o
 obj-$(CONFIG_KPROBES_ON_FTRACE)        += kprobes-ftrace.o
-obj-$(CONFIG_RETHOOK)          += rethook.o
 obj-$(CONFIG_UPROBES)          += uprobes.o
 obj-$(CONFIG_PPC_UDBG_16550)   += legacy_serial.o udbg_16550.o
 obj-$(CONFIG_SWIOTLB)          += dma-swiotlb.o
diff --git a/arch/powerpc/kernel/rethook.c b/arch/powerpc/kernel/rethook.c
deleted file mode 100644 (file)
index a8a1287..0000000
+++ /dev/null
@@ -1,72 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-only
-/*
- * PowerPC implementation of rethook. This depends on kprobes.
- */
-
-#include <linux/kprobes.h>
-#include <linux/rethook.h>
-
-/*
- * Function return trampoline:
- *     - init_kprobes() establishes a probepoint here
- *     - When the probed function returns, this probe
- *             causes the handlers to fire
- */
-asm(".global arch_rethook_trampoline\n"
-       ".type arch_rethook_trampoline, @function\n"
-       "arch_rethook_trampoline:\n"
-       "nop\n"
-       "blr\n"
-       ".size arch_rethook_trampoline, .-arch_rethook_trampoline\n");
-
-/*
- * Called when the probe at kretprobe trampoline is hit
- */
-static int trampoline_rethook_handler(struct kprobe *p, struct pt_regs *regs)
-{
-       unsigned long orig_ret_address;
-
-       orig_ret_address = rethook_trampoline_handler(regs, 0);
-       /*
-        * We get here through one of two paths:
-        * 1. by taking a trap -> kprobe_handler() -> here
-        * 2. by optprobe branch -> optimized_callback() -> opt_pre_handler() -> here
-        *
-        * When going back through (1), we need regs->nip to be setup properly
-        * as it is used to determine the return address from the trap.
-        * For (2), since nip is not honoured with optprobes, we instead setup
-        * the link register properly so that the subsequent 'blr' in
-        * __kretprobe_trampoline jumps back to the right instruction.
-        *
-        * For nip, we should set the address to the previous instruction since
-        * we end up emulating it in kprobe_handler(), which increments the nip
-        * again.
-        */
-       regs_set_return_ip(regs, orig_ret_address - 4);
-       regs->link = orig_ret_address;
-
-       return 0;
-}
-NOKPROBE_SYMBOL(trampoline_rethook_handler);
-
-void arch_rethook_prepare(struct rethook_node *rh, struct pt_regs *regs, bool mcount)
-{
-       rh->ret_addr = regs->link;
-       rh->frame = 0;
-
-       /* Replace the return addr with trampoline addr */
-       regs->link = (unsigned long)arch_rethook_trampoline;
-}
-NOKPROBE_SYMBOL(arch_prepare_kretprobe);
-
-static struct kprobe trampoline_p = {
-       .addr = (kprobe_opcode_t *) &arch_rethook_trampoline,
-       .pre_handler = trampoline_rethook_handler
-};
-
-static int init_arch_rethook(void)
-{
-       return register_kprobe(&trampoline_p);
-}
-
-core_initcall(init_arch_rethook);