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=1796099331; b=F6Rw+d3PyMIZPOLr2kn2kmX8//MOoLigyjWxwnsbtm/0g5KhBPxYqsq4hE/ExEnq12RZ h9AGo1LZFtl5ORUPETM7hWC3k7l+y8FRUx2O0yrCex1FvHfkKdLmdOI9bPmO1eU3/jI84 1JjN/3J3Bk+tyvvo4bd0oqh992WN9XqmWqSSIonBS/NGZ9CoaQVcrKrnyg7709jWEWBDv iafzj1uJH0zfiIQSCtA6f0AXP9HPo+321HjYgeJYJ+xzN7xgp9RIMRZ75f5rc/hFRMCI2 nnVSDl4gXu5NkHm1u1FARkdulfaID9d9qfeTRAvzjBvuYD1DoeiQncJ4HgVcBcLfSTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796099331; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=y92XPTRyMOgcrKQ5+Bm4vgl3irJIFo1nwoVYOyPgSTc=; b=xQdjFkg7Ev+a916QOuZSO9KfAuQRh9zkCvTeowQluBJ4zYtfmv3LVFNYDpv39gvrHuYQ ZKRS1nKmU7jSBY4BI+4hxTlB88+6EYrMiYbFvrYLNXhSDSPOouuPOgW51hNI++2v/G0f2 1ISbi62zUZxRRIIEmDT0SSD3plkhIATkl37ucATG6jK+vYhkdORo6PWV403co47rwv529 x5hSE5/9oVhYft7i5b3cQUvA7LvK0TXq/cjAtV7VR2XHcwJ9n9+um3FJOToQ5zoawbccs LpahwkFhTWBXCF4Yd0kl6KxHq6pRzOhPcxscu4LikKZ7O2YiWVPfn34nnODjwHYks2Q== 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=O3n9X4PO; 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 E2AAF606A335; Tue, 1 Dec 2026 04:28:50 +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=O3n9X4PO Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA1221F00927; Tue, 1 Dec 2026 04:28:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796099330; bh=y92XPTRyMOgcrKQ5+Bm4vgl3irJIFo1nwoVYOyPgSTc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=O3n9X4PO5GfPnL7wAZArM327uwre/LAy0ejoqyTF6YK+mVSLi0afcyVG3SCcSxQwB sJnv+s4U/IZp6Jljv/ht5zB2jmQNRipuwiuzwSWYoasQrDhR0NaY3lpojn06bl8qIE uXxGI26fS+9aPDB2tEnISeYbxU7BbYQriKII46KkG/Q8+aS1jyzMKzSwvavOmdC02Q c0yDIn3pSzh0QiPJvuyd2xPX0J2Q7DNtfrD07VTNg3t3cgYG/z83htQCTBBG6rnX4K HrgoTJxMSWyFGbKOTJkczmD4F9IIO9tAoQtJMRbH+xbf9SYK1kHpEIiNSpvtDtN3bO hSLmBBIGugiNA== From: Song Liu To: linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, live-patching@vger.kernel.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, bpf@vger.kernel.org Cc: rostedt@goodmis.org, mhiramat@kernel.org, mark.rutland@arm.com, peterz@infradead.org, tglx@kernel.org, frederic@kernel.org, paulmck@kernel.org, catalin.marinas@arm.com, will@kernel.org, maddy@linux.ibm.com, mpe@ellerman.id.au, npiggin@gmail.com, chleroy@kernel.org, pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, ojeda@kernel.org, kernel-team@meta.com, Song Liu Subject: [PATCH v3 21/22] riscv: Mark helpers called from noinstr code notrace Date: Mon, 30 Nov 2026 20:22:00 -0800 Message-ID: <20261201042201.3199928-22-song@kernel.org> X-Mailer: git-send-email 2.53.1 In-Reply-To: <20261201042201.3199928-1-song@kernel.org> References: <20261201042201.3199928-1-song@kernel.org> 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 Some noinstr code calls plain inline riscv helpers at points where tracing is not safe: - ct_idle_exit() calls raw_local_irq_save() and raw_local_irq_restore() around ct_kernel_enter(), and cpu_idle_poll() calls raw_local_irq_enable() and cpu_relax() between ct_cpuidle_enter() and ct_cpuidle_exit(), while RCU is not watching. On riscv, the arch_local_irq_*() helpers behind these are plain inline functions. On x86 and arm64 they are __always_inline. - arch_cpu_idle() calls cpu_do_idle() while RCU is not watching. - do_trap_ecall_u() calls riscv_v_vstate_discard() before syscall_enter_from_user_mode(), while RCU is not watching. With clang, a riscv defconfig build has out-of-line copies of cpu_do_idle(), riscv_v_vstate_discard() and several of the irqflags helpers, called from these functions and from other noinstr code. The copies are untraced only because inline implies notrace. Mark these helpers notrace explicitly, together with the rest of the irqflags helpers and the helpers that riscv_v_vstate_discard() calls. No functional change. Assisted-by: Claude:claude-opus-5 Signed-off-by: Song Liu --- arch/riscv/include/asm/cpuidle.h | 2 +- arch/riscv/include/asm/irqflags.h | 14 +++++++------- arch/riscv/include/asm/vdso/processor.h | 2 +- arch/riscv/include/asm/vector.h | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/arch/riscv/include/asm/cpuidle.h b/arch/riscv/include/asm/cpuidle.h index 71fdc607d4bc..20b34b344451 100644 --- a/arch/riscv/include/asm/cpuidle.h +++ b/arch/riscv/include/asm/cpuidle.h @@ -10,7 +10,7 @@ #include #include -static inline void cpu_do_idle(void) +static inline void notrace cpu_do_idle(void) { /* * Add mb() here to ensure that all diff --git a/arch/riscv/include/asm/irqflags.h b/arch/riscv/include/asm/irqflags.h index 6fd8cbfcfcc7..905ea914521f 100644 --- a/arch/riscv/include/asm/irqflags.h +++ b/arch/riscv/include/asm/irqflags.h @@ -10,43 +10,43 @@ #include /* read interrupt enabled status */ -static inline unsigned long arch_local_save_flags(void) +static inline unsigned long notrace arch_local_save_flags(void) { return csr_read(CSR_STATUS); } /* unconditionally enable interrupts */ -static inline void arch_local_irq_enable(void) +static inline void notrace arch_local_irq_enable(void) { csr_set(CSR_STATUS, SR_IE); } /* unconditionally disable interrupts */ -static inline void arch_local_irq_disable(void) +static inline void notrace arch_local_irq_disable(void) { csr_clear(CSR_STATUS, SR_IE); } /* get status and disable interrupts */ -static inline unsigned long arch_local_irq_save(void) +static inline unsigned long notrace arch_local_irq_save(void) { return csr_read_clear(CSR_STATUS, SR_IE); } /* test flags */ -static inline int arch_irqs_disabled_flags(unsigned long flags) +static inline int notrace arch_irqs_disabled_flags(unsigned long flags) { return !(flags & SR_IE); } /* test hardware interrupt enable bit */ -static inline int arch_irqs_disabled(void) +static inline int notrace arch_irqs_disabled(void) { return arch_irqs_disabled_flags(arch_local_save_flags()); } /* set interrupt enabled status */ -static inline void arch_local_irq_restore(unsigned long flags) +static inline void notrace arch_local_irq_restore(unsigned long flags) { csr_set(CSR_STATUS, flags & SR_IE); } diff --git a/arch/riscv/include/asm/vdso/processor.h b/arch/riscv/include/asm/vdso/processor.h index c42f95dc8811..a0636bbda765 100644 --- a/arch/riscv/include/asm/vdso/processor.h +++ b/arch/riscv/include/asm/vdso/processor.h @@ -8,7 +8,7 @@ #include #include -static inline void cpu_relax(void) +static inline void notrace cpu_relax(void) { #ifdef __riscv_muldiv int dummy; diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h index 3381a535abb4..735841258fe3 100644 --- a/arch/riscv/include/asm/vector.h +++ b/arch/riscv/include/asm/vector.h @@ -90,7 +90,7 @@ static inline void __riscv_v_vstate_clean(struct pt_regs *regs) regs->status = __riscv_v_vstate_or(regs->status, CLEAN); } -static inline void __riscv_v_vstate_dirty(struct pt_regs *regs) +static inline void notrace __riscv_v_vstate_dirty(struct pt_regs *regs) { regs->status = __riscv_v_vstate_or(regs->status, DIRTY); } @@ -105,7 +105,7 @@ static inline void riscv_v_vstate_on(struct pt_regs *regs) regs->status = __riscv_v_vstate_or(regs->status, INITIAL); } -static inline bool riscv_v_vstate_query(struct pt_regs *regs) +static inline bool notrace riscv_v_vstate_query(struct pt_regs *regs) { return !__riscv_v_vstate_check(regs->status, OFF); } @@ -272,7 +272,7 @@ static inline void __riscv_v_vstate_restore(struct __riscv_v_ext_state *restore_ riscv_v_disable(); } -static inline void __riscv_v_vstate_discard(void) +static inline void notrace __riscv_v_vstate_discard(void) { unsigned long vl, vtype_inval = 1UL << (BITS_PER_LONG - 1); @@ -300,7 +300,7 @@ static inline void __riscv_v_vstate_discard(void) riscv_v_disable(); } -static inline void riscv_v_vstate_discard(struct pt_regs *regs) +static inline void notrace riscv_v_vstate_discard(struct pt_regs *regs) { if (riscv_v_vstate_query(regs)) { __riscv_v_vstate_discard(); -- 2.53.1-Meta