Move notrace from inline to __always_inline
Song Liu
maintainerv3 cover Move notrace from inline to __always_inline
Since commit 45959ee7aa64 ("ftrace: Do not function trace inlined functions"), every function marked inline is also notrace. When the compiler does not inline such a function, the out-of-line copy cannot be traced with ftrace, cannot be a BPF fentry/fexit target, and cannot be livepatched. This series moves notrace from inline to __always_inline, so these copies become traceable. __always_inline functions, which are mostly low-level helpers, stay untraced.
Patches 1-21 add notrace explicitly to the inline helpers that need it. While inline still implies notrace, they do not change the generated
code: vmlinux .text is byte-identical with and without them on x86_64 (gcc 11.5), and on arm64, powerpc and riscv (clang 22).
- 1-2: x86 paravirt native helpers, and the helpers used by resume and kexec.
- 3-6: helpers used by bpf_spin_lock, the BPF trampoline and bpf_mem_alloc, where an fentry program on one of them could deadlock, recurse without bound or corrupt the free lists.
- 7-8: tracepoint and SRCU helpers used by tracing.
- 9-12: helpers used by ftrace recursion protection: the accessors behind preempt_count() and current on arm64, powerpc, csky, mips and sh, the Tiny RCU rcu_is_watching(), and the tracing_gen_ctx helpers.
- 13-15: helpers called by notrace code in the trace clocks, core_kernel_text() and the nofault accessors.
- 16-21 (new in v3): helpers that noinstr code calls while RCU is not watching or before NMI entry: exception_enter(), the thread flag helpers, and helpers on arm64, powerpc and riscv, including the arm64 stack unwinder helpers.
To find these, I compared builds with and without patch 22, and listed the functions that become traceable and are called from code without an fentry call (notrace, noinstr, or built without -pg). On x86_64 this includes calls through pv_ops, and objtool's noinstr validation checks that the noinstr callers call them inside instrumentation windows. For v2, I repeated the x86_64 analysis with -fno-inline, to also cover helpers that gcc happens to inline today.
For v3, I also ran the analysis on arm64, powerpc and riscv, built with clang. These architectures do not have objtool's noinstr validation, and their noinstr code calls out-of-line copies of plain inline helpers, some of them before entry code has made RCU watch, in the cpuidle RCU-idle windows, or in NMI-like handlers. Patches 16-21 mark these helpers. The remaining untraced callers on these architectures are the same kinds as on x86_64: noinstr code that calls them while RCU is watching, __schedule(), the TRACE_EVENT() output functions, and directories built without -pg. I could not build loongarch or 32-bit arm, so they are only covered for ftrace recursion protection.
The series makes 712 more functions traceable on x86_64 with CONFIG_PARAVIRT_XXL and gcc 11.5, and 1464, 1429 and 1128 on arm64, powerpc and riscv defconfigs with clang 22. None become untraceable. In QEMU, with ftrace filtered to native_load_idt(), a kernel with v1 dies on resume from S3, as Sashiko predicted. With this series, S3 suspend/resume, CPU hotplug and hibernation test mode pass with ftrace on all native_* functions, repeated kexec passes with ftrace on all functions, and the function and function_graph tracers on all functions show no warnings. The series also builds for i386.
Changes v2 => v3:
- Rebase on v7.4-rc5 (Steven Rostedt). Patch 9 now applies on top of
these changes to arch/arm64/include/asm/preempt.h:
commit 1bee18253c2e ("arm64: preempt: Simplify and optimize __preempt_count_dec_and_test()") commit 6254b223153d ("arm64: preempt: Treat should_resched() as unlikely")
- Add patches 16-21, found by running the analysis on arm64, powerpc
and riscv.
- Add Acked-by from Steven to patch 7.
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
Song Liu (22):
x86/paravirt: Mark native pv_ops helpers notrace
x86: Mark CPU state helpers used by resume and kexec notrace
bpf: Mark bpf_spin_lock helpers notrace
bpf: Mark the BPF trampoline helpers notrace
bpf: Mark the bpf_mem_alloc fast path helpers notrace
u64_stats: Mark the update helpers used by BPF notrace
tracepoint: Mark __do_trace_##name() notrace
srcu: Mark the fast notrace read-side helpers notrace
arm64: Mark the preempt count helpers notrace
powerpc, csky, mips, sh: Mark the accessors behind current notrace
rcu: Mark the Tiny RCU rcu_is_watching() notrace
tracing: Mark the tracing_gen_ctx helpers notrace
ktime: Mark ktime_to_ns() notrace
kallsyms: Mark the kernel text address checks notrace
uaccess: Mark pagefault_disable() and pagefault_enable() notrace
context_tracking: Mark exception_enter() and exception_exit() notrace
thread_info: Mark the thread flag helpers notrace
arm64: Mark helpers called from noinstr code notrace
arm64: Mark the stack unwinder helpers notrace
powerpc: Mark helpers called from noinstr code notrace
riscv: Mark helpers called from noinstr code notrace
compiler_types: Move notrace from inline to __always_inline
arch/arm64/include/asm/cpufeature.h | 4 +- arch/arm64/include/asm/memory.h | 2 +- arch/arm64/include/asm/mmu.h | 2 +- arch/arm64/include/asm/percpu.h | 2 +- arch/arm64/include/asm/preempt.h | 12 ++-- arch/arm64/include/asm/ptrace.h | 2 +- arch/arm64/include/asm/stacktrace.h | 16 ++--- arch/arm64/include/asm/stacktrace/common.h | 10 ++-- arch/arm64/include/asm/vdso/processor.h | 2 +- arch/arm64/include/asm/virt.h | 2 +- arch/csky/include/asm/thread_info.h | 2 +- arch/mips/include/asm/thread_info.h | 2 +- arch/powerpc/include/asm/atomic.h | 38 ++++++------ arch/powerpc/include/asm/bitops.h | 29 ++++----- arch/powerpc/include/asm/cmpxchg.h | 2 +- arch/powerpc/include/asm/current.h | 2 +- arch/powerpc/include/asm/entry-common.h | 32 +++++----- arch/powerpc/include/asm/hw_irq.h | 68 +++++++++++----------- arch/powerpc/include/asm/interrupt.h | 2 +- arch/powerpc/include/asm/io.h | 16 ++--- arch/powerpc/include/asm/plpar_wrappers.h | 4 +- arch/powerpc/include/asm/ptrace.h | 14 ++--- arch/powerpc/include/asm/rtas.h | 10 ++-- arch/powerpc/include/asm/synch.h | 6 +- arch/powerpc/include/asm/thread_info.h | 4 +- arch/powerpc/kernel/watchdog.c | 4 +- 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 +-- arch/sh/include/asm/thread_info.h | 2 +- arch/x86/include/asm/cpuid/api.h | 4 +- arch/x86/include/asm/desc.h | 17 +++--- arch/x86/include/asm/gsseg.h | 4 +- arch/x86/include/asm/io.h | 2 +- arch/x86/include/asm/io_bitmap.h | 2 +- arch/x86/include/asm/local.h | 8 +-- arch/x86/include/asm/msr.h | 8 +-- arch/x86/include/asm/paravirt-spinlock.h | 2 +- arch/x86/include/asm/paravirt.h | 20 +++---- arch/x86/include/asm/pgalloc.h | 2 +- arch/x86/include/asm/pgtable_64.h | 10 ++-- arch/x86/include/asm/processor.h | 2 +- arch/x86/include/asm/segment.h | 4 +- arch/x86/include/asm/special_insns.h | 8 +-- include/asm-generic/sections.h | 4 +- include/linux/bpf.h | 8 +-- include/linux/compiler_attributes.h | 6 +- include/linux/compiler_types.h | 3 +- include/linux/context_tracking.h | 4 +- include/linux/kallsyms.h | 2 +- include/linux/ktime.h | 2 +- include/linux/llist.h | 16 ++--- include/linux/percpu-refcount.h | 12 ++-- include/linux/pgtable.h | 12 ++-- include/linux/rcupdate.h | 14 ++--- include/linux/rcupdate_trace.h | 4 +- include/linux/rcutiny.h | 2 +- include/linux/sched.h | 8 +-- include/linux/srcu.h | 10 ++-- include/linux/srcutiny.h | 5 +- include/linux/srcutree.h | 2 +- include/linux/thread_info.h | 12 ++-- include/linux/trace_events.h | 6 +- include/linux/tracepoint.h | 4 +- include/linux/u64_stats_sync.h | 30 +++++----- include/linux/uaccess.h | 4 +- kernel/bpf/helpers.c | 12 ++-- 68 files changed, 300 insertions(+), 292 deletions(-)
base-commit: fe6ff8d5d675c01793b9f051d16055dd4aa75244
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 1/22 x86/paravirt: Mark native pv_ops helpers notrace
The native implementations of several pv_ops are static inline functions in headers. pv_ops stores their address, so with CONFIG_PARAVIRT_XXL the compiler emits an out-of-line copy of each one, and pv_ops calls go to that copy. Today these copies are not traced only because the inline macro implies notrace.
Some callers of these helpers must not be traced:restore_processor_state() is notrace and runs during resume, __switch_to() is __notrace_funcgraph, and arch/x86/kernel/cpu/common.c and arch/x86/kernel/tsc.c, which call several of them, are built without -pg.
Mark these helpers notrace explicitly, like native_write_msr() and native_write_msr_safe() already are, so they stay untraced if inline no longer implies notrace. No functional change.
--- arch/x86/include/asm/cpuid/api.h | 4 ++-- arch/x86/include/asm/desc.h | 17 +++++++++-------- arch/x86/include/asm/gsseg.h | 2 +- arch/x86/include/asm/io_bitmap.h | 2 +- arch/x86/include/asm/msr.h | 6 +++--- arch/x86/include/asm/pgalloc.h | 2 +- arch/x86/include/asm/pgtable_64.h | 10 +++++----- arch/x86/include/asm/processor.h | 2 +- arch/x86/include/asm/special_insns.h | 2 +- include/linux/pgtable.h | 12 ++++++------ 10 files changed, 30 insertions(+), 29 deletions(-)
arch/x86/include/asm/cpuid/api.h +2 -2
@@ -23,8 +23,8 @@ static inline bool cpuid_feature(void) }#endif -static inline void native_cpuid (u32 *eax,u32 *ebx, -u32 *ecx,u32 *edx) +static inline void notrace native_cpuid(u32 *eax, u32 *ebx, +u32 *ecx,u32 *edx) {/* ecx is often an input as well as an output. */ asm volatile("cpuid"
arch/x86/include/asm/desc.h +9 -8
@@ -134,17 +134,18 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)#define store_ldt (ldt) asm("sldt %0" : "=m"(ldt)) -static inline void native_write_idt_entry (gate_desc *idt,int entry,const gate_desc *gate) +static inline void notrace native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate) {memcpy (&idt[entry], gate,sizeof (*gate)); } -static inline void native_write_ldt_entry (struct desc_struct *ldt,int entry,const void *desc) +static inline void notrace +native_write_ldt_entry (struct desc_struct *ldt,int entry,const void *desc) {memcpy (&ldt[entry], desc,8 ); } -static inline void +static inline void notracenative_write_gdt_entry (struct desc_struct *gdt,int entry,const void *desc,int type) {unsigned int size;
@@ -189,7 +190,7 @@ static inline void __set_tss_desc(unsigned cpu, unsigned int entry, struct x86_h#define set_tss_desc (cpu, addr) __set_tss_desc(cpu, GDT_ENTRY_TSS, addr) -static inline void native_set_ldt (const void *addr,unsigned int entries) +static inline void notrace native_set_ldt(const void *addr, unsigned int entries) {if (likely (entries ==0 )) asmvolatile ("lldt %w0" ::"q" (0 ));
@@ -205,7 +206,7 @@ static inline void native_set_ldt(const void *addr, unsigned int entries) } } -static inline void native_load_gdt (const struct desc_ptr *dtr) +static inline void notrace native_load_gdt(const struct desc_ptr *dtr) { asmvolatile ("lgdt %0" ::"m" (*dtr)); }
@@ -251,7 +252,7 @@ static inline void native_idt_invalidate(void)* original writeable version when needed. */ #ifdef CONFIG_X86_64 -static inline void native_load_tr_desc (void ) +static inline void notrace native_load_tr_desc(void) {struct desc_ptr gdt;int cpu =raw_smp_processor_id ();
@@ -280,7 +281,7 @@ static inline void native_load_tr_desc(void) }#endif -static inline unsigned long native_store_tr (void ) +static inline unsigned long notrace native_store_tr (void ) {unsigned long tr;
@@ -289,7 +290,7 @@ static inline unsigned long native_store_tr(void)return tr; } -static inline void native_load_tls (struct thread_struct *t,unsigned int cpu) +static inline void notrace native_load_tls(struct thread_struct *t, unsigned int cpu) {struct desc_struct *gdt =get_cpu_gdt_rw (cpu);unsigned int i;
arch/x86/include/asm/gsseg.h +1 -1
@@ -25,7 +25,7 @@ static inline void native_lkgs(unsigned int selector) : [sel] "+D" (sel)); } -static inline void native_load_gs_index (unsigned int selector) +static inline void notrace native_load_gs_index(unsigned int selector) {if (cpu_feature_enabled (X86_FEATURE_LKGS )) {native_lkgs (selector);
arch/x86/include/asm/io_bitmap.h +1 -1
@@ -19,7 +19,7 @@ struct task_struct;void io_bitmap_share (struct task_struct *tsk);void io_bitmap_exit (struct task_struct *tsk); -static inline void native_tss_invalidate_io_bitmap (void ) +static inline void notrace native_tss_invalidate_io_bitmap(void) {/* * Invalidate the I/O bitmap by moving io_bitmap_base outside the
arch/x86/include/asm/msr.h +3 -3
@@ -101,7 +101,7 @@ static __always_inline u64 native_rdmsrq(u32 msr)#define native_wrmsrq (msr, val) \ __wrmsrq((msr), (val)) -static inline u64 native_read_msr (u32 msr) +static inline u64 notrace native_read_msr(u32 msr) {u64 val;
@@ -113,7 +113,7 @@ static inline u64 native_read_msr(u32 msr)return val; } -static inline int native_read_msr_safe (u32 msr,u64 *p) +static inline int notrace native_read_msr_safe(u32 msr, u64 *p) {int err;EAX_EDX_DECLARE_ARGS (val, low, high);
@@ -159,7 +159,7 @@ static inline int notrace native_write_msr_safe(u32 msr, u64 val)extern int rdmsr_safe_regs (u32 regs[8 ]);extern int wrmsr_safe_regs (u32 regs[8 ]); -static inline u64 native_read_pmc (int counter) +static inline u64 notrace native_read_pmc(int counter) {EAX_EDX_DECLARE_ARGS (val, low, high);
arch/x86/include/asm/pgalloc.h +1 -1
@@ -12,7 +12,7 @@#define __HAVE_ARCH_PGD_FREE#include <asm-generic/pgalloc.h> -static inline int __paravirt_pgd_alloc (struct mm_struct *mm) {return 0 ; } +static inline int notrace __paravirt_pgd_alloc(struct mm_struct *mm) { return 0; }#ifdef CONFIG_PARAVIRT_XXL #include <asm/paravirt.h>
arch/x86/include/asm/pgtable_64.h +5 -5
@@ -40,7 +40,7 @@ static inline bool mm_p4d_folded(struct mm_struct *mm)void set_pte_vaddr_p4d (p4d_t *p4d_page,unsigned long vaddr,pte_t new_pte);void set_pte_vaddr_pud (pud_t *pud_page,unsigned long vaddr,pte_t new_pte); -static inline void native_set_pte (pte_t *ptep,pte_t pte) +static inline void notrace native_set_pte(pte_t *ptep, pte_t pte) {WRITE_ONCE (*ptep, pte); }
@@ -56,7 +56,7 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)native_set_pte (ptep, pte); } -static inline void native_set_pmd (pmd_t *pmdp,pmd_t pmd) +static inline void notrace native_set_pmd(pmd_t *pmdp, pmd_t pmd) {WRITE_ONCE (*pmdp, pmd); }
@@ -92,7 +92,7 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)#endif } -static inline void native_set_pud (pud_t *pudp,pud_t pud) +static inline void notrace native_set_pud(pud_t *pudp, pud_t pud) {WRITE_ONCE (*pudp, pud); }
@@ -117,7 +117,7 @@ static inline pud_t native_pudp_get_and_clear(pud_t *xp)#endif } -static inline void native_set_p4d (p4d_t *p4dp,p4d_t p4d) +static inline void notrace native_set_p4d(p4d_t *p4dp, p4d_t p4d) {pgd_t pgd;
@@ -137,7 +137,7 @@ static inline void native_p4d_clear(p4d_t *p4d)native_set_p4d (p4d,native_make_p4d (0 )); } -static inline void native_set_pgd (pgd_t *pgdp,pgd_t pgd) +static inline void notrace native_set_pgd(pgd_t *pgdp, pgd_t pgd) {WRITE_ONCE (*pgdp,pti_set_user_pgtbl (pgdp, pgd)); }
arch/x86/include/asm/processor.h +1 -1
@@ -548,7 +548,7 @@ static inline void arch_thread_struct_whitelist(unsigned long *offset,fpu_thread_struct_whitelist (offset, size); } -static inline void +static inline void notracenative_load_sp0 (unsigned long sp0) {this_cpu_write (cpu_tss_rw.x86_tss.sp0, sp0);
arch/x86/include/asm/special_insns.h +1 -1
@@ -12,7 +12,7 @@void native_write_cr0 (unsigned long val); -static inline unsigned long native_read_cr0 (void ) +static inline unsigned long notrace native_read_cr0 (void ) {unsigned long val; asmvolatile ("mov %%cr0,%0" :"=r" (val));
include/linux/pgtable.h +6 -6
@@ -1607,9 +1607,9 @@ static inline int pmd_none_or_clear_bad(pmd_t *pmd)return 0 ; } -static inline pte_t __ptep_modify_prot_start (struct vm_area_struct *vma, -unsigned long addr, -pte_t *ptep) +static inline pte_t notrace __ptep_modify_prot_start(struct vm_area_struct *vma, +unsigned long addr, +pte_t *ptep) {/* * Get the current pte state, but zero it out to make it
@@ -1619,9 +1619,9 @@ static inline pte_t __ptep_modify_prot_start(struct vm_area_struct *vma,return ptep_get_and_clear (vma->vm_mm, addr, ptep); } -static inline void __ptep_modify_prot_commit (struct vm_area_struct *vma, -unsigned long addr, -pte_t *ptep,pte_t pte) +static inline void notrace __ptep_modify_prot_commit(struct vm_area_struct *vma, +unsigned long addr, +pte_t *ptep,pte_t pte) {/* * The pte is non-present, so there's no hardware state to
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 2/22 x86: Mark CPU state helpers used by resume and kexec notrace
In reply to Song Liu__restore_processor_state() is notrace because it starts running before %gs and the IDT are restored, when the function tracer cannot run yet. Before it restores MSR_GS_BASE, it calls wrmsrq(), __write_cr4(), write_cr3(), write_cr0(), load_idt() and loadsegment(), and after that it calls load_gs_index(). With CONFIG_PARAVIRT_XXL, wrmsrq() calls paravirt_write_msr(). machine_kexec() calls virt_to_phys() after load_segments() has reset %gs. All of these are plain inline functions. If the compiler emits one of them out of line, that copy is untraced only because inline implies notrace.
Mark them notrace explicitly, together with the other paravirt MSR accessors, so they stay consistent with paravirt_write_msr(). No functional change.
--- arch/x86/include/asm/gsseg.h | 2 +- arch/x86/include/asm/io.h | 2 +- arch/x86/include/asm/msr.h | 2 +- arch/x86/include/asm/paravirt.h | 20 ++++++++++---------- arch/x86/include/asm/segment.h | 4 ++-- arch/x86/include/asm/special_insns.h | 6 +++--- 6 files changed, 18 insertions(+), 18 deletions(-)
arch/x86/include/asm/gsseg.h +1 -1
@@ -52,7 +52,7 @@ static inline void __init lkgs_init(void)#ifndef CONFIG_PARAVIRT_XXL -static inline void load_gs_index (unsigned int selector) +static inline void notrace load_gs_index(unsigned int selector) {#ifdef CONFIG_X86_64 native_load_gs_index (selector);
arch/x86/include/asm/io.h +1 -1
@@ -126,7 +126,7 @@ extern int valid_mmap_phys_addr_range(unsigned long pfn, size_t size);* this function */ -static inline phys_addr_t virt_to_phys (volatile void *address) +static inline phys_addr_t notrace virt_to_phys(volatile void *address) {return __pa (address); }
arch/x86/include/asm/msr.h +1 -1
@@ -194,7 +194,7 @@ static inline void wrmsr(u32 msr, u32 low, u32 high)#define rdmsrq (msr, val) \ ((val) = native_read_msr((msr))) -static inline void wrmsrq (u32 msr,u64 val) +static inline void notrace wrmsrq(u32 msr, u64 val) {native_write_msr (msr, val); }
arch/x86/include/asm/paravirt.h +10 -10
@@ -98,7 +98,7 @@ static inline unsigned long read_cr0(void) return PVOP_CALL0(unsigned long, pv_ops, cpu.read_cr0); } -static inline void write_cr0 (unsigned long x) +static inline void notrace write_cr0(unsigned long x) {PVOP_VCALL1 (pv_ops, cpu.write_cr0, x); }
@@ -120,32 +120,32 @@ static inline unsigned long __read_cr3(void) "mov %%cr3, %%rax", ALT_NOT_XEN); } -static inline void write_cr3 (unsigned long x) +static inline void notrace write_cr3(unsigned long x) {PVOP_ALT_VCALL1 (pv_ops, mmu.write_cr3, x,"mov %%rdi, %%cr3" ,ALT_NOT_XEN ); } -static inline void __write_cr4 (unsigned long x) +static inline void notrace __write_cr4(unsigned long x) {PVOP_VCALL1 (pv_ops, cpu.write_cr4, x); } -static inline u64 paravirt_read_msr (u32 msr) +static inline u64 notrace paravirt_read_msr(u32 msr) {return PVOP_CALL1 (u64, pv_ops, cpu.read_msr, msr); } -static inline void paravirt_write_msr (u32 msr,u64 val) +static inline void notrace paravirt_write_msr(u32 msr, u64 val) {PVOP_VCALL2 (pv_ops, cpu.write_msr, msr, val); } -static inline int paravirt_read_msr_safe (u32 msr,u64 *val) +static inline int notrace paravirt_read_msr_safe(u32 msr, u64 *val) {return PVOP_CALL2 (int, pv_ops, cpu.read_msr_safe, msr, val); } -static inline int paravirt_write_msr_safe (u32 msr,u64 val) +static inline int notrace paravirt_write_msr_safe(u32 msr, u64 val) {return PVOP_CALL2 (int, pv_ops, cpu.write_msr_safe, msr, val); }
@@ -167,7 +167,7 @@ do { \ val =paravirt_read_msr (msr); \ }while (0 ) -static inline void wrmsrq(u32 msr, u64 val) +static inline void notrace wrmsrq(u32 msr, u64 val) {paravirt_write_msr (msr, val); }
@@ -215,7 +215,7 @@ static inline void load_gdt(const struct desc_ptr *dtr) {PVOP_VCALL1 (pv_ops, cpu.load_gdt, dtr); } -static inline void load_idt (const struct desc_ptr *dtr) +static inline void notrace load_idt(const struct desc_ptr *dtr) {PVOP_VCALL1 (pv_ops, cpu.load_idt, dtr); }
@@ -234,7 +234,7 @@ static inline void load_TLS(struct thread_struct *t, unsigned cpu)PVOP_VCALL2 (pv_ops, cpu.load_tls, t, cpu); } -static inline void load_gs_index (unsigned int gs) +static inline void notrace load_gs_index(unsigned int gs) {PVOP_VCALL1 (pv_ops, cpu.load_gs_index, gs); }
arch/x86/include/asm/segment.h +2 -2
@@ -303,7 +303,7 @@ extern const char xen_early_idt_handler_array[NUM_EXCEPTION_VECTORS][XEN_EARLY_I* FS and GS. */ #define LOAD_SEGMENT (seg) \ -static inline void __loadsegment_##seg(u16 value) \ +static inline void notrace __loadsegment_##seg(u16 value) \ { \ asm volatile("1: movl %k0,%%" #seg "\n" \ _ASM_EXTABLE_TYPE_REG(1b, 1b, EX_TYPE_ZERO_REG, %k0)\
@@ -325,7 +325,7 @@ LOAD_SEGMENT(gs)#else -static inline void __loadsegment_fs (u16 value) +static inline void notrace __loadsegment_fs(u16 value) { asmvolatile ("1: movw %0, %%fs\n" "2:\n"
arch/x86/include/asm/special_insns.h +3 -3
@@ -134,7 +134,7 @@ static inline unsigned long read_cr0(void)return native_read_cr0 (); } -static inline void write_cr0 (unsigned long x) +static inline void notrace write_cr0(unsigned long x) {native_write_cr0 (x); }
@@ -158,12 +158,12 @@ static inline unsigned long __read_cr3(void)return __native_read_cr3 (); } -static inline void write_cr3 (unsigned long x) +static inline void notrace write_cr3(unsigned long x) {native_write_cr3 (x); } -static inline void __write_cr4 (unsigned long x) +static inline void notrace __write_cr4(unsigned long x) {native_write_cr4 (x); }
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 3/22 bpf: Mark bpf_spin_lock helpers notrace
In reply to Song LiuCommit 178c54666f9c ("bpf: Mark bpf_spin_{lock,unlock}() helpers with notrace correctly") made bpf_spin_lock() and bpf_spin_unlock() untraceable, so that an fentry program that also takes the lock cannot deadlock. These helpers call the static inline functions __bpf_spin_lock_irqsave(), __bpf_spin_unlock_irqrestore(), __bpf_spin_lock() and __bpf_spin_unlock(). __bpf_spin_unlock() releases the lock with queued_spin_unlock(), which is a plain inline function on x86 with CONFIG_PARAVIRT_SPINLOCKS. The generic version is __always_inline. __bpf_spin_unlock_irqrestore(), __bpf_spin_unlock() and queued_spin_unlock() run with the lock held, so an fentry program attached to an out-of-line copy of one of them can hit the same deadlock. These copies are untraced today only because inline implies notrace.
Mark all of these helpers notrace explicitly, so that nothing called by bpf_spin_lock() and bpf_spin_unlock() is traceable. No functional change.
--- arch/x86/include/asm/paravirt-spinlock.h | 2 +- kernel/bpf/helpers.c | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
arch/x86/include/asm/paravirt-spinlock.h +1 -1
@@ -71,7 +71,7 @@ static inline void queued_spin_lock_slowpath(struct qspinlock *lock, u32 val)pv_queued_spin_lock_slowpath (lock, val); } -static inline void queued_spin_unlock (struct qspinlock *lock) +static inline void notrace queued_spin_unlock(struct qspinlock *lock) {kcsan_release ();pv_queued_spin_unlock (lock);
kernel/bpf/helpers.c +6 -6
@@ -284,7 +284,7 @@ const struct bpf_func_proto bpf_get_current_comm_proto = { #if defined(CONFIG_QUEUED_SPINLOCKS) || defined(CONFIG_BPF_ARCH_SPINLOCK) -static inline void __bpf_spin_lock(struct bpf_spin_lock *lock) +static inline void notrace __bpf_spin_lock(struct bpf_spin_lock *lock) { arch_spinlock_t *l = (void *)lock; union {
@@ -299,7 +299,7 @@ static inline void __bpf_spin_lock(struct bpf_spin_lock *lock)arch_spin_lock (l); } -static inline void __bpf_spin_unlock (struct bpf_spin_lock *lock) +static inline void notrace __bpf_spin_unlock(struct bpf_spin_lock *lock) {arch_spinlock_t *l = (void *)lock;
@@ -309,7 +309,7 @@ static inline void __bpf_spin_unlock(struct bpf_spin_lock *lock)#else -static inline void __bpf_spin_lock (struct bpf_spin_lock *lock) +static inline void notrace __bpf_spin_lock(struct bpf_spin_lock *lock) {atomic_t *l = (void *)lock;
@@ -319,7 +319,7 @@ static inline void __bpf_spin_lock(struct bpf_spin_lock *lock) }while (atomic_xchg (l,1 )); } -static inline void __bpf_spin_unlock (struct bpf_spin_lock *lock) +static inline void notrace __bpf_spin_unlock(struct bpf_spin_lock *lock) {atomic_t *l = (void *)lock;
@@ -330,7 +330,7 @@ static inline void __bpf_spin_unlock(struct bpf_spin_lock *lock) static DEFINE_PER_CPU(unsigned long, irqsave_flags); -static inline void __bpf_spin_lock_irqsave (struct bpf_spin_lock *lock) +static inline void notrace __bpf_spin_lock_irqsave(struct bpf_spin_lock *lock) {unsigned long flags;
@@ -353,7 +353,7 @@ const struct bpf_func_proto bpf_spin_lock_proto = { .arg1_btf_id = BPF_PTR_POISON, }; -static inline void __bpf_spin_unlock_irqrestore (struct bpf_spin_lock *lock) +static inline void notrace __bpf_spin_unlock_irqrestore(struct bpf_spin_lock *lock) {unsigned long flags;
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 4/22 bpf: Mark the BPF trampoline helpers notrace
In reply to Song LiuThe BPF trampoline calls __bpf_prog_enter*() before each program and __bpf_prog_exit*() after it, and calls __bpf_tramp_enter() and __bpf_tramp_exit() around the traced function. These functions are
notrace: if anything they call could run a BPF program, attaching a program there would recurse without bound. The recursion check in __bpf_prog_enter_recur() does not prevent this, because the trampoline calls the enter and exit functions even for a program it then skips. For the same reason, btf_id_deny already rejects attaching to the out-of-line migrate_disable() and migrate_enable(), and, with CONFIG_PREEMPT_RCU, to __rcu_read_lock() and __rcu_read_unlock().
Many of the helpers they call are plain inline functions:
- bpf_set_run_ctx(), bpf_reset_run_ctx(), bpf_prog_get_recursion_context() and bpf_prog_put_recursion_context();
- __migrate_disable() and __migrate_enable();
- the !CONFIG_PREEMPT_RCU __rcu_read_lock() and __rcu_read_unlock(), rcu_read_unlock() and rcu_read_unlock_migrate(), and the lockdep annotations rcu_lock_acquire(), rcu_try_lock_acquire() and rcu_lock_release();
- rcu_read_lock_trace(), rcu_read_unlock_trace() and srcu_lock_release();
- percpu_ref_get(), percpu_ref_put(), percpu_ref_get_many(), percpu_ref_put_many() and __ref_is_percpu();
- local_inc() and local_add() on x86, called through u64_stats_inc() and u64_stats_add() from bpf_prog_inc_misses_counter() and __update_prog_stats().
An out-of-line copy of any of them is untraced only because inline implies notrace. Mark them notrace explicitly. No functional change.
--- arch/x86/include/asm/local.h | 4 ++-- include/linux/bpf.h | 8 ++++---- include/linux/percpu-refcount.h | 12 ++++++------ include/linux/rcupdate.h | 14 +++++++------- include/linux/rcupdate_trace.h | 4 ++-- include/linux/sched.h | 8 ++++---- include/linux/srcu.h | 2 +- 7 files changed, 26 insertions(+), 26 deletions(-)
arch/x86/include/asm/local.h +2 -2
@@ -16,7 +16,7 @@ typedef struct {#define local_read (l) atomic_long_read(&(l)->a)#define local_set (l, i) atomic_long_set(&(l)->a, (i)) -static inline void local_inc (local_t *l) +static inline void notrace local_inc(local_t *l) { asmvolatile (_ASM_INC"%0" :"+m" (l->a.counter));
@@ -28,7 +28,7 @@ static inline void local_dec(local_t *l) : "+m" (l->a.counter)); } -static inline void local_add (long i,local_t *l) +static inline void notrace local_add(long i, local_t *l) { asmvolatile (_ASM_ADD"%1,%0" : "+m" (l->a.counter)
include/linux/bpf.h +4 -4
@@ -2330,7 +2330,7 @@ struct bpf_struct_ops_common_value {enum bpf_struct_ops_state state; }; -static inline bool bpf_prog_get_recursion_context (struct bpf_prog *prog) +static inline bool notrace bpf_prog_get_recursion_context(struct bpf_prog *prog) {#ifdef CONFIG_ARM64 u8 rctx =interrupt_context_level ();
@@ -2350,7 +2350,7 @@ static inline bool bpf_prog_get_recursion_context(struct bpf_prog *prog)#endif } -static inline void bpf_prog_put_recursion_context (struct bpf_prog *prog) +static inline void notrace bpf_prog_put_recursion_context(struct bpf_prog *prog) {#ifdef CONFIG_ARM64 u8 rctx =interrupt_context_level ();
@@ -2769,7 +2769,7 @@ struct bpf_tramp_run_ctx {struct bpf_run_ctx *saved_run_ctx; }; -static inline struct bpf_run_ctx *bpf_set_run_ctx (struct bpf_run_ctx *new_ctx) +static inline notrace struct bpf_run_ctx *bpf_set_run_ctx(struct bpf_run_ctx *new_ctx) {struct bpf_run_ctx *old_ctx =NULL ;
@@ -2780,7 +2780,7 @@ static inline struct bpf_run_ctx *bpf_set_run_ctx(struct bpf_run_ctx *new_ctx)return old_ctx; } -static inline void bpf_reset_run_ctx (struct bpf_run_ctx *old_ctx) +static inline void notrace bpf_reset_run_ctx(struct bpf_run_ctx *old_ctx) {#ifdef CONFIG_BPF_SYSCALL current->bpf_ctx = old_ctx;
include/linux/percpu-refcount.h +6 -6
@@ -155,8 +155,8 @@ static inline void percpu_ref_kill(struct percpu_ref *ref)* because doing so forces the compiler to generate two conditional * branches as it can't assume that @ref->percpu_count is not NULL. */ -static inline bool __ref_is_percpu (struct percpu_ref *ref, -unsigned long __percpu **percpu_countp) +static inline bool notrace __ref_is_percpu(struct percpu_ref *ref, +unsigned long __percpu **percpu_countp) {unsigned long percpu_ptr;
@@ -195,7 +195,7 @@ static inline bool __ref_is_percpu(struct percpu_ref *ref,* * This function is safe to call as long as @ref is between init and exit. */ -static inline void percpu_ref_get_many (struct percpu_ref *ref,unsigned long nr) +static inline void notrace percpu_ref_get_many(struct percpu_ref *ref, unsigned long nr) {unsigned long __percpu *percpu_count;
@@ -217,7 +217,7 @@ static inline void percpu_ref_get_many(struct percpu_ref *ref, unsigned long nr)* * This function is safe to call as long as @ref is between init and exit. */ -static inline void percpu_ref_get (struct percpu_ref *ref) +static inline void notrace percpu_ref_get(struct percpu_ref *ref) {percpu_ref_get_many (ref,1 ); }
@@ -324,7 +324,7 @@ static inline bool percpu_ref_tryget_live(struct percpu_ref *ref)* * This function is safe to call as long as @ref is between init and exit. */ -static inline void percpu_ref_put_many (struct percpu_ref *ref,unsigned long nr) +static inline void notrace percpu_ref_put_many(struct percpu_ref *ref, unsigned long nr) {unsigned long __percpu *percpu_count;
@@ -347,7 +347,7 @@ static inline void percpu_ref_put_many(struct percpu_ref *ref, unsigned long nr)* * This function is safe to call as long as @ref is between init and exit. */ -static inline void percpu_ref_put (struct percpu_ref *ref) +static inline void notrace percpu_ref_put(struct percpu_ref *ref) {percpu_ref_put_many (ref,1 ); }
include/linux/rcupdate.h +7 -7
@@ -107,12 +107,12 @@ void __rcu_read_unlock(void);void rcu_read_unlock_strict (void );#endif -static inline void __rcu_read_lock (void ) +static inline void notrace __rcu_read_lock(void) {preempt_disable (); } -static inline void __rcu_read_unlock (void ) +static inline void notrace __rcu_read_unlock(void) {if (IS_ENABLED (CONFIG_RCU_STRICT_GRACE_PERIOD ))rcu_read_unlock_strict ();
@@ -304,17 +304,17 @@ extern struct lockdep_map rcu_callback_map;#ifdef CONFIG_DEBUG_LOCK_ALLOC -static inline void rcu_lock_acquire (struct lockdep_map *map) +static inline void notrace rcu_lock_acquire(struct lockdep_map *map) {lock_acquire (map,0 ,0 ,2 ,0 ,NULL , _THIS_IP_); } -static inline void rcu_try_lock_acquire (struct lockdep_map *map) +static inline void notrace rcu_try_lock_acquire(struct lockdep_map *map) {lock_acquire (map,0 ,1 ,2 ,0 ,NULL , _THIS_IP_); } -static inline void rcu_lock_release (struct lockdep_map *map) +static inline void notrace rcu_lock_release(struct lockdep_map *map) {lock_release (map, _THIS_IP_); }
@@ -872,7 +872,7 @@ static __always_inline void rcu_read_lock(void)* * See rcu_read_lock() for more information. */ -static inline void rcu_read_unlock (void ) +static inline void notrace rcu_read_unlock(void)__releases_shared (RCU ) { RCU_LOCKDEP_WARN(!rcu_is_watching(),
@@ -991,7 +991,7 @@ static __always_inline void rcu_read_lock_dont_migrate(void)rcu_read_lock (); } -static inline void rcu_read_unlock_migrate (void ) +static inline void notrace rcu_read_unlock_migrate(void)__releases_shared (RCU ) {rcu_read_unlock ();
include/linux/rcupdate_trace.h +2 -2
@@ -93,7 +93,7 @@ static inline void rcu_read_unlock_tasks_trace(struct srcu_ctr __percpu *scp)* * For more details, please see the documentation for rcu_read_lock(). */ -static inline void rcu_read_lock_trace (void ) +static inline void notrace rcu_read_lock_trace(void) {int n;struct task_struct *t = current;
@@ -120,7 +120,7 @@ static inline void rcu_read_lock_trace(void)* * For more details, please see the documentation for rcu_read_unlock(). */ -static inline void rcu_read_unlock_trace (void ) +static inline void notrace rcu_read_unlock_trace(void) {int n;struct srcu_ctr __percpu *scp;
include/linux/sched.h +4 -4
@@ -2441,7 +2441,7 @@ DECLARE_PER_CPU_SHARED_ALIGNED(struct rq, runqueues);#endif #define this_rq_pinned () (*(unsigned int *)((void *)this_rq_raw() + RQ_nr_pinned)) -static inline void __migrate_enable (void ) +static inline void notrace __migrate_enable(void) {struct task_struct *p = current;
@@ -2476,7 +2476,7 @@ static inline void __migrate_enable(void)this_rq_pinned ()--; } -static inline void __migrate_disable (void ) +static inline void notrace __migrate_disable(void) {struct task_struct *p = current;
@@ -2496,8 +2496,8 @@ static inline void __migrate_disable(void) p->migration_disabled =1 ; }#else /* !COMPILE_OFFSETS */ -static inline void __migrate_disable (void ) { } -static inline void __migrate_enable (void ) { } +static inline void notrace __migrate_disable(void) { } +static inline void notrace __migrate_enable(void) { }#endif /* !COMPILE_OFFSETS */ /*
include/linux/srcu.h +1 -1
@@ -250,7 +250,7 @@ static inline void srcu_lock_acquire(struct lockdep_map *map) }/* Annotates a srcu_read_lock() */ -static inline void srcu_lock_release (struct lockdep_map *map) +static inline void notrace srcu_lock_release(struct lockdep_map *map) {lock_map_release (map); }
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 5/22 bpf: Mark the bpf_mem_alloc fast path helpers notrace
In reply to Song Liuunit_alloc(), unit_free() and unit_free_rcu() are notrace so that BPF programs cannot attach to them and corrupt the per-CPU free lists, as the comment above unit_alloc() says. To take and release c->active and to update the free lists, they call local_inc_return() (local_add_return() on x86), local_dec(), __llist_add() and llist_add(). These are plain inline functions, as are __llist_add_batch() and llist_add_batch(), which the llist helpers call. An out-of-line copy of any of them is untraced only because inline implies notrace.
Mark them notrace explicitly. No functional change.
--- arch/x86/include/asm/local.h | 4 ++-- include/linux/llist.h | 16 ++++++++-------- 2 files changed, 10 insertions(+), 10 deletions(-)
arch/x86/include/asm/local.h +2 -2
@@ -22,7 +22,7 @@ static inline void notrace local_inc(local_t *l) : "+m" (l->a.counter)); } -static inline void local_dec (local_t *l) +static inline void notrace local_dec(local_t *l) { asmvolatile (_ASM_DEC"%0" :"+m" (l->a.counter));
@@ -103,7 +103,7 @@ static inline bool local_add_negative(long i, local_t *l)* * Atomically adds @i to @l and returns @i + @l */ -static inline long local_add_return (long i,local_t *l) +static inline long notrace local_add_return (long i,local_t *l) {long __i = i; asm volatile(_ASM_XADD "%0, %1"
include/linux/llist.h +8 -8
@@ -231,9 +231,9 @@ static inline struct llist_node *llist_next(struct llist_node *node)* * Return whether list is empty before adding. */ -static inline bool llist_add_batch (struct llist_node *new_first, -struct llist_node *new_last, -struct llist_head *head) +static inline bool notrace llist_add_batch(struct llist_node *new_first, +struct llist_node *new_last, +struct llist_head *head) {struct llist_node *first =READ_ONCE (head->first);
@@ -244,9 +244,9 @@ static inline bool llist_add_batch(struct llist_node *new_first,return !first; } -static inline bool __llist_add_batch (struct llist_node *new_first, -struct llist_node *new_last, -struct llist_head *head) +static inline bool notrace __llist_add_batch(struct llist_node *new_first, +struct llist_node *new_last, +struct llist_head *head) { new_last->next = head->first; head->first = new_first;
@@ -260,12 +260,12 @@ static inline bool __llist_add_batch(struct llist_node *new_first,* * Returns true if the list was empty prior to adding this entry. */ -static inline bool llist_add (struct llist_node *new,struct llist_head *head) +static inline bool notrace llist_add(struct llist_node *new, struct llist_head *head) {return llist_add_batch (new, new, head); } -static inline bool __llist_add (struct llist_node *new,struct llist_head *head) +static inline bool notrace __llist_add(struct llist_node *new, struct llist_head *head) {return __llist_add_batch (new, new, head); }
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 6/22 u64_stats: Mark the update helpers used by BPF notrace
In reply to Song Liubpf_prog_inc_misses_counter() is notrace because it runs when a BPF program was not run due to recursion. If it could call traced code, an fentry program attached to that code would recurse forever. It calls u64_stats_update_begin_irqsave(), u64_stats_inc() and u64_stats_update_end_irqrestore(). The BPF trampoline calls u64_stats_add() and u64_stats_inc() from __update_prog_stats() in the same way. These are plain inline helpers, so an out-of-line copy is untraced only because inline implies notrace.
Mark these helpers, and the __u64_stats_*() helpers they call, notrace explicitly. No functional change.
--- include/linux/u64_stats_sync.h | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-)
include/linux/u64_stats_sync.h +15 -15
@@ -92,7 +92,7 @@ static inline void u64_stats_set(u64_stats_t *p, u64 val)local64_set (&p->v, val); } -static inline void u64_stats_add (u64_stats_t *p,unsigned long val) +static inline void notrace u64_stats_add(u64_stats_t *p, unsigned long val) {local64_add (val, &p->v); }
@@ -102,16 +102,16 @@ static inline void u64_stats_sub(u64_stats_t *p, s64 val)local64_sub (val, &p->v); } -static inline void u64_stats_inc (u64_stats_t *p) +static inline void notrace u64_stats_inc(u64_stats_t *p) {local64_inc (&p->v); }static inline void u64_stats_init (struct u64_stats_sync *syncp) { } -static inline void __u64_stats_update_begin (struct u64_stats_sync *syncp) { } -static inline void __u64_stats_update_end (struct u64_stats_sync *syncp) { } -static inline unsigned long __u64_stats_irqsave (void ) {return 0 ; } -static inline void __u64_stats_irqrestore (unsigned long flags) { } +static inline void notrace __u64_stats_update_begin(struct u64_stats_sync *syncp) { } +static inline void notrace __u64_stats_update_end(struct u64_stats_sync *syncp) { } +static inline unsigned long notrace __u64_stats_irqsave (void ) {return 0 ; } +static inline void notrace __u64_stats_irqrestore(unsigned long flags) { }static inline unsigned int __u64_stats_fetch_begin (const struct u64_stats_sync *syncp) {return 0 ;
@@ -145,7 +145,7 @@ static inline void u64_stats_set(u64_stats_t *p, u64 val) p->v = val; } -static inline void u64_stats_add (u64_stats_t *p,unsigned long val) +static inline void notrace u64_stats_add(u64_stats_t *p, unsigned long val) { p->v += val; }
@@ -155,7 +155,7 @@ static inline void u64_stats_sub(u64_stats_t *p, s64 val) p->v -= val; } -static inline void u64_stats_inc (u64_stats_t *p) +static inline void notrace u64_stats_inc(u64_stats_t *p) { p->v++; }
@@ -166,19 +166,19 @@ static inline void u64_stats_inc(u64_stats_t *p)seqcount_init (&__s->seq); \ }while (0 ) -static inline void __u64_stats_update_begin(struct u64_stats_sync *syncp) +static inline void notrace __u64_stats_update_begin(struct u64_stats_sync *syncp) {preempt_disable_nested ();write_seqcount_begin (&syncp->seq); } -static inline void __u64_stats_update_end (struct u64_stats_sync *syncp) +static inline void notrace __u64_stats_update_end(struct u64_stats_sync *syncp) {write_seqcount_end (&syncp->seq);preempt_enable_nested (); } -static inline unsigned long __u64_stats_irqsave (void ) +static inline unsigned long notrace __u64_stats_irqsave (void ) {unsigned long flags;
@@ -186,7 +186,7 @@ static inline unsigned long __u64_stats_irqsave(void)return flags; } -static inline void __u64_stats_irqrestore (unsigned long flags) +static inline void notrace __u64_stats_irqrestore(unsigned long flags) {local_irq_restore (flags); }
@@ -213,7 +213,7 @@ static inline void u64_stats_update_end(struct u64_stats_sync *syncp)__u64_stats_update_end (syncp); } -static inline unsigned long u64_stats_update_begin_irqsave (struct u64_stats_sync *syncp) +static inline unsigned long notrace u64_stats_update_begin_irqsave (struct u64_stats_sync *syncp) {unsigned long flags =__u64_stats_irqsave ();
@@ -221,8 +221,8 @@ static inline unsigned long u64_stats_update_begin_irqsave(struct u64_stats_syncreturn flags; } -static inline void u64_stats_update_end_irqrestore (struct u64_stats_sync *syncp, -unsigned long flags) +static inline void notrace u64_stats_update_end_irqrestore(struct u64_stats_sync *syncp, +unsigned long flags) {__u64_stats_update_end (syncp);__u64_stats_irqrestore (flags);
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 7/22 tracepoint: Mark __do_trace_##name() notrace
In reply to Song Liu__do_trace_##name() takes the tracepoint SRCU read lock and calls the probes. It is called from trace_##name(), trace_call__##name(), and the notrace rust_do_trace_##name(). It is a plain inline function, so if the compiler emits it out of line, that copy is untraced only because inline implies notrace.
Mark it notrace explicitly. No functional change.
--- include/linux/tracepoint.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/tracepoint.h +2 -2
@@ -308,7 +308,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)#define __DECLARE_TRACE (name, proto, args, cond, data_proto) \ __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \ - static inline void __do_trace_##name(proto) \ + static inline void notrace __do_trace_##name(proto) \ { \ TRACEPOINT_CHECK(name) \ if (cond) { \
@@ -332,7 +332,7 @@ static inline struct tracepoint *tracepoint_ptr_deref(tracepoint_ptr_t *p)#define __DECLARE_TRACE_SYSCALL (name, proto, args, data_proto) \ __DECLARE_TRACE_COMMON(name, PARAMS(proto), PARAMS(args), PARAMS(data_proto)) \ - static inline void __do_trace_##name(proto) \ + static inline void notrace __do_trace_##name(proto) \ { \ TRACEPOINT_CHECK(name) \ guard(rcu_tasks_trace)(); \
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 8/22 srcu: Mark the fast notrace read-side helpers notrace
In reply to Song Liusrcu_read_lock_fast_notrace() and srcu_read_unlock_fast_notrace() are used by tracepoints, and their comments say they cannot be traced. They are plain inline functions, as are srcu_check_read_flavor() and the Tiny SRCU versions of __srcu_read_lock_fast() and __srcu_read_unlock_fast() that they call. An out-of-line copy of any of them is untraced only because inline implies notrace.
Mark them notrace explicitly, as srcu_read_lock_notrace() and the Tree SRCU __srcu_read_lock_fast() and __srcu_read_unlock_fast() already are. No functional change.
--- include/linux/srcu.h | 8 +++++--- include/linux/srcutiny.h | 5 +++-- include/linux/srcutree.h | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-)
include/linux/srcu.h +5 -3
@@ -487,7 +487,8 @@ static inline struct srcu_ctr __percpu *srcu_read_lock_fast_updown(struct srcu_s* Used by tracing, cannot be traced and cannot call lockdep. * See srcu_read_lock_fast() for more information. */ -static inline struct srcu_ctr __percpu *srcu_read_lock_fast_notrace (struct srcu_struct *ssp) +static inline struct srcu_ctr __percpu notrace * +srcu_read_lock_fast_notrace (struct srcu_struct *ssp)__acquires_shared (ssp) {struct srcu_ctr __percpu *retval;
@@ -651,8 +652,9 @@ srcu_read_unlock_fast_updown(struct srcu_struct *ssp, struct srcu_ctr __percpu ** Used by tracing, cannot be traced and cannot call lockdep. * See srcu_read_unlock_fast() for more information. */ -static inline void srcu_read_unlock_fast_notrace (struct srcu_struct *ssp, -struct srcu_ctr __percpu *scp)__releases_shared (ssp) +static inline void notrace +srcu_read_unlock_fast_notrace (struct srcu_struct *ssp, +struct srcu_ctr __percpu *scp)__releases_shared (ssp) {srcu_check_read_flavor (ssp,SRCU_READ_FLAVOR_FAST );__srcu_read_unlock_fast (ssp, scp);
include/linux/srcutiny.h +3 -2
@@ -114,13 +114,14 @@ static inline struct srcu_ctr __percpu *__srcu_ctr_to_ptr(struct srcu_struct *ssreturn (struct srcu_ctr __percpu *)(intptr_t )idx; } -static inline struct srcu_ctr __percpu *__srcu_read_lock_fast (struct srcu_struct *ssp) +static inline struct srcu_ctr __percpu notrace *__srcu_read_lock_fast(struct srcu_struct *ssp)__acquires_shared (ssp) {return __srcu_ctr_to_ptr (ssp,__srcu_read_lock (ssp)); } -static inline void __srcu_read_unlock_fast (struct srcu_struct *ssp,struct srcu_ctr __percpu *scp) +static inline void notrace +__srcu_read_unlock_fast (struct srcu_struct *ssp,struct srcu_ctr __percpu *scp)__releases_shared (ssp) {__srcu_read_unlock (ssp,__srcu_ptr_to_ctr (ssp, scp));
include/linux/srcutree.h +1 -1
@@ -381,7 +381,7 @@ __srcu_read_unlock_fast_updown(struct srcu_struct *ssp, struct srcu_ctr __percpuvoid __srcu_check_read_flavor (struct srcu_struct *ssp,int read_flavor);// Record SRCU-reader usage type only for CONFIG_PROVE_RCU=y kernels. -static inline void srcu_check_read_flavor (struct srcu_struct *ssp,int read_flavor) +static inline void notrace srcu_check_read_flavor(struct srcu_struct *ssp, int read_flavor) {if (IS_ENABLED (CONFIG_PROVE_RCU ))__srcu_check_read_flavor (ssp, read_flavor);
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 9/22 arm64: Mark the preempt count helpers notrace
In reply to Song Liuftrace_test_recursion_trylock() reads preempt_count() to find the current context, and preempt_disable_notrace() and preempt_enable_notrace() use __preempt_count_add(), __preempt_count_sub(), __preempt_count_dec_and_test() and should_resched(). On arm64 these are plain inline functions. If the compiler emits one of them out of line, that copy is untraced only because inline implies notrace, and tracing it would recurse before the recursion check takes effect.
Mark them, and preempt_count_set(), notrace explicitly. The x86 and generic versions are __always_inline. No functional change.
--- arch/arm64/include/asm/preempt.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/arm64/include/asm/preempt.h +6 -6
@@ -7,12 +7,12 @@#define PREEMPT_NEED_RESCHED BIT(32)#define PREEMPT_ENABLED (PREEMPT_NEED_RESCHED) -static inline int preempt_count (void ) +static inline int notrace preempt_count(void) {return READ_ONCE (current_thread_info ()->preempt.count); } -static inline void preempt_count_set (u64 pc) +static inline void notrace preempt_count_set(u64 pc) {/* Preserve existing value of PREEMPT_NEED_RESCHED */ WRITE_ONCE (current_thread_info ()->preempt.count, pc);
@@ -41,14 +41,14 @@ static inline bool test_preempt_need_resched(void)return !current_thread_info ()->preempt.need_resched; } -static inline void __preempt_count_add (int val) +static inline void notrace __preempt_count_add(int val) {u32 pc =READ_ONCE (current_thread_info ()->preempt.count); pc += val;WRITE_ONCE (current_thread_info ()->preempt.count, pc); } -static inline void __preempt_count_sub (int val) +static inline void notrace __preempt_count_sub(int val) {u32 pc =READ_ONCE (current_thread_info ()->preempt.count); pc -= val;
@@ -75,13 +75,13 @@ static inline int __preempt_count_sub_return(int val)return pc; } -static inline bool should_resched (int preempt_offset) +static inline bool notrace should_resched(int preempt_offset) {u64 pc =READ_ONCE (current_thread_info ()->preempt_count);return unlikely (pc == preempt_offset); } -static inline bool __preempt_count_dec_and_test (void ) +static inline bool notrace __preempt_count_dec_and_test(void) {/* * We must load the combined 'preempt_count' after decrementing
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 10/22 powerpc, csky, mips, sh: Mark the accessors behind current notrace
In reply to Song Liuftrace_test_recursion_trylock() reads current->trace_recursion before it knows whether it is safe to trace, so reading current must never be a traced call. On powerpc, get_current() is a plain inline function. On csky, mips and sh, current comes from the generic get_current(), which calls current_thread_info(), and current_thread_info() is a plain inline function. An out-of-line copy of any of these is untraced only because inline implies notrace.
Mark them notrace explicitly. On the other architectures that support the function tracer, get_current() is already __always_inline. No functional change.
--- arch/csky/include/asm/thread_info.h | 2 +- arch/mips/include/asm/thread_info.h | 2 +- arch/powerpc/include/asm/current.h | 2 +- arch/sh/include/asm/thread_info.h | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
arch/csky/include/asm/thread_info.h +1 -1
@@ -42,7 +42,7 @@ struct thread_info {#define thread_saved_lr (tsk) \ ((unsigned long)(((struct switch_stack *)(tsk->thread.sp))->r15)) -static inline struct thread_info *current_thread_info (void ) +static inline notrace struct thread_info *current_thread_info(void) {unsigned long sp;
arch/mips/include/asm/thread_info.h +1 -1
@@ -64,7 +64,7 @@ extern struct thread_info *__current_thread_info; registerstruct thread_info *__current_thread_info __asm__("$28" );#endif -static inline struct thread_info *current_thread_info (void ) +static inline notrace struct thread_info *current_thread_info(void) {return __current_thread_info; }
arch/powerpc/include/asm/current.h +1 -1
@@ -12,7 +12,7 @@ struct task_struct;#include <linux/stddef.h> #include <asm/paca.h> -static inline struct task_struct *get_current (void ) +static inline notrace struct task_struct *get_current(void) {struct task_struct *task;
arch/sh/include/asm/thread_info.h +1 -1
@@ -63,7 +63,7 @@ struct thread_info { registerunsigned long current_stack_pointer asm("r15" )__used ;/* how to get the thread information struct from C */ -static inline struct thread_info *current_thread_info (void ) +static inline notrace struct thread_info *current_thread_info(void) {struct thread_info *ti;#if defined(CONFIG_CPU_HAS_SR_RB )
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 11/22 rcu: Mark the Tiny RCU rcu_is_watching() notrace
In reply to Song Liuftrace_test_recursion_trylock() calls rcu_is_watching() before it has taken the recursion lock. The Tree RCU version is a notrace function, but the Tiny RCU version is a plain inline function. An out-of-line copy of it is untraced only because inline implies notrace.
Mark it notrace explicitly. No functional change.
--- include/linux/rcutiny.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/rcutiny.h +1 -1
@@ -123,7 +123,7 @@ static inline void rcu_preempt_deferred_qs(struct task_struct *t) { }void rcu_scheduler_starting (void );static inline void rcu_end_inkernel_boot (void ) { }static inline bool rcu_inkernel_boot_has_ended (void ) {return true; } -static inline bool rcu_is_watching (void ) {return true; } +static inline bool notrace rcu_is_watching(void) { return true; }static inline void rcu_momentary_eqs (void ) { }/* Avoid RCU read-side critical sections leaking across. */
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 12/22 tracing: Mark the tracing_gen_ctx helpers notrace
In reply to Song Liutracing_gen_ctx(), tracing_gen_ctx_flags() and tracing_gen_ctx_dec() are called by ftrace callbacks before they take any recursion protection, for example function_test_events_call() in kernel/trace/trace_events.c, which is built with -pg when CONFIG_FUNCTION_SELF_TRACING=y. They are plain inline functions, so an out-of-line copy is untraced only because inline implies notrace.
Mark them notrace explicitly. No functional change.
--- include/linux/trace_events.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
include/linux/trace_events.h +3 -3
@@ -197,13 +197,13 @@ enum trace_flag_type { TRACE_FLAG_BH_OFF = 0x80, }; -static inline unsigned int tracing_gen_ctx_flags (unsigned long irqflags) +static inline unsigned int notrace tracing_gen_ctx_flags(unsigned long irqflags) {unsigned int irq_status =irqs_disabled_flags (irqflags) ?TRACE_FLAG_IRQS_OFF :0 ;return tracing_gen_ctx_irq_test (irq_status); } -static inline unsigned int tracing_gen_ctx (void ) +static inline unsigned int notrace tracing_gen_ctx(void) {unsigned long irqflags;
@@ -211,7 +211,7 @@ static inline unsigned int tracing_gen_ctx(void)return tracing_gen_ctx_flags (irqflags); } -static inline unsigned int tracing_gen_ctx_dec (void ) +static inline unsigned int notrace tracing_gen_ctx_dec(void) {unsigned int trace_ctx;
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 13/22 ktime: Mark ktime_to_ns() notrace
In reply to Song LiuThe NMI safe accessors used as trace clocks, such as ktime_get_mono_fast_ns() and ktime_get_boot_fast_ns(), are notrace and call ktime_to_ns(). ktime_to_ns() is a plain inline function, so an out-of-line copy is untraced only because inline implies notrace, and tracing it would recurse through the trace clock.
Mark it notrace explicitly. No functional change.
--- include/linux/ktime.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/ktime.h +1 -1
@@ -75,7 +75,7 @@ static inline ktime_t timespec64_to_ktime(struct timespec64 ts)#define ktime_to_timespec64 (kt) ns_to_timespec64((kt))/* Convert ktime_t to nanoseconds */ -static inline s64 ktime_to_ns (const ktime_t kt) +static inline s64 notrace ktime_to_ns(const ktime_t kt) {return kt; }
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 14/22 kallsyms: Mark the kernel text address checks notrace
In reply to Song LiuCommit c0d80ddab899 ("kernel/extable.c: mark core_kernel_text notrace") made core_kernel_text() notrace, because the MIPS function graph tracer calls it and tracing it recursed without bound. core_kernel_text() calls is_kernel_text() and is_kernel_inittext(), and is_kernel_text() calls __is_kernel_text(). These are plain inline functions, so an out-of-line copy of any of them is untraced only because inline implies notrace.
Mark them notrace explicitly. No functional change.
--- include/asm-generic/sections.h | 4 ++-- include/linux/kallsyms.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
include/asm-generic/sections.h +2 -2
@@ -193,7 +193,7 @@ static inline bool is_kernel_ro_after_init(unsigned long addr)* * Returns: true if the address is located in .init.text, false otherwise. */ -static inline bool is_kernel_inittext (unsigned long addr) +static inline bool notrace is_kernel_inittext(unsigned long addr) {return addr >= (unsigned long )_sinittext && addr < (unsigned long )_einittext;
@@ -208,7 +208,7 @@ static inline bool is_kernel_inittext(unsigned long addr)* Returns: true if the address is located in .text, false otherwise. * Note: an internal helper, only check the range of _stext to _etext. */ -static inline bool __is_kernel_text (unsigned long addr) +static inline bool notrace __is_kernel_text(unsigned long addr) {return addr >= (unsigned long )_stext && addr < (unsigned long )_etext;
include/linux/kallsyms.h +1 -1
@@ -24,7 +24,7 @@struct cred ;struct module ; -static inline int is_kernel_text (unsigned long addr) +static inline int notrace is_kernel_text(unsigned long addr) {if (__is_kernel_text (addr))return 1 ;
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 15/22 uaccess: Mark pagefault_disable() and pagefault_enable() notrace
In reply to Song Liucopy_to_kernel_nofault() and copy_to_user_nofault() are declared notrace in <linux/uaccess.h>. They call pagefault_disable() and pagefault_enable(), which are plain inline functions, so an out-of-line copy is untraced only because inline implies notrace.
Mark them notrace explicitly. No functional change.
--- include/linux/uaccess.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/uaccess.h +2 -2
@@ -260,7 +260,7 @@ static __always_inline void pagefault_disabled_dec(void)* User access methods will not sleep when called from a pagefault_disabled() * environment. */ -static inline void pagefault_disable (void ) +static inline void notrace pagefault_disable(void) {pagefault_disabled_inc ();/*
@@ -270,7 +270,7 @@ static inline void pagefault_disable(void)barrier (); } -static inline void pagefault_enable (void ) +static inline void notrace pagefault_enable(void) {/* * make sure to issue those last loads/stores before enabling
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 16/22 context_tracking: Mark exception_enter() and exception_exit() notrace
In reply to Song LiuThe tracing code uses preempt_enable_notrace(), which calls preempt_schedule_notrace(). Tracing can happen before the kernel has left user context, so preempt_schedule_notrace() calls exception_enter() to leave it before calling the scheduler. exception_enter() therefore runs while RCU may not be watching. exception_enter() and exception_exit() are plain inline functions, so an out-of-line copy is untraced only because inline implies notrace. With clang, a powerpc ppc64le_defconfig build has such a copy of exception_enter(), called from preempt_schedule_notrace().
Mark them notrace explicitly. No functional change.
--- include/linux/context_tracking.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/context_tracking.h +2 -2
@@ -48,7 +48,7 @@ static __always_inline void user_exit_irqoff(void)__ct_user_exit (CT_STATE_USER ); } -static inline enum ctx_state exception_enter (void ) +static inline enum ctx_state notrace exception_enter(void) {enum ctx_state prev_ctx;
@@ -63,7 +63,7 @@ static inline enum ctx_state exception_enter(void)return prev_ctx; } -static inline void exception_exit (enum ctx_state prev_ctx) +static inline void notrace exception_exit(enum ctx_state prev_ctx) {if (!IS_ENABLED (CONFIG_HAVE_CONTEXT_TRACKING_USER_OFFSTACK ) &&context_tracking_enabled ()) {
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 17/22 thread_info: Mark the thread flag helpers notrace
In reply to Song Liuset_ti_thread_flag(), clear_ti_thread_flag() and the other thread flag helpers are plain inline functions. Some idle code uses them while RCU is not watching: snooze_loop() on pseries is a cpuidle state without CPUIDLE_FLAG_RCU_IDLE, so it runs after cpuidle_enter_state() has called ct_cpuidle_enter(), and it sets and clears TIF_POLLING_NRFLAG. With clang, a powerpc ppc64le_defconfig build has out-of-line copies of set_ti_thread_flag() and clear_ti_thread_flag(), called from snooze_loop(). The copies are untraced only because inline implies notrace.
Mark the thread flag helpers notrace explicitly. No functional change.
--- include/linux/thread_info.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
include/linux/thread_info.h +6 -6
@@ -99,17 +99,17 @@ static inline long set_restart_fn(struct restart_block *restart,* - pass TIF_xxxx constants to these functions */ -static inline void set_ti_thread_flag (struct thread_info *ti,int flag) +static inline notrace void set_ti_thread_flag(struct thread_info *ti, int flag) {set_bit (flag, (unsigned long *)&ti->flags); } -static inline void clear_ti_thread_flag (struct thread_info *ti,int flag) +static inline notrace void clear_ti_thread_flag(struct thread_info *ti, int flag) {clear_bit (flag, (unsigned long *)&ti->flags); } -static inline void update_ti_thread_flag (struct thread_info *ti,int flag, +static inline notrace void update_ti_thread_flag(struct thread_info *ti, int flag,bool value) {if (value)
@@ -118,17 +118,17 @@ static inline void update_ti_thread_flag(struct thread_info *ti, int flag,clear_ti_thread_flag (ti, flag); } -static inline int test_and_set_ti_thread_flag (struct thread_info *ti,int flag) +static inline notrace int test_and_set_ti_thread_flag(struct thread_info *ti, int flag) {return test_and_set_bit (flag, (unsigned long *)&ti->flags); } -static inline int test_and_clear_ti_thread_flag (struct thread_info *ti,int flag) +static inline notrace int test_and_clear_ti_thread_flag(struct thread_info *ti, int flag) {return test_and_clear_bit (flag, (unsigned long *)&ti->flags); } -static inline int test_ti_thread_flag (struct thread_info *ti,int flag) +static inline notrace int test_ti_thread_flag(struct thread_info *ti, int flag) {return test_bit (flag, (unsigned long *)&ti->flags); }
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 18/22 arm64: Mark helpers called from noinstr code notrace
In reply to Song LiuSome arm64 noinstr code calls plain inline helpers at points where tracing is not safe:
- el0_ia(), el0_pc(), el0_breakpt() and el0_softstp() call is_ttbr0_addr(), which reads TCR_EL1 with read_tcr() to compute TASK_SIZE, and arm64_apply_bp_hardening(), which reads the per-CPU offset with __kern_my_cpu_offset(). el0_pc() also calls instruction_pointer(). This runs before arm64_enter_from_user_mode(), while RCU is not watching.
- __sdei_handler() calls system_uses_hw_pan(), cpu_has_pan(), arm64_kernel_unmapped_at_el0() and __kern_my_cpu_offset() before irqentry_nmi_enter().
- The context tracking code, irqentry_nmi_enter() and irqentry_nmi_exit() use __kern_my_cpu_offset() for per-CPU accesses while RCU is not watching, and the noinstr sched_clock() read functions raw_counter_get_cntpct_stable() and raw_counter_get_cntvct_stable() use it too.
- The alternative callback kvm_patch_ich_vtr_el2() calls is_hyp_mode_available().
- cpu_idle_poll() calls cpu_relax() between ct_cpuidle_enter() and ct_cpuidle_exit(), while RCU is not watching. The other function it calls there, tick_check_broadcast_expired(), is noinstr.
With clang, an arm64 defconfig build has out-of-line copies of all of these helpers, called from the functions above. The copies are untraced only because inline implies notrace.
Mark them notrace explicitly. No functional change.
--- arch/arm64/include/asm/cpufeature.h | 4 ++-- arch/arm64/include/asm/memory.h | 2 +- arch/arm64/include/asm/mmu.h | 2 +- arch/arm64/include/asm/percpu.h | 2 +- arch/arm64/include/asm/ptrace.h | 2 +- arch/arm64/include/asm/vdso/processor.h | 2 +- arch/arm64/include/asm/virt.h | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-)
arch/arm64/include/asm/cpufeature.h +2 -2
@@ -774,7 +774,7 @@ static __always_inline bool system_supports_fpsimd(void)return alternative_has_cap_likely (ARM64_HAS_FPSIMD ); } -static inline bool system_uses_hw_pan (void ) +static inline bool notrace system_uses_hw_pan(void) {return alternative_has_cap_unlikely (ARM64_HAS_PAN ); }
@@ -955,7 +955,7 @@ static inline bool cpu_has_hw_af(void) ID_AA64MMFR1_EL1_HAFDBS_SHIFT); } -static inline bool cpu_has_pan (void ) +static inline bool notrace cpu_has_pan(void) {u64 mmfr1 =read_cpuid (ID_AA64MMFR1_EL1 ); return cpuid_feature_extract_unsigned_field(mmfr1,
arch/arm64/include/asm/memory.h +1 -1
@@ -223,7 +223,7 @@#include <asm/sections.h> #include <asm/sysreg.h> -static inline u64 __pure read_tcr (void ) +static inline u64 __pure notrace read_tcr(void) {u64 tcr;
arch/arm64/include/asm/mmu.h +1 -1
@@ -55,7 +55,7 @@ typedef struct {*/ #define ASID (mm) (atomic64_read(&(mm)->context.id) & 0xffff) -static inline bool arm64_kernel_unmapped_at_el0 (void ) +static inline bool notrace arm64_kernel_unmapped_at_el0(void) {return alternative_has_cap_unlikely (ARM64_UNMAP_KERNEL_AT_EL0 ); }
arch/arm64/include/asm/percpu.h +1 -1
@@ -37,7 +37,7 @@ static inline unsigned long __hyp_my_cpu_offset(void) "mrs " dst ", tpidr_el2", \ ARM64_HAS_VIRT_HOST_EXTN) -static inline unsigned long __kern_my_cpu_offset (void ) +static inline unsigned long notrace __kern_my_cpu_offset (void ) {unsigned long off;
arch/arm64/include/asm/ptrace.h +1 -1
@@ -360,7 +360,7 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,struct task_struct ;int valid_user_regs (struct user_pt_regs *regs,struct task_struct *task); -static inline unsigned long instruction_pointer (struct pt_regs *regs) +static inline unsigned long notrace instruction_pointer (struct pt_regs *regs) {return regs->pc; }
arch/arm64/include/asm/vdso/processor.h +1 -1
@@ -7,7 +7,7 @@#ifndef __ASSEMBLER__ -static inline void cpu_relax (void ) +static inline void notrace cpu_relax(void) { asmvolatile ("yield" :::"memory" ); }
arch/arm64/include/asm/virt.h +1 -1
@@ -104,7 +104,7 @@ static inline bool pkvm_force_reclaim_guest_page(phys_addr_t phys)#endif /* Reports the availability of HYP mode */ -static inline bool is_hyp_mode_available (void ) +static inline bool notrace is_hyp_mode_available(void) {/* * If KVM protected mode is initialized, all CPUs must have been booted
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 19/22 arm64: Mark the stack unwinder helpers notrace
In reply to Song LiuCommit 0fbcd8abf337 ("arm64: Prohibit instrumentation on arch_stack_walk()") made arch_stack_walk() noinstr, and made the inline functions it calls __always_inline, so that it cannot be instrumented:
lockdep calls it through return_address(), and a kprobe on it crashed the kernel. The helpers in <asm/stacktrace.h> and <asm/stacktrace/common.h>, such as stackinfo_get_irq(), on_task_stack() and unwind_consume_stack(), are still plain inline functions. With clang, an arm64 defconfig build has out-of-line copies of several of them, called from arch_stack_walk(), arch_stack_walk_reliable() and arch_bpf_stack_walk(). The copies are untraced only because inline implies notrace.
Mark these helpers notrace explicitly. No functional change.
--- arch/arm64/include/asm/stacktrace.h | 16 ++++++++-------- arch/arm64/include/asm/stacktrace/common.h | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-)
arch/arm64/include/asm/stacktrace.h +8 -8
@@ -22,7 +22,7 @@ extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk, DECLARE_PER_CPU(unsigned long *, irq_stack_ptr); -static inline struct stack_info stackinfo_get_irq (void ) +static inline struct stack_info notrace stackinfo_get_irq(void) {unsigned long low = (unsigned long )raw_cpu_read (irq_stack_ptr);unsigned long high = low +IRQ_STACK_SIZE ;
@@ -33,13 +33,13 @@ static inline struct stack_info stackinfo_get_irq(void) }; } -static inline bool on_irq_stack (unsigned long sp,unsigned long size) +static inline bool notrace on_irq_stack(unsigned long sp, unsigned long size) {struct stack_info info =stackinfo_get_irq ();return stackinfo_on_stack (&info, sp, size); } -static inline struct stack_info stackinfo_get_task (const struct task_struct *tsk) +static inline struct stack_info notrace stackinfo_get_task(const struct task_struct *tsk) {unsigned long low = (unsigned long )task_stack_page (tsk);unsigned long high = low +THREAD_SIZE ;
@@ -50,7 +50,7 @@ static inline struct stack_info stackinfo_get_task(const struct task_struct *tsk }; } -static inline bool on_task_stack (const struct task_struct *tsk, +static inline bool notrace on_task_stack(const struct task_struct *tsk,unsigned long sp,unsigned long size) {struct stack_info info =stackinfo_get_task (tsk);
@@ -61,7 +61,7 @@ static inline bool on_task_stack(const struct task_struct *tsk, DECLARE_PER_CPU(unsigned long [OVERFLOW_STACK_SIZE/sizeof(long)], overflow_stack); -static inline struct stack_info stackinfo_get_overflow (void ) +static inline struct stack_info notrace stackinfo_get_overflow(void) {unsigned long low = (unsigned long )raw_cpu_ptr (overflow_stack);unsigned long high = low +OVERFLOW_STACK_SIZE ;
@@ -76,7 +76,7 @@ static inline struct stack_info stackinfo_get_overflow(void) DECLARE_PER_CPU(unsigned long *, sdei_stack_normal_ptr); DECLARE_PER_CPU(unsigned long *, sdei_stack_critical_ptr); -static inline struct stack_info stackinfo_get_sdei_normal (void ) +static inline struct stack_info notrace stackinfo_get_sdei_normal(void) {unsigned long low = (unsigned long )raw_cpu_read (sdei_stack_normal_ptr);unsigned long high = low +SDEI_STACK_SIZE ;
@@ -87,7 +87,7 @@ static inline struct stack_info stackinfo_get_sdei_normal(void) }; } -static inline struct stack_info stackinfo_get_sdei_critical (void ) +static inline struct stack_info notrace stackinfo_get_sdei_critical(void) {unsigned long low = (unsigned long )raw_cpu_read (sdei_stack_critical_ptr);unsigned long high = low +SDEI_STACK_SIZE ;
@@ -105,7 +105,7 @@ static inline struct stack_info stackinfo_get_sdei_critical(void)#ifdef CONFIG_EFI extern u64 *efi_rt_stack_top; -static inline struct stack_info stackinfo_get_efi (void ) +static inline struct stack_info notrace stackinfo_get_efi(void) {unsigned long high = (u64 )efi_rt_stack_top;unsigned long low = high -THREAD_SIZE ;
arch/arm64/include/asm/stacktrace/common.h +5 -5
@@ -35,7 +35,7 @@ struct unwind_state {int nr_stacks; }; -static inline struct stack_info stackinfo_get_unknown (void ) +static inline struct stack_info notrace stackinfo_get_unknown(void) {return (struct stack_info ) { .low =0 ,
@@ -43,7 +43,7 @@ static inline struct stack_info stackinfo_get_unknown(void) }; } -static inline bool stackinfo_on_stack (const struct stack_info *info, +static inline bool notrace stackinfo_on_stack(const struct stack_info *info,unsigned long sp,unsigned long size) {if (!info->low)
@@ -55,7 +55,7 @@ static inline bool stackinfo_on_stack(const struct stack_info *info,return true; } -static inline void unwind_init_common (struct unwind_state *state) +static inline void notrace unwind_init_common(struct unwind_state *state) { state->stack =stackinfo_get_unknown (); }
@@ -99,7 +99,7 @@ static struct stack_info *unwind_find_stack(struct unwind_state *state,* * Return: 0 upon success, an error code otherwise. */ -static inline void unwind_consume_stack (struct unwind_state *state, +static inline void notrace unwind_consume_stack(struct unwind_state *state,struct stack_info *info,unsigned long sp,unsigned long size)
@@ -142,7 +142,7 @@ static inline void unwind_consume_stack(struct unwind_state *state,* * Return: 0 upon success, an error code otherwise. */ -static inline int +static inline int notraceunwind_next_frame_record (struct unwind_state *state) {struct stack_info *info;
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 20/22 powerpc: Mark helpers called from noinstr code notrace
In reply to Song LiuMuch of the powerpc code that must not be traced uses plain inline helpers from headers: the atomic, bitops and barrier helpers, the irqflags and hard irq helpers in <asm/hw_irq.h>, the interrupt entry and exit helpers in <asm/entry-common.h>, and the MMIO accessors. noinstr code calls them at points where tracing is not safe, for example:
- The context tracking code updates its state with arch_atomic_add_return_relaxed() while RCU is not watching.
- ct_idle_exit(), cpu_idle_poll(), snooze_loop() and the cede loops call the irqflags and hard irq helpers, test_thread_local_flags() and cede_processor() while RCU is not watching.
- DEFINE_INTERRUPT_HANDLER() and its variants call arch_interrupt_enter_prepare() before irqentry_enter(). On entry from user mode, irqentry_enter() calls arch_enter_from_user_mode(), which uses regs_is_unrecoverable(), trap_is_syscall(), isync() and irq_soft_mask_regs_set_state(), before user_exit_irqoff().
- get_pseries_errorlog(), which runs in real mode, calls the RTAS error log helpers, and xive_teardown_cpu() calls out_8() on a CPU that is going offline.
- soft_nmi_interrupt() calls wd_smp_lock().
With clang, a ppc64le_defconfig build has out-of-line copies of many of these helpers, called from the functions above. The copies are untraced only because inline implies notrace.
Mark them notrace explicitly, like the irq_soft_mask_*() helpers in <asm/hw_irq.h> already are. On x86, arm64 and riscv, the atomic, bitops and irqflags helpers are __always_inline. No functional change.
--- arch/powerpc/include/asm/atomic.h | 38 ++++++------- arch/powerpc/include/asm/bitops.h | 29 +++++----- arch/powerpc/include/asm/cmpxchg.h | 2 +- arch/powerpc/include/asm/entry-common.h | 32 +++++------ arch/powerpc/include/asm/hw_irq.h | 68 +++++++++++------------ arch/powerpc/include/asm/interrupt.h | 2 +- arch/powerpc/include/asm/io.h | 16 +++--- arch/powerpc/include/asm/plpar_wrappers.h | 4 +- arch/powerpc/include/asm/ptrace.h | 14 ++--- arch/powerpc/include/asm/rtas.h | 10 ++-- arch/powerpc/include/asm/synch.h | 6 +- arch/powerpc/include/asm/thread_info.h | 4 +- arch/powerpc/kernel/watchdog.c | 4 +- 13 files changed, 115 insertions(+), 114 deletions(-)
arch/powerpc/include/asm/atomic.h +19 -19
@@ -24,7 +24,7 @@#define __atomic_release_fence () \ __asm__ __volatile__(PPC_RELEASE_BARRIER "" : : : "memory") -static __inline__int arch_atomic_read (const atomic_t *v) +static __inline__ notrace int arch_atomic_read(const atomic_t *v) {int t;
@@ -37,7 +37,7 @@ static __inline__ int arch_atomic_read(const atomic_t *v)return t; } -static __inline__void arch_atomic_set (atomic_t *v,int i) +static __inline__ notrace void arch_atomic_set(atomic_t *v, int i) {/* -mprefixed can generate offsets beyond range, fall back hack */ if (IS_ENABLED (CONFIG_PPC_KERNEL_PREFIXED ))
@@ -47,7 +47,7 @@ static __inline__ void arch_atomic_set(atomic_t *v, int i) }#define ATOMIC_OP (op, asm_op, suffix, sign, ...) \ -static __inline__ void arch_atomic_##op(int a, atomic_t *v) \ +static __inline__ notrace void arch_atomic_##op(int a, atomic_t *v) \ { \ int t; \ \
@@ -62,7 +62,7 @@ static __inline__ void arch_atomic_##op(int a, atomic_t *v) \ } \#define ATOMIC_OP_RETURN_RELAXED (op, asm_op, suffix, sign, ...) \ -static inline int arch_atomic_##op##_return_relaxed(int a, atomic_t *v) \ +static inline notrace int arch_atomic_##op##_return_relaxed(int a, atomic_t *v) \ { \ int t; \ \
@@ -79,7 +79,7 @@ static inline int arch_atomic_##op##_return_relaxed(int a, atomic_t *v) \ }#define ATOMIC_FETCH_OP_RELAXED (op, asm_op, suffix, sign, ...) \ -static inline int arch_atomic_fetch_##op##_relaxed(int a, atomic_t *v) \ +static inline notrace int arch_atomic_fetch_##op##_relaxed(int a, atomic_t *v) \ { \ int res, t; \ \
@@ -136,7 +136,7 @@ ATOMIC_OPS(xor, xor, "", K)* Atomically adds @a to @v, so long as it was not @u. * Returns the old value of @v. */ -static __inline__int arch_atomic_fetch_add_unless (atomic_t *v,int a,int u) +static __inline__ notrace int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u) {int t;
@@ -164,7 +164,7 @@ static __inline__ int arch_atomic_fetch_add_unless(atomic_t *v, int a, int u)* The function returns the old value of *v minus 1, even if * the atomic variable, v, was not decremented. */ -static __inline__int arch_atomic_dec_if_positive (atomic_t *v) +static __inline__ notrace int arch_atomic_dec_if_positive(atomic_t *v) {int t;
@@ -190,7 +190,7 @@ static __inline__ int arch_atomic_dec_if_positive(atomic_t *v)#define ATOMIC64_INIT (i) { (i) } -static __inline__s64 arch_atomic64_read (const atomic64_t *v) +static __inline__ notrace s64 arch_atomic64_read(const atomic64_t *v) {s64 t;
@@ -203,7 +203,7 @@ static __inline__ s64 arch_atomic64_read(const atomic64_t *v)return t; } -static __inline__void arch_atomic64_set (atomic64_t *v,s64 i) +static __inline__ notrace void arch_atomic64_set(atomic64_t *v, s64 i) {/* -mprefixed can generate offsets beyond range, fall back hack */ if (IS_ENABLED (CONFIG_PPC_KERNEL_PREFIXED ))
@@ -213,7 +213,7 @@ static __inline__ void arch_atomic64_set(atomic64_t *v, s64 i) }#define ATOMIC64_OP (op, asm_op) \ -static __inline__ void arch_atomic64_##op(s64 a, atomic64_t *v) \ +static __inline__ notrace void arch_atomic64_##op(s64 a, atomic64_t *v) \ { \ s64 t; \ \
@@ -228,7 +228,7 @@ static __inline__ void arch_atomic64_##op(s64 a, atomic64_t *v) \ }#define ATOMIC64_OP_RETURN_RELAXED (op, asm_op) \ -static inline s64 \ +static inline notrace s64 \ arch_atomic64_##op##_return_relaxed(s64 a, atomic64_t *v) \ { \ s64 t; \
@@ -246,7 +246,7 @@ arch_atomic64_##op##_return_relaxed(s64 a, atomic64_t *v) \ }#define ATOMIC64_FETCH_OP_RELAXED (op, asm_op) \ -static inline s64 \ +static inline notrace s64 \ arch_atomic64_fetch_##op##_relaxed(s64 a, atomic64_t *v) \ { \ s64 res, t; \
@@ -295,7 +295,7 @@ ATOMIC64_OPS(xor, xor)#undef ATOMIC64_OP_RETURN_RELAXED#undef ATOMIC64_OP -static __inline__void arch_atomic64_inc (atomic64_t *v) +static __inline__ notrace void arch_atomic64_inc(atomic64_t *v) {s64 t;
@@ -310,7 +310,7 @@ static __inline__ void arch_atomic64_inc(atomic64_t *v) }#define arch_atomic64_inc arch_atomic64_inc -static __inline__s64 arch_atomic64_inc_return_relaxed (atomic64_t *v) +static __inline__ notrace s64 arch_atomic64_inc_return_relaxed(atomic64_t *v) {s64 t;
@@ -326,7 +326,7 @@ static __inline__ s64 arch_atomic64_inc_return_relaxed(atomic64_t *v)return t; } -static __inline__void arch_atomic64_dec (atomic64_t *v) +static __inline__ notrace void arch_atomic64_dec(atomic64_t *v) {s64 t;
@@ -341,7 +341,7 @@ static __inline__ void arch_atomic64_dec(atomic64_t *v) }#define arch_atomic64_dec arch_atomic64_dec -static __inline__s64 arch_atomic64_dec_return_relaxed (atomic64_t *v) +static __inline__ notrace s64 arch_atomic64_dec_return_relaxed(atomic64_t *v) {s64 t;
@@ -364,7 +364,7 @@ static __inline__ s64 arch_atomic64_dec_return_relaxed(atomic64_t *v)* Atomically test *v and decrement if it is greater than 0. * The function returns the old value of *v minus 1. */ -static __inline__s64 arch_atomic64_dec_if_positive (atomic64_t *v) +static __inline__ notrace s64 arch_atomic64_dec_if_positive(atomic64_t *v) {s64 t;
@@ -394,7 +394,7 @@ static __inline__ s64 arch_atomic64_dec_if_positive(atomic64_t *v)* Atomically adds @a to @v, so long as it was not @u. * Returns the old value of @v. */ -static __inline__s64 arch_atomic64_fetch_add_unless (atomic64_t *v,s64 a,s64 u) +static __inline__ notrace s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u) {s64 t;
@@ -424,7 +424,7 @@ static __inline__ s64 arch_atomic64_fetch_add_unless(atomic64_t *v, s64 a, s64 u* Atomically increments @v by 1, so long as @v is non-zero. * Returns non-zero if @v was non-zero, and zero otherwise. */ -static __inline__int arch_atomic64_inc_not_zero (atomic64_t *v) +static __inline__ notrace int arch_atomic64_inc_not_zero(atomic64_t *v) {s64 t1, t2;
arch/powerpc/include/asm/bitops.h +15 -14
@@ -63,7 +63,7 @@/* Macro for generating the ***_bits() functions */ #define DEFINE_BITOP (fn, op, prefix) \ -static inline void fn(unsigned long mask, \ +static inline notrace void fn(unsigned long mask, \ volatile unsigned long *_p) \ { \ unsigned long old; \
@@ -94,7 +94,7 @@ static __always_inline bool is_rlwinm_mask_valid(unsigned long x) }#define DEFINE_CLROP (fn, prefix) \ -static inline void fn(unsigned long mask, volatile unsigned long *_p) \ +static inline notrace void fn(unsigned long mask, volatile unsigned long *_p) \ { \ unsigned long old; \ unsigned long *p = (unsigned long *)_p; \
@@ -126,22 +126,22 @@ static inline void fn(unsigned long mask, volatile unsigned long *_p) \ DEFINE_CLROP(clear_bits, "") DEFINE_CLROP(clear_bits_unlock, PPC_RELEASE_BARRIER) -static inline void arch_set_bit (int nr,volatile unsigned long *addr) +static inline notrace void arch_set_bit(int nr, volatile unsigned long *addr) {set_bits (BIT_MASK (nr), addr +BIT_WORD (nr)); } -static inline void arch_clear_bit (int nr,volatile unsigned long *addr) +static inline notrace void arch_clear_bit(int nr, volatile unsigned long *addr) {clear_bits (BIT_MASK (nr), addr +BIT_WORD (nr)); } -static inline void arch_clear_bit_unlock (int nr,volatile unsigned long *addr) +static inline notrace void arch_clear_bit_unlock(int nr, volatile unsigned long *addr) {clear_bits_unlock (BIT_MASK (nr), addr +BIT_WORD (nr)); } -static inline void arch_change_bit (int nr,volatile unsigned long *addr) +static inline notrace void arch_change_bit(int nr, volatile unsigned long *addr) {change_bits (BIT_MASK (nr), addr +BIT_WORD (nr)); }
@@ -149,7 +149,7 @@ static inline void arch_change_bit(int nr, volatile unsigned long *addr)/* Like DEFINE_BITOP(), with changes to the arguments to 'op' and the output * operands. */ #define DEFINE_TESTOP (fn, op, prefix, postfix, eh) \ -static inline unsigned long fn( \ +static inline notrace unsigned long fn( \ unsigned long mask, \ volatile unsigned long *_p) \ { \
@@ -175,7 +175,8 @@ DEFINE_TESTOP(test_and_set_bits_lock, or, "",DEFINE_TESTOP (test_and_change_bits, xor,PPC_ATOMIC_ENTRY_BARRIER , PPC_ATOMIC_EXIT_BARRIER, 0) -static inline unsigned long test_and_clear_bits (unsigned long mask,volatile unsigned long *_p) +static inline notrace unsigned long +test_and_clear_bits (unsigned long mask,volatile unsigned long *_p) {unsigned long old, t;unsigned long *p = (unsigned long *)_p;
@@ -208,32 +209,32 @@ static inline unsigned long test_and_clear_bits(unsigned long mask, volatile unsreturn (old & mask); } -static inline int arch_test_and_set_bit (unsigned long nr, +static inline notrace int arch_test_and_set_bit(unsigned long nr,volatile unsigned long *addr) {return test_and_set_bits (BIT_MASK (nr), addr +BIT_WORD (nr)) !=0 ; } -static inline int arch_test_and_set_bit_lock (unsigned long nr, +static inline notrace int arch_test_and_set_bit_lock(unsigned long nr,volatile unsigned long *addr) {return test_and_set_bits_lock (BIT_MASK (nr), addr +BIT_WORD (nr)) !=0 ; } -static inline int arch_test_and_clear_bit (unsigned long nr, +static inline notrace int arch_test_and_clear_bit(unsigned long nr,volatile unsigned long *addr) {return test_and_clear_bits (BIT_MASK (nr), addr +BIT_WORD (nr)) !=0 ; } -static inline int arch_test_and_change_bit (unsigned long nr, +static inline notrace int arch_test_and_change_bit(unsigned long nr,volatile unsigned long *addr) {return test_and_change_bits (BIT_MASK (nr), addr +BIT_WORD (nr)) !=0 ; } -static inline bool arch_xor_unlock_is_negative_byte (unsigned long mask, +static inline notrace bool arch_xor_unlock_is_negative_byte(unsigned long mask,volatile unsigned long *p) {unsigned long old, t;
@@ -254,7 +255,7 @@ static inline bool arch_xor_unlock_is_negative_byte(unsigned long mask,#include <asm-generic/bitops/non-atomic.h> -static inline void arch___clear_bit_unlock (int nr,volatile unsigned long *addr) +static inline notrace void arch___clear_bit_unlock(int nr, volatile unsigned long *addr) { __asm__ __volatile__(PPC_RELEASE_BARRIER "" :::"memory" );__clear_bit (nr, addr);
arch/powerpc/include/asm/cmpxchg.h +1 -1
@@ -14,7 +14,7 @@#endif #define XCHG_GEN (type, sfx, cl) \ -static inline u32 __xchg_##type##sfx(volatile void *p, u32 val) \ +static inline notrace u32 __xchg_##type##sfx(volatile void *p, u32 val) \ { \ unsigned int prev, prev_mask, tmp, bitoff, off; \ \
arch/powerpc/include/asm/entry-common.h +16 -16
@@ -31,7 +31,7 @@ unsigned long search_kernel_restart_table(unsigned long addr);DECLARE_STATIC_KEY_FALSE (interrupt_exit_not_reentrant); -static inline bool is_implicit_soft_masked (struct pt_regs *regs) +static inline notrace bool is_implicit_soft_masked(struct pt_regs *regs) {if (user_mode (regs))return false;
@@ -42,28 +42,28 @@ static inline bool is_implicit_soft_masked(struct pt_regs *regs)return search_kernel_soft_mask_table (regs->nip); } -static inline void srr_regs_clobbered (void ) +static inline notrace void srr_regs_clobbered(void) { local_paca->srr_valid =0 ; local_paca->hsrr_valid =0 ; }#else -static inline unsigned long search_kernel_restart_table (unsigned long addr) +static inline notrace unsigned long search_kernel_restart_table (unsigned long addr) {return 0 ; } -static inline bool is_implicit_soft_masked (struct pt_regs *regs) +static inline notrace bool is_implicit_soft_masked(struct pt_regs *regs) {return false; } -static inline void srr_regs_clobbered (void ) +static inline notrace void srr_regs_clobbered(void) { }#endif -static inline void nap_adjust_return (struct pt_regs *regs) +static inline notrace void nap_adjust_return(struct pt_regs *regs) {#ifdef CONFIG_PPC_970_NAP /*
@@ -103,7 +103,7 @@ static __always_inline void booke_load_dbcr0(void)#endif } -static inline void booke_restore_dbcr0 (void ) +static inline notrace void booke_restore_dbcr0(void) {#ifdef CONFIG_PPC_ADV_DEBUG_REGS unsigned long dbcr0 = current->thread.debug.dbcr0;
@@ -115,7 +115,7 @@ static inline void booke_restore_dbcr0(void)#endif } -static inline void check_return_regs_valid (struct pt_regs *regs) +static inline notrace void check_return_regs_valid(struct pt_regs *regs) {#ifdef CONFIG_PPC_BOOK3S_64 unsigned long trap, srr0, srr1;
@@ -195,7 +195,7 @@ static inline void check_return_regs_valid(struct pt_regs *regs)#endif } -static inline void arch_interrupt_enter_prepare (struct pt_regs *regs) +static inline notrace void arch_interrupt_enter_prepare(struct pt_regs *regs) {#ifdef CONFIG_PPC64 irq_soft_mask_set (IRQS_ALL_DISABLED );
@@ -255,7 +255,7 @@ static inline void arch_interrupt_enter_prepare(struct pt_regs *regs)* However arch_interrupt_nmi_exit_prepare does return directly to regs, because * NMIs do not do "exit work" or replay soft-masked interrupts. */ -static inline void arch_interrupt_exit_prepare (struct pt_regs *regs) +static inline notrace void arch_interrupt_exit_prepare(struct pt_regs *regs) {if (user_mode (regs)) {BUG_ON (regs_is_unrecoverable (regs));
@@ -271,7 +271,7 @@ static inline void arch_interrupt_exit_prepare(struct pt_regs *regs)hard_irq_disable (); } -static inline void arch_interrupt_async_enter_prepare (struct pt_regs *regs) +static inline notrace void arch_interrupt_async_enter_prepare(struct pt_regs *regs) {#ifdef CONFIG_PPC64 /* Ensure arch_interrupt_enter_prepare does not enable MSR[EE] */
@@ -289,7 +289,7 @@ static inline void arch_interrupt_async_enter_prepare(struct pt_regs *regs)#endif } -static inline void arch_interrupt_async_exit_prepare (struct pt_regs *regs) +static inline notrace void arch_interrupt_async_exit_prepare(struct pt_regs *regs) {arch_interrupt_exit_prepare (regs); }
@@ -303,7 +303,7 @@ struct interrupt_nmi_state {#endif }; -static inline bool nmi_disables_ftrace (struct pt_regs *regs) +static inline notrace bool nmi_disables_ftrace(struct pt_regs *regs) {/* Allow DEC and PMI to be traced when they are soft-NMI */ if (IS_ENABLED (CONFIG_PPC_BOOK3S_64 )) {
@@ -320,7 +320,7 @@ static inline bool nmi_disables_ftrace(struct pt_regs *regs)return true; } -static inline void arch_interrupt_nmi_enter_prepare (struct pt_regs *regs, +static inline notrace void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,struct interrupt_nmi_state *state) {#ifdef CONFIG_PPC64
@@ -358,7 +358,7 @@ static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,#endif } -static inline void arch_interrupt_nmi_exit_prepare (struct pt_regs *regs, +static inline notrace void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,struct interrupt_nmi_state *state) {/*
@@ -480,7 +480,7 @@ static __always_inline void arch_enter_from_user_mode(struct pt_regs *regs)#define arch_enter_from_user_mode arch_enter_from_user_mode -static inline void arch_exit_to_user_mode_prepare (struct pt_regs *regs, +static inline notrace void arch_exit_to_user_mode_prepare(struct pt_regs *regs,unsigned long ti_work) {unsigned long mathflags;
arch/powerpc/include/asm/hw_irq.h +34 -34
233 lines not on this page · raw message
arch/powerpc/include/asm/interrupt.h +1 -1
@@ -397,7 +397,7 @@ void __noreturn unrecoverable_exception(struct pt_regs *regs);void replay_system_reset (void );void replay_soft_interrupts (void ); -static inline void interrupt_cond_local_irq_enable (struct pt_regs *regs) +static inline notrace void interrupt_cond_local_irq_enable(struct pt_regs *regs) {if (!regs_irqs_disabled (regs))local_irq_enable ();
arch/powerpc/include/asm/io.h +8 -8
@@ -91,7 +91,7 @@ extern bool isa_io_special;/* -mprefixed can generate offsets beyond range, fall back hack */ #ifdef CONFIG_PPC_KERNEL_PREFIXED #define DEF_MMIO_IN_X (name, size, insn) \ -static inline u##size name(const volatile u##size __iomem *addr) \ +static inline notrace u##size name(const volatile u##size __iomem *addr) \ { \ u##size ret; \ __asm__ __volatile__("sync;"#insn" %0,0,%1;twi 0,%0,0;isync" \
@@ -100,7 +100,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \ }#define DEF_MMIO_OUT_X (name, size, insn) \ -static inline void name(volatile u##size __iomem *addr, u##size val) \ +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \ { \ __asm__ __volatile__("sync;"#insn" %1,0,%0" \ : : "r" (addr), "r" (val) : "memory"); \
@@ -108,7 +108,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \ }#define DEF_MMIO_IN_D (name, size, insn) \ -static inline u##size name(const volatile u##size __iomem *addr) \ +static inline notrace u##size name(const volatile u##size __iomem *addr) \ { \ u##size ret; \ __asm__ __volatile__("sync;"#insn" %0,0(%1);twi 0,%0,0;isync"\
@@ -117,7 +117,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \ }#define DEF_MMIO_OUT_D (name, size, insn) \ -static inline void name(volatile u##size __iomem *addr, u##size val) \ +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \ { \ __asm__ __volatile__("sync;"#insn" %1,0(%0)" \ : : "b" (addr), "r" (val) : "memory"); \
@@ -125,7 +125,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \ }#else #define DEF_MMIO_IN_X (name, size, insn) \ -static inline u##size name(const volatile u##size __iomem *addr) \ +static inline notrace u##size name(const volatile u##size __iomem *addr) \ { \ u##size ret; \ __asm__ __volatile__("sync;"#insn" %0,%y1;twi 0,%0,0;isync" \
@@ -134,7 +134,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \ }#define DEF_MMIO_OUT_X (name, size, insn) \ -static inline void name(volatile u##size __iomem *addr, u##size val) \ +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \ { \ __asm__ __volatile__("sync;"#insn" %1,%y0" \ : "=Z" (*addr) : "r" (val) : "memory"); \
@@ -142,7 +142,7 @@ static inline void name(volatile u##size __iomem *addr, u##size val) \ }#define DEF_MMIO_IN_D (name, size, insn) \ -static inline u##size name(const volatile u##size __iomem *addr) \ +static inline notrace u##size name(const volatile u##size __iomem *addr) \ { \ u##size ret; \ __asm__ __volatile__("sync;"#insn"%U1%X1 %0,%1;twi 0,%0,0;isync"\
@@ -151,7 +151,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \ }#define DEF_MMIO_OUT_D (name, size, insn) \ -static inline void name(volatile u##size __iomem *addr, u##size val) \ +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \ { \ __asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \ : "=m<>" (*addr) : "r" (val) : "memory"); \
arch/powerpc/include/asm/plpar_wrappers.h +2 -2
@@ -13,12 +13,12 @@#include <asm/lppaca.h> #include <asm/page.h> -static inline long poll_pending (void ) +static inline notrace long poll_pending (void ) {return plpar_hcall_norets (H_POLL_PENDING ); } -static inline long cede_processor (void ) +static inline notrace long cede_processor (void ) {/* * We cannot call tracepoints inside RCU idle regions which
arch/powerpc/include/asm/ptrace.h +7 -7
@@ -255,17 +255,17 @@ static __always_inline void set_trap(struct pt_regs *regs, unsigned long val) regs->trap = (regs->trap &TRAP_FLAGS_MASK ) | (val & ~TRAP_FLAGS_MASK ); } -static inline bool trap_is_scv (struct pt_regs *regs) +static inline notrace bool trap_is_scv(struct pt_regs *regs) {return (IS_ENABLED (CONFIG_PPC_BOOK3S_64 ) &&TRAP (regs) ==0x3000 ); } -static inline bool trap_is_unsupported_scv (struct pt_regs *regs) +static inline notrace bool trap_is_unsupported_scv(struct pt_regs *regs) {return IS_ENABLED (CONFIG_PPC_BOOK3S_64 ) &&TRAP (regs) ==0x7ff0 ; } -static inline bool trap_is_syscall (struct pt_regs *regs) +static inline notrace bool trap_is_syscall(struct pt_regs *regs) {return (trap_is_scv (regs) ||TRAP (regs) ==0xc00 ); }
@@ -305,23 +305,23 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) regs->gpr[3 ] = rc; } -static inline bool cpu_has_msr_ri (void ) +static inline notrace bool cpu_has_msr_ri(void) {return !IS_ENABLED (CONFIG_BOOKE ); } -static inline bool regs_is_unrecoverable (struct pt_regs *regs) +static inline notrace bool regs_is_unrecoverable(struct pt_regs *regs) {return unlikely (cpu_has_msr_ri () && !(regs->msr &MSR_RI )); } -static inline void regs_set_recoverable (struct pt_regs *regs) +static inline notrace void regs_set_recoverable(struct pt_regs *regs) {if (cpu_has_msr_ri ())regs_set_return_msr (regs, regs->msr |MSR_RI ); } -static inline void regs_set_unrecoverable (struct pt_regs *regs) +static inline notrace void regs_set_unrecoverable(struct pt_regs *regs) {if (cpu_has_msr_ri ())regs_set_return_msr (regs, regs->msr & ~MSR_RI );
arch/powerpc/include/asm/rtas.h +5 -5
@@ -343,7 +343,7 @@ static inline uint8_t rtas_error_initiator(const struct rtas_error_log *elog)#define rtas_error_type (x) ((x)->byte3) -static inline +static inline notrace uint32_t rtas_error_extended_log_length(const struct rtas_error_log *elog) {return be32_to_cpu (elog->extended_log_length);
@@ -354,13 +354,13 @@ uint32_t rtas_error_extended_log_length(const struct rtas_error_log *elog)#define RTAS_V6EXT_COMPANY_ID_IBM (('I' << 24) | ('B' << 16) | ('M' << 8))static -inline uint8_t rtas_ext_event_log_format (struct rtas_ext_event_log_v6 *ext_log) +inline notrace uint8_t rtas_ext_event_log_format(struct rtas_ext_event_log_v6 *ext_log) {return ext_log->byte2 &0x0F ; }static -inline uint32_t rtas_ext_event_company_id (struct rtas_ext_event_log_v6 *ext_log) +inline notrace uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log) {return be32_to_cpu (ext_log->company_id); }
@@ -389,13 +389,13 @@ inline uint32_t rtas_ext_event_company_id(struct rtas_ext_event_log_v6 *ext_log)#define PSERIES_ELOG_SECT_ID_MCE (('M' << 8) | 'C')static -inline uint16_t pseries_errorlog_id (struct pseries_errorlog *sect) +inline notrace uint16_t pseries_errorlog_id(struct pseries_errorlog *sect) {return be16_to_cpu (sect->id); }static -inline uint16_t pseries_errorlog_length (struct pseries_errorlog *sect) +inline notrace uint16_t pseries_errorlog_length(struct pseries_errorlog *sect) {return be16_to_cpu (sect->length); }
arch/powerpc/include/asm/synch.h +3 -3
@@ -12,7 +12,7 @@ extern unsigned int __start___lwsync_fixup, __stop___lwsync_fixup;extern void do_lwsync_fixups (unsigned long value,void *fixup_start,void *fixup_end); -static inline void eieio (void ) +static inline notrace void eieio(void) {if (IS_ENABLED (CONFIG_BOOKE )) __asm__ __volatile__ ("mbar" : : :"memory" );
@@ -20,12 +20,12 @@ static inline void eieio(void) __asm__ __volatile__ ("eieio" : : :"memory" ); } -static inline void isync (void ) +static inline notrace void isync(void) { __asm__ __volatile__ ("isync" : : :"memory" ); } -static inline void ppc_after_tlbiel_barrier (void ) +static inline notrace void ppc_after_tlbiel_barrier(void) { asmvolatile ("ptesync" : : :"memory" );/*
arch/powerpc/include/asm/thread_info.h +2 -2
@@ -165,13 +165,13 @@ void arch_setup_new_exec(void);#ifndef __ASSEMBLER__ -static inline void clear_thread_local_flags (unsigned int flags) +static inline notrace void clear_thread_local_flags(unsigned int flags) {struct thread_info *ti =current_thread_info (); ti->local_flags &= ~flags; } -static inline bool test_thread_local_flags (unsigned int flags) +static inline notrace bool test_thread_local_flags(unsigned int flags) {struct thread_info *ti =current_thread_info ();return (ti->local_flags & flags) !=0 ;
arch/powerpc/kernel/watchdog.c +2 -2
@@ -121,7 +121,7 @@ static void wd_end_reporting(void)WRITE_ONCE (__wd_reporting,0 ); } -static inline void wd_smp_lock (unsigned long *flags) +static inline notrace void wd_smp_lock(unsigned long *flags) {/* * Avoid locking layers if possible.
@@ -138,7 +138,7 @@ static inline void wd_smp_lock(unsigned long *flags) } } -static inline void wd_smp_unlock (unsigned long *flags) +static inline notrace void wd_smp_unlock(unsigned long *flags) {clear_bit_unlock (0 , &__wd_smp_lock);raw_local_irq_restore (*flags);
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 21/22 riscv: Mark helpers called from noinstr code notrace
In reply to Song LiuSome 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.
--- 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(-)
arch/riscv/include/asm/cpuidle.h +1 -1
@@ -10,7 +10,7 @@#include <asm/barrier.h> #include <asm/processor.h> -static inline void cpu_do_idle (void ) +static inline void notrace cpu_do_idle(void) {/* * Add mb() here to ensure that all
arch/riscv/include/asm/irqflags.h +7 -7
@@ -10,43 +10,43 @@#include <asm/csr.h> /* 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 ); }
arch/riscv/include/asm/vdso/processor.h +1 -1
@@ -8,7 +8,7 @@#include <asm/errata_list.h> #include <asm/insn-def.h> -static inline void cpu_relax (void ) +static inline void notrace cpu_relax(void) {#ifdef __riscv_muldivint dummy;
arch/riscv/include/asm/vector.h +4 -4
@@ -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 ();
Signature · 1 line
2.53.1-Meta
Song Liu
maintainerPATCH v3 22/22 compiler_types: Move notrace from inline to __always_inline
In reply to Song LiuCommit 45959ee7aa64 ("ftrace: Do not function trace inlined functions") added notrace to the inline macro. At the time, inline was only a hint with CONFIG_OPTIMIZE_INLINING, and whether a given inline function got an mcount call depended on the gcc version. Some functions that must not be traced, such as the paravirt native_*() helpers, were marked inline and relied on being inlined, so a different gcc could silently break the function tracer. Making all inline functions notrace removed that dependency on the compiler.
That trade-off no longer makes sense. CONFIG_OPTIMIZE_INLINING was made always on by commit ac7c3e4ff401 ("compiler: enable CONFIG_OPTIMIZE_INLINING forcibly") and removed by commit 889b3c1245de ("compiler: remove CONFIG_OPTIMIZE_INLINING entirely"). The compiler also inlines static functions that are not marked inline, and creates .constprop, .isra and .part clones, so the set of traceable functions already depends on the compiler. notrace on inline does not make it consistent. It only hides the inline functions that the compiler chose not to inline. Hidden functions cannot be traced with ftrace or used as BPF fentry/fexit targets. They also cannot be livepatched, because livepatch redirects functions through ftrace, so a fix to one of them has to be shipped by livepatching its callers instead.
A function that must not be traced should say so. The previous patches mark notrace the inline helpers that relied on inline implying notrace:
the paravirt native helpers, the helpers used by resume and kexec, the helpers used by bpf_spin_lock, the BPF trampoline and bpf_mem_alloc, the helpers used by ftrace recursion protection, tracepoints, SRCU, the trace clocks, core_kernel_text() and the nofault accessors, and the helpers that noinstr code calls on arm64, powerpc and riscv, including the generic exception_enter(), exception_exit() and thread flag helpers, and the arm64 stack unwinder helpers.
Keep notrace on __always_inline. Such functions are meant to be inlined into their callers. An out-of-line copy exists only when the address of the function is taken or when it has external linkage, and those copies are mostly low-level helpers used by entry, context switch and tracing code.
--- include/linux/compiler_attributes.h | 6 +++++- include/linux/compiler_types.h | 3 +-- 2 files changed, 6 insertions(+), 3 deletions(-)
include/linux/compiler_attributes.h +5 -1
@@ -49,10 +49,14 @@* to its docs (and also "warning: always_inline function might not be * inlinable [-Wattributes]" is emitted). * +* The compiler still emits an out-of-line copy of an __always_inline function +* when its address is taken or when it has external linkage. These functions +* are often used by code that must not be traced, so mark them notrace. +* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute * clang: mentioned */ -#define __always_inline inline __attribute__((__always_inline__)) +#define __always_inline inline __attribute__((__always_inline__)) notrace/* * The second argument is optional (default 0), so we use a variadic macro
include/linux/compiler_types.h +1 -2
@@ -230,9 +230,8 @@ struct ftrace_likely_data {* externally visible function. This makes extern inline behave as per gnu89 * semantics rather than c99. This prevents multiple symbol definition errors * of extern inline functions at link time. -* A lot of inline functions can cause havoc with function tracing. */ -#define inline inline __gnu_inline __inline_maybe_unused notrace +#define inline inline __gnu_inline __inline_maybe_unused/* * gcc provides both __inline__ and __inline as alternate spellings of
Signature · 1 line
2.53.1-Meta
[email protected]
AI reviewRe: [PATCH v3 14/22] kallsyms: Mark the kernel text address checks notrace
In reply to Song LiuThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] kallsyms: missing notrace on in_gate_area_no_mm() called by is_kernel_text() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] kallsyms: missing notrace on in_gate_area_no_mm() called by is_kernel_text()
--
commit 2feaa205ac66915ee68ecd74dd6cf20dacbb4d93
Author: Song Liu <[email protected]>
kallsyms: Mark the kernel text address checks notrace
This commit marks is_kernel_inittext(), __is_kernel_text(), and is_kernel_text() as notrace so out-of-line copies of these inline helpers cannot be traced when called from core_kernel_text().
[ ... ]
include/linux/kallsyms.h line 30
Quoted 13 lines
include/linux/kallsyms.h +1
-1@@ -24,7 +24,7 @@struct cred ;struct module ; -static inline int is_kernel_text (unsigned long addr) +static inline int notrace is_kernel_text(unsigned long addr) {if (__is_kernel_text (addr))return 1 ;
[Severity: Medium]
Should in_gate_area_no_mm() also be marked notrace?
When __is_kernel_text(addr) returns false (for example, on module or .init.text addresses before core_kernel_text() reaches is_kernel_inittext()), is_kernel_text() calls in_gate_area_no_mm(addr). On MIPS and other architectures without __HAVE_ARCH_GATE_AREA, in_gate_area_no_mm() in include/linux/mm.h is a plain static inline function without notrace, so an out-of-line copy of it can still cause the MIPS function graph tracer to recurse without bound when inline no longer implies notrace.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=14
[email protected]
AI reviewRe: [PATCH v3 08/22] srcu: Mark the fast notrace read-side helpers notrace
In reply to Song LiuThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] srcu: missing notrace on Tiny SRCU inline helpers called by fast lock/unlock --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Low] srcu: missing notrace on Tiny SRCU inline helpers called by fast lock/unlock
--
commit 58446ad08cebec81369ae61a32f8e4673fca1dc1
Author: Song Liu <[email protected]>
srcu: Mark the fast notrace read-side helpers notrace
This commit adds explicit notrace annotations to srcu_read_lock_fast_notrace(), srcu_read_unlock_fast_notrace(), srcu_check_read_flavor(), and the Tiny SRCU implementations of __srcu_read_lock_fast() and __srcu_read_unlock_fast().
Quoted 11 lines
include/linux/srcutiny.h +1
-1@@ -114,13 +114,14 @@ static inline struct srcu_ctr __percpu *__srcu_ctr_to_ptr(struct srcu_struct *ssreturn (struct srcu_ctr __percpu *)(intptr_t )idx; } -static inline struct srcu_ctr __percpu *__srcu_read_lock_fast (struct srcu_struct *ssp) +static inline struct srcu_ctr __percpu notrace *__srcu_read_lock_fast(struct srcu_struct *ssp)__acquires_shared (ssp)
include/linux/srcutiny.h static inline struct srcu_ctr __percpu *__srcu_ctr_to_ptr(struct srcu_struct *ss · line 127
Quoted 10 lines
include/linux/srcutiny.h +2
-1{return __srcu_ctr_to_ptr (ssp,__srcu_read_lock (ssp)); } -static inline void __srcu_read_unlock_fast (struct srcu_struct *ssp,struct srcu_ctr __percpu *scp) +static inline void notrace +__srcu_read_unlock_fast (struct srcu_struct *ssp,struct srcu_ctr __percpu *scp)__releases_shared (ssp) {__srcu_read_unlock (ssp,__srcu_ptr_to_ctr (ssp, scp));
[Severity: Low]
Should __srcu_read_lock(), __srcu_ctr_to_ptr(), and __srcu_ptr_to_ctr() in include/linux/srcutiny.h also be marked notrace?
__srcu_read_lock_fast() and __srcu_read_unlock_fast() call those plain static inline helpers directly (and srcu_read_lock_notrace() also calls __srcu_read_lock()). Once commit "compiler_types: Move notrace from inline to __always_inline" drops notrace from inline, any out-of-line copy of those helpers under CONFIG_TINY_SRCU will be traceable when called from tracepoints.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=8
[email protected]
AI reviewRe: [PATCH v3 19/22] arm64: Mark the stack unwinder helpers notrace
In reply to Song LiuThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] arm64: missing notrace or __always_inline on unwind_find_stack() --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] arm64: missing notrace or __always_inline on unwind_find_stack()
--
commit b836a86f5820d0a3b22ab6c11f3d581e0f3097d0
Author: Song Liu <[email protected]>
arm64: Mark the stack unwinder helpers notrace
This commit marks the stack unwinder inline helpers in <asm/stacktrace.h> and <asm/stacktrace/common.h> as notrace so that out-of-line copies cannot be instrumented.
Quoted 4 lines
arch/arm64/include/asm/stacktrace/common.h +0
-0
[ ... ]
Quoted 10 lines
arch/arm64/include/asm/stacktrace/common.h +1
-1@@ -99,7 +99,7 @@ static struct stack_info *unwind_find_stack(struct unwind_state *state,* * Return: 0 upon success, an error code otherwise. */ -static inline void unwind_consume_stack (struct unwind_state *state, +static inline void notrace unwind_consume_stack(struct unwind_state *state,struct stack_info *info,unsigned long sp,unsigned long size)
arch/arm64/include/asm/stacktrace/common.h static inline void unwind_consume_stack(struct unwind_state *state, · line 148
Quoted 8 lines
arch/arm64/include/asm/stacktrace/common.h +1
-1@@ -142,7 +142,7 @@ static inline void unwind_consume_stack(struct unwind_state *state,* * Return: 0 upon success, an error code otherwise. */ -static inline int +static inline int notraceunwind_next_frame_record (struct unwind_state *state) {struct stack_info *info;
[Severity: Medium]
Should unwind_find_stack() in this header also be marked inline notrace?
It is defined as a plain static function without inline or notrace, and is called on every frame by unwind_next_frame_record() and by the __always_inline helpers in arch/arm64/kernel/stacktrace.c inside noinstr arch_stack_walk(). An out-of-line copy of unwind_find_stack() remains instrumented by ftrace and kprobeable, which can trigger recursive tracing or a fatal kprobe recursion BUG() when lockdep unwinds via return_address() -> arch_stack_walk().
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=19
[email protected]
AI reviewRe: [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace
In reply to Song LiuThank you for your contribution! Sashiko AI review found 4 potential issues to consider: - [Medium] powerpc: missing notrace on 64-bit byte-swapped MMIO helpers in asm/io.h - [Medium] powerpc…
Thank you for your contribution! Sashiko AI review found 4 potential issues to consider:
- [Medium] powerpc: missing notrace on 64-bit byte-swapped MMIO helpers in asm/io.h
- [Medium] powerpc: missing notrace on return register helpers in asm/ptrace.h
- [Medium] powerpc: missing notrace on ftrace enable helpers in asm/ftrace.h
- [Low] powerpc: missing notrace on CMPXCHG_GEN() in asm/cmpxchg.h --
commit 8cbdd62036fd779308aae93f2caa0e8f191ee974
Author: Song Liu <[email protected]>
powerpc: Mark helpers called from noinstr code notrace
This commit adds explicit notrace annotations to inline helpers across PowerPC headers and watchdog code that are called from noinstr and untraced contexts.
arch/powerpc/include/asm/cmpxchg.h line 20
Quoted 13 lines
arch/powerpc/include/asm/cmpxchg.h +1
-1@@ -14,7 +14,7 @@#endif #define XCHG_GEN (type, sfx, cl) \ -static inline u32 __xchg_##type##sfx(volatile void *p, u32 val) \ +static inline notrace u32 __xchg_##type##sfx(volatile void *p, u32 val) \ { \ unsigned int prev, prev_mask, tmp, bitoff, off; \ \
[Severity: Low]
Should the companion CMPXCHG_GEN() macro right below XCHG_GEN() also be marked notrace? On !CONFIG_PPC_HAS_LBARX_LHARX builds it still defines the sub-word __cmpxchg_u8* and __cmpxchg_u16* helpers as plain static inline functions:
arch/powerpc/include/asm/cmpxchg.h:
#define CMPXCHG_GEN(type, sfx, br, br2, cl) \
static inline \
u32 __cmpxchg_##type##sfx(volatile void *p, u32 old, u32 new) \
Quoted 4 lines
arch/powerpc/include/asm/entry-common.h +0
-0
[ ... ]
Quoted 10 lines
arch/powerpc/include/asm/entry-common.h +1
-1@@ -320,7 +320,7 @@ static inline bool nmi_disables_ftrace(struct pt_regs *regs)return true; } -static inline void arch_interrupt_nmi_enter_prepare (struct pt_regs *regs, +static inline notrace void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,struct interrupt_nmi_state *state) {#ifdef CONFIG_PPC64
arch/powerpc/include/asm/entry-common.h static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs, · line 364
Quoted 8 lines
arch/powerpc/include/asm/entry-common.h +1
-1@@ -358,7 +358,7 @@ static inline void arch_interrupt_nmi_enter_prepare(struct pt_regs *regs,#endif } -static inline void arch_interrupt_nmi_exit_prepare (struct pt_regs *regs, +static inline notrace void arch_interrupt_nmi_exit_prepare(struct pt_regs *regs,struct interrupt_nmi_state *state) {/*
[Severity: Medium]
Should this_cpu_get_ftrace_enabled() and this_cpu_set_ftrace_enabled() in arch/powerpc/include/asm/ftrace.h also be marked notrace?
arch_interrupt_nmi_enter_prepare() and arch_interrupt_nmi_exit_prepare() call them before irqentry_nmi_enter() and after irqentry_nmi_exit() to save, disable and restore per-CPU ftrace state while paca->ftrace_enabled is still non-zero (including in real mode when MSR_DR is 0). In arch/powerpc/include/asm/ftrace.h those helpers are still plain static inline functions, so an out-of-line copy can be traced in NMI entry/exit once inline no longer implies notrace.
Quoted 4 lines
arch/powerpc/include/asm/io.h +0
-0
[ ... ]
arch/powerpc/include/asm/io.h static inline u##size name(const volatile u##size __iomem *addr) \ · line 157
Quoted 9 lines
arch/powerpc/include/asm/io.h +1
-1@@ -151,7 +151,7 @@ static inline u##size name(const volatile u##size __iomem *addr) \ }#define DEF_MMIO_OUT_D (name, size, insn) \ -static inline void name(volatile u##size __iomem *addr, u##size val) \ +static inline notrace void name(volatile u##size __iomem *addr, u##size val) \ { \ __asm__ __volatile__("sync;"#insn"%U0%X0 %1,%0" \ : "=m<>" (*addr) : "r" (val) : "memory"); \
[Severity: Medium]
Should the byte-swapped 64-bit MMIO helpers (in_le64() and out_le64() on big-endian, and in_be64() and out_be64() on little-endian) in arch/powerpc/include/asm/io.h also be marked notrace?
DEF_MMIO_IN_D and DEF_MMIO_OUT_D only generate the native-endian 64-bit accessors, while the opposite-endian 64-bit wrappers around swab64() just below them remain plain static inline functions. On little-endian builds, in_be64() is called from the noinstr CPU teardown path via xive_teardown_cpu() -> xive_cleanup_cpu_ipi() -> xive_do_source_set_mask() -> xive_esb_read(), so an out-of-line copy of in_be64() can be traced while a CPU is going offline.
Quoted 4 lines
arch/powerpc/include/asm/ptrace.h +0
-0
[ ... ]
Quoted 18 lines
arch/powerpc/include/asm/ptrace.h +3
-3@@ -305,23 +305,23 @@ static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) regs->gpr[3 ] = rc; } -static inline bool cpu_has_msr_ri (void ) +static inline notrace bool cpu_has_msr_ri(void) {return !IS_ENABLED (CONFIG_BOOKE ); } -static inline bool regs_is_unrecoverable (struct pt_regs *regs) +static inline notrace bool regs_is_unrecoverable(struct pt_regs *regs) {return unlikely (cpu_has_msr_ri () && !(regs->msr &MSR_RI )); } -static inline void regs_set_recoverable (struct pt_regs *regs) +static inline notrace void regs_set_recoverable(struct pt_regs *regs)
arch/powerpc/include/asm/ptrace.h static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc) · line 327
Quoted 10 lines
arch/powerpc/include/asm/ptrace.h +1
-1{if (cpu_has_msr_ri ())regs_set_return_msr (regs, regs->msr |MSR_RI ); } -static inline void regs_set_unrecoverable (struct pt_regs *regs) +static inline notrace void regs_set_unrecoverable(struct pt_regs *regs) {if (cpu_has_msr_ri ())regs_set_return_msr (regs, regs->msr & ~MSR_RI );
[Severity: Medium]
Should regs_set_return_msr(), regs_set_return_ip() and set_return_regs_changed() in arch/powerpc/include/asm/ptrace.h also be marked notrace?
regs_set_recoverable() and regs_set_unrecoverable() call regs_set_return_msr() -> set_return_regs_changed(), and arch_interrupt_nmi_exit_prepare() (which runs on NMI exit after irqentry_nmi_exit()) and nap_adjust_return() call regs_set_return_ip() -> set_return_regs_changed(). Because those three helpers remain plain static inline functions, an out-of-line copy could be traced during NMI exit once inline no longer implies notrace.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=20
[email protected]
AI reviewRe: [PATCH v3 18/22] arm64: Mark helpers called from noinstr code notrace
In reply to Song LiuThank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [Medium] arm64: noinstr helpers use static inline notrace instead of __always_inline - [Medium] arm64…
Thank you for your contribution! Sashiko AI review found 2 potential issues to consider:
- [Medium] arm64: noinstr helpers use static inline notrace instead of __always_inline
- [Medium] arm64: missing notrace/__always_inline on is_pkvm_initialized() and gic_read_pmr()
--
commit 58c12e9a90cffb79899ef34a6a22fce486bc0793
Author: Song Liu <[email protected]>
arm64: Mark helpers called from noinstr code notrace
This commit marks several arm64 inline helpers called from noinstr and cpuidle paths as notrace so out-of-line copies emitted by Clang are not traced by ftrace.
Quoted 92 lines
arch/arm64/include/asm/cpufeature.h +2
-2@@ -774,7 +774,7 @@ static __always_inline bool system_supports_fpsimd(void)return alternative_has_cap_likely (ARM64_HAS_FPSIMD ); } -static inline bool system_uses_hw_pan (void ) +static inline bool notrace system_uses_hw_pan(void) {return alternative_has_cap_unlikely (ARM64_HAS_PAN ); }@@ -955,7 +955,7 @@ static inline bool cpu_has_hw_af(void) ID_AA64MMFR1_EL1_HAFDBS_SHIFT); } -static inline bool cpu_has_pan (void ) +static inline bool notrace cpu_has_pan(void) {u64 mmfr1 =read_cpuid (ID_AA64MMFR1_EL1 ); return cpuid_feature_extract_unsigned_field(mmfr1,arch/arm64/include/asm/memory.h +1
-1@@ -223,7 +223,7 @@#include <asm/sections.h> #include <asm/sysreg.h> -static inline u64 __pure read_tcr (void ) +static inline u64 __pure notrace read_tcr(void) {u64 tcr;arch/arm64/include/asm/mmu.h +1
-1@@ -55,7 +55,7 @@ typedef struct {*/ #define ASID (mm) (atomic64_read(&(mm)->context.id) & 0xffff) -static inline bool arm64_kernel_unmapped_at_el0 (void ) +static inline bool notrace arm64_kernel_unmapped_at_el0(void) {return alternative_has_cap_unlikely (ARM64_UNMAP_KERNEL_AT_EL0 ); }arch/arm64/include/asm/percpu.h +1
-1@@ -37,7 +37,7 @@ static inline unsigned long __hyp_my_cpu_offset(void) "mrs " dst ", tpidr_el2", \ ARM64_HAS_VIRT_HOST_EXTN) -static inline unsigned long __kern_my_cpu_offset (void ) +static inline unsigned long notrace __kern_my_cpu_offset (void ) {unsigned long off;arch/arm64/include/asm/ptrace.h +1
-1@@ -360,7 +360,7 @@ static inline unsigned long regs_get_kernel_argument(struct pt_regs *regs,struct task_struct ;int valid_user_regs (struct user_pt_regs *regs,struct task_struct *task); -static inline unsigned long instruction_pointer (struct pt_regs *regs) +static inline unsigned long notrace instruction_pointer (struct pt_regs *regs) {return regs->pc; }arch/arm64/include/asm/vdso/processor.h +1
-1@@ -7,7 +7,7 @@#ifndef __ASSEMBLER__ -static inline void cpu_relax (void ) +static inline void notrace cpu_relax(void) { asmvolatile ("yield" :::"memory" ); }arch/arm64/include/asm/virt.h +0
-0
arch/arm64/include/asm/virt.h static inline bool pkvm_force_reclaim_guest_page(phys_addr_t phys) · line 110
Quoted 8 lines
arch/arm64/include/asm/virt.h +1
-1@@ -104,7 +104,7 @@ static inline bool pkvm_force_reclaim_guest_page(phys_addr_t phys)#endif /* Reports the availability of HYP mode */ -static inline bool is_hyp_mode_available (void ) +static inline bool notrace is_hyp_mode_available(void) {/* * If KVM protected mode is initialized, all CPUs must have been booted
[Severity: Medium]
Should these eight helpers be marked static __always_inline instead of static inline notrace?
Because noinstr and __cpuidle expand to include __no_profile, Clang refuses to inline a plain inline callee that lacks __no_profile into a noinstr or __cpuidle caller, emitting out-of-line copies in regular .text. Even with notrace, those out-of-line copies sit outside .noinstr.text and .cpuidle.text and lack __no_kcsan, __no_sanitize_address, __no_sanitize_coverage and __no_sanitize_memory:
- They are not covered by the .noinstr.text kprobe blacklist, so placing a kprobe on system_uses_hw_pan(), cpu_has_pan(), arm64_kernel_unmapped_at_el0() or __kern_my_cpu_offset() called from __sdei_handler() before exception registers are saved and before vbar_el1 is switched off the KPTI trampoline vectors clobbers live exception registers or traps into the unpopulated current-EL KPTI vectors.
- In translation units that do not disable sanitizers or coverage in the Makefile (such as kvm_patch_ich_vtr_el2() calling is_hyp_mode_available(), or el0_pc() calling instruction_pointer()), the out-of-line copies remain subject to KCOV, KASAN and KCSAN while RCU is not watching.
- cpu_relax() called from __cpuidle cpu_idle_poll() executes in .text outside __cpuidle_text_start..__cpuidle_text_end, causing cpu_in_idle() to return false.
[Severity: Medium]
Should is_pkvm_initialized() and gic_read_pmr() also be marked __always_inline (or notrace)?
is_hyp_mode_available() calls is_pkvm_initialized() unconditionally when invoked from noinstr kvm_patch_ich_vtr_el2(), and __cpuidle cpu_do_idle() calls gic_read_pmr() via arm_cpuidle_save_irq_context() while RCU is not watching when CONFIG_ARM64_PSEUDO_NMI=y:
arch/arm64/include/asm/arch_gicv3.h:
static inline u32 gic_read_pmr(void)
{
return read_sysreg_s(SYS_ICC_PMR_EL1);
}static __always_inline void gic_write_pmr(u32 val)
Once commit "compiler_types: Move notrace from inline to __always_inline" removes notrace from plain inline, Clang emits an out-of-line traceable copy of gic_read_pmr() from __cpuidle cpu_do_idle() (and of is_pkvm_initialized() if is_hyp_mode_available() is inlined into kvm_patch_ich_vtr_el2()), allowing ftrace to trace them while RCU is not watching.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=18
[email protected]
AI reviewRe: [PATCH v3 06/22] u64_stats: Mark the update helpers used by BPF notrace
In reply to Song LiuTL;DR: The seqcount helpers called by the u64_stats helpers (32-bit/PREEMPT_RT) aren't marked notrace, so once plain inline stops implying notrace, an fentry program may possibly recurse from BPF…
Quoted 1 line
u64_stats: Mark the update helpers used by BPF notrace
TL;DR: The seqcount helpers called by the u64_stats helpers (32-bit/PREEMPT_RT) aren't marked notrace, so once plain inline stops implying notrace, an fentry program may possibly recurse from BPF stats updates.
Quoted 3 lines
include/linux/u64_stats_sync.h +0
-0
[ ... ]
Quoted 7 lines
include/linux/u64_stats_sync.h +1
-1@@ -166,19 +166,19 @@ static inline void u64_stats_inc(u64_stats_t *p)seqcount_init (&__s->seq); \ }while (0 ) -static inline void __u64_stats_update_begin(struct u64_stats_sync *syncp) +static inline void notrace __u64_stats_update_begin(struct u64_stats_sync *syncp) {
include/linux/u64_stats_sync.h static inline void u64_stats_inc(u64_stats_t *p) · line 179
Quoted 10 lines
include/linux/u64_stats_sync.h +1
-1preempt_disable_nested ();write_seqcount_begin (&syncp->seq); } -static inline void __u64_stats_update_end (struct u64_stats_sync *syncp) +static inline void notrace __u64_stats_update_end(struct u64_stats_sync *syncp) {write_seqcount_end (&syncp->seq);preempt_enable_nested (); }
On 32-bit and PREEMPT_RT, these helpers call write_seqcount_begin() and write_seqcount_end(), which expand to do_write_seqcount_begin() and do_write_seqcount_end() in include/linux/seqlock.h, and then to the do_raw_write_seqcount_*() helpers.
Those are plain static inline without notrace. Once the last patch in this series removes notrace from plain inline, can an out-of-line copy of them be traced?
If so, could an fentry program attached there and run from bpf_prog_inc_misses_counter() or __update_prog_stats() recurse, which is what this patch is meant to prevent?
Should the seqcount helpers be marked notrace as well, or is the commit message claim that the helpers they call are covered too broad?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
[email protected]
AI reviewRe: [PATCH v3 03/22] bpf: Mark bpf_spin_lock helpers notrace
In reply to Song LiuTL;DR: Commit message only: the claim that nothing called by bpf_spin_lock()/unlock() is traceable looks inaccurate, since out-of-line callees like queued_spin_release_traced() and the qspinlock…
Quoted 1 line
bpf: Mark
bpf_spin_lockhelpers notrace
TL;DR: Commit message only: the claim that nothing called by bpf_spin_lock()/unlock() is traceable looks inaccurate, since out-of-line callees like queued_spin_release_traced() and the qspinlock slowpath remain traceable; narrow it or cover them.
Quoted 11 lines
bpf: Mark
bpf_spin_lockhelpers notrace[ ... ]
__bpf_spin_unlock_irqrestore(),__bpf_spin_unlock()
andqueued_spin_unlock()run with the lock held, so an fentry program attached to an out-of-line copy of one of them can hit the same deadlock. These copies are untraced today only because inline implies notrace.
Mark all of these helpers notrace explicitly, so that nothing called bybpf_spin_lock()andbpf_spin_unlock()is traceable. No functional change.
Quoted 2 lines
[ ... ]Signed-off-by Song Liu <[email protected]>
Is the claim that "nothing called by bpf_spin_lock() and bpf_spin_unlock() is traceable" accurate?
The patch only covers the inline helpers, and btf_id_deny in kernel/bpf/verifier.c has no lock entries. Some out-of-line callees remain traceable.
With CONFIG_QUEUED_SPINLOCKS_TRACE_CONTENDED_RELEASE and no x86 PARAVIRT_SPINLOCKS, the generic queued_spin_unlock() calls the extern queued_spin_release_traced():
kernel/locking/qspinlock.c:queued_spin_release_traced()
It runs with the lock still held, which is the same deadlock the message describes, and it is not marked notrace (qspinlock.o is not built without -pg).
queued_spin_lock_slowpath() / native_queued_spin_lock_slowpath() in qspinlock.c is also a traceable out-of-line function called from the bpf_spin_lock() path.
The x86 "static inline queued_spin_lock_slowpath" wrapper and native_queued_spin_unlock() in paravirt-spinlock.h are plain inline and are not marked. The end of this series (a833438864c3) removes notrace from inline, so an out-of-line copy of that wrapper in helpers.c would then become traceable.
Could the sentence be narrowed, or should these callees be covered as well?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
[email protected]
AI reviewRe: [PATCH v3 10/22] powerpc, csky, mips, sh: Mark the accessors behind current notrace
In reply to Song LiuTL;DR: Microblaze's current_thread_info() is not marked notrace; once inline stops implying notrace, ftrace may possibly recurse without bound before the recursion bit is set. Should it get the same…
Quoted 1 line
powerpc, csky, mips, sh: Mark the accessors behind current notrace
TL;DR: Microblaze's current_thread_info() is not marked notrace; once inline stops implying notrace, ftrace may possibly recurse without bound before the recursion bit is set. Should it get the same annotation?
arch/csky/include/asm/thread_info.h struct thread_info { · line 48
Quoted 12 lines
arch/csky/include/asm/thread_info.h +1
-1@@ -42,7 +42,7 @@ struct thread_info {#define thread_saved_lr (tsk) \ ((unsigned long)(((struct switch_stack *)(tsk->thread.sp))->r15)) -static inline struct thread_info *current_thread_info (void ) +static inline notrace struct thread_info *current_thread_info(void) {unsigned long sp;
[ ... ]
Microblaze also selects HAVE_FUNCTION_TRACER and does not select THREAD_INFO_IN_TASK, and its current_thread_info() is still a plain inline:
arch/microblaze/include/asm/thread_info.h:
static inline struct thread_info *current_thread_info(void)
{
register unsigned long sp asm("r1");
return (struct thread_info *)(sp & ~(THREAD_SIZE-1));
}On microblaze, current is the r31 register variable, so this helper is not behind current. It is behind preempt_count() though, because microblaze uses the generic include/asm-generic/preempt.h:
static __always_inline int preempt_count(void)
{
return READ_ONCE(current_thread_info()->preempt_count);
}The recursion protection reaches it before the recursion bit is set:
function_trace_call()
ftrace_test_recursion_trylock()
trace_test_and_set_recursion()
trace_get_context_bit()
interrupt_context_level()
preempt_count()
current_thread_info()
preempt_disable_notrace() at the end of trace_test_and_set_recursion() also reaches it through preempt_count_ptr().
Right now the helper is still notrace because inline implies notrace. Once a833438864c3 ("compiler_types: Move notrace from inline to __always_inline") removes that, can an out-of-line copy of microblaze's current_thread_info() get an mcount call, so that tracing it re-enters the callback before the recursion bit is set and recurses without bound?
This is the same condition the patch handles on csky, mips and sh, where current_thread_info() is behind both current and the generic preempt_count(). The arm64 patch 4a65f9d5e118 says the generic preempt count helpers are __always_inline, but they depend on the arch's current_thread_info().
No commit in this series touches arch/microblaze. m68k, nios2 and arc keep a plain inline current_thread_info() but do not select HAVE_FUNCTION_TRACER.
Should arch/microblaze/include/asm/thread_info.h get the same notrace annotation, here or in the preempt count patch?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
[email protected]
AI reviewRe: [PATCH v3 20/22] powerpc: Mark helpers called from noinstr code notrace
In reply to Song LiuTL;DR: - wrtee() and mtmsr_isync() may be left traceable out of line in noinstr paths; unverified in a build - commit message has wrong riscv irqflags and soft_nmi_interrupt() claims
Quoted 1 line
powerpc: Mark helpers called from noinstr code notrace
TL;DR:
- wrtee() and mtmsr_isync() may be left traceable out of line in noinstr paths; unverified in a build
- commit message has wrong riscv irqflags and soft_nmi_interrupt() claims
Quoted 16 lines
powerpc: Mark helpers called from noinstr code notrace
Much of the powerpc code that must not be traced uses plain inline helpers from headers: the atomic, bitops and barrier helpers, the irqflags and hard irq helpers in <
asm/hw_irq.h>, the interrupt entry and exit helpers in <asm/entry-common.h>, and the MMIO accessors. noinstr code calls them at points where tracing is not safe, for example:
[ ... ]
-soft_nmi_interrupt()callswd_smp_lock().
With clang, appc64le_defconfigbuild has out-of-line copies of many of these helpers, called from the functions above. The copies are untraced only because inline implies notrace.
Mark them notrace explicitly, like the irq_soft_mask_*() helpers in <asm/hw_irq.h> already are. On x86, arm64 and riscv, the atomic, bitops and irqflags helpers are__always_inline. No functional change.
Quoted 2 lines
Assisted-by Claude:claude-opus-5Signed-off-by Song Liu <[email protected]>
The commit message says that on riscv the irqflags helpers are __always_inline. Is that accurate?
In arch/riscv/include/asm/irqflags.h they are plain inline:
static inline unsigned long arch_local_save_flags(void) static inline void arch_local_irq_enable(void) static inline void arch_local_irq_disable(void)
The riscv patch later in this series, 0c13f314b0bd ("riscv: Mark helpers called from noinstr code notrace"), says "On riscv, the arch_local_irq_*() helpers behind these are plain inline functions. On x86 and arm64 they are __always_inline." That patch adds notrace and leaves them plain inline, so the sentence stays wrong after the series. The riscv atomic and bitops helpers are __always_inline, so only the irqflags part is off.
Could the sentence name only x86 and arm64 for the irqflags helpers?
The commit message also gives soft_nmi_interrupt() calling wd_smp_lock() as an example of noinstr code calling a helper where tracing is not safe. Is that accurate?
powerpc interrupt handlers are deliberately not noinstr; interrupt.h says "Don't use noinstr here like x86, but rather add NOKPROBE_SYMBOL". soft_nmi_interrupt() is entered with IVEC=0x900 in virtual mode, so DEFINE_INTERRUPT_HANDLER_NMI calls irqentry_nmi_enter() before the body runs and RCU is watching when wd_smp_lock() is called. In addition, nmi_disables_ftrace() has:
/* Allow DEC and PMI to be traced when they are soft-NMI */
and returns false for INTERRUPT_DECREMENTER on BOOK3S_64, so ftrace is left enabled on purpose. The same handler body also calls wd_try_report(), set_cpu_stuck() and pr_emerg(), which are all traceable.
Marking wd_smp_lock() and wd_smp_unlock() notrace looks harmless, but could this example be dropped or reworded to give the real reason?
Quoted 3 lines
arch/powerpc/include/asm/hw_irq.h +0
-0
[ ... ]
arch/powerpc/include/asm/hw_irq.h static __always_inline bool should_hard_irq_enable(struct pt_regs *regs) · line 496
Quoted 5 lines
arch/powerpc/include/asm/hw_irq.h +1
-1-static inline unsigned long mtmsr_isync_irqsafe (unsigned long msr) +static inline notrace unsigned long mtmsr_isync_irqsafe (unsigned long msr) {#ifdef CONFIG_PPC64 if (arch_irqs_disabled ()) {
mtmsr_isync_irqsafe() and the BookE irqflags helpers call two leaf helpers from arch/powerpc/include/asm/reg.h that stay plain inline and are not marked anywhere in the series:
static inline void mtmsr_isync(unsigned long val) static inline void wrtee(unsigned long val)
On Book3S-64 mtmsr_isync() is reached from code that is notrace on purpose:
arch_exit_to_user_mode_prepare() (notrace)
-> restore_math() (notrace)
-> msr_check_and_set() (notrace)
-> mtmsr_isync_irqsafe() -> mtmsr_isync()On 32-bit BookE, ct_idle_exit() (noinstr) calls raw_local_irq_save() and raw_local_irq_restore(), which reach arch_local_irq_save() -> wrtee(0) and arch_local_irq_restore() -> wrtee(flags) before RCU is watching.
Once a833438864c3 ("compiler_types: Move notrace from inline to __always_inline") is applied, an out-of-line copy of either function would get an ftrace call site. Should wrtee() and mtmsr_isync() (and possibly msr_check_and_clear(), which restore_math() also calls) be marked notrace here? This was not seen in a build.
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
[email protected]
AI reviewRe: [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline
In reply to Song LiuTL;DR: - notrace in compiler_attributes.h may break the powerpc boot wrapper build (unverified) - dropping notrace from inline may allow ftrace recursion on microblaze, x86-32 and other…
Quoted 1 line
compiler_types: Move notrace from inline to__always_inline
TL;DR:
- notrace in compiler_attributes.h may break the powerpc boot wrapper build (unverified)
- dropping notrace from inline may allow ftrace recursion on microblaze, x86-32 and other architectures (unlikely)
Quoted 3 lines
include/linux/compiler_attributes.h +0
-0
[ ... ]
include/linux/compiler_attributes.h line 59
Quoted 2 lines
include/linux/compiler_attributes.h +1
-1-#define __always_inline inline __attribute__((__always_inline__)) +#define __always_inline inline __attribute__((__always_inline__)) notrace
Is notrace defined everywhere compiler_attributes.h is used?
notrace is defined in compiler_types.h, and its definition depends on CC_USING_HOTPATCH / CC_USING_PATCHABLE_FUNCTION_ENTRY. The powerpc boot wrapper only gets compiler_attributes.h:
arch/powerpc/boot/Makefile:
BOOTCFLAGS += -include $(srctree)/include/linux/compiler_attributes.h
and deliberately does not -include compiler_types.h (see commit 77433830ed16 ("powerpc: boot: include compiler_attributes.h")).
With CONFIG_KERNEL_XZ=y, arch/powerpc/boot/decompress.c includes lib/decompress_unxz.c, which pulls in lib/xz/xz_dec_lzma2.c:
static __always_inline void rc_normalize(struct rc_dec *rc)
This now preprocesses to:
static inline __attribute__((__always_inline__)) notrace void rc_normalize(...)
Nothing under arch/powerpc/boot/, lib/xz/ or lib/decompress_unxz.c defines notrace, so should decompress.o fail to compile? skiroot_defconfig sets CONFIG_KERNEL_XZ=y. I could not compile this to confirm.
The comment at the top of compiler_attributes.h also says that attributes which depend on a configuration option or on other attributes should be defined elsewhere, e.g. compiler_types.h.
Would it work to leave this definition alone and add notrace to __always_inline in compiler_types.h after notrace is defined? Alternatively, the powerpc boot wrapper could get its own empty notrace definition.
Quoted 3 lines
include/linux/compiler_types.h +0
-0
[ ... ]
include/linux/compiler_types.h struct ftrace_likely_data { · line 234
Quoted 2 lines
include/linux/compiler_types.h +1
-1-#define inline inline __gnu_inline __inline_maybe_unused notrace +#define inline inline __gnu_inline __inline_maybe_unused
Can the removal of notrace here cause recursion on microblaze?
ftrace_test_recursion_trylock() also reads preempt_count():
ftrace_test_recursion_trylock()
trace_test_and_set_recursion()
trace_get_context_bit()
interrupt_context_level()
preempt_count()
On microblaze, preempt_count() reads current_thread_info()->preempt_count, and current_thread_info() is still a plain inline:
arch/microblaze/include/asm/thread_info.h:
static inline struct thread_info *current_thread_info(void)
fs/pstore/ftrace.c is built with CC_FLAGS_FTRACE, and pstore_ftrace_call() calls ftrace_test_recursion_trylock() on an ops without FTRACE_OPS_FL_RECURSION. If the compiler emits an out-of-line copy of current_thread_info() in that object, the copy now has an mcount call:
mcount -> pstore_ftrace_call() -> ftrace_test_recursion_trylock()
-> current_thread_info() -> mcount
and the recursion is unbounded because protection is not yet held.
The neighbouring microblaze irqflags helpers are already 'static inline notrace'. The trigger needs the compiler to keep a one-instruction helper out of line, which is unlikely, but the series applied the same standard to the equivalent helpers on csky, mips and sh. Should current_thread_info() on microblaze be marked notrace too?
Similarly, the riscv patch in this series marks the arch_local_irq_*() helpers notrace because ct_idle_exit() and cpu_idle_poll() call raw_local_irq_save()/raw_local_irq_restore()/raw_local_irq_enable() while RCU is not watching. Both are generic code in traced files (kernel/context_tracking.c and kernel/sched/idle.c).
Several other architectures that select HAVE_FUNCTION_TRACER still define these helpers as plain inline, so their out-of-line copies become traceable:
arch/arm/include/asm/irqflags.h: arch_local_irq_save/enable/disable arch/loongarch/include/asm/irqflags.h arch/mips/include/asm/irqflags.h arch/csky/include/asm/irqflags.h arch/parisc/include/asm/irqflags.h arch/xtensa/include/asm/irqflags.h
For example:
arch/loongarch/include/asm/irqflags.h:
static inline void arch_local_irq_enable(void)
s390 noinstr entry code has a similar gap: __do_pgm_check() calls the plain-inline set_pt_regs_flag() before irqentry_enter().
The commit message says the previous patches mark notrace "the inline helpers that relied on inline implying notrace", but the noinstr audit covered only arm64, powerpc and riscv. Only x86_64 has objtool noinstr validation.
Were arm, loongarch, mips, csky, parisc, xtensa and s390 checked, for example with a clang build as was done for arm64 and riscv? If not, should their irqflags helpers get the same notrace treatment?
A subsystem pattern also flags the following as potentially concerning. On x86-32, HAVE_DYNAMIC_FTRACE_WITH_ARGS is only selected for X86_64, so ftrace_get_regs() ends up calling the generic plain-inline helper:
include/linux/ftrace.h:
static inline struct pt_regs *arch_ftrace_get_regs(struct ftrace_regs *fregs)
{
return &arch_ftrace_regs(fregs)->regs;
}The x86 kprobe_ftrace_handler() calls it before taking recursion protection:
arch/x86/kernel/kprobes/ftrace.c:kprobe_ftrace_handler() {
struct pt_regs *regs = ftrace_get_regs(fregs);
...
bit = ftrace_test_recursion_trylock(ip, parent_ip);arch/x86/kernel/kprobes/ftrace.o is built with ftrace flags, and kprobe_ftrace_ops and kprobe_ipmodify_ops set only FTRACE_OPS_FL_SAVE_REGS (and IPMODIFY), not FTRACE_OPS_FL_RECURSION. Once inline no longer implies notrace, an out-of-line copy of arch_ftrace_get_regs() in that object is a traceable function called from an ftrace callback before recursion protection.
The helper is a single address computation and is almost certainly inlined, and recursion would also need a kprobe placed on the out-of-line copy itself, so this seems very unlikely in practice. Would making the generic arch_ftrace_get_regs() __always_inline, as the arch-specific versions already are, remove the question?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
[email protected]
AI reviewRe: [PATCH v3 04/22] bpf: Mark the BPF trampoline helpers notrace
In reply to Song LiuTL;DR: - Possible unbounded BPF trampoline recursion if powerpc local_add helpers stay unmarked notrace - Same possible recursion on arm64 via unmarked __percpu_add_case_64() used by percpu_ref…
Quoted 1 line
bpf: Mark the BPF trampoline helpers notrace
TL;DR:
- Possible unbounded BPF trampoline recursion if powerpc local_add helpers stay unmarked notrace
- Same possible recursion on arm64 via unmarked __percpu_add_case_64() used by percpu_ref helpers
arch/x86/include/asm/local.h typedef struct { · line 19
Quoted 9 lines
arch/x86/include/asm/local.h +1
-1@@ -16,7 +16,7 @@ typedef struct {#define local_read (l) atomic_long_read(&(l)->a)#define local_set (l, i) atomic_long_set(&(l)->a, (i)) -static inline void local_inc (local_t *l) +static inline void notrace local_inc(local_t *l)
The commit message says local_inc() and local_add() are marked "on x86", because u64_stats_inc() and u64_stats_add() reach them from bpf_prog_inc_misses_counter() and __update_prog_stats().
Should the powerpc equivalents be covered as well? powerpc64 also supports BPF trampolines and has its own plain __inline__ helpers in arch/powerpc/include/asm/local.h:
#define LOCAL_OP_RETURN(op, c_op) \
static __inline__ long local_##op##_return(long a, local_t *l) \
...
#define local_inc_return(l) local_add_return(1LL, l)
#define local_inc(l) local_inc_return(l)
On 64-bit, local64_inc() and local64_add() map to local_inc() and local_add() (include/asm-generic/local64.h), so:
__bpf_prog_enter_recur()
bpf_prog_inc_misses_counter()
u64_stats_inc()
local64_inc()
local_add_return()__bpf_prog_exit*()
__update_prog_stats()
u64_stats_inc()/u64_stats_add()
local_add_return()/local_add()Nothing in this series touches arch/powerpc/include/asm/local.h, and a later commit in the series (compiler_types: Move notrace from inline to __always_inline) removes the implied notrace from plain inline. If an out-of-line local_add_return() gets a patchable entry, attaching to it would make __bpf_prog_enter_recur() reject the program and call bpf_prog_inc_misses_counter(), which re-enters the trampoline, without bound.
loongarch looks similar one level down: local_inc()/local_add() are macros for atomic_long_inc()/atomic_long_add(), ending in arch_atomic64_add(), a plain static inline in arch/loongarch/include/asm/atomic-amo.h.
Should the powerpc local_add()/local_add_return() helpers be marked notrace together with the x86 ones?
[ ... ]
Quoted 3 lines
include/linux/percpu-refcount.h +0
-0
[ ... ]
include/linux/percpu-refcount.h static inline bool __ref_is_percpu(struct percpu_ref *ref, · line 201
Quoted 9 lines
include/linux/percpu-refcount.h +1
-1@@ -195,7 +195,7 @@ static inline bool __ref_is_percpu(struct percpu_ref *ref,* * This function is safe to call as long as @ref is between init and exit. */ -static inline void percpu_ref_get_many (struct percpu_ref *ref,unsigned long nr) +static inline void notrace percpu_ref_get_many(struct percpu_ref *ref, unsigned long nr) {unsigned long __percpu *percpu_count;
This marks percpu_ref_get_many() and percpu_ref_put_many() notrace because __bpf_tramp_enter() and __bpf_tramp_exit() call them. On arm64, though, the per-CPU op they use is still a plain inline helper that nothing in the series marks:
this_cpu_add()
this_cpu_add_8()
__percpu_add_case_64()
and this_cpu_sub() is this_cpu_add() with a negated value. In arch/arm64/include/asm/percpu.h the helper is generated as:
#define __PERCPU_OP_CASE(w, sfx, name, sz, op_llsc, op_lse) \ static inline void \ __percpu_##name##_case_##sz(void __percpu *pcp, unsigned long val) \
The arm64 trampoline calls __bpf_tramp_enter() before the fentry programs when BPF_TRAMP_F_CALL_ORIG is set, so:
arm64 trampoline
__bpf_tramp_enter()
percpu_ref_get()
percpu_ref_get_many()
this_cpu_add()
__percpu_add_case_64()and likewise __bpf_tramp_exit() -> percpu_ref_put_many() -> this_cpu_sub().
The only later commit in the series touching arch/arm64/include/asm/percpu.h is "arm64: Mark helpers called from noinstr code notrace", which marks only __kern_my_cpu_offset(). Its changelog says clang emits an out-of-line copy of that helper in an arm64 defconfig build, and __percpu_add_case_64() has a longer ALTERNATIVE asm body, so an out-of-line copy seems at least as plausible.
Once "compiler_types: Move notrace from inline to __always_inline" lands, such a copy gets a patchable entry. An fexit or fmod_ret program attached to it would recurse:
trampoline -> __bpf_tramp_enter() -> __percpu_add_case_64() -> trampoline -> __bpf_tramp_enter() -> ...
This happens before any __bpf_prog_enter*() recursion check runs. On x86 this_cpu_add() is an asm macro, so this is specific to arm64.
Should the arm64 __percpu_*_case_*() helpers, or at least the add case used here, be marked notrace as part of this commit?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46577721107
[email protected]
AI reviewRe: [PATCH v3 22/22] compiler_types: Move notrace from inline to __always_inline
In reply to Song LiuThank you for your contribution! Sashiko AI review found 5 potential issues to consider: - [High] compiler_attributes: undefined notrace in __always_inline breaks powerpc build - [Medium]…
Thank you for your contribution! Sashiko AI review found 5 potential issues to consider:
- [High] compiler_attributes: undefined notrace in __always_inline breaks powerpc build
- [Medium] microblaze: missing notrace on current_thread_info() after inline change
- [Medium] compiler_types: missing notrace on powerpc/loongarch local_t and seqlock helpers
- [Medium] srcu: tiny SRCU helpers called by notrace paths lack notrace after inline change
- [Medium] context_tracking: missing notrace on !CONFIG_CONTEXT_TRACKING_USER stubs
--
commit 5cd366f4e5c4bf3ecfbc5c1521c4971b8756f081
Author: Song Liu <[email protected]>
compiler_types: Move notrace from inline to __always_inline
This commit removes notrace from the inline macro in include/linux/compiler_types.h and adds it to __always_inline in include/linux/compiler_attributes.h so that out-of-line copies of plain inline functions can be traced and livepatched.
Quoted 7 lines
include/linux/compiler_attributes.h +0
-0@@ -49,10 +49,14 @@* to its docs (and also "warning: always_inline function might not be * inlinable [-Wattributes]" is emitted).
include/linux/compiler_attributes.h line 59
Quoted 10 lines
include/linux/compiler_attributes.h +5
-1* +* The compiler still emits an out-of-line copy of an __always_inline function +* when its address is taken or when it has external linkage. These functions +* are often used by code that must not be traced, so mark them notrace. +* * gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-always_005finline-function-attribute * clang: mentioned */ -#define __always_inline inline __attribute__((__always_inline__)) +#define __always_inline inline __attribute__((__always_inline__)) notrace
[Severity: High]
Does adding notrace to __always_inline in compiler_attributes.h break translation units that include compiler_attributes.h without compiler_types.h?
notrace is only defined in include/linux/compiler_types.h under __KERNEL__. In arch/powerpc/boot/Makefile, the pre-boot wrapper is built with -include include/linux/compiler_attributes.h and without compiler_types.h or -D__KERNEL__. When CONFIG_KERNEL_XZ=y, arch/powerpc/boot/decompress.c includes lib/decompress_unxz.c and lib/xz/xz_dec_lzma2.c, where static __always_inline helpers such as rc_normalize() expand with an undeclared notrace token and fail to compile.
include/linux/compiler_types.h struct ftrace_likely_data { · line 234
Quoted 12 lines
include/linux/compiler_types.h +1
-2@@ -230,9 +230,8 @@ struct ftrace_likely_data {* externally visible function. This makes extern inline behave as per gnu89 * semantics rather than c99. This prevents multiple symbol definition errors * of extern inline functions at link time. -* A lot of inline functions can cause havoc with function tracing. */ -#define inline inline __gnu_inline __inline_maybe_unused notrace +#define inline inline __gnu_inline __inline_maybe_unused
[Severity: Medium]
Can removing notrace from inline cause infinite ftrace recursion via current_thread_info() on MicroBlaze?
MicroBlaze selects HAVE_FUNCTION_TRACER and uses generic preempt_count() and preempt_count_ptr() from include/asm-generic/preempt.h, which both call current_thread_info(). In include/linux/trace_recursion.h, trace_test_and_set_recursion() calls trace_get_context_bit() -> interrupt_context_level() -> preempt_count() before setting current->trace_recursion. Because current_thread_info() in arch/microblaze/include/asm/thread_info.h is a plain static inline function without notrace or __always_inline, any out-of-line copy emitted by the compiler will be instrumented by ftrace and recurse indefinitely.
[Severity: Medium]
Does dropping notrace from inline leave the PowerPC and LoongArch local_t helpers and the 32-bit seqlock helpers traceable from notrace BPF paths?
The notrace BPF trampoline helpers (__bpf_prog_enter_recur() -> bpf_prog_inc_misses_counter() and __bpf_prog_exit_recur() -> __update_prog_stats()) and bpf_mem_alloc helpers (unit_alloc(), unit_free(), unit_free_rcu()) call local_inc(), local_dec(), local_add(), local_inc_return() and __u64_stats_update_begin() / __u64_stats_update_end(). Both 64-bit PowerPC and LoongArch implement BPF trampolines, but local_add(), local_add_return() and local_sub_return() in arch/powerpc/include/asm/local.h, local_add_return() in arch/loongarch/include/asm/local.h, and arch_atomic64_add() / arch_atomic64_sub() in arch/loongarch/include/asm/atomic-amo.h remain plain static inline functions without notrace. On 32-bit builds, __u64_stats_update_begin() and __u64_stats_update_end() also call write_seqcount_begin() and write_seqcount_end(), whose underlying helpers in include/linux/seqlock.h (such as do_raw_write_seqcount_begin()) are plain static inline. If the compiler emits an out-of-line copy of any of these helpers, attaching a BPF fentry/fexit program to it can trigger infinite trampoline recursion or re-enter bpf_mem_alloc around c->active updates.
[Severity: Medium]
Should __srcu_read_lock(), __srcu_ptr_to_ctr() and __srcu_ctr_to_ptr() in include/linux/srcutiny.h also be marked notrace?
With CONFIG_TINY_SRCU=y, the notrace helpers __srcu_read_lock_fast(), __srcu_read_unlock_fast() and srcu_read_lock_notrace() call those three functions directly:
include/linux/srcutiny.h:__srcu_read_lock_fast() {
return __srcu_ctr_to_ptr(ssp, __srcu_read_lock(ssp));
}Because __srcu_read_lock(), __srcu_ptr_to_ctr() and __srcu_ctr_to_ptr() are still plain static inline without notrace, any out-of-line copy emitted by the compiler will be instrumented by ftrace when called from tracepoints or other notrace SRCU paths.
[Severity: Medium]
Can the !CONFIG_CONTEXT_TRACKING_USER stubs in include/linux/context_tracking.h be traced when inline loses notrace?
When CONFIG_CONTEXT_TRACKING_USER is disabled, user_enter_irqoff(), user_exit_irqoff(), exception_enter() and exception_exit() in include/linux/context_tracking.h are defined as plain static inline functions without __always_inline or notrace:
include/linux/context_tracking.h:
static inline void user_enter_irqoff(void) { } static inline void user_exit_irqoff(void) { }
static inline int exception_enter(void) { return 0; } static inline void exception_exit(enum ctx_state prev_ctx) { }
user_exit_irqoff() and user_enter_irqoff() are called from noinstr entry and exit paths (enter_from_user_mode() and exit_to_user_mode() in include/linux/irq-entry-common.h) and from notrace exit paths in arch/powerpc/kernel/interrupt.c, while exception_enter() and exception_exit() are called from preempt_schedule_notrace() in kernel/sched/core.c. If the compiler emits an out-of-line copy of these stubs, it will be instrumented by ftrace and cause noinstr violations or trace within non-traceable entry and preemption paths.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=22