Indirect calls in BPF

Anton Protopopov kicked off the BPF track on the second day of the 2025 Linux Storage, Filesystem, Memory-Management, and BPF Summit with a discussion about permitting indirect calls in BPF. He also spoke about his continuing work on static keys, a topic which is related because the implementation of indirect jumps and static keys in the verifier use some of the same mechanisms for tracking indirect control-flow. Although some design work remains to be done, it may soon be possible to make indirect calls in BPF without any extra work compared to normal C.

Anton Protopopov 在 2025 年 Linux 存储、文件系统、内存管理与 BPF 峰会的第二天开启了 BPF 专场议程,讨论了在 BPF 中允许使用间接调用的问题。他还谈到了自己正在进行的有关静态键(static key)的工作。由于间接跳转和静态键在 BPF 验证器中的实现都使用了类似的间接控制流跟踪机制,因此这是一个相关的话题。尽管仍有部分设计工作尚未完成,但未来在 BPF 中进行间接调用可能不再比普通 C 程序多出额外工作。

BPF has actually had preliminary support for indirect calls for a long time, Protopopov said. LLVM's BPF backend has supported emitting indirect-jump instructions since 2017. Tools such as libbpf, objdump, and bpftool are also all set up to handle indirect calls correctly. The only obstacle to using indirect function calls was support for them in the verifier — but he was able to fix that with a reasonably compact patch. He didn't share the whole patch, because it is not yet complete, but at a minimum it depends on his existing patch set that introduces a new type of BPF map called an instruction set.

Protopopov 表示,实际上 BPF 早已有初步的间接调用支持。自 2017 年起,LLVM 的 BPF 后端就可以生成间接跳转指令。像 libbpf、objdump 和 bpftool 这些工具也都已经能够正确处理间接调用。唯一的障碍是验证器对间接函数调用缺乏支持——但他已经通过一个相对简洁的补丁解决了这个问题。他并未公开整个补丁,因为它尚未完成,不过它至少依赖于他现有的一个补丁集,该补丁集引入了一种新的 BPF 映射类型,称为指令集(instruction set)。

Supporting indirect calls lets users of BPF write some programs in a more straightforward way. Protopopov shared the example of a reverse-polish-notation calculator that used function pointers to represent operations. That demonstrated that his change allows the verifier to understand function pointers assigned to a single variable, but there's still more work to

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

mounter625

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值