From: Thomas Monjalon <thomas@monjalon.net>
To: Marat Khalili <marat.khalili@huawei.com>
Cc: dev@dpdk.org, stephen@networkplumber.org,
Konstantin Ananyev <konstantin.ananyev@huawei.com>,
Ferruh Yigit <ferruh.yigit@amd.com>,
stable@dpdk.org, stable@dpdk.org
Subject: Re: [PATCH v3] bpf: fix x86 call stack alignment for external calls
Date: Wed, 04 Feb 2026 10:35:40 +0100 [thread overview]
Message-ID: <7022287.MhkbZ0Pkbq@thomas> (raw)
In-Reply-To: <20260121101653.66438-1-marat.khalili@huawei.com>
21/01/2026 11:16, Marat Khalili:
> Correctly align stack pointer on x86 JIT if external calls are present.
>
> According to x86-64 ABI (https://gitlab.com/x86-psABIs/x86-64-ABI,
> section 3.2.2 The Stack Frame) stack needs to be 16 (or more) bytes
> aligned immediately before the call instruction is executed. Once
> control has been transferred to the function entry point it is always
> off by 8 bytes. It means that JIT-compiled BPF function will always have
> its stack misaligned for any nested call unless it performs operations
> with the stack; even if it does use stack there is still 50% chance of
> stack being misaligned since it uses it in multiples of 8.
>
> To solve the issue mark RBP as used whenever we have external function
> calls, and align RSP using AND instruction at the end of the prolog.
> Marking RBP as used triggers stack pointer saving in prolog and
> restoration in epilog.
>
> Add tests for external calls from BPF program demonstrating the problem:
> * direct verification of a local variable alignment;
> * operations with 128-bit integers;
> * aligned and unaligned SSE2 instructions;
> * memcpy and rte_memcpy (may use vector instructions in their code).
>
> (Such variety is needed because not all of these tests are available or
> reproduce the problem on all targets even when the problem exists.)
>
> Fixes: cc752e43e079 ("bpf: add JIT compilation for x86_64 ISA")
> Cc: stable@dpdk.org
>
> Signed-off-by: Marat Khalili <marat.khalili@huawei.com>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> Tested-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
Applied, thanks.
next prev parent reply other threads:[~2026-02-04 9:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-19 18:26 [PATCH] bpf: fix x86 call stack alignment, add tests Marat Khalili
2025-12-28 14:16 ` Konstantin Ananyev
2026-01-05 16:09 ` [PATCH v2] " Marat Khalili
2026-01-21 10:16 ` [PATCH v3] bpf: fix x86 call stack alignment for external calls Marat Khalili
2026-02-04 9:35 ` Thomas Monjalon [this message]
2026-01-14 17:49 ` [PATCH] bpf: fix x86 call stack alignment, add tests Stephen Hemminger
2026-01-14 19:43 ` Stephen Hemminger
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=7022287.MhkbZ0Pkbq@thomas \
--to=thomas@monjalon.net \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@amd.com \
--cc=konstantin.ananyev@huawei.com \
--cc=marat.khalili@huawei.com \
--cc=stable@dpdk.org \
--cc=stephen@networkplumber.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.