Re: [RFC bpf-next v2 2/9] bpf: no_caller_saved_registers attribute for helper calls

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

 



On Thu, Jul 4, 2024 at 3:24 AM Eduard Zingerman <eddyz87@xxxxxxxxx> wrote:
>
> +                       for (j = 1; j <= spills_num; ++j) {
> +                               if ((insn - j)->off >= subprogs[cur_subprog].nocsr_stack_off ||
> +                                   (insn + j)->off >= subprogs[cur_subprog].nocsr_stack_off) {
> +                                       /* do a second visit of this instruction,
> +                                        * so that verifier can inline it
> +                                        */
> +                                       i -= 1;
> +                                       insn -= 1;
> +                                       goto next_insn;
> +                               }
> +                       }
> +
> +                       /* apply the rewrite:
> +                        *   *(u64 *)(r10 - X) = rY ; num-times
> +                        *   call()                               -> call()
> +                        *   rY = *(u64 *)(r10 - X) ; num-times
> +                        */
> +                       err = verifier_remove_insns(env, i + delta - spills_num, spills_num);
> +                       if (err)
> +                               return err;
> +                       err = verifier_remove_insns(env, i + delta - spills_num + 1, spills_num);
> +                       if (err)
> +                               return err;
> +
> +                       i += spills_num - 1;
> +                       /*   ^            ^   do a second visit of this instruction,
> +                        *   |            '-- so that verifier can inline it
> +                        *   '--------------- jump over deleted fills
> +                        */
> +                       delta -= 2 * spills_num;
> +                       insn = env->prog->insnsi + i + delta;
> +                       goto next_insn;
> +               }

somewhere after spill/fill removal subprog->stack_depth
needs to be adjust to nocsr_stack_off,
otherwise extra stack space is wasted.
I couldn't find this logic in the patch.

Once the adjustment logic is done, pls add a selftest with
nocsr and may_goto, since may_goto processing is in the same
do_misc_fixups() loop and it needs to grow the stack while
spill/fill removal will shrink the stack.





[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