From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Alexis Lothoré (eBPF Foundation)" <alexis.lothore@bootlin.com>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>, "Shuah Khan" <shuah@kernel.org>
Cc: <ebpf@linuxfoundation.org>,
"Bastien Curutchet" <bastien.curutchet@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
<bpf@vger.kernel.org>, <linux-kselftest@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: ignore call depth accounting for retbleed in verifier tests
Date: Mon, 01 Jun 2026 20:45:01 -0400 [thread overview]
Message-ID: <DIY5C759S2C7.MLK4G59NRVJ7@etsalapatis.com> (raw)
In-Reply-To: <20260528-fix_tests_for_retbleed_stuff-v1-1-c2022a1f3bee@bootlin.com>
On Thu May 28, 2026 at 9:27 AM EDT, Alexis Lothoré (eBPF Foundation) wrote:
> When running the selftests on a retbleed-affected platform (eg:
> Skylake), with call depth accounting enabled
> (CONFIG_CALL_DEPTH_TRACKING=y) _and_ with retbleed=stuff, some verifier
> selftests fail to validate the jited instructions. For example:
>
> MATCHED SUBSTR: ' endbr64'
> MATCHED SUBSTR: ' nopl (%rax,%rax)'
> MATCHED SUBSTR: ' xorq %rax, %rax'
> MATCHED SUBSTR: ' pushq %rbp'
> MATCHED SUBSTR: ' movq %rsp, %rbp'
> MATCHED SUBSTR: ' endbr64'
> MATCHED SUBSTR: ' cmpq $0x21, %rax'
> MATCHED SUBSTR: ' ja L0'
> MATCHED SUBSTR: ' pushq %rax'
> MATCHED SUBSTR: ' movq %rsp, %rax'
> MATCHED SUBSTR: ' jmp L1'
> MATCHED SUBSTR: 'L0: pushq %rax'
> MATCHED SUBSTR: 'L1: pushq %rax'
> MATCHED SUBSTR: ' movq -0x10(%rbp), %rax'
> WRONG LINE REGEX: ' callq 0x{{.*}}'
>
> Those affected selftests allways fail on some call instruction: this
> failure is due to the JIT compiler emitting call depth accounting for
> retbleed mitigation (see x86_call_depth_emit_accounting calls in
> bpf_jit_comp.c), resulting in an additional instruction being inserted
> in front of every call instruction, similar to this one:
>
> sarq $0x5, %gs:-0x39882741(%rip)
>
> Fix those selftests by allowing them to ignore this possibly present
> call depth accounting instruction.
>
> Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
Makes sense.
Reviewed-by: Emil Tsalapatis <emil@etsalapatis.com>
> ---
> tools/testing/selftests/bpf/progs/verifier_private_stack.c | 5 +++++
> tools/testing/selftests/bpf/progs/verifier_tailcall_jit.c | 1 +
> 2 files changed, 6 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/progs/verifier_private_stack.c b/tools/testing/selftests/bpf/progs/verifier_private_stack.c
> index 046f7445a458..bb8206e10880 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_private_stack.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_private_stack.c
> @@ -94,6 +94,7 @@ __jited(" addq %gs:{{.*}}, %r9")
> __jited(" movl $0x2a, %edi")
> __jited(" movq %rdi, -0x200(%r9)")
> __jited(" pushq %r9")
> +__jited("...")
> __jited(" callq 0x{{.*}}")
> __jited(" popq %r9")
> __jited(" xorl %eax, %eax")
> @@ -153,11 +154,13 @@ __jited(" endbr64")
> __jited(" movabsq $0x{{.*}}, %r9")
> __jited(" addq %gs:{{.*}}, %r9")
> __jited(" pushq %r9")
> +__jited("...")
> __jited(" callq")
> __jited(" popq %r9")
> __jited(" movl $0x2a, %edi")
> __jited(" movq %rdi, -0x200(%r9)")
> __jited(" pushq %r9")
> +__jited("...")
> __jited(" callq")
> __jited(" popq %r9")
> __arch_arm64
> @@ -199,6 +202,7 @@ __description("Private stack, exception in main prog")
> __success __retval(0)
> __arch_x86_64
> __jited(" pushq %r9")
> +__jited("...")
> __jited(" callq")
> __jited(" popq %r9")
> __arch_arm64
> @@ -246,6 +250,7 @@ __success __retval(0)
> __arch_x86_64
> __jited(" movq %rdi, -0x200(%r9)")
> __jited(" pushq %r9")
> +__jited("...")
> __jited(" callq")
> __jited(" popq %r9")
> __arch_arm64
> diff --git a/tools/testing/selftests/bpf/progs/verifier_tailcall_jit.c b/tools/testing/selftests/bpf/progs/verifier_tailcall_jit.c
> index 8d60c634a114..48fa34d2959f 100644
> --- a/tools/testing/selftests/bpf/progs/verifier_tailcall_jit.c
> +++ b/tools/testing/selftests/bpf/progs/verifier_tailcall_jit.c
> @@ -56,6 +56,7 @@ __jited("L1: pushq %rax") /* rbp[-16] = rax */
> * (cause original rax might be clobbered by this point)
> */
> __jited(" movq -0x10(%rbp), %rax")
> +__jited("...")
> __jited(" callq 0x{{.*}}") /* call to sub() */
> __jited(" xorl %eax, %eax")
> __jited(" leave")
>
> ---
> base-commit: 4a8eaccfdd6f4ae4b0e8735664e9d3e5ce826329
> change-id: 20260528-fix_tests_for_retbleed_stuff-c3c89b738e70
>
> Best regards,
> --
> Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
next prev parent reply other threads:[~2026-06-02 0:45 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-28 13:27 Alexis Lothoré (eBPF Foundation)
2026-06-02 0:45 ` Emil Tsalapatis [this message]
2026-06-04 16:50 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=DIY5C759S2C7.MLK4G59NRVJ7@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=alexis.lothore@bootlin.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bastien.curutchet@bootlin.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=ebpf@linuxfoundation.org \
--cc=eddyz87@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome