On Wed, Jul 24, 2019 at 12:27:38PM -0700, Andrii Nakryiko wrote:
> Add tests for various array handling/relocation scenarios.
> 
> Signed-off-by: Andrii Nakryiko <andr...@fb.com>
...
> +
> +#define CORE_READ(dst, src) \
> +     bpf_probe_read(dst, sizeof(*src), __builtin_preserve_access_index(src))

This is the key accessor that all progs will use.
Please split just this single macro into individual commit and add
detailed comment about its purpose and
what __builtin_preserve_access_index() does underneath.

> +SEC("raw_tracepoint/sys_enter")
> +int test_core_nesting(void *ctx)
> +{
> +     struct core_reloc_arrays *in = (void *)&data.in;
> +     struct core_reloc_arrays_output *out = (void *)&data.out;
> +
> +     /* in->a[2] */
> +     if (CORE_READ(&out->a2, &in->a[2]))
> +             return 1;
> +     /* in->b[1][2][3] */
> +     if (CORE_READ(&out->b123, &in->b[1][2][3]))
> +             return 1;

Reply via email to