> riscv: Mark helpers called from noinstr code notrace
TL;DR: Possible incomplete fix: two plain inline helpers in
cpuidle-riscv-sbi.c, run while RCU isn't watching, may become traceable by
ftrace/BPF fentry once inline stops implying notrace.
> diff --git a/arch/riscv/include/asm/cpuidle.h
> b/arch/riscv/include/asm/cpuidle.h
> --- a/arch/riscv/include/asm/cpuidle.h
> +++ b/arch/riscv/include/asm/cpuidle.h
> @@ -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)
> {
The same cpuidle code has two more plain inline helpers that run while RCU
is not watching and are not covered. In drivers/cpuidle/cpuidle-riscv-sbi.c,
__sbi_enter_domain_idle_state() is __cpuidle and calls:
ct_cpuidle_enter();
if (sbi_is_domain_state_available())
state = sbi_get_domain_state();
else
state = states[idx];
ret = riscv_sbi_hart_suspend(state) ? -1 : idx;
ct_cpuidle_exit();
Both sbi_is_domain_state_available() and sbi_get_domain_state() are plain
"static inline", for example:
static inline u32 sbi_get_domain_state(void)
{
struct sbi_domain_state *data = this_cpu_ptr(&domain_state);
return data->state;
}
Their out-of-line copies are untraced only because inline implies notrace,
which is the situation the commit message describes for cpu_do_idle(). The
compiler can emit out-of-line copies here as well, since __cpuidle callers
carry __no_profile and __no_sanitize_* attributes (for example with clang or
KASAN).
Once 3c5bdbf65e31 ("compiler_types: Move notrace from inline to
__always_inline") removes notrace from inline, could those copies be traced
with ftrace or BPF fentry while RCU is not watching? That commit does not
touch cpuidle-riscv-sbi.c, and no later commit in the range seems to fix it.
Should these two helpers be marked notrace (or __always_inline) along with
cpu_do_idle()?
---
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/46748297297