[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAADnVQKnoFc=_jKNH=8-HWYuEw=FP941igh5Y1OgtQjdnoFLTw@mail.gmail.com>
Date: Wed, 29 Sep 2021 13:50:54 -0700
From: Alexei Starovoitov <alexei.starovoitov@...il.com>
To: Kumar Kartikeya Dwivedi <memxor@...il.com>
Cc: bpf <bpf@...r.kernel.org>, Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <kafai@...com>,
Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
Jesper Dangaard Brouer <brouer@...hat.com>,
Toke Høiland-Jørgensen <toke@...hat.com>,
Network Development <netdev@...r.kernel.org>
Subject: Re: [PATCH bpf-next v5 08/12] libbpf: Make gen_loader data aligned.
On Mon, Sep 27, 2021 at 8:00 AM Kumar Kartikeya Dwivedi
<memxor@...il.com> wrote:
>
> From: Alexei Starovoitov <ast@...nel.org>
>
> Align gen_loader data to 8 byte boundary to make sure union bpf_attr,
> bpf_insns and other structs are aligned.
>
> Signed-off-by: Alexei Starovoitov <ast@...nel.org>
> ---
> tools/lib/bpf/gen_loader.c | 7 ++++++-
> 1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/tools/lib/bpf/gen_loader.c b/tools/lib/bpf/gen_loader.c
> index 8df718a6b142..80087b13877f 100644
> --- a/tools/lib/bpf/gen_loader.c
> +++ b/tools/lib/bpf/gen_loader.c
> @@ -5,6 +5,7 @@
> #include <string.h>
> #include <errno.h>
> #include <linux/filter.h>
> +#include <sys/param.h>
> #include "btf.h"
> #include "bpf.h"
> #include "libbpf.h"
> @@ -135,13 +136,17 @@ void bpf_gen__init(struct bpf_gen *gen, int log_level)
>
> static int add_data(struct bpf_gen *gen, const void *data, __u32 size)
> {
> + __u32 size8 = roundup(size, 8);
> + __u64 zero = 0;
> void *prev;
>
> - if (realloc_data_buf(gen, size))
> + if (realloc_data_buf(gen, size8))
> return 0;
> prev = gen->data_cur;
> memcpy(gen->data_cur, data, size);
> gen->data_cur += size;
> + memcpy(gen->data_cur, &zero, size8 - size);
> + gen->data_cur += size8 - size;
Since we both need this patch, I pushed it to bpf-next to
simplify rebasing.
Powered by blists - more mailing lists