On Mon, Mar 18, 2024 at 06:16:09PM -0700, Andrii Nakryiko wrote: > On Mon, Mar 18, 2024 at 2:32 AM Jiri Olsa <jolsa@xxxxxxxxxx> wrote: > > > > Add uretprobe syscall test and compare register values before > > and after the uretprobe is hit. Also compare the register values > > seen from attached bpf program. > > > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > > --- > > tools/testing/selftests/bpf/Makefile | 13 ++- > > .../bpf/prog_tests/arch/x86/uprobe_syscall.S | 89 +++++++++++++++++++ > > .../selftests/bpf/prog_tests/uprobe_syscall.c | 84 +++++++++++++++++ > > .../selftests/bpf/progs/uprobe_syscall.c | 15 ++++ > > 4 files changed, 200 insertions(+), 1 deletion(-) > > create mode 100644 tools/testing/selftests/bpf/prog_tests/arch/x86/uprobe_syscall.S > > create mode 100644 tools/testing/selftests/bpf/prog_tests/uprobe_syscall.c > > create mode 100644 tools/testing/selftests/bpf/progs/uprobe_syscall.c > > > > Can all the above be achieved with inline assembly inside .c files? It > would probably simplify logistics overall. We can guard with > arch-specific #ifdefs, of course. ok, probably yes.. I'll check > > [...] > > > diff --git a/tools/testing/selftests/bpf/progs/uprobe_syscall.c b/tools/testing/selftests/bpf/progs/uprobe_syscall.c > > new file mode 100644 > > index 000000000000..0cc7e8761410 > > --- /dev/null > > +++ b/tools/testing/selftests/bpf/progs/uprobe_syscall.c > > @@ -0,0 +1,15 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +#include "vmlinux.h" > > +#include <bpf/bpf_helpers.h> > > +#include <string.h> > > + > > +struct pt_regs regs; > > + > > +char _license[] SEC("license") = "GPL"; > > + > > +SEC("uretprobe//proc/self/exe:uprobe_syscall_arch_test") > > +int uretprobe(struct pt_regs *ctx) > > +{ > > + memcpy(®s, ctx, sizeof(regs)); > > nit: please use __builtin_memcpy(), given this is BPF code. And we > don't need string.h include. right, thanks jirka > > > + return 0; > > +} > > -- > > 2.44.0 > >