Re: [PATCH bpf-next v2 3/3] bpf, arm64: use bpf_jit_binary_pack_alloc

From: Song Liu
Date: Thu Jun 08 2023 - 17:13:20 EST


On Thu, Jun 8, 2023 at 9:51 AM Puranjay Mohan <puranjay12@xxxxxxxxx> wrote:
>
> Hi Song,
>
> On Thu, Jun 8, 2023 at 6:28 PM Song Liu <song@xxxxxxxxxx> wrote:
> >
> > On Wed, Jun 7, 2023 at 2:18 AM Puranjay Mohan <puranjay12@xxxxxxxxx> wrote:
> > >
> > [...]
> > > +
> > > static inline int epilogue_offset(const struct jit_ctx *ctx)
> > > {
> > > int to = ctx->epilogue_offset;
> > > @@ -701,7 +716,8 @@ static int add_exception_handler(const struct bpf_insn *insn,
> > > struct jit_ctx *ctx,
> > > int dst_reg)
> > > {
> > > - off_t offset;
> > > + off_t ins_offset;
> > > + off_t fixup_offset;
> >
> > Please add some comments for these two offsets.
>
> Here I am using two variables because I need to change from the RO
> buffer for calculating offsets
> to the RW buffer for writing.
>
> Earlier, a single variable could work because it was being reused for
> calculating the second offset
> after writing the first one. Here, I can't re-calculate using the same
> variable because I have to change
> to the RW buffer, and using the same variable would need changing back
> to the RO buffer.
>
> So, I am calculating both offsets first, changing to RW buffer and
> writing both offsets.
>
> But I will add comments explaining what these offsets are being used for.

Thanks for the explanation! These comments will be useful for future work.

Song