From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: daniel@iogearbox.net, alexei.starovoitov@gmail.com
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
Jiong Wang <jiong.wang@netronome.com>
Subject: [RFC bpf-next 2/2] tools: bpftool: improve architecture detection by using offload arch info
Date: Fri, 12 Jan 2018 14:06:24 -0800 [thread overview]
Message-ID: <20180112220624.14424-2-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180112220624.14424-1-jakub.kicinski@netronome.com>
From: Jiong Wang <jiong.wang@netronome.com>
The current architecture detection method in bpftool is designed for host
case.
For offload case, we can't use the architecture of "bpftool" itself. We
use the new arch name field in bpf_prog_info and use bfd_scan_arch to
return the correct bfd arch.
Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
---
tools/bpf/bpftool/jit_disasm.c | 16 +++++++++++++++-
tools/bpf/bpftool/main.h | 3 ++-
tools/bpf/bpftool/prog.c | 7 ++++++-
3 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/tools/bpf/bpftool/jit_disasm.c b/tools/bpf/bpftool/jit_disasm.c
index 57d32e8a1391..a54fc0695a50 100644
--- a/tools/bpf/bpftool/jit_disasm.c
+++ b/tools/bpf/bpftool/jit_disasm.c
@@ -76,7 +76,8 @@ static int fprintf_json(void *out, const char *fmt, ...)
return 0;
}
-void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes)
+void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes,
+ char *arch)
{
disassembler_ftype disassemble;
struct disassemble_info info;
@@ -100,6 +101,19 @@ void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes)
else
init_disassemble_info(&info, stdout,
(fprintf_ftype) fprintf);
+
+ /* Update architecture info for offload. */
+ if (arch) {
+ const bfd_arch_info_type *inf = bfd_scan_arch(arch);
+
+ if (inf) {
+ bfdf->arch_info = inf;
+ } else {
+ p_err("No libfd support for %s", arch);
+ return;
+ }
+ }
+
info.arch = bfd_get_arch(bfdf);
info.mach = bfd_get_mach(bfdf);
info.buffer = image;
diff --git a/tools/bpf/bpftool/main.h b/tools/bpf/bpftool/main.h
index 65b526fe6e7e..0c2898a68340 100644
--- a/tools/bpf/bpftool/main.h
+++ b/tools/bpf/bpftool/main.h
@@ -121,7 +121,8 @@ int do_cgroup(int argc, char **arg);
int prog_parse_fd(int *argc, char ***argv);
-void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes);
+void disasm_print_insn(unsigned char *image, ssize_t len, int opcodes,
+ char *arch);
void print_hex_data_json(uint8_t *data, size_t len);
#endif
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index c6a28be4665c..97c2649f71f8 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -775,7 +775,12 @@ static int do_dump(int argc, char **argv)
}
} else {
if (member_len == &info.jited_prog_len) {
- disasm_print_insn(buf, *member_len, opcodes);
+ if (info.ifindex)
+ disasm_print_insn(buf, *member_len, opcodes,
+ info.offload_arch_name);
+ else
+ disasm_print_insn(buf, *member_len, opcodes,
+ NULL);
} else {
kernel_syms_load(&dd);
if (json_output)
--
2.15.1
next prev parent reply other threads:[~2018-01-12 22:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-12 0:47 [RFC bpf-next] bpf: add new jited info fields in bpf_dev_offload and bpf_prog_info Jakub Kicinski
2018-01-12 2:17 ` Jakub Kicinski
2018-01-12 11:31 ` Daniel Borkmann
2018-01-12 22:06 ` [RFC bpf-next 1/2] nfp: bpf: set new jit info fields Jakub Kicinski
2018-01-12 22:06 ` Jakub Kicinski [this message]
2018-01-12 22:17 ` [RFC bpf-next] bpf: add new jited info fields in bpf_dev_offload and bpf_prog_info Jakub Kicinski
2018-01-15 12:27 ` Jiong Wang
2018-01-15 14:07 ` Daniel Borkmann
2018-01-15 17:13 ` Alexei Starovoitov
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=20180112220624.14424-2-jakub.kicinski@netronome.com \
--to=jakub.kicinski@netronome.com \
--cc=alexei.starovoitov@gmail.com \
--cc=daniel@iogearbox.net \
--cc=jiong.wang@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.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).