bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@kernel.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>, Ingo Molnar <mingo@kernel.org>
Cc: X86 ML <x86@kernel.org>, Masami Hiramatsu <mhiramat@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: [RFC PATCH -tip 1/3] x86/kprobes: Add ORC information to optprobe template
Date: Wed, 31 Mar 2021 14:44:34 +0900	[thread overview]
Message-ID: <161716947469.721514.10958896582230159703.stgit@devnote2> (raw)
In-Reply-To: <161716946413.721514.4057380464113663840.stgit@devnote2>

As same as kretprobe_trampoline, move the optprobe template
code in the text for making ORC information on that.

Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org>
---
 arch/x86/kernel/kprobes/opt.c |   18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
index 4299fc865732..6d26e5cf2ba2 100644
--- a/arch/x86/kernel/kprobes/opt.c
+++ b/arch/x86/kernel/kprobes/opt.c
@@ -100,9 +100,13 @@ static void synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
 	*(unsigned long *)addr = val;
 }
 
+static void
+optimized_callback(struct optimized_kprobe *op, struct pt_regs *regs);
+
 asm (
-			".pushsection .rodata\n"
+			".text\n"
 			"optprobe_template_func:\n"
+			".type optprobe_template_func, @function\n"
 			".global optprobe_template_entry\n"
 			"optprobe_template_entry:\n"
 #ifdef CONFIG_X86_64
@@ -120,7 +124,8 @@ asm (
 			ASM_NOP5
 			".global optprobe_template_call\n"
 			"optprobe_template_call:\n"
-			ASM_NOP5
+			/* Dummy call for ORC */
+			"	callq optimized_callback\n"
 			/* Move flags to rsp */
 			"	movq 18*8(%rsp), %rdx\n"
 			"	movq %rdx, 19*8(%rsp)\n"
@@ -141,7 +146,8 @@ asm (
 			ASM_NOP5
 			".global optprobe_template_call\n"
 			"optprobe_template_call:\n"
-			ASM_NOP5
+			/* Dummy call for ORC */
+			"	call optimized_callback\n"
 			/* Move flags into esp */
 			"	movl 14*4(%esp), %edx\n"
 			"	movl %edx, 15*4(%esp)\n"
@@ -152,10 +158,12 @@ asm (
 #endif
 			".global optprobe_template_end\n"
 			"optprobe_template_end:\n"
-			".popsection\n");
+			/* Dummy return for objtool */
+			"	ret\n"
+			".size optprobe_template_func, .-optprobe_template_func\n"
+);
 
 void optprobe_template_func(void);
-STACK_FRAME_NON_STANDARD(optprobe_template_func);
 
 #define TMPL_CLAC_IDX \
 	((long)optprobe_template_clac - (long)optprobe_template_entry)


  reply	other threads:[~2021-03-31  5:45 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 ` Masami Hiramatsu [this message]
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

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=161716947469.721514.10958896582230159703.stgit@devnote2 \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).