Message ID | 20240123103241.2282122-2-pulehui@huaweicloud.com (mailing list archive) |
---|---|
State | Handled Elsewhere |
Headers | show |
Series | Use bpf_prog_pack for RV64 bpf trampoline | expand |
On Tue, Jan 23, 2024 at 2:32 AM Pu Lehui <pulehui@huaweicloud.com> wrote: > > From: Pu Lehui <pulehui@huawei.com> > > For trampoline using bpf_prog_pack, we need to generate a rw_image > buffer with size of (image_end - image). For regular trampoline, we use > the precise image size generated by arch_bpf_trampoline_size to allocate > rw_image. But for struct_ops trampoline, we allocate rw_image directly > using close to PAGE_SIZE size. We do not need to allocate for that much, > as the patch size is usually much smaller than PAGE_SIZE. Let's use > precise image size for it too. > > Signed-off-by: Pu Lehui <pulehui@huawei.com> Acked-by: Song Liu <song@kernel.org>
diff --git a/kernel/bpf/bpf_struct_ops.c b/kernel/bpf/bpf_struct_ops.c index 02068bd0e4d9..e2e1bf3c69a3 100644 --- a/kernel/bpf/bpf_struct_ops.c +++ b/kernel/bpf/bpf_struct_ops.c @@ -368,7 +368,7 @@ int bpf_struct_ops_prepare_trampoline(struct bpf_tramp_links *tlinks, return size; if (size > (unsigned long)image_end - (unsigned long)image) return -E2BIG; - return arch_prepare_bpf_trampoline(NULL, image, image_end, + return arch_prepare_bpf_trampoline(NULL, image, image + size, model, flags, tlinks, stub_func); }