Re: [PATCH v3 3/7] riscv: ftrace: prepare ftrace for atomic code patching

Bagas Sanjaya
2024-12-06T23:35:33Z

[-- Attachment #1: Type: text/plain, Size: 1064 bytes --]

On Fri, Dec 06, 2024 at 11:02:29AM +0100, Björn Töpel wrote:
> Adding Robbin for input, who's doing much more crazy text patching in
> JVM, than what we do in the kernel. ;-)
>
> Let's say we're tracing "f". Previously w/ stop_machine() it was
> something like:
>
> f:
> 1: nop
> nop
> ...
> ...
>
> ftrace_caller:
> ...
> auipc a2, function_trace_op
> ld a2, function_trace_op(a2)
> ...
> 2: auipc ra, ftrace_stub
> jalr ftrace_stub(ra)
>
> The text was patched by ftrace in 1 and 2.
>
> ...and now:
> f:
> auipc t0, ftrace_caller
> A: nop
> ...
> ...
>
> ftrace_caller:
> ...
> auipc a2, function_trace_op
> ld a2, function_trace_op(a2)
> ...
> auipc ra, ftrace_call_dest
> ld ra, ftrace_call_dest(ra)
> jalr ra
>
> The text is only patched in A, and the tracer func is loaded via
> ftrace_call_dest.

Previously the operation was no-op, right?

Confused...

--
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]