Re: [PATCH v6 bpf-next 5/7] bpf: Add arch_bpf_trampoline_size()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Dec 6, 2023 at 1:18 PM Song Liu <song@xxxxxxxxxx> wrote:
>
> On Wed, Dec 6, 2023 at 11:34 AM Alexei Starovoitov
> <alexei.starovoitov@xxxxxxxxx> wrote:
> >
> > On Fri, Dec 01, 2023 at 11:06:52AM -0800, Song Liu wrote:
> > > +int arch_bpf_trampoline_size(const struct btf_func_model *m, u32 flags,
> > > +                          struct bpf_tramp_links *tlinks, void *func_addr)
> > > +{
> > > +     struct bpf_tramp_image im;
> > > +     void *image;
> > > +     int ret;
> > > +
> > > +     /* Allocate a temporary buffer for __arch_prepare_bpf_trampoline().
> > > +      * This will NOT cause fragmentation in direct map, as we do not
> > > +      * call set_memory_*() on this buffer.
> > > +      */
> > > +     image = bpf_jit_alloc_exec(PAGE_SIZE);
> > > +     if (!image)
> > > +             return -ENOMEM;
> > > +
> > > +     ret = __arch_prepare_bpf_trampoline(&im, image, image + PAGE_SIZE, m, flags,
> > > +                                         tlinks, func_addr);
> > > +     bpf_jit_free_exec(image);
> > > +     return ret;
> > > +}
> >
> > There is no need to allocate an executable page just to compute the size, right?
> > Instead of bpf_jit_alloc_exec() it should work with alloc_page() ?
>
> We can use kvmalloc in patch 7. But we need bpf_jit_alloc_exec(). The reason is
> __arch_prepare_bpf_trampoline() assumes "image" falls in certain memory ranges.
> If we use kvmalloc here, we may fail those checks, for example is_simm32() in
> emit_patch().

Ahh. Makes sense. Please add a comment then.





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux