From: Anton Arapov <anton@redhat.com>
To: Oleg Nesterov <oleg@redhat.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Josh Stone <jistone@redhat.com>, Frank Eigler <fche@redhat.com>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@elte.hu>,
Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
Anton Arapov <anton@redhat.com>
Subject: [RFC PATCH v2 2/4] uretprobes: trampoline implementation
Date: Wed, 9 Jan 2013 12:24:50 +0100 [thread overview]
Message-ID: <1357730692-3928-3-git-send-email-anton@redhat.com> (raw)
In-Reply-To: <1357730692-3928-1-git-send-email-anton@redhat.com>
The first time a uprobe with return consumer is hit for a process, a
trampoline slot is obtained in the xol_area and initialized with a
breakpoint instruction. This slot is subsequently used by all
uretprobes.
todo:
unify with xol_take_insn_slot()
Signed-off-by: Anton Arapov <anton@redhat.com>
---
include/linux/uprobes.h | 1 +
kernel/events/uprobes.c | 33 +++++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/include/linux/uprobes.h b/include/linux/uprobes.h
index 95d0002..bddfad6 100644
--- a/include/linux/uprobes.h
+++ b/include/linux/uprobes.h
@@ -91,6 +91,7 @@ struct xol_area {
* the vma go away, and we must handle that reasonably gracefully.
*/
unsigned long vaddr; /* Page(s) of instruction slots */
+ unsigned long rp_trampoline_vaddr; /* address of trampolines */
};
struct uprobes_state {
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
index 473db3f..0ad2ac3 100644
--- a/kernel/events/uprobes.c
+++ b/kernel/events/uprobes.c
@@ -1208,6 +1208,39 @@ static unsigned long xol_get_insn_slot(struct uprobe *uprobe)
return xol_vaddr;
}
+/*
+ * xol_get_trampoline_slot - A trampoline slot is obtained the first
+ * time a uprobe with return consumer is hit for a process. Use one
+ * trampoline slot for all probes pertaining to a process, i.e.
+ * one per xol_area.
+ */
+static unsigned long xol_get_trampoline_slot(void)
+{
+ struct xol_area *area;
+ unsigned long offset;
+ uprobe_opcode_t bp_insn = UPROBE_SWBP_INSN;
+ void *vaddr;
+
+ area = get_xol_area();
+ if (!area)
+ return 0;
+
+ if (!area->rp_trampoline_vaddr)
+ area->rp_trampoline_vaddr = xol_take_insn_slot(area);
+
+ if (unlikely(!area->rp_trampoline_vaddr))
+ return 0;
+
+ offset = area->rp_trampoline_vaddr & ~PAGE_MASK;
+ vaddr = kmap_atomic(area->page);
+ memcpy(vaddr + offset, &bp_insn, UPROBE_SWBP_INSN_SIZE);
+ kunmap_atomic(vaddr);
+
+ flush_dcache_page(area->page);
+
+ return area->rp_trampoline_vaddr;
+}
+
/*
* xol_free_insn_slot - If slot was earlier allocated by
* @xol_get_insn_slot(), make the slot available for
--
1.8.0.2
next prev parent reply other threads:[~2013-01-09 11:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-09 11:24 [RFC PATCH v2 0/4] uprobes: return probe implementation Anton Arapov
2013-01-09 11:24 ` [RFC PATCH v2 1/4] uretprobes/x86: hijack return address Anton Arapov
2013-01-09 11:24 ` Anton Arapov [this message]
2013-01-09 16:13 ` [RFC PATCH v2 2/4] uretprobes: trampoline implementation Oleg Nesterov
2013-01-09 11:24 ` [RFC PATCH v2 3/4] uretprobes: return probe entry, prepare uretprobe Anton Arapov
2013-01-09 16:17 ` Oleg Nesterov
2013-01-10 11:44 ` Anton Arapov
2013-01-09 11:24 ` [RFC PATCH v2 4/4] uretprobes: invoke return probe handlers Anton Arapov
2013-01-09 16:28 ` Oleg Nesterov
2013-01-10 11:42 ` Anton Arapov
2013-01-09 16:12 ` [RFC PATCH v2 0/4] uprobes: return probe implementation Oleg Nesterov
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=1357730692-3928-3-git-send-email-anton@redhat.com \
--to=anton@redhat.com \
--cc=ananth@in.ibm.com \
--cc=fche@redhat.com \
--cc=jistone@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=oleg@redhat.com \
--cc=peterz@infradead.org \
--cc=srikar@linux.vnet.ibm.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).