|
|
Subscribe / Log in / New account

BPF in GCC

BPF in GCC

Posted Sep 16, 2020 6:50 UTC (Wed) by wahern (subscriber, #37304)
In reply to: BPF in GCC by dxin
Parent article: BPF in GCC

Classic BPF has fixed-width 64-bit instructions with a 16-bit opcode field: http://www.tcpdump.org/papers/bpf-usenix93.pdf (see also https://www.kernel.org/doc/html/latest/networking/filter....).

Linux eBPF instructions have only an 8-bit opcode field: https://www.kernel.org/doc/html/latest/networking/filter.... (see end of section, just before https://www.kernel.org/doc/html/latest/networking/filter....). IIUC, eBPF is mostly fixed-width 64-bit, excepting a 128-bit double-word (64-bit) load immediate instruction. Judging by the source code at include/linux/filter.h:BPF_LD_IMM64_RAW the bottom 64 bits would have an opcode of 0 (top 32 bits cleared) if decoded alone, so would have to be consumed as part of the whole. As opposed to two well-formed instructions that implicitly fuse, e.g. left shift of and bitwise OR into a 64-bit register of a 32-bit immediate that could be executed serially to load a 64-bit value. (I don't do assembly programming so probably not using correct jargon.)


to post comments


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds