From: Viktor Malik <vmalik@redhat.com>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
Thomas Gleixner <tglx@kernel.org>, Borislav Petkov <bp@alien8.de>,
Peter Zijlstra <peterz@infradead.org>,
Josh Poimboeuf <jpoimboe@kernel.org>,
Pawan Gupta <pawan.kumar.gupta@linux.intel.com>,
Ingo Molnar <mingo@redhat.com>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Valentin Schneider <vschneid@redhat.com>,
Tomas Glozar <tglozar@redhat.com>,
Viktor Malik <vmalik@redhat.com>
Subject: [PATCH bpf-next 0/2] bpf, x86: Restrict BPF JIT IBPB flush to CPUs that ran BPF
Date: Fri, 4 Dec 2026 14:44:00 +0100 [thread overview]
Message-ID: <cover.1796391323.git.vmalik@redhat.com> (raw)
Hi,
we have recently started observing latency spikes on systems with
isolated CPUs when classic BPF programs were running in the background
(e.g. executed by NetworkManager or seccomp). The latencies are caused
by the BPF JIT-spraying mitigation introduced by commit 96cce16e26dd
("bpf: Support for hardening against JIT spraying") and its follow-ups.
The reason is that the IBPB flush is currently broadcast to every online
CPU, including the isolated ones that never run BPF programs.
While recent changes [1] have significantly decreased the frequency of
the IBPB flushes, they haven't eliminated them completely, which still
poses a serious problem for latency-sensitive workloads.
This patch series implement one of the ideas from a9b1f19a6a67 ("bpf:
Prefer packs that won't trigger an IBPB flush on allocation") and
introduce a mechanism to completely avoid the IBPB flushes on CPUs that
have not run any BPF program since the last flush. This is sound because
the original Spectre-v2 vulnerability is only exploitable if a cBPF
program runs on a CPU that previously ran any BPF program (and therefore
can reuse the branch predictors trained on the previous program).
Patch #1 introduces a new per-cpu flag bpf_prog_ran, which records that
a CPU executed any BPF program, and patch #2 restricts the IBPB flushes
on x86 to CPUs that have the flag set. This way, the isolated CPUs that
never run any BPF programs do not receive the unnecessary flushes.
[1] https://lore.kernel.org/bpf/cover.1796304466.git.xukuohai@huawei.com/
Viktor Malik (2):
bpf: Track CPUs that have executed a BPF program
x86/bugs: Restrict BPF JIT IBPB flush to CPUs that ran BPF
arch/x86/kernel/cpu/bugs.c | 8 +++++++-
include/linux/filter.h | 27 ++++++++++++++++++++++++++-
kernel/bpf/core.c | 8 ++++++++
kernel/bpf/trampoline.c | 5 +++++
4 files changed, 46 insertions(+), 2 deletions(-)
--
2.56.1
next reply other threads:[~2026-12-04 13:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-04 13:44 Viktor Malik [this message]
2026-12-04 13:44 ` [PATCH bpf-next 1/2] bpf: Track CPUs that have executed a BPF program Viktor Malik
2026-12-04 14:03 ` sashiko-bot
2026-12-04 15:22 ` Viktor Malik
2026-12-04 14:51 ` Valentin Schneider
2026-12-04 16:27 ` Dave Hansen
2026-12-04 16:45 ` Viktor Malik
2026-12-04 13:44 ` [PATCH bpf-next 2/2] x86/bugs: Restrict BPF JIT IBPB flush to CPUs that ran BPF Viktor Malik
2026-12-04 14:17 ` sashiko-bot
2026-12-04 15:33 ` Viktor Malik
2026-12-04 14:51 ` Valentin Schneider
2026-12-04 15:01 ` [PATCH bpf-next 0/2] bpf, x86: " Valentin Schneider
2026-12-04 16:37 ` Dave Hansen
2026-12-04 17:46 ` Valentin Schneider
2026-12-04 19:42 ` Alexei Starovoitov
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=cover.1796391323.git.vmalik@redhat.com \
--to=vmalik@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bp@alien8.de \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=dave.hansen@linux.intel.com \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=hpa@zytor.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jpoimboe@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mingo@redhat.com \
--cc=pawan.kumar.gupta@linux.intel.com \
--cc=peterz@infradead.org \
--cc=song@kernel.org \
--cc=tglozar@redhat.com \
--cc=tglx@kernel.org \
--cc=vschneid@redhat.com \
--cc=x86@kernel.org \
--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