Re: [PATCH v4 bpf-next 5/5] selftests/bpf: Add sleepable tests

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

 



On Mon, Jun 29, 2020 at 8:06 PM Alexei Starovoitov
<alexei.starovoitov@xxxxxxxxx> wrote:
>
> On Mon, Jun 29, 2020 at 06:25:38PM -0700, Andrii Nakryiko wrote:
> >
> > > +
> > > +SEC("fentry.s/__x64_sys_setdomainname")
> > > +int BPF_PROG(test_sys_setdomainname, struct pt_regs *regs)
> > > +{
> > > +       int buf = 0;
> > > +       long ret;
> > > +
> > > +       ret = bpf_copy_from_user(&buf, sizeof(buf), (void *)regs->di);
> > > +       if (regs->si == -2 && ret == 0 && buf == 1234)
> > > +               copy_test++;
> > > +       if (regs->si == -3 && ret == -EFAULT)
> > > +               copy_test++;
> > > +       if (regs->si == -4 && ret == -EFAULT)
> > > +               copy_test++;
> >
> > regs->si and regs->di won't compile on non-x86 arches, better to use
> > PT_REGS_PARM1() and PT_REGS_PARM2() from bpf_tracing.h.
>
> the test is x86 only due to:
> +SEC("fentry.s/__x64_sys_setdomainname")

Right, but here I'm talking about compilation error because pt_regs
don't have si, di fields on other arches. __x64 just won't attach in
runtime, which is not a big deal if you are ignoring this particular
test.

>
> I guess we can move samples/bpf/trace_common.h into libbpf as well
> to clean the whole thing up. Something for later patches.

trace_common.h works only for the latest kernels. Before some version
(don't remember which version precisely), __x64 shouldn't be added.
Which makes this header not a good candidate for inclusion to libbpf.
BCC does this dynamically in runtime based on kallsyms, which I'm not
a big fan of doing as well. So let's punt trace_common.h for better
times :)



[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