From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Nadav Amit <nadav.amit@gmail.com>
Cc: x86@kernel.org, Borislav Petkov <bp@alien8.de>,
Peter Zijlstra <peterz@infradead.org>,
Steven Rostedt <rostedt@goodmis.org>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH -tip] kprobes/x86: Remove unneeded casting from immediate value
Date: Wed, 15 Feb 2023 08:57:14 +0900 [thread overview]
Message-ID: <20230215085714.8d46b98ce787a6e0c962ebf5@kernel.org> (raw)
In-Reply-To: <b79052ee-07d2-a6b9-03cb-b33f61985fe2@gmail.com>
On Fri, 10 Feb 2023 02:01:54 +0200
Nadav Amit <nadav.amit@gmail.com> wrote:
>
> On 2/9/23 5:36 PM, Masami Hiramatsu (Google) wrote:
> > From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> >
> > Remove unneeded casting from immediate value assignments for relative
> > jump offset. Since the immediate values in the 'insn' data structure are
> > assigned from immediate bytes as a signed value to insn.immediate.value
> > by insn_field_set(). Thus, if we need to access that value as a signed
> > value (in this kprobe's case), we don't need to cast it.
> > This is a kind of clean up (should not change behavior) follows Nadav's
> > bugfix.
> >
> > Link: https://lore.kernel.org/all/20230208071708.4048-1-namit@vmware.com/
> >
> > Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
> > ---
> > arch/x86/kernel/kprobes/core.c | 16 ++++++++--------
> > 1 file changed, 8 insertions(+), 8 deletions(-)
> >
> > diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
> > index 695873c0f50b..2440e736d0e4 100644
> > --- a/arch/x86/kernel/kprobes/core.c
> > +++ b/arch/x86/kernel/kprobes/core.c
> > @@ -607,19 +607,19 @@ static int prepare_emulation(struct kprobe *p, struct insn *insn)
> > case 0xe8: /* near call relative */
> > p->ainsn.emulate_op = kprobe_emulate_call;
> > if (insn->immediate.nbytes == 2)
> > - p->ainsn.rel32 = *(s16 *)&insn->immediate.value;
> > + p->ainsn.rel32 = insn->immediate.value;
> > else
> > - p->ainsn.rel32 = *(s32 *)&insn->immediate.value;
> > + p->ainsn.rel32 = insn->immediate.value;
>
> Hmm.. I don't get it. What the purpose of keeping the duplicated code
> (after your change)?
>
Oops, good catch! I think p->ainsn.rel32 can be set without any check in general.
Let me update it.
Thank you!
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
prev parent reply other threads:[~2023-02-14 23:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-09 15:36 [PATCH -tip] kprobes/x86: Remove unneeded casting from immediate value Masami Hiramatsu (Google)
2023-02-09 15:41 ` Peter Zijlstra
2023-02-10 0:01 ` Nadav Amit
2023-02-14 23: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=20230215085714.8d46b98ce787a6e0c962ebf5@kernel.org \
--to=mhiramat@kernel.org \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=nadav.amit@gmail.com \
--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