]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
s390/kprobes: Avoid stop machine if possible
authorVasily Gorbik <gor@linux.ibm.com>
Wed, 28 Aug 2024 17:06:52 +0000 (19:06 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 29 Aug 2024 20:56:34 +0000 (22:56 +0200)
Avoid stop machine on kprobes arm/disarm when sequential instruction
fetching is present.

Reviewed-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/kernel/kprobes.c

index 05c83505e9799011364c3d157c7de9095f8ceb7d..6295faf0987d86fcb20d5f2c2183bd0a0cb168c0 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/hardirq.h>
 #include <linux/ftrace.h>
 #include <linux/execmem.h>
+#include <asm/text-patching.h>
 #include <asm/set_memory.h>
 #include <asm/sections.h>
 #include <asm/dis.h>
@@ -152,7 +153,12 @@ void arch_arm_kprobe(struct kprobe *p)
 {
        struct swap_insn_args args = {.p = p, .arm_kprobe = 1};
 
-       stop_machine_cpuslocked(swap_instruction, &args, NULL);
+       if (MACHINE_HAS_SEQ_INSN) {
+               swap_instruction(&args);
+               text_poke_sync();
+       } else {
+               stop_machine_cpuslocked(swap_instruction, &args, NULL);
+       }
 }
 NOKPROBE_SYMBOL(arch_arm_kprobe);
 
@@ -160,7 +166,12 @@ void arch_disarm_kprobe(struct kprobe *p)
 {
        struct swap_insn_args args = {.p = p, .arm_kprobe = 0};
 
-       stop_machine_cpuslocked(swap_instruction, &args, NULL);
+       if (MACHINE_HAS_SEQ_INSN) {
+               swap_instruction(&args);
+               text_poke_sync();
+       } else {
+               stop_machine_cpuslocked(swap_instruction, &args, NULL);
+       }
 }
 NOKPROBE_SYMBOL(arch_disarm_kprobe);