[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20250116145751.717d370483a1764657dea8c9@kernel.org>
Date: Thu, 16 Jan 2025 14:57:51 +0900
From: Masami Hiramatsu (Google) <mhiramat@...nel.org>
To: Jiri Olsa <jolsa@...nel.org>
Cc: Steven Rostedt <rostedt@...dmis.org>, David Laight
<David.Laight@...LAB.COM>, Peter Zijlstra <peterz@...radead.org>, lkml
<linux-kernel@...r.kernel.org>, linux-trace-kernel@...r.kernel.org,
bpf@...r.kernel.org, x86@...nel.org
Subject: Re: [RFC] x86/alternatives: Merge first and second step in
text_poke_bp_batch
On Tue, 14 Jan 2025 15:02:37 +0100
Jiri Olsa <jolsa@...nel.org> wrote:
> hi,
> while checking on similar code for uprobes I was wondering if we
> can merge first 2 steps of instruction update in text_poke_bp_batch
> function.
>
> Basically the first step now would be to write int3 byte together
> with the rest of the bytes of the new instruction instead of doing
> that separately. And the second step would be to overwrite int3
> byte with first byte of the new instruction.
>
> Would that work or do I miss some x86 detail that could lead to crash?
I agree with Peterz and David. My original idea is that the putting
int3 is safe anyway because it is just 1 byte. Then we can update
following bytes (only after we ensure no one executing(e.g. interrupted)
that part). The another good point of int3 is that can avoid writing
over cache-line boundary because it is 1 byte.
Without this int3 detour, it is possible to see half-way updated
instruction from some other CPU cores :(
Thank you,
--
Masami Hiramatsu (Google) <mhiramat@...nel.org>
Powered by blists - more mailing lists