The bpf_jit_convergence je <-> jmp test reproduces the cycle fixed by commit c8831bdbfbab ("bpf, x64: Fix a jit convergence issue") with 125 bytes of x86-64 code between the je to l0 and l0 when the last goto l9 is two bytes and 128 when it is five, so that the je fits into an imm8 only while the jmp does not and the two flip each other's size from pass to pass. The recent JIT changes shortened that code by five bytes: the three loads and stores with a zero offset lost their displacement byte with commit 44df4d88aa63 ("bpf, x86: Omit the displacement byte for zero offsets"), and r2 += 0x1 became an inc and r3 &= 0x1 an and without REX.W with commit d59f47e031ae ("bpf, x86: Use shorter and faster forms for some ALU immediates"). At 120 and 123 bytes the je fits either way, nothing flips, and the test passes without exercising the fix. Add a five byte mov to the region to get the distance back. The je is forced into its long form again as the fix intends: # ./vmtest.sh -- ./test_progs -v -t verifier_jit_convergence [...] 96: 0f 84 7d 00 00 00 je L14 117: eb 83 jmp L6 119: bf 03 00 00 00 L14: movl $0x3, %edi [...] #668/1 verifier_jit_convergence/bpf_jit_convergence je <-> jmp:OK #668 verifier_jit_convergence:OK Summary: 1/1 PASSED, 0 SKIPPED, 0/0 FAILED Reported-by: Alexei Starovoitov Signed-off-by: Daniel Borkmann --- .../testing/selftests/bpf/progs/verifier_jit_convergence.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/verifier_jit_convergence.c b/tools/testing/selftests/bpf/progs/verifier_jit_convergence.c index 9f3f2b7db450..4fd717334858 100644 --- a/tools/testing/selftests/bpf/progs/verifier_jit_convergence.c +++ b/tools/testing/selftests/bpf/progs/verifier_jit_convergence.c @@ -68,6 +68,13 @@ __naked void btf_jit_convergence_je_jmp(void) "r3 &= 0x1;" "r2 *= 0xa8;" "if r3 == 0x0 goto l2_%=;" + /* + * The x86-64 code from the je to l0 up to l0 has to be 125 bytes with + * the last goto l9 at two bytes and 128 with it at five, so that the + * je fits into an imm8 only while the jmp does not and the two keep + * flipping each other's size. The mov pads the region to that. + */ + "r3 = 0x1234;" "r1 += r2;" "r1 -= r7;" "r1 += 0x8;" -- 2.43.0