diff --git a/study/kernel/00-DESCRIPTION/BPF.md b/study/kernel/00-DESCRIPTION/BPF.md
index edc06d7..53ca296 100644
--- a/study/kernel/00-DESCRIPTION/BPF.md
+++ b/study/kernel/00-DESCRIPTION/BPF.md
@@ -15,24 +15,24 @@ blogexcerpt: 虚拟化 & KVM 子系统
-本作品采用知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可, 转载请注明出处, 谢谢合作
+本作品采用 知识共享署名 - 非商业性使用 - 相同方式共享 4.0 国际许可协议 进行许可, 转载请注明出处, 谢谢合作
-
+
因本人技术水平和知识面有限, 内容如有纰漏或者需要修正的地方, 欢迎大家指正, 鄙人在此谢谢啦
-**转载请务必注明出处, 谢谢, 不胜感激**
+** 转载请务必注明出处, 谢谢, 不胜感激 **
| 日期 | 作者 | GitHub| CSDN | BLOG |
| ------- |:-------:|:-------:|:-------:|:-------:|
-| 2021-02-15 | [成坚-gatieme](https://kernel.blog.csdn.net) | [`AderXCoding/system/tools/fzf`](https://github.com/gatieme/AderXCoding/tree/master/system/tools/fzf) | [使用模糊搜索神器 FZF 来提升办公体验](https://blog.csdn.net/gatieme/article/details/113828826) | [Using FZF to Improve Productivit](https://oskernellab.com/2021/02/15/2021/0215-0001-Using_FZF_to_Improve_Productivity)|
+| 2021-02-15 | [成坚 - gatieme](https://kernel.blog.csdn.net) | [`AderXCoding/system/tools/fzf`](https://github.com/gatieme/AderXCoding/tree/master/system/tools/fzf) | [使用模糊搜索神器 FZF 来提升办公体验](https://blog.csdn.net/gatieme/article/details/113828826) | [Using FZF to Improve Productivit](https://oskernellab.com/2021/02/15/2021/0215-0001-Using_FZF_to_Improve_Productivity)|
-2 **BPF 系统**
+2 **BPF 系统 **
=====================
@@ -44,7 +44,7 @@ blogexcerpt: 虚拟化 & KVM 子系统
-下文将按此目录分析 Linux 内核中 MM 的重要功能和引入版本:
+下文将按此目录分析 Linux 内核中 eBPF 的重要功能和引入版本:
@@ -58,9 +58,9 @@ blogexcerpt: 虚拟化 & KVM 子系统
[eBPF kernel-versions.md](https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md)
-[BPF的可移植性和CO-RE (Compile Once – Run Everywhere)](https://www.cnblogs.com/charlieroro/p/14206214.html)
+[BPF 的可移植性和 CO-RE (Compile Once – Run Everywhere)](https://www.cnblogs.com/charlieroro/p/14206214.html)
-[BCC和libbpf的转换](https://www.cnblogs.com/charlieroro/p/14244276.html)
+[BCC 和 libbpf 的转换](https://www.cnblogs.com/charlieroro/p/14244276.html)
[Libbpf-tools —— 让 Tracing 工具身轻如燕](https://blog.csdn.net/TiDB_PingCAP/article/details/107953554)
@@ -68,7 +68,7 @@ blogexcerpt: 虚拟化 & KVM 子系统
[使用 bpftrace 分析内核](https://developer.aliyun.com/article/741492)
-[狄卫华--eBPF 技术全面介绍 -- 历史、现在、未来(阅码场--直播回放)](https://shop.yomocode.com/live_pc/l_627e47efe4b0cedf38b1850f), 直播视频解读 [一文读懂 eBPF 的前世今生](https://mp.weixin.qq.com/s/ww510TUdLG8jd6VzfQnjxw)
+[狄卫华 --eBPF 技术全面介绍 -- 历史、现在、未来 (阅码场 -- 直播回放)](https://shop.yomocode.com/live_pc/l_627e47efe4b0cedf38b1850f), 直播视频解读 [一文读懂 eBPF 的前世今生](https://mp.weixin.qq.com/s/ww510TUdLG8jd6VzfQnjxw)
[bpftrace Cheat Sheet](https://www.brendangregg.com/BPF/bpftrace-cheat-sheet.html)
@@ -89,7 +89,7 @@ GCC 的支持 eBPF 经过了 3 个阶段.
2. 确保生成的程序能够被内核里的 BPF verifier 验证通过, 从而允许加载到内核中.
-3. 最后一个阶段是为 BPF 开发者提供额外工具. 除了编译器和汇编器(compiler and assembler)之外, 还需要调试器和模拟器(debuggers and simulators). 例如 BPF 的 simulator, 用来在 user space 运行, 可以通过 GDB 来调试 BPF program. BPF 就像是某种类型的嵌入式平台一样, 需要针对这种平台创建各种工具才能让普通开发者正常进行开发.
+3. 最后一个阶段是为 BPF 开发者提供额外工具. 除了编译器和汇编器 (compiler and assembler) 之外, 还需要调试器和模拟器 (debuggers and simulators). 例如 BPF 的 simulator, 用来在 user space 运行, 可以通过 GDB 来调试 BPF program. BPF 就像是某种类型的嵌入式平台一样, 需要针对这种平台创建各种工具才能让普通开发者正常进行开发.
| 日期 | LWN | 翻译 |
@@ -129,26 +129,26 @@ git log --oneline -- samples/bpf/bpf_load.c samples/bpf/bpf_load.h
### 2.2.2 libbpf
-------
-v4.3 的时候, 王楠为 perf 提供了加载和执行 eBPF 程序的能力, 引入了 `perf bpf` 命令和 `perf-bpf-record` 等子命令. 为了架构更解耦, 将常见的 eBPF 和 eBPF 对象操作放入工具 libbpf 中, 而不是 perf 本身. 其他程序, 如 iproute2, 也可以直接借助 libbpf 来完成自己的工作. libbpf 封装和隐藏了所有对 eBPF 的操作和数据结构, 而 `perf bpf` 则通过调用 libbpf 的 API 来处理 eBPF 程序和访问对象文件的数据.
+v4.3 的时候, HUAWEI 的王楠为 perf 提供了加载和执行 eBPF 程序的能力, 引入了 `perf bpf` 命令和 `perf-bpf-record` 等子命令. 为了架构更解耦, 将常见的 eBPF 和 eBPF 对象操作放入工具 libbpf 中, 而不是 perf 本身. 其他程序, 如 iproute2, 也可以直接借助 libbpf 来完成自己的工作. libbpf 封装和隐藏了所有对 eBPF 的操作和数据结构, 而 `perf bpf` 则通过调用 libbpf 的 API 来处理 eBPF 程序和访问对象文件的数据.
libbpf 将被编译为 libbpf.a 和 libbpf.so. 它可以分为两部分:
1. 用户内核接口. API 由 `bpf_xxx.h` 定义, 封装映射和程序加载操作. 在 bpf_load_program() 中, 为了提高性能, 它在第一次尝试时不使用日志缓冲区, 并在失败时启用日志缓冲区重试.
-2. ELF操作. 此处定义了 eBPF 对象文件的结构. 此部分的 API 可以在 `libbpf_xxx.h` 中找到.
+2. ELF 操作. 此处定义了 eBPF 对象文件的结构. 此部分的 API 可以在 `libbpf_xxx.h` 中找到.
struct bpf_object 是整个对象文件的处理程序.
structbpf_prog_handler 是程序的处理程序和迭代器. 一些访问者被定义为使调用者能够检索程序的节名和文件描述符. 可以附加更多的访问器.
-libpf 明确地将整个过程分为打开和加载阶段. 数据是在"打开"阶段收集的. 在"加载"阶段调用BPF系统调用.
+libpf 明确地将整个过程分为打开和加载阶段. 数据是在 "打开" 阶段收集的. 在 "加载" 阶段调用 BPF 系统调用.
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|:---:|:----:|:---:|:----:|:---------:|:----:|
-| 2015/07/01 | Wang Nan | [bpf tools: Introduce 'bpf' library and add bpf feature check](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=9a208effd1832e50e1f7ea002f400f8b9ca8b1ed) | perf 支持 eBPF 系列 [perf tools: filtering events using eBPF programs](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=9a208effd1832e50e1f7ea002f400f8b9ca8b1ed) 的[部分补丁](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=9a208effd1832e50e1f7ea002f400f8b9ca8b1ed), 引入了一个 libbpf 的用户态工具, 可用于加载 eBPF 程序. | v10 ☑✓ 4.3-rc1 | [LORE RFC,v1,00/22](https://lkml.org/lkml/2015/4/30/264)
*-*-*-*-*-*-*-*
[LORE v2,00/37](https://lore.kernel.org/all/1431676290-1230-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v3,00/37](https://lore.kernel.org/all/1431860222-61636-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v4,00/29](https://lore.kernel.org/all/1432704004-171454-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v5,00/30](https://lore.kernel.org/all/1433144296-74992-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v6,00/32](https://lore.kernel.org/all/1433829036-23687-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v7,00/37](https://lore.kernel.org/all/1434087345-127225-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v8,00/49](https://lore.kernel.org/all/1435149113-51142-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v10,0/50](https://lore.kernel.org/all/1435716878-189507-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v11,00/39](https://lore.kernel.org/all/1436361268-234530-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[PULL, 00/31](https://lore.kernel.org/all/1444826502-49291-1-git-send-email-wangnan0@huawei.com) |
+| 2015/07/01 | Wang Nan | [bpf tools: Introduce'bpf'library and add bpf feature check](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=9a208effd1832e50e1f7ea002f400f8b9ca8b1ed) | perf 支持 eBPF 系列 [perf tools: filtering events using eBPF programs](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=9a208effd1832e50e1f7ea002f400f8b9ca8b1ed) 的 [部分补丁](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=9a208effd1832e50e1f7ea002f400f8b9ca8b1ed), 引入了一个 libbpf 的用户态工具, 可用于加载 eBPF 程序. | v10 ☑✓ 4.3-rc1 | [LORE RFC,v1,00/22](https://lkml.org/lkml/2015/4/30/264)
*-*-*-*-*-*-*-*
[LORE v2,00/37](https://lore.kernel.org/all/1431676290-1230-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v3,00/37](https://lore.kernel.org/all/1431860222-61636-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v4,00/29](https://lore.kernel.org/all/1432704004-171454-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v5,00/30](https://lore.kernel.org/all/1433144296-74992-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v6,00/32](https://lore.kernel.org/all/1433829036-23687-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v7,00/37](https://lore.kernel.org/all/1434087345-127225-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v8,00/49](https://lore.kernel.org/all/1435149113-51142-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v10,0/50](https://lore.kernel.org/all/1435716878-189507-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[LORE v11,00/39](https://lore.kernel.org/all/1436361268-234530-1-git-send-email-wangnan0@huawei.com)
*-*-*-*-*-*-*-*
[PULL, 00/31](https://lore.kernel.org/all/1444826502-49291-1-git-send-email-wangnan0@huawei.com) |
| 2016/12/14 | Joe Stringer | [Reuse libbpf from samples/bpf](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=9899694a7f67714216665b87318eb367e2c5c901) | 内核主线中同时实现了两套 libbpf 的用户态库 libbpf(位于 `tools/lib/bpf`) 和 mini bpf lib(用于 samples 样例, 位于 `samples/bpf/libbpf.c`), 这是非常冗余的, 因此为 `tools/lib/bpf` 下的 libbpf 实现了 `samples/bpf` 所需的 bpf wrapper function, 从而使 samples 可以直接使用 libbpf. | v1 ☑✓ 4.10-rc1 | [LORE v1,0/5](https://lore.kernel.org/all/20161214224342.12858-1-joe@ovn.org) |
| 2018/05/14 | Jakub Kicinski | [samples: bpf: fix build after move to full libbpf](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=787360f8c2b87d4ae4858bb8736a19c289904885) | mini bpf lib 最终寿终正寝, 只包含了一个 `filter.h` 的 instruction helpers, 因此被重命名为 `bpf_insn.h`. | v2 ☐☑✓ | [LORE v2,0/5](https://lore.kernel.org/all/20180515053506.4345-1-jakub.kicinski@netronome.com) |
-| 2020/11/24 | Daniel T. Lee | [bpf: remove bpf_load loader completely](https://lore.kernel.org/all/20201124090310.24374-1-danieltimlee@gmail.com) | 将使用 bpf_load 编写的BPF程序重写为使用 libbpf 加载器. 使用 libbpf 重构剩余的 bpf 程序, 并完全删除 bpf_load 这个过时的 bpf 加载器, 它已经很难跟上最新的内核 bpf. | v3 ☐☑✓ | [LORE v3,0/7](https://lore.kernel.org/all/20201124090310.24374-1-danieltimlee@gmail.com) |
+| 2020/11/24 | Daniel T. Lee | [bpf: remove bpf_load loader completely](https://lore.kernel.org/all/20201124090310.24374-1-danieltimlee@gmail.com) | 将使用 bpf_load 编写的 BPF 程序重写为使用 libbpf 加载器. 使用 libbpf 重构剩余的 bpf 程序, 并完全删除 bpf_load 这个过时的 bpf 加载器, 它已经很难跟上最新的内核 bpf. | v3 ☐☑✓ | [LORE v3,0/7](https://lore.kernel.org/all/20201124090310.24374-1-danieltimlee@gmail.com) |
## 2.3 验证器
@@ -162,11 +162,63 @@ libpf 明确地将整个过程分为打开和加载阶段. 数据是在"打开"
## 2.5 JIT
-------
+
+[bcc/docs/kernel-versions.md--BPF Features by Linux Kernel Version](https://github.com/iovisor/bcc/blob/master/docs/kernel-versions.md)
+
+| 标记 | 描述 |
+|:---:|:---:|
+| HAVE_CBPF_JIT | 架构下是否实现了 classic BPF JIT, 参考 [Documentation/features/core/cBPF-JIT/arch-support.txt](https://www.kernel.org/doc/Documentation/features/core/cBPF-JIT/arch-support.txt) |
+| HAVE_EBPF_JIT | 架构下是否实现了 extended BPF JIT, 参考 [Documentation/features/core/eBPF-JIT/arch-support.txt](https://www.kernel.org/doc/Documentation/features/core/eBPF-JIT/arch-support.txt) |
+
+> 注意, 支持 eBPF JIT 的一定支持 cBPF JIT.
+
+| 架构 | cBPF | eBPF |
+|:---:|:-----:|:----:|
+| x86 | 3.0 | 3.16 |
+| ARM | 3.4-rc1 | 4.14 |
+| ARM64 | NA | 3.18 |
+| PPC32 | NA | 5.13 |
+| PPC64 | 3.1 | 4.8 |
+| sparc | 3.5 | 4.7 |
+| s390 | 3.7 | 4.1 |
+| MIPS | 3.16 | 5.16 |
+| RISC-V 32 | NA | 5.7 |
+| RISC-V 64 | NA | 5.1 |
+| LoongArch | NA | 6.1 |
+
+### 2.5.1 classic BPF JIT
+-------
+
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|:----:|:----:|:---:|:----:|:---------:|:----:|
-| 2011/04/03 | Eric Dumazet | [net: filter: Just In Time compiler](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0a14842f5a3c0e88a1e59fac5c3025db39721f74) | TODO | v2 ☐☑✓ 3.5-rc1 | [LORE](https://lore.kernel.org/all/1301838968.2837.200.camel@edumazet-laptop) |
-| 2011/04/03 | Eric Dumazet | [net: filter: Just In Time compiler for sparc](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2809a2087cc44b55e4377d7b9be3f7f5d2569091) | TODO | v2 ☐☑✓ 3.5-rc1 | [LORE](https://lore.kernel.org/all/1301838968.2837.200.camel@edumazet-laptop) |
-| 2014/07/08 | Zi Shen Lim | [arm64: eBPF JIT compiler](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=e54bcde3d69d40023ae77727213d14f920eb264a) | TODO | v1 ☑✓ 3.18-rc1 | [LORE](https://lore.kernel.org/all/1404803213-10653-1-git-send-email-zlim.lnx@gmail.com)
*-*-*-*-*-*-*-*
[LORE v2](https://lore.kernel.org/all/1495754003-21099-1-git-send-email-illusionist.neo@gmail.com)
*-*-*-*-*-*-*-*
[LORE 00/14](https://lore.kernel.org/all/1405708100-13604-1-git-send-email-zlim.lnx@gmail.com) |
+| 2011/04/03 | Eric Dumazet | [net: filter: Just In Time compiler](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0a14842f5a3c0e88a1e59fac5c3025db39721f74) | 为了加快数据包过滤, 为 x86_64 实现了 BPF 的 JIT 编译器, 通过 `/proc/sys/net/core/bpf_jit_enable` 开启. 引入了 HAVE_BPF_JIT, 并为 X86_64 做了标记. 参见 LWN 报道 [A JIT for packet filters](https://lwn.net/Articles/437981). | v2 ☐☑✓ 3.0-rc1 | [LORE](https://lore.kernel.org/all/1301838968.2837.200.camel@edumazet-laptop) |
+| 2012/07/20 | Matt Evans | [net: filter: BPF 'JIT' compiler for PPC64](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0ca87f05ba8bdc6791c14878464efc901ad71e99) | PPC64 上 BPF JIT 实现, 以加快 PPC64 上的数据包过滤, 其灵感来自 Eric Dumazet 的 x86-64 版本. | v1 ☐☑✓ 3.1-rc1 | [COMMIT](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=0ca87f05ba8bdc6791c14878464efc901ad71e99) |
+| 2012/04/15 | Eric Dumazet | [net: filter: Just In Time compiler for sparc](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2809a2087cc44b55e4377d7b9be3f7f5d2569091) | 为 sparc 架构实现 BPF JIT. | v2 ☐☑✓ 3.5-rc1 | [COMMIT](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=2809a2087cc44b55e4377d7b9be3f7f5d2569091) |
+| 2012/03/16 | Mircea Gherzan | [ARM: 7259/3: net: JIT compiler for packet filters](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ddecdfcea0ae891f782ae853771c867ab51024c2) | ARM 支持 BPF JIT. | v1 ☐☑✓ 3.4-rc1 | [LORE](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ddecdfcea0ae891f782ae853771c867ab51024c2) |
+| 2012/07/31 | Martin Schwidefsky | [s390/bpf,jit: BPF Just In Time compiler for s390](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c10302efe569bfd646b4c22df29577a4595b4580) | s390 架构的 BPF JIT 支持. | v1 ☐☑✓ 3.7-rc1 | [LORE](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=c10302efe569bfd646b4c22df29577a4595b4580) |
+| 2012/07/31 | Martin Schwidefsky | [MIPS: net: Add BPF JIT](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=3f5fdb4bd193091fd30db52c609c4b304151d656) | MIPS 架构的 BPF JIT 支持. | v1 ☐☑✓ 3.16-rc1 | [LORE](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=3f5fdb4bd193091fd30db52c609c4b304151d656) |
+
+
+### 2.5.2 extended BPF JIT
+-------
+
+| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
+|:----:|:----:|:---:|:----:|:---------:|:----:|
+| 2014/05/13 | Alexei Starovoitov | [seccomp: JIT compile seccomp filter](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8f577cadf7181243d336be9aba40c1bcc02c4c54) | x86_64 支持 eBPF JIT, 同时将 seccomp 转换为使用 eBPF 实现. | v1 ☑✓ 3.16-rc1 | [LORE v10,1/3](https://lore.kernel.org/all/1394660614-4436-1-git-send-email-ast@plumgrid.com) |
+| 2014/07/08 | Zi Shen Lim | [arm64: eBPF JIT compiler](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=e54bcde3d69d40023ae77727213d14f920eb264a) | ARM64 架构的 eBPF JIT. | v1 ☑✓ 3.18-rc1 | [LORE](https://lore.kernel.org/all/1404803213-10653-1-git-send-email-zlim.lnx@gmail.com)
*-*-*-*-*-*-*-*
[LORE v2](https://lore.kernel.org/all/1495754003-21099-1-git-send-email-illusionist.neo@gmail.com)
*-*-*-*-*-*-*-*
[LORE 00/14](https://lore.kernel.org/all/1405708100-13604-1-git-send-email-zlim.lnx@gmail.com) |
+| 2015/04/01 | Michael Holzheu | [s390/bpf: Add s390x eBPF JIT compiler backend](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=054623105728b06852f077299e2bf1bf3d5f2b0b) | s390 支持 eBPF JIT. | v1 ☐☑✓ 4.1-rc1 | [LORE](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=054623105728b06852f077299e2bf1bf3d5f2b0b) |
+| 2016/05/13 | Daniel Borkmann | [bpf: add generic constant blinding for use in jits](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=d93a47f735f3455a896e46b18d0ac26fa19639e6) | eBPF 增加了 "Constant blinding", 这个机制本质上会对 program 里面的常量值同一个随机数进行特定的 OR 操作, 这个操作在运行时每次用到这个常量值的时候都会进行一次, 可以避免攻击者把 BPF 代码假扮成常量值来进行攻击. 其中 [commit 6077776b5908 ("bpf: split HAVE_BPF_JIT into cBPF and eBPF variant")](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6077776b5908e0493a3946f7d3bc63871b201e87) 将原来 HAVE_BPF_JIT 细化成了 HAVE_CBPF_JIT 和 HAVE_EBPF_JIT. 而当前支持 eBPF JIT 的架构只有 x86_64, ARM64, s390, 只支持 cBPF JIT 的架构有 X86(_32), ARM, MIPS, POWERPC, sparc. | v1 ☐☑✓ 4.7-rc1 | [LORE v1,0/10](https://lore.kernel.org/all/cover.1463158442.git.daniel@iogearbox.net) |
+| 2018/05/03 | Wang YanQing | [bpf, x86_32: add eBPF JIT compiler for ia32](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=03f5781be2c7b7e728d724ac70ba10799cc710d7) | x86_32 支持 eBPF JIT. | v1 ☐☑✓ 4.18-rc1 | [LORE](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=03f5781be2c7b7e728d724ac70ba10799cc710d7) |
+| 2016/06/22 | Naveen N. Rao | [eBPF JIT for PPC64](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=156d0e290e969caba25f1851c52417c14d141b24) | PPC64 支持 eBPF JIT. | v2 ☐☑✓ 4.8-rc1 | [LORE v2,0/7](https://lore.kernel.org/all/cover.1466612260.git.naveen.n.rao@linux.vnet.ibm.com) |
+| 2017/08/22 | Shubham Bansal | [arm: eBPF JIT compiler](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=39c13c204bb1150d401e27d41a9d8b332be47c49) | ARM 支持 eBPF JIT. | v1 ☐☑✓ 4.14-rc1 | [LORE](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=39c13c204bb1150d401e27d41a9d8b332be47c49) |
+| 2019/02/05 | bjorn.topel@gmail.com | [Add RISC-V (RV64G) BPF JIT](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=e2c6f50e48849298bed694de03cceb537d95cdc4) | RISC-V 64 支持 eBPF JIT. | v2 ☐☑✓ 5.1-rc1 | [LORE v2,0/4](https://lore.kernel.org/all/20190205124125.5553-1-bjorn.topel@gmail.com) |
+| 2020/03/04 | Luke Nelson | [eBPF JIT for RV32G](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=dad737c926b5b286b9c91abbda66811a8a6618e9) | RISC-V 32 支持 eBPF JIT. | v5 ☐☑✓ 5.7-rc1 | [LORE v5,0/4](https://lore.kernel.org/all/20200305050207.4159-1-luke.r.nels@gmail.com) |
+| 2021/03/22 | Christophe Leroy | [Implement EBPF on powerpc32](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=40272035e1d0edcd515ad45be297c4cce044536d) | PPC32 架构的 eBPF JIT. | v2 ☐☑✓5.13-rc1 | [LORE v2,0/8](https://lore.kernel.org/all/cover.1616430991.git.christophe.leroy@csgroup.eu) |
+| 2021/10/05 | Tony Ambardar | [MIPS: eBPF: refactor code, add MIPS32 JIT](https://lore.kernel.org/all/cover.1633392335.git.Tony.Ambardar@gmail.com) | MIPS32 架构的 eBPF JIT | v2 ☐☑✓ |[LORE v2,0/16](https://lore.kernel.org/all/cover.1633392335.git.Tony.Ambardar@gmail.com) |
+| 2021/10/05 | Johan Almbladh | [A new eBPF JIT implementation for MIPS](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=ebcbacfa50ecd7a828f40fefbb58d641f265da0d) | 用于 MIPS I-V 和 MIPS32/64 r1-r6 的 eBPF JIT 的实现. 使用了与其他 eBPF JIT 相同的架构. | v1 ☐☑✓ 5.16-rc1 | [LORE v1,0/7](https://lore.kernel.org/all/20211005165408.2305108-1-johan.almbladh@anyfinetworks.com) |
+| 2020/06/29 | Tobias Klauser | [Factor common x86 JIT code](https://lore.kernel.org/all/20200629093336.20963-1-tklauser@distanz.ch) | TODO | v1 ☐☑✓ | [LORE v1,0/2](https://lore.kernel.org/all/20200629093336.20963-1-tklauser@distanz.ch) |
+| 2022/09/01 | Tiezhu Yang | [Add BPF JIT support for LoongArch](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=5dc615520c4dfb358245680f1904bad61116648e) | 龙芯支持 eBPF JIT. | v3 ☐☑✓ 6.1-rc1 | [LORE v3,0/4](https://lore.kernel.org/all/1661999249-10258-1-git-send-email-yangtiezhu@loongson.cn) |
+
# 3 BPF Core
-------
@@ -183,7 +235,7 @@ eBPF 已经是一个独立的模块了, 因此后来 3.18 直接将 eBPF 从 NET
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|:----:|:----:|:---:|:----:|:---------:|:----:|
| 2014/03/28 | Daniel Borkmann | [BPF updates](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=9a985cdc5ccb0d557720221d01bd70c19f04bb8c) | 支持 eBPF | v1 ☑✓ 3.15-rc1 | [LORE 0/9](https://lore.kernel.org/netdev/1395404418-25376-1-git-send-email-dborkman@redhat.com)
*-*-*-*-*-*-*-*
[LORE v2,0/9](https:/lhttps://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=99c55f7d47c0dc6fc64729f37bf435abf43f4c60ore.kernel.org/netdev/1395749457-16178-1-git-send-email-dborkman@redhat.com)
*-*-*-*-*-*-*-*
[LORE v3,0/9](https://lore.kernel.org/netdev/1395867970-1338-1-git-send-email-dborkman@redhat.com)
*-*-*-*-*-*-*-*
[LORE v4,0/9](https://lore.kernel.org/netdev/1396029506-16776-1-git-send-email-dborkman@redhat.com) |
-| 2014/09/04 | Alexei Starovoitov | [net: filter: add "load 64-bit immediate" eBPF instruction](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=daedfb22451dd02b35c0549566cbb7cc06bdd53b) | 添加 BPF_LD_IMM64 指令, 将 64 位立即数加载到寄存器中. | v1 ☑✓ 3.18-rc1 | [LORE 0/2](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=daedfb22451dd02b35c0549566cbb7cc06bdd53b) |
+| 2014/09/04 | Alexei Starovoitov | [net: filter: add"load 64-bit immediate"eBPF instruction](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=daedfb22451dd02b35c0549566cbb7cc06bdd53b) | 添加 BPF_LD_IMM64 指令, 将 64 位立即数加载到寄存器中. | v1 ☑✓ 3.18-rc1 | [LORE 0/2](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=daedfb22451dd02b35c0549566cbb7cc06bdd53b) |
| 2014/10/23 | Alexei Starovoitov | [bpf: split eBPF out of NET](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f89b7755f517cdbb755d7543eef986ee9d54e654) | TODO | v1 ☐☑✓ 3.18-rc3 | [LORE](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=f89b7755f517cdbb755d7543eef986ee9d54e654) |
随后 Alexei Starovoitov 实现了 v3.18 [BPF syscall, maps, verifier, samples, llvm](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=3c731eba48e1b0650decfc91a839b80f0e05ce8f). 这是一组比较大的补丁, 最终在 v3.18, v3.19 分批合入.
@@ -225,7 +277,7 @@ v3.19 支持了 MAP, [BPF maps](https://git.kernel.org/pub/scm/linux/kernel/git/
git grep -W 'bpf_prog_type {' include/uapi/linux/bpf.h
```
-[BPF 程序类型及其原理s](https://blog.csdn.net/weixin_41036447/article/details/107817340)
+[BPF 程序类型及其原理 s](https://blog.csdn.net/weixin_41036447/article/details/107817340)
### 3.3.1 SOCKET
-------
@@ -252,7 +304,7 @@ git grep -W 'bpf_prog_type {' include/uapi/linux/bpf.h
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|:----:|:----:|:---:|:----:|:---------:|:----:|
-| 2014/11/26 | Alexei Starovoitov | [allow eBPF programs to be attached to sockets](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=fbe3310840c65f3cf97dd90d23e177d061c376f2) | 引入可以通过 setsockopt() 附加到套接字的 BPF_PROG_TYPE_SOCKET_FILTER 类型的 eBPF 程序. 允许这些程序通过查找/更新/删除助手访问 MAPs. | v1 ☑✓ 3.19-rc1 | [LORE v1,0/6](https://lore.kernel.org/all/1417066951-1999-1-git-send-email-ast@plumgrid.com)
*-*-*-*-*-*-*-*
[LORE v2,0/6](https://lore.kernel.org/lkml/1417475199-15950-1-git-send-email-ast@plumgrid.com) |
+| 2014/11/26 | Alexei Starovoitov | [allow eBPF programs to be attached to sockets](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=fbe3310840c65f3cf97dd90d23e177d061c376f2) | 引入可以通过 setsockopt() 附加到套接字的 BPF_PROG_TYPE_SOCKET_FILTER 类型的 eBPF 程序. 允许这些程序通过查找 / 更新 / 删除助手访问 MAPs. | v1 ☑✓ 3.19-rc1 | [LORE v1,0/6](https://lore.kernel.org/all/1417066951-1999-1-git-send-email-ast@plumgrid.com)
*-*-*-*-*-*-*-*
[LORE v2,0/6](https://lore.kernel.org/lkml/1417475199-15950-1-git-send-email-ast@plumgrid.com) |
| 2016/11/23 | Daniel Mack | [Add eBPF hooks for cgroups](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=d8c5b17f2bc0de09fbbfa14d90e8168163a579e7) | eBPF 程序支持 attach 到 cgroup | v9 ☑✓ 4.10-rc1 | [LORE v9,0/6](https://lore.kernel.org/all/1479916350-28462-1-git-send-email-daniel@zonque.org) |
| 2016/12/01 | David Ahern | [net: Add bpf support for sockets](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=554ae6e792ef38020b80b4d5127c51d510c0918f) | eBPF 程序支持 attach 到 socket | v7 ☑✓ 4.10-rc1 | [LORE v7,0/6](https://lore.kernel.org/all/1480610888-31082-1-git-send-email-dsa@cumulusnetworks.com) |
| 2018/03/13 | Alexei Starovoitov | [bpf: introduce cgroup-bpf bind, connect, post-bind hooks](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=aac3fc320d9404f2665a8b1249dc3170d5fa3caf) | eBPF 程序支持 attach 到 syscal bind 和 conntect. | v1 ☑✓ 4.17-rc1 | [LORE v1,0/6](https://lore.kernel.org/all/20180314033934.3502167-1-ast@kernel.org)
*-*-*-*-*-*-*-*
[LORE v2,0/9](https://lore.kernel.org/netdev/20180328034140.291484-1-ast@kernel.org)
*-*-*-*-*-*-*-*
[LORE v3](https://lore.kernel.org/netdev/20180330220808.763556-1-ast@kernel.org) |
@@ -373,7 +425,7 @@ raw_tracepoint 相比 tracepoint
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|:----:|:----:|:---:|:----:|:---------:|:----:|
| 2018/03/01 | Jan H. Schönherr | [bpf: Support calling kernel function](https://patchwork.kernel.org/project/netdevbpf/cover/20210325015124.1543397-1-kafai@fb.com) | BPF 支持直接调用内核函数 | v2 ☑ 5.13-rc1 | [PatchWork v2,bpf-next,00/14](http://patches.linaro.org/cover/221148) |
-| 2021/08/30 | Kumar Kartikeya Dwivedi | [Support kernel module function calls from eBPF](https://patchwork.kernel.org/project/netdevbpf/cover/20210830173424.1385796-1-memxor@gmail.com) | 这组补丁允许 BPF 程序调用内核模块的函数, 并修改验证器逻辑以允许无效的内核函数调用, 只要它们作为死代码消除的一部分被修剪. 这样做是为了为 BPF 对象提供更好的运行时可移植性, 它可以有条件地禁用稍后被验证器修剪的部分代码(例如const volatile vars, kconfig选项). libbpf 的修改与内核的修改一起进行, 以支持模块函数调用.
+| 2021/08/30 | Kumar Kartikeya Dwivedi | [Support kernel module function calls from eBPF](https://patchwork.kernel.org/project/netdevbpf/cover/20210830173424.1385796-1-memxor@gmail.com) | 这组补丁允许 BPF 程序调用内核模块的函数, 并修改验证器逻辑以允许无效的内核函数调用, 只要它们作为死代码消除的一部分被修剪. 这样做是为了为 BPF 对象提供更好的运行时可移植性, 它可以有条件地禁用稍后被验证器修剪的部分代码 (例如 const volatile vars, kconfig 选项). libbpf 的修改与内核的修改一起进行, 以支持模块函数调用.
它还将 TCP 拥塞控制对象转换为使用模块 kfunc 支持, 而不是依赖于 IS_BUILTIN ifdef. | v1 ☐ | [PatchWork bpf-next,RFC,v1,0/8](https://patchwork.kernel.org/project/netdevbpf/cover/20210830173424.1385796-1-memxor@gmail.com) |
@@ -383,7 +435,7 @@ raw_tracepoint 相比 tracepoint
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|:----:|:----:|:---:|:----:|:---------:|:----:|
| 2018/03/01 | Jan H. Schönherr | [bpf: implement variadic printk helper](https://patchwork.kernel.org/project/netdevbpf/cover/20210913035609.160722-1-davemarchevsky@fb.com) | 这组补丁引入了一个新的接口 bpf_trace_vprintk(), 它的功能与 bpf_trace_printk() 类似, 但通过伪 vararg u64 的数组支持 > 3 个参数, 使用与 bpf_trace_printk() 相同的机制写入 `/sys/kernel/debug/tracing/trace_pipe`, 帮助程序的功能是在 libbpf 问题跟踪程序中请求的. libbpf 的 bpf_printk() 宏被修改为在传递 > 3 个变量时使用 bpf_trace_vprintk(), 否则保留之前的行为, 使用 bpf_trace_printk().
-在实现 bpf_seq_printf() 和 bpf_snprintf() 期间添加的 helper函数和宏为 bpf_trace_vprintk() 完成了大部分繁重的工作. 用例很简单: 为 BPF 开发人员提供一个更强大的 printk 将简化 BPF 程序的开发, 特别是在调试和测试期间, 这里往往使用 printk. 这个特性是由 [Andrii 在 libbpf 的 issue 中提出](https://github.com/libbpf/libbpf/issues/315)的. | v2 ☑ 5.13-rc1 | [PatchWork v5,bpf-next,0/9](https://patchwork.kernel.org/project/netdevbpf/cover/20210913035609.160722-1-davemarchevsky@fb.com) |
+在实现 bpf_seq_printf() 和 bpf_snprintf() 期间添加的 helper 函数和宏为 bpf_trace_vprintk() 完成了大部分繁重的工作. 用例很简单: 为 BPF 开发人员提供一个更强大的 printk 将简化 BPF 程序的开发, 特别是在调试和测试期间, 这里往往使用 printk. 这个特性是由 [Andrii 在 libbpf 的 issue 中提出](https://github.com/libbpf/libbpf/issues/315) 的. | v2 ☑ 5.13-rc1 | [PatchWork v5,bpf-next,0/9](https://patchwork.kernel.org/project/netdevbpf/cover/20210913035609.160722-1-davemarchevsky@fb.com) |
## 3.3 MAP
@@ -391,7 +443,7 @@ raw_tracepoint 相比 tracepoint
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|:----:|:----:|:---:|:----:|:---------:|:----:|
-| 2018/08/26 | Kumar Kartikeya Dwivedi | [Implement file local storage](https://patchwork.kernel.org/project/netdevbpf/cover/20210826133913.627361-1-memxor@gmail.com/) | 本系列实现了 eBPF LSM 程序的文件本地存储映射. 这允许将映射中数据的生存期与打开的文件描述联系起来. 与其他本地存储映射类型一样, 数据的生存期与结构文件实例相关联. 主要用途是:
1. 用于将与 eBPF 程序中打开的文件(而非 fd)关联的数据绑定在一起, 以便在文件消失时释放数据(例如, 检查点checkpoint/恢复用例restore usecase).
2. 使用eBPF LSM 在用户空间中实现[辣椒(Capsicum)风格的功能沙盒](https://www.usenix.org/legacy/event/sec10/tech/full_papers/Watson), 使用此机制在文件级别强制执行权限. | v2 ☐ | [PatchWork bpf-next,v2,0/5](https://patchwork.kernel.org/project/netdevbpf/cover/20210826133913.627361-1-memxor@gmail.com) |
+| 2018/08/26 | Kumar Kartikeya Dwivedi | [Implement file local storage](https://patchwork.kernel.org/project/netdevbpf/cover/20210826133913.627361-1-memxor@gmail.com/) | 本系列实现了 eBPF LSM 程序的文件本地存储映射. 这允许将映射中数据的生存期与打开的文件描述联系起来. 与其他本地存储映射类型一样, 数据的生存期与结构文件实例相关联. 主要用途是:
1. 用于将与 eBPF 程序中打开的文件 (而非 fd) 关联的数据绑定在一起, 以便在文件消失时释放数据 (例如, 检查点 checkpoint / 恢复用例 restore usecase).
2. 使用 eBPF LSM 在用户空间中实现 [辣椒 (Capsicum) 风格的功能沙盒](https://www.usenix.org/legacy/event/sec10/tech/full_papers/Watson), 使用此机制在文件级别强制执行权限. | v2 ☐ | [PatchWork bpf-next,v2,0/5](https://patchwork.kernel.org/project/netdevbpf/cover/20210826133913.627361-1-memxor@gmail.com) |
| 2022/04/08 | Song Liu | [vmalloc: bpf: introduce VM_ALLOW_HUGE_VMAP](https://patchwork.kernel.org/project/linux-mm/cover/20220408223443.3303509-1-song@kernel.org/) | 630581 | v1 ☐☑ | [LORE v1,0/2](https://lore.kernel.org/r/20220408223443.3303509-1-song@kernel.org) |
@@ -435,7 +487,7 @@ raw_tracepoint 相比 tracepoint
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|:----:|:----:|:---:|:----:|:---------:|:----:|
-| 2021/09/09 | Kumar Kartikeya Dwivedi | [bmc-cache](https://www.phoronix.com/scan.php?page=news_item&px=Orange-BPF-Memory-Cache-BMC) | 法国电信巨头奥兰治公司(Orange)已经发布了 "BMC", 作为 (e)BPF 内存缓存缓存, 提供了一个专注于 Linux 内核中模棱两两的用法的缓存. Orange 的开源 BPF 内存缓存允许在标准网络堆栈之前处理模组请求, 据说防撞安全, 并且此模块不需要其他内核模块. 此外, 模组用户空间软件本身可以在 BMC 上运行未经修改的软件. 这种内核 eBPF 缓存可将 Memcached 的吞吐量提高 18 倍, 而没有此内核缓存的夹层则提高了 18 倍. 参考 [GitHub](https://github.com/Orange-OpenSource/bmc-cache) | v2 ☐ | [github Orange-OpenSource/bmc-cache](https://github.com/Orange-OpenSource/bmc-cache) |
+| 2021/09/09 | Kumar Kartikeya Dwivedi | [bmc-cache](https://www.phoronix.com/scan.php?page=news_item&px=Orange-BPF-Memory-Cache-BMC) | 法国电信巨头奥兰治公司 (Orange) 已经发布了 "BMC", 作为 (e)BPF 内存缓存缓存, 提供了一个专注于 Linux 内核中模棱两两的用法的缓存. Orange 的开源 BPF 内存缓存允许在标准网络堆栈之前处理模组请求, 据说防撞安全, 并且此模块不需要其他内核模块. 此外, 模组用户空间软件本身可以在 BMC 上运行未经修改的软件. 这种内核 eBPF 缓存可将 Memcached 的吞吐量提高 18 倍, 而没有此内核缓存的夹层则提高了 18 倍. 参考 [GitHub](https://github.com/Orange-OpenSource/bmc-cache) | v2 ☐ | [github Orange-OpenSource/bmc-cache](https://github.com/Orange-OpenSource/bmc-cache) |
| 2021/09/15 | Roman Gushchin | [Scheduler BPF](https://www.phoronix.com/scan.php?page=news_item&px=Orange-BPF-Memory-Cache-BMC) | NA | RFC ☐ | [PatchWork rfc,0/6](https://lore.kernel.org/bpf/CA+khW7i460ey-UFzpMSJ8AP9QeD8ufa4FzLA4PQckNP00ShQSw@mail.gmail.com)
*-*-*-*-*-*-*-*
[LPC 2021](https://linuxplumbersconf.org/event/11/contributions/954)
*-*-*-*-*-*-*-*
[LKML](https://lkml.org/lkml/2021/9/16/1049), [LWN](https://lwn.net/Articles/869433) |
@@ -460,15 +512,15 @@ raw_tracepoint 相比 tracepoint
| 时间 | 作者 | 特性 | 描述 | 是否合入主线 | 链接 |
|:---:|:----:|:---:|:----:|:---------:|:----:|
| 2015/10/14 | Wang Nan | [perf tools: filtering events using eBPF programs](https://lore.kernel.org/all/1444826502-49291-1-git-send-email-wangnan0@huawei.com) | TODO | v1 ☐☑✓ | [LORE v1,0/31](https://lore.kernel.org/all/1444826502-49291-1-git-send-email-wangnan0@huawei.com) |
-| 2023/03/14 | Namhyung Kim | [perf record: Implement BPF sample filter (v5)](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=c46bf3bd00167e09729f884dd479b0a8d1a63f95) | 社区有诉求基于 sample 数据进行更复杂的性能事件示例过滤. 最近内核增加了 BPF 程序可以访问性能样本数据, 这是用户空间部分启用这样的过滤.
perf record 具有 `--filter` 选项, 用于在命令行中对最后一个指定的事件设置筛选器. 到目前为止, 它只适用于跟踪点和英特尔 PT 事件. 这个补丁集将其扩展为使用 BPF, 以便为任何事件启用通用样本过滤器. 添加了一个新的过滤器表达式解析器(使用 flex/bison)来处理过滤器字符串. 当前它只接受用逗号分隔的非常简单的表达式. | v5 ☑✓ 6.4-rc1 | [LORE v5,0/10](https://lore.kernel.org/all/20230314234237.3008956-1-namhyung@kernel.org) |
+| 2023/03/14 | Namhyung Kim | [perf record: Implement BPF sample filter (v5)](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/?id=c46bf3bd00167e09729f884dd479b0a8d1a63f95) | 社区有诉求基于 sample 数据进行更复杂的性能事件示例过滤. 最近内核增加了 BPF 程序可以访问性能样本数据, 这是用户空间部分启用这样的过滤.
perf record 具有 `--filter` 选项, 用于在命令行中对最后一个指定的事件设置筛选器. 到目前为止, 它只适用于跟踪点和英特尔 PT 事件. 这个补丁集将其扩展为使用 BPF, 以便为任何事件启用通用样本过滤器. 添加了一个新的过滤器表达式解析器 (使用 flex/bison) 来处理过滤器字符串. 当前它只接受用逗号分隔的非常简单的表达式. | v5 ☑✓ 6.4-rc1 | [LORE v5,0/10](https://lore.kernel.org/all/20230314234237.3008956-1-namhyung@kernel.org) |
## 8.3 coolbpf(surtrace & pyLCC)
-------
-[龙蜥社区开源 coolbpf, BPF 程序开发效率提升百倍 | 龙蜥技术](https://openanolis.cn/blog/detail/601601711630939267) coolbpf 项目, 以 CO-RE(Compile Once-Run Everywhere)为基础实现, 保留了资源占用低、可移植性强等优点, 还融合了 BCC 动态编译的特性, 适合在生产环境批量部署所开发的应用.
+[龙蜥社区开源 coolbpf, BPF 程序开发效率提升百倍 | 龙蜥技术](https://openanolis.cn/blog/detail/601601711630939267) coolbpf 项目, 以 CO-RE(Compile Once-Run Everywhere) 为基础实现, 保留了资源占用低、可移植性强等优点, 还融合了 BCC 动态编译的特性, 适合在生产环境批量部署所开发的应用.
-coolbpf 开创了一个新的思路, 利用远程编译的思想, 把用户的BPF程序推送到远端的服务器并返回给用户.o或.so, 提供高级语言如 `Python/Rust/Go/C` 等进行加载, 然后在全量内核版本安全运行. 用户只需专注自己的功能开发, 不用关心底层库(如 LLVM、python 等)安装、环境搭建, 给广大 BPF 爱好者提供一种新的探索和实践.
+coolbpf 开创了一个新的思路, 利用远程编译的思想, 把用户的 BPF 程序推送到远端的服务器并返回给用户. o 或. so, 提供高级语言如 `Python/Rust/Go/C` 等进行加载, 然后在全量内核版本安全运行. 用户只需专注自己的功能开发, 不用关心底层库 (如 LLVM、python 等) 安装、环境搭建, 给广大 BPF 爱好者提供一种新的探索和实践.
coolbpf 本质上是一个 eBPF 开发平台, 通过 pylcc、rlcc、golcc 和 clcc 等实现了高级语言的支持, 同时支持远程编译.
@@ -486,22 +538,22 @@ glcc 则实现了 eBPF 驱动和 libbpf 的支持, 允许 eBPF 程序无需修
2. 通过 libbpf 则屏蔽了不同内核版本的差异.
-[微信公众号-Linux 内核之旅--内核 trace 三板斧 - surtrace-cmd](https://mp.weixin.qq.com/s/XanaxrLDwkqTqcfq9B2eOw)
+[微信公众号 - Linux 内核之旅 -- 内核 trace 三板斧 - surtrace-cmd](https://mp.weixin.qq.com/s/XanaxrLDwkqTqcfq9B2eOw)
[龙蜥开源内核追踪利器 Surftrace:协议包解析效率提升 10 倍! | 龙蜥技术](https://mp.weixin.qq.com/s/o3Q-spZmBbs4Gbhv-3U91g)
[iofsstat:帮你轻松定位 IO 突高, 前因后果一目了然 | 龙蜥技术](https://developer.aliyun.com/article/867067)
-[libbpf 编译平台 LCC——eBPF从入门到享受 | 龙蜥大讲堂第 20 期](https://www.bilibili.com/video/BV1Ar4y1G7R8)
+[libbpf 编译平台 LCC——eBPF 从入门到享受 | 龙蜥大讲堂第 20 期](https://www.bilibili.com/video/BV1Ar4y1G7R8)
-[eBPF在低版本内核如何跑起来?| 龙蜥大讲堂第46期](https://www.bilibili.com/video/BV1Se411u7zD)
+[eBPF 在低版本内核如何跑起来?| 龙蜥大讲堂第 46 期](https://www.bilibili.com/video/BV1Se411u7zD)
## 8.4 eunomia-bpf
-------
[eunomia-bpf: A dynamic loader to run CO-RE eBPF as a service](https://github.com/eunomia-bpf/eunomia-bpf)
-[OpenAnolis/eBPF技术探索 SIG/Eunomia项目介绍](https://openanolis.cn/sig/ebpfresearch/doc/640013458629853191)
+[OpenAnolis/eBPF 技术探索 SIG/Eunomia 项目介绍](https://openanolis.cn/sig/ebpfresearch/doc/640013458629853191)
## 8.5 ubpf
@@ -536,15 +588,15 @@ glcc 则实现了 eBPF 驱动和 libbpf 的支持, 允许 eBPF 程序无需修
# 9 WASM(WebAssembly)
-------
-[WebAssembly 中文网|Wasm 中文文档](https://www.wasm.com.cn)
+[WebAssembly 中文网 | Wasm 中文文档](https://www.wasm.com.cn)
## 9.1 Wasmtime
-------
-2019 年, 英特尔、Mozilla 和红帽就启动了字节码联盟, 作为一项旨在促进"无处不在"运行 WebAssembly, 并将 WASM 的范围扩展到 Web 浏览器之外的倡议. 开发三年后(2022 年), WebAssembly 运行时 Wasmtime 1.0 发布了. 参见 phoronix 报道 [Wasmtime 1.0 Released - Bytecode Alliance Declares It Production Ready](https://www.phoronix.com/news/Wasmtime-1.0-Released).
+2019 年, 英特尔、Mozilla 和红帽就启动了字节码联盟, 作为一项旨在促进 "无处不在" 运行 WebAssembly, 并将 WASM 的范围扩展到 Web 浏览器之外的倡议. 开发三年后 (2022 年), WebAssembly 运行时 Wasmtime 1.0 发布了. 参见 phoronix 报道 [Wasmtime 1.0 Released - Bytecode Alliance Declares It Production Ready](https://www.phoronix.com/news/Wasmtime-1.0-Released).
-Wasmtime 完全开源, 使用 Rust 编程语言, 是的, 并且符合 WASI 标准. Wasmtime还支持与 C/C++, Python, .NET, Go 和其他编程语言的集成, 同时在 Windows / Linux / macOS 平台上运行等等.
+Wasmtime 完全开源, 使用 Rust 编程语言, 是的, 并且符合 WASI 标准. Wasmtime 还支持与 C/C++, Python, .NET, Go 和其他编程语言的集成, 同时在 Windows / Linux / macOS 平台上运行等等.
@@ -589,16 +641,16 @@ Wasmtime 完全开源, 使用 Rust 编程语言, 是的, 并且符合 WASI 标
| 论文 | 描述 |
|:---:|:----:|
-| [Flexible and Low-Overhead System-Call Aggregation using BPF](https://www4.cs.fau.de/Ausarbeitung/MA-I4-2021-12-Gerhorst.pdf)
[AnyCall: Fast and Flexible System-Call Aggregation](https://dl.acm.org/doi/10.1145/3477113.3487267) | 通过 eBPF 实现的 ANYCALL, 它使用内核内字节码编译器在内核模式下执行安全检查的用户代码. 这允许多个快速的系统调用与错误检查和处理逻辑交织聚合在一起, 只使用一次用户态 / 内核态转换. 并将其扩展为支持系统调用和用户内存访问. 由于内核已经支持灵活的事件处理和调试, 重用 BPF 来实现系统调用聚合, 这表明软件隔离进程对于现代通用操作系统是可行的. 为了证明将真实的用户应用程序移植到 ANYCALL 既实用又直接, 我移植了两个真实的工具, 并记录了所需的代码更改. 最后, 我评估了 ANYCALL 在具有操作系统级缓解措施的系统上的性能, 以对抗活跃或不活跃的瞬时执行漏洞, 包括例如针对 Meltdown 的内核页表隔离 (KPTI). 在 KPTI 不活跃的系统上, 我演示了在计算受限的实际应用程序中高达 10% 的加速. 另一方面, 当 KPTI 处于活动状态时, 我的评估表明, 使用 ANYCALL 可以使系统调用爆发速度提高 98%, 而实际应用程序的速度提高了 32% 到 40%. 参见 [【欧拉多咖 | OS每周快讯】2022.12.06~2022.12.12](https://www.chaspark.com/#/hotspots/821172234535870464) |
+| [Flexible and Low-Overhead System-Call Aggregation using BPF](https://www4.cs.fau.de/Ausarbeitung/MA-I4-2021-12-Gerhorst.pdf)
[AnyCall: Fast and Flexible System-Call Aggregation](https://dl.acm.org/doi/10.1145/3477113.3487267) | 通过 eBPF 实现的 ANYCALL, 它使用内核内字节码编译器在内核模式下执行安全检查的用户代码. 这允许多个快速的系统调用与错误检查和处理逻辑交织聚合在一起, 只使用一次用户态 / 内核态转换. 并将其扩展为支持系统调用和用户内存访问. 由于内核已经支持灵活的事件处理和调试, 重用 BPF 来实现系统调用聚合, 这表明软件隔离进程对于现代通用操作系统是可行的. 为了证明将真实的用户应用程序移植到 ANYCALL 既实用又直接, 我移植了两个真实的工具, 并记录了所需的代码更改. 最后, 我评估了 ANYCALL 在具有操作系统级缓解措施的系统上的性能, 以对抗活跃或不活跃的瞬时执行漏洞, 包括例如针对 Meltdown 的内核页表隔离 (KPTI). 在 KPTI 不活跃的系统上, 我演示了在计算受限的实际应用程序中高达 10% 的加速. 另一方面, 当 KPTI 处于活动状态时, 我的评估表明, 使用 ANYCALL 可以使系统调用爆发速度提高 98%, 而实际应用程序的速度提高了 32% 到 40%. 参见 [【欧拉多咖 | OS 每周快讯】2022.12.06~2022.12.12](https://www.chaspark.com/#/hotspots/821172234535870464) |
| [XRP: In-Kernel Storage Functions with eBPF【OSDI’22】](https://www.usenix.org/system/files/osdi22-zhong_1.pdf) | XRP 框架允许应用程序从 NVMe 驱动程序中的 eBPF 探针执行用户定义的存储功能, 如索引查找或聚合, 从而安全地绕过内核的大部分存储堆栈. 为了保持文件系统语义, XRP 将少量内核态转移到其 NVMe 驱动程序探针, 并在探针处调用用户注册的 eBPF 函数. |
-* 本作品/博文 ( [AderStep-紫夜阑珊-青伶巷草 Copyright ©2013-2017](http://blog.csdn.net/gatieme) ), 由 [成坚(gatieme)](http://blog.csdn.net/gatieme) 创作.
+* 本作品 / 博文 ([AderStep - 紫夜阑珊 - 青伶巷草 Copyright ©2013-2017](http://blog.csdn.net/gatieme) ), 由 [成坚 (gatieme)](http://blog.csdn.net/gatieme) 创作.
-* 采用
知识共享署名-非商业性使用-相同方式共享 4.0 国际许可协议进行许可. 欢迎转载、使用、重新发布, 但务必保留文章署名[成坚gatieme](http://blog.csdn.net/gatieme) ( 包含链接: http://blog.csdn.net/gatieme ), 不得用于商业目的.
+* 采用
知识共享署名 - 非商业性使用 - 相同方式共享 4.0 国际许可协议 进行许可. 欢迎转载、使用、重新发布, 但务必保留文章署名 [成坚 gatieme](http://blog.csdn.net/gatieme) (包含链接: http://blog.csdn.net/gatieme), 不得用于商业目的.
* 基于本文修改后的作品务必以相同的许可发布. 如有任何疑问, 请与我联系.
-* **转载请务必注明出处, 谢谢, 不胜感激**
+* ** 转载请务必注明出处, 谢谢, 不胜感激 **
diff --git a/study/kernel/00-DESCRIPTION/TODO.md b/study/kernel/00-DESCRIPTION/TODO.md
index 0c58b3a..26af51f 100644
--- a/study/kernel/00-DESCRIPTION/TODO.md
+++ b/study/kernel/00-DESCRIPTION/TODO.md
@@ -461,4 +461,12 @@ kagi.com/summarizer
[Memory passthrough for virtual machines](https://lwn.net/Articles/931933)
-当 `{rt, cfs}_rq` 或 `dl` 任务被节流时, 由于 cookie 任务不会从核心树中退出队列, 因此 sched_core_find() 和 sched_core_next() 可能返回 throttledtask, 这可能导致 throttledtask 在 CPU 上运行. 因此, 我们在 sched_core_find() 和 sched_core_next() 中添加检查, 以确保返回的是一个未受限制的可运行任务.
\ No newline at end of file
+BPF verifiery 已经做了很多工作来尽量确保加载进 kernel 的 BPF program 是不会导致安全问题的. 包括检查 memory 的访问, 以及模拟执行流程来确保 program 会在有限时间内结束, 等等. 其中很多检查都有助于确保 program 是安全的, 能避免某些类型的 bug, 其他的检查都是专门为了排查恶意 program 的, 如果 kernel 允许接受非特权用户的 BPF program 的话, 这些检查都是必须的.
+
+大多数这类恶意 program 的检查工作都是在 2015 年的 4.4 kernel 里实现的. 尤其是其中很多工作是为了阻止 BPF program 把 kernel 指针值泄露给 user space. 这些指针对攻击者会很有用, 因为他们可以被用来推算出某些特定的数据结构或者代码的位置. 所以我们一定要避免被非特权的进程拿到这些指针数据. 在 kernel 4.7 里面
+
+
+ 其他还有一些 patch 是用来避免 BPF program 里的预测执行(speculative-execution)类型的攻击.
+
+
+