From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02B04CC6B2E for ; Thu, 15 Oct 2026 04:48:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Kx88kaP0umLRRbZLGvbpJa22c/puSOqz3f1tRZolr7g=; b=tuNdIpVjxPA5/J LAnU/chtNGbs2j23JHikKqAlyt6Jdd5UZzxHMtUHpumqTHFrkIymehG6K2K29gJeQdYAgTl17/81y UlXxDNlC7Mft6kyNqyGM+kJ0KF+u/px9VmCu4j8UNh/C4XCwoMlibkksPV4BdfYfjx3FGqDkrLfNw As4n5As5s+gK0WZ2Q+fp61oqm30zWadbVOh+pOV8DZNG4gvA+9KtNLcIWQOfMKpA+UUfYeqQaskgE 8M3DSnWbB3YoRqFXRRIpCHLpDgJR/875oJ4u2MZPiC+yVGYmaiFJ8gqOlGgSF1filT5i4IsG+ruuJ sat9EBp5LtIKiuwKKoiw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xHDO8-0000000Gp9z-2H0Z; Thu, 15 Oct 2026 04:48:20 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xHDO7-0000000Gp9Y-2GI9 for linux-riscv@lists.infradead.org; Thu, 15 Oct 2026 04:48:19 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 5F28E43E1F; Thu, 15 Oct 2026 04:48:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 466761F000C4; Thu, 15 Oct 2026 04:48:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792039698; bh=lPhFMlKbnevA2dxyWYfEBOkTsgsLNfvFF+EJg8wslHg=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=n8Jq3rp43rSd6COSaLNj2L3jMeE5/yEwtWaQdaJR+2q9UNsCYR+qfy8ys5eC1eNA4 lebFiJ+0mhZSg46bdDhgFMrlVPzvF7IKw+tbFtzCU0biUvEa8AyQ8KZvCNtu6AKnqY ghlJ7uL9kWgLqFlL7Z29MZLzvoiRz6NHINaWXBF+FndlvpKZWNRDqeO5VkN/LAOrjI S9DL1CVr5RzyUrqUzY/TOZ1AiHuIIvRM52n6gQFyGBmjFLROuEDT0gQrZK2ltR4xEr EbObgbS+FsBAbIeg0sScDFZmZ7fbBUMEEDcYQhUD97X9v+AnQc7UT5SqU8rXJeKpnz 37tYTUpO0PmlA== Date: Thu, 15 Oct 2026 12:28:15 +0800 From: Jisheng Zhang To: Karl Mehltretter Cc: Paul Walmsley , Palmer Dabbelt , Albert Ou , Alexandre Ghiti , Guo Ren , Andrey Konovalov , Alexander Potapenko , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] riscv: Always inline on_thread_stack() Message-ID: References: <20261012204211.3351-1-kmehltretter@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20261012204211.3351-1-kmehltretter@gmail.com> X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org On Mon, Oct 12, 2026 at 10:42:11PM +0200, Karl Mehltretter wrote: > With CONFIG_IRQ_STACKS=y, GCC may outline on_thread_stack(). > CONFIG_KCOV_INSTRUMENT_ALL instruments it, and do_irq() calls it before > irq_enter_rcu() increments the hardirq count. > > Normal KCOV records this interrupt coverage in the task's buffer, making > results timing-dependent. > > With CONFIG_KCOV_SELFTEST=y, current->kcov_area remains NULL. In QEMU, a > timer interrupt called the helper before hardirq accounting. KCOV treated > it as task coverage and dereferenced NULL. Fault handling recursed to stack > overflow and stopped boot. > > On a BeagleV Ahead, the unpatched kernel did not finish the selftest within > 120 seconds. Three patched boots completed it and reached init. > > Mark the helper __always_inline to keep it in noinstr do_irq(), following > commit 1894a4030582 ("x86: Always inline on_thread_stack() and > current_top_of_stack()"), which fixed the same out-of-line call from x86 > noinstr code. > > Fixes: 163e76cc6ef4 ("riscv: stack: Support HAVE_IRQ_EXIT_ON_IRQ_STACK") > Cc: stable@vger.kernel.org > Assisted-by: LLM > Signed-off-by: Karl Mehltretter Good catch! Reviewed-by: Jisheng Zhang > --- > Tested with GCC 15.2.0 and QEMU 10.2.1 on v7.3-rc7. Both images > used byte-identical configs and v7.3-rc7 rebases of these seven pending > patches (canonical commit IDs shown): > > 3a25097bf845 kcov: use unsigned int for kcov_start() mode parameter > e39a9c820c37 kcov: add kcov_pause()/kcov_resume() helpers > ae2662563c3e hrtimer: pause KCOV during deferred rearm > 554af946139e sched: pause KCOV in __schedule() > 7f608b777204 sched: pause KCOV in try_to_wake_up() > 2ba73ec2a246 sched: pause KCOV in wake_up_new_task() > 5ee777070fac context_tracking: exclude from KCOV instrumentation > > plain inline __always_inline > KCOV selftest started yes yes > KCOV selftest finished no yes > Reached /init no yes > > The plain-inline image stopped after printing "kcov: running self test" > and reached the 45-second limit. The patched image reached /init in two > 60-second runs. Those runs timed out after the marker because the test > /init deliberately loops. > > The first common patch is a type prerequisite. The remaining pause and > exclusion changes suppress separate KCOV callbacks that otherwise obscure > this test. CONFIG_RISCV_ISA_V_PREEMPTIVE was disabled to avoid a separate > vector-entry callback. The only A/B source difference was this patch. > > The same images were tested on a BeagleV Ahead (TH1520, four C910 CPUs). > The plain-inline image did not finish the selftest or reach /init during > 120 seconds after the start message. It reported RCU stalls, and CPU 1 > did not answer NMI requests. No panic or stack-overflow message was > printed. All three patched runs completed the selftest in about 0.301 > seconds and reached /init. > > arch/riscv/include/asm/stacktrace.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/riscv/include/asm/stacktrace.h b/arch/riscv/include/asm/stacktrace.h > index b1495a7e06ce..c7c991452e11 100644 > --- a/arch/riscv/include/asm/stacktrace.h > +++ b/arch/riscv/include/asm/stacktrace.h > @@ -16,7 +16,7 @@ extern void notrace walk_stackframe(struct task_struct *task, struct pt_regs *re > extern void dump_backtrace(struct pt_regs *regs, struct task_struct *task, > const char *loglvl); > > -static inline bool on_thread_stack(void) > +static __always_inline bool on_thread_stack(void) > { > return !(((unsigned long)(current->stack) ^ current_stack_pointer) & ~(THREAD_SIZE - 1)); > } > > base-commit: 24a19b953e2a3d0ea5a8c4951a0ab8f32720c907 > -- > 2.53.0 > > > _______________________________________________ > linux-riscv mailing list > linux-riscv@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-riscv _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv