]> www.infradead.org Git - users/hch/misc.git/commitdiff
powerpc/ftrace: ensure ftrace record ops are always set for NOPs
authorJoe Lawrence <joe.lawrence@redhat.com>
Fri, 12 Sep 2025 14:27:38 +0000 (10:27 -0400)
committerMadhavan Srinivasan <maddy@linux.ibm.com>
Mon, 15 Sep 2025 11:10:52 +0000 (16:40 +0530)
When an ftrace call site is converted to a NOP, its corresponding
dyn_ftrace record should have its ftrace_ops pointer set to
ftrace_nop_ops.

Correct the powerpc implementation to ensure the
ftrace_rec_set_nop_ops() helper is called on all successful NOP
initialization paths. This ensures all ftrace records are consistent
before being handled by the ftrace core.

Fixes: eec37961a56a ("powerpc64/ftrace: Move ftrace sequence out of line")
Suggested-by: Naveen N Rao <naveen@kernel.org>
Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Acked-by: Naveen N Rao (AMD) <naveen@kernel.org>
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Link: https://patch.msgid.link/20250912142740.3581368-2-joe.lawrence@redhat.com
arch/powerpc/kernel/trace/ftrace.c

index 6dca92d5a6e82208ffc8e0e8ef851681e37c3801..841d077e28251abdff3b08d095d52cb4a31916d5 100644 (file)
@@ -488,8 +488,10 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
                return ret;
 
        /* Set up out-of-line stub */
-       if (IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE))
-               return ftrace_init_ool_stub(mod, rec);
+       if (IS_ENABLED(CONFIG_PPC_FTRACE_OUT_OF_LINE)) {
+               ret = ftrace_init_ool_stub(mod, rec);
+               goto out;
+       }
 
        /* Nop-out the ftrace location */
        new = ppc_inst(PPC_RAW_NOP());
@@ -520,6 +522,10 @@ int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec)
                return -EINVAL;
        }
 
+out:
+       if (!ret)
+               ret = ftrace_rec_set_nop_ops(rec);
+
        return ret;
 }