From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796551940; b=f2LpkHvjQU46/3JwlFecnoI7a+GDZgQkbqlaRIEL6j4/GbpXVeTRJsuvtk4ngc1ShbGS nGGY61ACYxrmiQzrpl3IKscNq5gq3Jgd0qm8Bm5GDtSQVFH4+auIee6qTwWPErbTaUUpI 8j4/G1JAIYG9jahuBt25zXUQ0whh6fZFdpRU/N0WvflOM9pY7hB/wuG0MtP7Ni6GwC+v4 T6TXSY1DSQYEvfDsGlDt8lsS2eiV5/wrhH5I0tIrDsZl+Kpf10ZG2LU9Zoo2RPn2+wvmS 740aNEatxOSa+v1EKErLAMf7JOJlW9Vh0/uHTJdoQ7YUQ9h2PIc067pT2ye47PY16Xw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796551940; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=jh5FQcK2K5M/bL+Go4Y1RTby6ZsiZFhlurMu3IXfr7M=; b=Rqadq/SrBYTnY/f0FkJisdVaALDX9cnGDWB5C+SvvO8iYlOMLKcbo82gE/OR27ao8mCl yTsKbA9TAwtpH2dOZ98ANoBiZPyw9+drDnyjYtpq5mf6O06bUrGQ1tlpnaFZFpqkwoLuM YFq0o0caz5rLZcU+7E5IWbiHVGav30yT5tZUXo3dHgP6R+if+CRisRX58k2zNTSnV4CG2 oo9NGZg2vKOiNlV38JUa5+e/pS1bRapi/rJ9h01hKtpLzgdDytXNHqNkOMTIAAAVZ9KoN hRlvPhEBr7JqOTc08EgE4EwE6tpgwxD4JW2tVRedmK6/fVNbwXZOMaUfGPw6Dtvaqfw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YbvZLmhW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 467BA606A31F for ; Sun, 6 Dec 2026 10:12:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YbvZLmhW Received: by smtp.kernel.org (Postfix) with ESMTPSA id F06471F0092B; Sun, 6 Dec 2026 10:12:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796551940; bh=jh5FQcK2K5M/bL+Go4Y1RTby6ZsiZFhlurMu3IXfr7M=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=YbvZLmhWcxHC8rbikJF08GOoSly1yssvJILkwOlcpIdQaB2hPDLgC94y9xJvosfx+ NF6kRX14xXEB4eboKSEDPRIZfMAVZDYBFjJW6hieMr90XfycsgVAjFaHKz3BTZXrA3 z9nAauFSCR8KfZv+NKk0A2twHS9DzwX85STjL8NZGdiEAoIaAY4MsQYJTMy2IZpu/4 5CH2pFQvp4p+OrJBylgzHvH5gR5/LWTZsSXBPYpOPpbbRmsMFct33QaXUKsnHJiGWV ZDorLULx+wHK4yI2XIj8ic2VAFyq4cXZNVX/fcG8GBvUDeG+/p+Fv/ntHSsinn7rLf zw/N3Tf4zrwbQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH bpf-next 3/6] arm64: patching: Add nosync helpers for instruction copy and set Reply-To: sashiko-reviews@lists.linux.dev To: "Xu Kuohai" , bpf@vger.kernel.org In-Reply-To: References: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Sun, 06 Dec 2026 10:12:19 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] arm64: missing local ISB on task migration before kick_all_cpus_sync() - [Low] arm64: __text_poke() duplicates flush_icache_range() and its KGDB check -- commit f0adbfc81bbc8b0254c57fd9e19c900c17d58113 Author: Xu Kuohai arm64: patching: Add nosync helpers for instruction copy and set This commit adds aarch64_insn_copy_nosync() and aarch64_insn_set_nosync() so callers can defer cross-CPU instruction synchronization instead of sending an IPI on every poke. > diff --git a/arch/arm64/kernel/patching.c b/arch/arm64/kernel/patching.c > index 09f019c6547a0..5e28476db046c 100644 > --- a/arch/arm64/kernel/patching.c > +++ b/arch/arm64/kernel/patching.c [ ... ] > @@ -126,7 +127,15 @@ static void *__text_poke(text_poke_f func, void *add= r, void *src, size_t len) > } > raw_spin_unlock_irqrestore(&patch_lock, flags); > =20 > - flush_icache_range((uintptr_t)addr, (uintptr_t)addr + len); > + caches_clean_inval_pou((uintptr_t)addr, (uintptr_t)addr + len); > + /* > + * IPI all online CPUs to force them to refetch the new instructions. > + * KGDB uses IPIs to round-up the secondary CPUs during the patching > + * operation, so we don't need extra IPIs here. See the comments in > + * flush_icache_range() in arch/arm64/include/asm/cacheflush.h. > + */ > + if (sync && !in_dbg_master()) > + kick_all_cpus_sync(); > =20 > return addr; > } [Severity: Low] Can this call flush_icache_range() when sync is true and caches_clean_inval_pou() otherwise, instead of duplicating flush_icache_range() and its in_dbg_master() check here? arch/arm64/include/asm/cacheflush.h already implements this exact sequence in flush_icache_range(). Calling it directly keeps the KGDB workaround in one place and avoids relying on a transitive include of linux/kgdb.h in patching.c. [ ... ] > +/** > + * aarch64_insn_copy_nosync - Copy instructions into RX memory, no sync > + * @dst: address to modify > + * @src: source of the copy > + * @len: length to copy > + * > + * Same as aarch64_insn_copy(), but does not IPI other CPUs to refetch > + * the new instructions. The caller must do the synchronization before > + * the text is executed. > + */ > +noinstr void *aarch64_insn_copy_nosync(void *dst, void *src, size_t len) > +{ > + return __aarch64_insn_copy(dst, src, len, false); > +} [Severity: Medium] Can a task that migrates between caches_clean_inval_pou() and kick_all_cpus_sync() execute stale prefetched instructions on the new CPU? caches_clean_inval_pou() only executes isb on the local CPU. If the caller migrates to another CPU via a voluntary switch from a thread sharing the same mm, switch_mm() is skipped and __switch_to() issues dsb(ish) without an unconditional isb(). CPU0 CPU1 aarch64_insn_copy_nosync() caches_clean_inval_pou() isb (CPU0 only) ... task migrates to CPU1 ... __switch_to() (same mm, no isb) kick_all_cpus_sync() skips this_cpu (CPU1) execute new text <-- stale prefetch kick_all_cpus_sync() calls smp_call_function_many_cond(), which excludes this_cpu, and sending the IPI does not guarantee a local isb() (for example, GICv2 gic_ipi_send_mask() uses dmb(ishst) and writel_relaxed()). Executing newly written text on CPU1, such as a reused BPF prog pack slot that held AARCH64_BREAK_FAULT, can hit stale prefetched instructions and cause unexpected BRK faults or corrupted execution. The same preemptible window exists in __text_poke() when sync is true, and aarch64_insn_set_nosync() shares this contract. Using on_each_cpu() to run a local isb(), and documenting that callers of the nosync helpers must also synchronize the local CPU, would cover every online CPU. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/cover.1796545068.gi= t.xukuohai@huawei.com?part=3D3