Re: [PATCH bpf-next v2 3/5] bpf: support bpf_fastcall patterns for kfuncs

Yonghong Song
2024-08-22T01:23:08Z

On 8/16/24 6:51 PM, Eduard Zingerman wrote:
> Recognize bpf_fastcall patterns around kfunc calls.
> For example, suppose bpf_cast_to_kern_ctx() follows bpf_fastcall
> contract (which it does), in such a case allow verifier to rewrite BPF
> program below:
>
> r2 = 1;
> *(u64 *)(r10 - 32) = r2;
> call %[bpf_cast_to_kern_ctx];
> r2 = *(u64 *)(r10 - 32);
> r0 = r2;
>
> By removing the spill/fill pair:
>
> r2 = 1;
> call %[bpf_cast_to_kern_ctx];
> r0 = r2;
>
> Signed-off-by: Eduard Zingerman <eddyz87@gmail.com>
Acked-by: Yonghong Song <yonghong.song@linux.dev>