Eduard Zingerman <eddyz87@xxxxxxxxx> writes: > On Thu, 2025-03-13 at 18:21 +0100, Luis Gerhorst wrote: >> + err = do_check_insn(env, insn, pop_log, &do_print_state, regs, state, >> + &prev_insn_idx); > > - `regs` remains declared in do_check(), while nothing prevents > pushing its declaration to do_check_insn(). > - `state` is `env->cur_state`, so I'd avoid passing it as a parameter > (just to reduce count); > - `prev_insn_idx` is unused by `do_check_insn`; > - `pop_log` is not used by `do_check_insn`; Changed for v2, thank you very much. > - given that `insn` is presumed to correspond to `env->insn_idx` in > many places down the stack not sure about this parameter. I don't have a strong opinion on this either. Unless someone objects I will keep it as it matches the other check_*() functions like this. >> + if (err < 0) { >> + return err; >> + } else if (err == INSN_IDX_MODIFIED) { > > Also, I'd get rid of `INSN_IDX_MODIFIED` and move `env->insn_idx++` > into `do_check_insn()`. This would save a few mental cycles when > looking at the code with full patch-set applied: > > } else if (err == INSN_IDX_MODIFIED) { > continue; > } else if (err == PROCESS_BPF_EXIT) { > goto process_bpf_exit; > } > WARN_ON_ONCE(err); > > if (state->speculative && cur_aux(env)->nospec_result) { > ... bunch of actions ... > } > > env->insn_idx++; > > One needs to stop for a moment and think why "bunch of actions" is > performed for regular index increment, but not for INSN_IDX_MODIFIED. That certainly makes it more readable. I changed it for v2. If we have an instruction that does not simply do `insn_idx++` but jumps, the `nospec_result` check should never trigger. Otherwise, the patched nospec might be skipped. Currently, this is satisfied because `nospec_result` is only used for store-instructions. I will add a comment and WARN_ON_ONCE to document that for v2.