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]
Date:	Sun, 26 Jun 2016 11:21:01 +0000
From:	He Kuang <hekuang@...wei.com>
To:	<acme@...nel.org>, <peterz@...radead.org>, <mingo@...hat.com>,
	<jolsa@...hat.com>, <brendan.d.gregg@...il.com>, <ast@...nel.org>,
	<alexander.shishkin@...ux.intel.com>, <wangnan0@...wei.com>,
	<hekuang@...wei.com>
CC:	<linux-kernel@...r.kernel.org>
Subject: [RFC PATCH v2 09/26] perf bpf: Implement empty instruction handler and build bpf-vm

This patch includes the existing code in "kernel/bpf/vm.c", and uses
empty handlers for building the userspace version of bpf-vm
code. Userspace bpf programs won't deal with 'struct skb' data so an
empty bpf_load_pointer() is placed here to help save us from including
too much kernel structures and headers.

CFLAGS are modified for supressing warnings of the existing bpf code.

Signed-off-by: Wang Nan <wangnan0@...wei.com>
Signed-off-by: He Kuang <hekuang@...wei.com>
---
 tools/perf/util/Build    |  2 ++
 tools/perf/util/bpf-vm.c | 34 ++++++++++++++++++++++++++++++++++
 tools/perf/util/bpf-vm.h |  7 +++++++
 3 files changed, 43 insertions(+)
 create mode 100644 tools/perf/util/bpf-vm.c
 create mode 100644 tools/perf/util/bpf-vm.h

diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index fced833..1d24d94 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -90,6 +90,7 @@ libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
 libperf-$(CONFIG_LIBELF) += symbol-elf.o
 libperf-$(CONFIG_LIBELF) += probe-file.o
 libperf-$(CONFIG_LIBELF) += probe-event.o
+libperf-$(CONFIG_UBPF)   += bpf-vm.o
 
 ifndef CONFIG_LIBELF
 libperf-y += symbol-minimal.o
@@ -152,6 +153,7 @@ CFLAGS_rbtree.o        += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ET
 CFLAGS_libstring.o     += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_hweight.o       += -Wno-unused-parameter -DETC_PERFCONFIG="BUILD_STR($(ETC_PERFCONFIG_SQ))"
 CFLAGS_parse-events.o  += -Wno-redundant-decls
+CFLAGS_bpf-vm.o        += -Wno-override-init -Wno-switch-default -Wno-sign-compare
 
 $(OUTPUT)util/kallsyms.o: ../lib/symbol/kallsyms.c FORCE
 	$(call rule_mkdir)
diff --git a/tools/perf/util/bpf-vm.c b/tools/perf/util/bpf-vm.c
new file mode 100644
index 0000000..23ac784
--- /dev/null
+++ b/tools/perf/util/bpf-vm.c
@@ -0,0 +1,34 @@
+#include <linux/atomic.h>
+#include "util.h"
+#include "tools/be_byteshift.h"
+#include "bpf-vm.h"
+
+static inline void
+bpf_vm_jmp_call_handler(u64 *regs __maybe_unused, void *ctx __maybe_unused,
+			const struct bpf_insn *insn __maybe_unused) {}
+
+static inline int
+bpf_vm_jmp_tail_call_handler(u64 *regs __maybe_unused,
+			     u32 *p_tail_call_cnt __maybe_unused,
+			     const struct bpf_insn **p_insn __maybe_unused) {
+	return 0;
+}
+
+static inline void
+bpf_vm_default_label_handler(void *ctx __maybe_unused,
+			     const struct bpf_insn *insn __maybe_unused) {}
+
+/* instructions for dealing with socket data use this function,
+ * userspace bpf don't use it now so leave it blank here, which saves
+ * us from including too much kernel structures.
+ */
+static inline void *bpf_load_pointer(const void *skb __maybe_unused,
+				     int k __maybe_unused,
+				     unsigned int size __maybe_unused,
+				     void *buffer __maybe_unused)
+{
+	return NULL;
+}
+
+#define UBPF_BUILD
+#include <../../../kernel/bpf/vm.c>
diff --git a/tools/perf/util/bpf-vm.h b/tools/perf/util/bpf-vm.h
new file mode 100644
index 0000000..bf96caa
--- /dev/null
+++ b/tools/perf/util/bpf-vm.h
@@ -0,0 +1,7 @@
+#ifndef _BPF_VM_H
+#define _BPF_VM_H
+
+struct bpf_insn;
+unsigned int __bpf_prog_run(void *ctx, const struct bpf_insn *insn);
+
+#endif /* _BPF_VM_H */
-- 
1.8.5.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ