From: Masami Hiramatsu <mhiramat@kernel.org>
To: Masami Hiramatsu <mhiramat@kernel.org>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>,
Ingo Molnar <mingo@kernel.org>, X86 ML <x86@kernel.org>,
Daniel Xu <dxu@dxuuu.xyz>,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
kuba@kernel.org, mingo@redhat.com, ast@kernel.org,
tglx@linutronix.de, kernel-team@fb.com, yhs@fb.com,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [RFC PATCH -tip 3/3] x86/kprobes,orc: Unwind optprobe trampoline correctly
Date: Thu, 1 Apr 2021 10:54:22 +0900 [thread overview]
Message-ID: <20210401105422.bc7953889a2e0aaf03201b92@kernel.org> (raw)
In-Reply-To: <161716949640.721514.14252504351086671126.stgit@devnote2>
On Wed, 31 Mar 2021 14:44:56 +0900
Masami Hiramatsu <mhiramat@kernel.org> wrote:
> +#ifdef CONFIG_UNWINDER_ORC
> +unsigned long recover_optprobe_trampoline(unsigned long addr, unsigned long *sp)
> +{
> + unsigned long offset, entry, probe_addr;
> + struct optimized_kprobe *op;
> + struct orc_entry *orc;
> +
> + entry = find_kprobe_optinsn_slot_entry(addr);
> + if (!entry)
> + return addr;
> +
> + offset = addr - entry;
> +
> + /* Decode arg1 and get the optprobe */
> + op = (void *)extract_set_arg1((void *)(entry + TMPL_MOVE_IDX));
> + if (!op)
> + return addr;
> +
> + probe_addr = (unsigned long)op->kp.addr;
> +
> + if (offset < TMPL_END_IDX) {
Maybe I should add a comment here.
/*
* Since this is on the trampoline code based on the template code,
* ORC information on the template code can be used for adjusting
* stack pointer. The template code may change the stack pointer to
* store pt_regs.
*/
> + orc = orc_find((unsigned long)optprobe_template_func + offset);
> + if (!orc || orc->sp_reg != ORC_REG_SP)
> + return addr;
> + /*
> + * Since optprobe trampoline doesn't push caller on the stack,
> + * need to decrement 1 stack entry size
> + */
> + *sp += orc->sp_offset - sizeof(long);
> + return probe_addr;
> + } else {
/*
* In this case, the address is on the instruction copied from probed
* address, and jump instruction. Here the stack pointer is exactly
* the same as the value where it was copied by the kprobes.
*/
> + return probe_addr + offset - TMPL_END_IDX;
> + }
> +}
> +#endif
> +
Thank you,
--
Masami Hiramatsu <mhiramat@kernel.org>
prev parent reply other threads:[~2021-04-01 1:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-31 5:44 [RFC PATCH -tip 0/3] x86/kprobes,orc: Fix ORC unwinder to unwind stack with optimized probe Masami Hiramatsu
2021-03-31 5:44 ` [RFC PATCH -tip 1/3] x86/kprobes: Add ORC information to optprobe template Masami Hiramatsu
2021-03-31 5:44 ` [RFC PATCH -tip 2/3] kprobes: Add functions to find instruction buffer entry address Masami Hiramatsu
2021-03-31 5:44 ` [RFC PATCH -tip 3/3] x86/kprobes,orc: Unwind optprobe trampoline correctly Masami Hiramatsu
2021-03-31 15:57 ` Josh Poimboeuf
2021-04-01 1:44 ` Masami Hiramatsu
2021-04-01 2:19 ` Masami Hiramatsu
2021-04-01 1:54 ` 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=20210401105422.bc7953889a2e0aaf03201b92@kernel.org \
--to=mhiramat@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dxu@dxuuu.xyz \
--cc=jpoimboe@redhat.com \
--cc=kernel-team@fb.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
--cc=yhs@fb.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.