From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796391864; b=Zgd4TgxzwfqaY0hGRyij04VH+g/eH6HjhXw05/HHO/FPtCrVac5KiYT9oBoLHFLc9xdk wT7Mmsbf1i0Idqas/DKso6/JBR1xnSqXC1Te/OOVsr2IWKWWQaMPPDphwCxXE3R6afmde cYV5/SonEc6uiGwPTxAg89AvZtoGWUfYPchjTwgsFYBcFAhhIe5X+c9pCrr/1y2wI//R/ AmzOgEmWOJkwWI+rtUSH3Mz5KIv5NhoulvOEwCjMnV2/J6LpTFwIIYQNSSKaPhHoMsRdr i1j2xZmfSydIwJWB9iqH4zqKgoRhEeW9VUaXl9dJQvVKu3BMl+o2lFmke7UConrGGHg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796391864; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:Received:From:To:Cc:Subject:Date: Message-ID:MIME-Version:Content-Transfer-Encoding:X-Scanned-By; bh=LrI36uS5wUdTunjVHmqcCKNKZjhZ27EaucF8SLKJE3c=; b=mB1kVspJOC1vP8rXwh8ee1D1aMw2ZjZ6rRA9FP+C66SUuzWjLoB8LXPtoQxiE95e1BO/ TwP4Q3KkK/q7amvnjqd0iLyt/5i8Sl55J2EICfuSp5EA4LoTA0XqOLODzS81DMKi/i2tZ 3t8v2K4RYy1pkpzmkEH82xAvhBbPcSR7boC0UGJAakSQ84rnw2tKnK3AAeYma+eb2OqWP c4LLnV/VD6hOqAx8v2EYtL9u6HeVgw9Omkk6m+OTiF+iSK5C4gY7APie2lS6guDuYuwLN uIO4fXinj8Ye2ahduHXqlYfKE7alSG3SrpleZG6CdNa6vo9vw5Pq5UI35JrvZLA2N2A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ga5x9PO1; arc=none smtp.remote-ip=170.10.133.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24585606A690 for ; Fri, 4 Dec 2026 13:44:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 24585606A690 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ga5x9PO1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796391864; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=LrI36uS5wUdTunjVHmqcCKNKZjhZ27EaucF8SLKJE3c=; b=ga5x9PO10az/1PMEmiUyTVcu8c6mJQjeKRxz2BS5YXe8LAWwT06om5/QPPnhIDf/kl+FRA jWK8VRh3AtEKosytOrVLkRkYCT7JohlhBio7wMq00oBcx4GPLjniRg9o5Foajlir0xffxy ozEJHUS7fhSI1tGScLzIFwOxUiimV38= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-528-Q7vCa1RGOdm6d8yK0RHVYw-1; Fri, 4 Dec 2026 13:44:16 +0000 X-MC-Unique: Q7vCa1RGOdm6d8yK0RHVYw-1 X-Mimecast-MFC-AGG-ID: Q7vCa1RGOdm6d8yK0RHVYw_1796391853 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8496A1891BB7; Fri, 4 Dec 2026 13:44:12 +0000 (UTC) Received: from vmalik-thinkpadx1carbongen11.redhat.corp (headnet04.pony-001.prod.iad2.dc.redhat.com [10.2.32.116]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F3AD11955F28; Fri, 4 Dec 2026 13:44:05 +0000 (UTC) From: Viktor Malik To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Eduard Zingerman , Kumar Kartikeya Dwivedi , Martin KaFai Lau , Song Liu , Yonghong Song , Jiri Olsa , Emil Tsalapatis , Ihor Solodrai , John Fastabend , Thomas Gleixner , Borislav Petkov , Peter Zijlstra , Josh Poimboeuf , Pawan Gupta , Ingo Molnar , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Valentin Schneider , Tomas Glozar , Viktor Malik 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 Message-ID: X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 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