Skip to content

Commit da653de

Browse files
pchaignoAlexei Starovoitov
authored andcommitted
selftests/bpf: Update reg_bound range refinement logic
This patch updates the range refinement logic in the reg_bound test to match the new logic from the previous commit. Without this change, tests would fail because we end with more precise ranges than the tests expect. Acked-by: Eduard Zingerman <[email protected]> Signed-off-by: Paul Chaignon <[email protected]> Link: https://lore.kernel.org/r/b7f6b1fbe03373cca4e1bb6a113035a6cd2b3ff7.1753695655.git.paul.chaignon@gmail.com Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 00bf8d0 commit da653de

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

tools/testing/selftests/bpf/prog_tests/reg_bounds.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,20 @@ static struct range range_refine(enum num_t x_t, struct range x, enum num_t y_t,
465465
return range_improve(x_t, x, x_swap);
466466
}
467467

468+
if (!t_is_32(x_t) && !t_is_32(y_t) && x_t != y_t) {
469+
if (x_t == S64 && x.a > x.b) {
470+
if (x.b < y.a && x.a <= y.b)
471+
return range(x_t, x.a, y.b);
472+
if (x.a > y.b && x.b >= y.a)
473+
return range(x_t, y.a, x.b);
474+
} else if (x_t == U64 && y.a > y.b) {
475+
if (y.b < x.a && y.a <= x.b)
476+
return range(x_t, y.a, x.b);
477+
if (y.a > x.b && y.b >= x.a)
478+
return range(x_t, x.a, y.b);
479+
}
480+
}
481+
468482
/* otherwise, plain range cast and intersection works */
469483
return range_improve(x_t, x, y_cast);
470484
}

0 commit comments

Comments
 (0)