linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hari Bathini <hbathini@linux.ibm.com>
To: Luis Gerhorst <luis.gerhorst@fau.de>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>,
	Puranjay Mohan <puranjay@kernel.org>,
	Xu Kuohai <xukuohai@huaweicloud.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will@kernel.org>,
	Christophe Leroy <christophe.leroy@csgroup.eu>,
	Naveen N Rao <naveen@kernel.org>,
	Madhavan Srinivasan <maddy@linux.ibm.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Nicholas Piggin <npiggin@gmail.com>,
	Mykola Lysenko <mykolal@fb.com>, Shuah Khan <shuah@kernel.org>,
	Henriette Herzog <henriette.herzog@rub.de>,
	Saket Kumar Bhaskar <skb99@linux.ibm.com>,
	Cupertino Miranda <cupertino.miranda@oracle.com>,
	Jiayuan Chen <mrpre@163.com>,
	Matan Shachnai <m.shachnai@gmail.com>,
	Dimitar Kanaliev <dimitar.kanaliev@siteground.com>,
	Shung-Hsi Yu <shung-hsi.yu@suse.com>, Daniel Xu <dxu@dxuuu.xyz>,
	bpf@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	linux-kselftest@vger.kernel.org
Cc: Maximilian Ott <ott@cs.fau.de>, Milan Stephan <milan.stephan@fau.de>
Subject: Re: [PATCH bpf-next v2 06/11] bpf, arm64, powerpc: Change nospec to include v1 barrier
Date: Mon, 19 May 2025 12:29:41 +0530	[thread overview]
Message-ID: <6dde4d2e-b249-4fb8-a8f6-359cb7c8b0fe@linux.ibm.com> (raw)
In-Reply-To: <d351c0ba-04fa-4764-a3a2-c4a8727aa582@linux.ibm.com>



On 18/05/25 4:11 pm, Hari Bathini wrote:
> 
> 
> On 21/04/25 2:47 pm, Luis Gerhorst wrote:
>> This changes the semantics of BPF_NOSPEC (previously a v4-only barrier)
>> to always emit a speculation barrier that works against both Spectre v1
>> AND v4. If mitigation is not needed on an architecture, the backend
>> should set bpf_jit_bypass_spec_v4/v1().
>>
>> As of now, this commit only has the user-visible implication that unpriv
>> BPF's performance on PowerPC is reduced. This is the case because we
>> have to emit additional v1 barrier instructions for BPF_NOSPEC now.
>>
>> This commit is required for a future commit to allow us to rely on
>> BPF_NOSPEC for Spectre v1 mitigation. As of this commit, the feature
>> that nospec acts as a v1 barrier is unused.
>>
>> Commit f5e81d111750 ("bpf: Introduce BPF nospec instruction for
>> mitigating Spectre v4") noted that mitigation instructions for v1 and v4
>> might be different on some archs. While this would potentially offer
>> improved performance on PowerPC, it was dismissed after the following
>> considerations:
>>
>> * Only having one barrier simplifies the verifier and allows us to
>>    easily rely on v4-induced barriers for reducing the complexity of
>>    v1-induced speculative path verification.
> 
> Fair enough.
> 
>>
>> * For the architectures that implemented BPF_NOSPEC, only PowerPC has
>>    distinct instructions for v1 and v4. Even there, some insns may be
>>    shared between the barriers for v1 and v4 (e.g., 'ori 31,31,0' and
>>    'sync'). If this is still found to impact performance in an
>>    unacceptable way, BPF_NOSPEC can be split into BPF_NOSPEC_V1 and
>>    BPF_NOSPEC_V4 later. As an optimization, we can already skip v1/v4
>>    insns from being emitted for PowerPC with this setup if
>>    bypass_spec_v1/v4 is set.
>>
> 
> Agreed.
> 
> Acked-by: Hari Bathini <hbathini@linux.ibm.com>

Applies to v3 too :)
Let me send for v3..

- Hari

  reply	other threads:[~2025-05-19  7:01 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-21  9:17 [PATCH bpf-next v2 00/11] bpf: Mitigate Spectre v1 using barriers Luis Gerhorst
2025-04-21  9:17 ` [PATCH bpf-next v2 01/11] selftests/bpf: Fix caps for __xlated/jited_unpriv Luis Gerhorst
2025-04-21  9:17 ` [PATCH bpf-next v2 02/11] bpf: Move insn if/else into do_check_insn() Luis Gerhorst
2025-04-21  9:17 ` [PATCH bpf-next v2 03/11] bpf: Return -EFAULT on misconfigurations Luis Gerhorst
2025-04-21  9:17 ` [PATCH bpf-next v2 04/11] bpf: Return -EFAULT on internal errors Luis Gerhorst
2025-04-21  9:17 ` [PATCH bpf-next v2 05/11] bpf, arm64, powerpc: Add bpf_jit_bypass_spec_v1/v4() Luis Gerhorst
     [not found]   ` <202504212142.V3yjAcaI-lkp@intel.com>
2025-04-21 14:22     ` Luis Gerhorst
2025-04-21  9:17 ` [PATCH bpf-next v2 06/11] bpf, arm64, powerpc: Change nospec to include v1 barrier Luis Gerhorst
     [not found]   ` <202504220035.SoGveGpj-lkp@intel.com>
2025-04-26 10:54     ` Luis Gerhorst
2025-05-18 10:41   ` Hari Bathini
2025-05-19  6:59     ` Hari Bathini [this message]
2025-04-21  9:17 ` [PATCH bpf-next v2 07/11] bpf: Rename sanitize_stack_spill to nospec_result Luis Gerhorst
2025-04-21  9:17 ` [PATCH bpf-next v2 08/11] bpf: Fall back to nospec for Spectre v1 Luis Gerhorst
2025-04-21  9:18 ` [PATCH bpf-next v2 09/11] selftests/bpf: Add test for Spectre v1 mitigation Luis Gerhorst
2025-04-21  9:18 ` [PATCH bpf-next v2 10/11] bpf: Allow nospec-protected var-offset stack access Luis Gerhorst
2025-04-21  9:18 ` [PATCH bpf-next v2 11/11] bpf: Fall back to nospec for sanitization-failures Luis Gerhorst

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=6dde4d2e-b249-4fb8-a8f6-359cb7c8b0fe@linux.ibm.com \
    --to=hbathini@linux.ibm.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=christophe.leroy@csgroup.eu \
    --cc=cupertino.miranda@oracle.com \
    --cc=daniel@iogearbox.net \
    --cc=dimitar.kanaliev@siteground.com \
    --cc=dxu@dxuuu.xyz \
    --cc=eddyz87@gmail.com \
    --cc=haoluo@google.com \
    --cc=henriette.herzog@rub.de \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=luis.gerhorst@fau.de \
    --cc=m.shachnai@gmail.com \
    --cc=maddy@linux.ibm.com \
    --cc=martin.lau@linux.dev \
    --cc=milan.stephan@fau.de \
    --cc=mpe@ellerman.id.au \
    --cc=mrpre@163.com \
    --cc=mykolal@fb.com \
    --cc=naveen@kernel.org \
    --cc=npiggin@gmail.com \
    --cc=ott@cs.fau.de \
    --cc=puranjay@kernel.org \
    --cc=sdf@fomichev.me \
    --cc=shuah@kernel.org \
    --cc=shung-hsi.yu@suse.com \
    --cc=skb99@linux.ibm.com \
    --cc=song@kernel.org \
    --cc=will@kernel.org \
    --cc=xukuohai@huaweicloud.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;
as well as URLs for NNTP newsgroup(s).