From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Jiri Olsa <jolsa@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
David Laight <David.Laight@ACULAB.COM>,
Peter Zijlstra <peterz@infradead.org>,
lkml <linux-kernel@vger.kernel.org>,
linux-trace-kernel@vger.kernel.org, bpf@vger.kernel.org,
x86@kernel.org
Subject: Re: [RFC] x86/alternatives: Merge first and second step in text_poke_bp_batch
Date: Thu, 16 Jan 2025 14:57:51 +0900 [thread overview]
Message-ID: <20250116145751.717d370483a1764657dea8c9@kernel.org> (raw)
In-Reply-To: <20250114140237.3506624-1-jolsa@kernel.org>
On Tue, 14 Jan 2025 15:02:37 +0100
Jiri Olsa <jolsa@kernel.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@kernel.org>
prev parent reply other threads:[~2025-01-16 5:57 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-14 14:02 [RFC] x86/alternatives: Merge first and second step in text_poke_bp_batch Jiri Olsa
2025-01-14 14:17 ` Peter Zijlstra
2025-01-14 14:31 ` Jiri Olsa
2025-01-14 15:36 ` Steven Rostedt
2025-01-15 18:26 ` Jiri Olsa
2025-01-14 14:38 ` David Laight
2025-01-16 11:48 ` Jiri Olsa
2025-01-16 5:57 ` Masami Hiramatsu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250116145751.717d370483a1764657dea8c9@kernel.org \
--to=mhiramat@kernel.org \
--cc=David.Laight@ACULAB.COM \
--cc=bpf@vger.kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox