aboutsummaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorPaul Chaignon <paul.chaignon@gmail.com>2023-11-27 16:31:21 +0100
committerAleksandr Nogikh <nogikh@google.com>2023-11-27 17:13:18 +0000
commite60264f30163b15b659d0c84a6a4c8e7edb7a0a3 (patch)
tree967c9c5bfcaf92cbac8447c1d8586e4425392f08 /sys
parent2fae018f887235bab9f683c782e2e9a93c8d3766 (diff)
sys/linux: add all format specifiers for bpf_trace_printk
The bpf_trace_printk helper supports a limited set of format specifiers [1]. This commit ensures they are all covered in the union. 1 - https://man7.org/linux/man-pages/man7/bpf-helpers.7.html Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Diffstat (limited to 'sys')
-rw-r--r--sys/linux/bpf.txt20
-rw-r--r--sys/linux/test/bpf_helpers2
2 files changed, 17 insertions, 5 deletions
diff --git a/sys/linux/bpf.txt b/sys/linux/bpf.txt
index a972af32d..9a6c4f498 100644
--- a/sys/linux/bpf.txt
+++ b/sys/linux/bpf.txt
@@ -700,11 +700,23 @@ type bpf_insn_null_check[REG] {
exit bpf_insn_exit
}
+# Format specifiers for bpf_trace_printk, encoded as a zero-terminated string
+# of 7 characters. For example, field 'p' corresponds to "%p ".
type bpf_insn_mov_printk_str_hex[DST] [
-# "%p "
- integer bpf_insn_mov_imm64[DST, 0x25702020, 0x20202000]
-# "%d "
- pointer bpf_insn_mov_imm64[DST, 0x25642020, 0x20202000]
+ p bpf_insn_mov_imm64[DST, 0x25702020, 0x20202000]
+ d bpf_insn_mov_imm64[DST, 0x25642020, 0x20202000]
+ i bpf_insn_mov_imm64[DST, 0x25692020, 0x20202000]
+ u bpf_insn_mov_imm64[DST, 0x25752020, 0x20202000]
+ x bpf_insn_mov_imm64[DST, 0x25782020, 0x20202000]
+ ld bpf_insn_mov_imm64[DST, 0x256c6420, 0x20202000]
+ li bpf_insn_mov_imm64[DST, 0x256c6920, 0x20202000]
+ lu bpf_insn_mov_imm64[DST, 0x256c7520, 0x20202000]
+ lx bpf_insn_mov_imm64[DST, 0x256c7820, 0x20202000]
+ lld bpf_insn_mov_imm64[DST, 0x256c6c64, 0x20202000]
+ lli bpf_insn_mov_imm64[DST, 0x256c6c69, 0x20202000]
+ llu bpf_insn_mov_imm64[DST, 0x256c6c75, 0x20202000]
+ llx bpf_insn_mov_imm64[DST, 0x256c6c78, 0x20202000]
+ s bpf_insn_mov_imm64[DST, 0x25732020, 0x20202000]
]
# (18) r1 = "%d "
diff --git a/sys/linux/test/bpf_helpers b/sys/linux/test/bpf_helpers
index c486dcdb4..e1f994afa 100644
--- a/sys/linux/test/bpf_helpers
+++ b/sys/linux/test/bpf_helpers
@@ -1,6 +1,6 @@
# Load and execute a BPF program that simply calls bpf_trace_printk
-r1 = bpf$PROG_LOAD(AUTO, &AUTO={0x3, AUTO, &AUTO=@framed={{AUTO, AUTO, AUTO, AUTO, 0x0, AUTO, AUTO, AUTO, 0x0}, [@printk={@integer=AUTO, AUTO, AUTO, AUTO, AUTO, {AUTO, AUTO, AUTO, AUTO, AUTO, AUTO, 0x1234}, AUTO}], AUTO}, &AUTO='GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 0xa0)
+r1 = bpf$PROG_LOAD(AUTO, &AUTO={0x3, AUTO, &AUTO=@framed={{AUTO, AUTO, AUTO, AUTO, 0x0, AUTO, AUTO, AUTO, 0x0}, [@printk={@d=AUTO, AUTO, AUTO, AUTO, AUTO, {AUTO, AUTO, AUTO, AUTO, AUTO, AUTO, 0x1234}, AUTO}], AUTO}, &AUTO='GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, "00000000000000000000000000000000", 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}, 0xa0)
r2 = bpf$BPF_PROG_TEST_RUN(AUTO, &AUTO={r1, AUTO, 0x10, 0x10, &AUTO="0000000000000000", &AUTO="0000000000000000", 0x1, AUTO, 0x0, 0x0, 0x0, 0x0, 0x0, AUTO, 0x0}, 0x4c)