lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1432456091-73384-13-git-send-email-hekuang@huawei.com>
Date:	Sun, 24 May 2015 08:28:08 +0000
From:	He Kuang <hekuang@...wei.com>
To:	<wangnan0@...wei.com>, <paulus@...ba.org>,
	<a.p.zijlstra@...llo.nl>, <mingo@...hat.com>, <acme@...nel.org>,
	<namhyung@...nel.org>, <jolsa@...nel.org>, <ast@...mgrid.com>,
	<masami.hiramatsu.pt@...achi.com>, <dsahern@...il.com>,
	<brendan.d.gregg@...il.com>, <daniel@...earbox.net>
CC:	<lizefan@...wei.com>, <linux-kernel@...r.kernel.org>
Subject: [RFC PATCH v2 12/15] perf bpf: Generate bpf prologue without debuginfo

When probing at function entry, fallback to generate bpf prologue by
calling args if '$param' is the only args and no debuginfo is provided.

Signed-off-by: He Kuang <hekuang@...wei.com>
---
 tools/perf/util/probe-event.c | 54 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index ccbf4d9..0de5879 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -46,6 +46,7 @@
 #include "probe-event.h"
 #include "probe-finder.h"
 #include "session.h"
+#include <bpf/libbpf.h>
 #include <dwarf-regs.h>
 
 #define MAX_CMDLEN 256
@@ -287,6 +288,45 @@ static void clear_probe_trace_events(struct probe_trace_event *tevs, int ntevs)
 		clear_probe_trace_event(tevs + i);
 }
 
+static int convert_parameters_to_bpf_prologue(char *new_prog, int *new_len)
+{
+	char *new_insn = new_prog;
+	int i;
+	int offset;
+
+	/* Find each argument */
+	for (i = 0; i < BPF_PROLOGUE_NRARGS_MAX; i++) {
+		offset = get_arch_calling_reg_offset(i);
+		if (offset < 0)
+			break;
+
+		new_insn += bpf_prologue_formal_parameters(
+			new_prog ? new_insn : NULL,
+			offset, i);
+	}
+	*new_len = new_insn - new_prog;
+
+	return 0;
+}
+
+static int get_bpf_prologue_default(char **result, int *count)
+{
+	char *new_prog;
+
+	convert_parameters_to_bpf_prologue(NULL, count);
+	if (*count == 0)
+		return 0;
+
+	new_prog = malloc(*count);
+	if (!new_prog)
+		return -ENOMEM;
+
+	convert_parameters_to_bpf_prologue(new_prog, count);
+	*result = (char *)new_prog;
+
+	return 0;
+}
+
 static bool perf_probe_is_function_entry(struct perf_probe_event *pev)
 {
 	if (pev->point.file || pev->point.line || pev->point.lazy_line)
@@ -931,7 +971,13 @@ int get_bpf_prologue(struct perf_probe_event *pev, char **result, int *count)
 	if (!dinfo) {
 		if (need_dwarf)
 			return -ENOENT;
-		pr_debug("Could not open debuginfo. Try to use symbols.\n");
+		pr_debug("Could not open debuginfo. Generate default prologue.\n");
+
+		if (perf_probe_is_function_entry(pev) &&
+			pev->nargs == 1 &&
+			!strcmp(pev->args[0].var, "$params"))
+			return get_bpf_prologue_default(result, count);
+
 		return 0;
 	}
 
@@ -943,6 +989,12 @@ int get_bpf_prologue(struct perf_probe_event *pev, char **result, int *count)
 }
 #else	/* !HAVE_DWARF_SUPPORT */
 
+int get_bpf_prologue(struct perf_probe_event *pev __maybe_unused,
+		char **result, int *count)
+{
+	return -ENOTSUP;
+}
+
 static int
 find_perf_probe_point_from_dwarf(struct probe_trace_point *tp __maybe_unused,
 				 struct perf_probe_point *pp __maybe_unused,
-- 
1.8.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ