mirror of
https://github.com/torvalds/linux.git
synced 2026-11-07 06:17:02 +01:00
bpf: Add bpf_spill_size()
A utility function counting the number of STACK_SPILL slots in a bpf_stat_state instance. For use by SCEV widening logic. Signed-off-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://patch.msgid.link/20261009-scev-minimal-rebase-v3-30-bcba9bc53ac9@gmail.com
This commit is contained in:
parent
4c3a56544b
commit
1291ad5906
|
|
@ -1420,6 +1420,15 @@ static inline bool bpf_is_spilled_reg(const struct bpf_stack_state *stack)
|
|||
return stack->slot_type[BPF_REG_SIZE - 1] == STACK_SPILL;
|
||||
}
|
||||
|
||||
static inline int bpf_spill_size(const struct bpf_stack_state *stack)
|
||||
{
|
||||
int i, spill_size = 0;
|
||||
|
||||
for (i = BPF_REG_SIZE - 1; i >= 0 && stack->slot_type[i] == STACK_SPILL; i--)
|
||||
spill_size++;
|
||||
return spill_size;
|
||||
}
|
||||
|
||||
static inline bool bpf_is_spilled_scalar_reg(const struct bpf_stack_state *stack)
|
||||
{
|
||||
return bpf_is_spilled_reg(stack) && stack->spilled_ptr.type == SCALAR_VALUE;
|
||||
|
|
|
|||
|
|
@ -4247,10 +4247,7 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env,
|
|||
bpf_diag_mod_begin(env, &state->regs[dst_regno], reg, BPF_DIAG_MOD_WRITE);
|
||||
|
||||
if (bpf_is_spilled_reg(ss)) {
|
||||
u8 spill_size = 1;
|
||||
|
||||
for (i = BPF_REG_SIZE - 1; i > 0 && stype[i - 1] == STACK_SPILL; i--)
|
||||
spill_size++;
|
||||
u8 spill_size = bpf_spill_size(ss);
|
||||
|
||||
if (size != BPF_REG_SIZE || spill_size != BPF_REG_SIZE) {
|
||||
if (reg->type != SCALAR_VALUE) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user