Re: [PATCH v3 bpf-next 03/13] bpf: Prepare relo_core.c for kernel duty.

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

 



On Sat, Nov 20, 2021 at 8:24 AM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> On Sat, Nov 20, 2021 at 7:27 AM Matteo Croce <mcroce@xxxxxxxxxxxxxxxxxxx> wrote:
> >
> > On Sat, Nov 20, 2021 at 4:33 AM Alexei Starovoitov
> > <alexei.starovoitov@xxxxxxxxx> wrote:
> > >
> > > From: Alexei Starovoitov <ast@xxxxxxxxxx>
> > >
> > > Make relo_core.c to be compiled for the kernel and for user space libbpf.
> > >
> > > Note the patch is reducing BPF_CORE_SPEC_MAX_LEN from 64 to 32.
> > > This is the maximum number of nested structs and arrays.
> > > For example:
> > >  struct sample {
> > >      int a;
> > >      struct {
> > >          int b[10];
> > >      };
> > >  };
> > >
> > >  struct sample *s = ...;
> > >  int y = &s->b[5];
> >
> > I don't understand this. Is this intentional, or it should be one of:
> >
> > int y = s->b[5];
> > int *y = &s->b[5];
>
> Eagle eye. I copy pasted this typo from libbpf.
> Will fix in all places at once either in a respin or in a separate patch.
> For the purpose of the example it could be either.
> int *y = &s->b[5]; is a relocatable ADD.

I think this was the intention (getting address in CO-RE-relocatable
way) at the time, we didn't yet have the direct memory access that
fentry provides. So that `int *` was intended to be then passed to
bpf_probe_read_kernel().

Now both options would work, but the first one only works in
fentry/fexit and similar program types.

> int y = s->b[5]; is a relocatable LDX.



[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