Message ID | ed361403b8ee965f758fe491c47336dddcfb8fd5.1676358308.git.jpoimboe@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp2810998wrn; Mon, 13 Feb 2023 23:09:34 -0800 (PST) X-Google-Smtp-Source: AK7set8jvbZsl1gPs6OnvObULLBt8wU6lGLdi8ch746yKtalJ+6A4esu0fzfHalT6V+0cnv1ySWd X-Received: by 2002:a50:ab11:0:b0:4ac:bce7:370e with SMTP id s17-20020a50ab11000000b004acbce7370emr1652752edc.14.1676358574450; Mon, 13 Feb 2023 23:09:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676358574; cv=none; d=google.com; s=arc-20160816; b=m6VeHWxO74WUjpD5yAa7YziQ52FCWmX5mGLznjklzaIRyyi0lVZoPjZUHBw1nmWRcZ 1lduLWpk6Vt0R+0RN02ZDBqqczWsiGB9Kpe4SgBEyWtnm+nSBYBnx5RVwMCsK2+l90g0 BqiQe4i0VHl3c33lZm16Mpei8H++o082jPoNdQw9jfAHGCyxh1VVlbcfSabtsh+7qzof 4jvVdZ9YLXfqU00249eBiIdNOxBHci/Rz3PbWoPKTm2Ta1ANef3FN0Yt1JDBEDtKaZ9/ /MAb4BisF4KVXRYJiaCks0B8XdorEcnbs4m9ac3h8QhU7KSlUAIFFnzo/j4Pk5ayu8SL 9ocg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=D3r7w9XxTxKKbkBhy8vhwLCKbYuvJUf+WvZUWHs3GDY=; b=Hzs5/xML/CDw+3U9g/pfSobbVC2d+4xLtNBWprY3UhF4BL/X4ZMQ9EEwGNYjiLnRJG X5rLCicrfcALVMYsJw/DpngMaLXcfG5xlC6f+eY8zYV5Gf68lJubsPi+DWCCXiQA0UFS 4NifTa/eX0feKg5ac9OyrgLgfpomD6MTnJi2aIKUCKycZGUnNVkxV8Xeuhch98/9XGFJ v+W8XFIqKp7MYOzCOuWqrf+2QN08Agv/kBZ43jxz7vhnKFJPo9LuFYXhksK+6UZOVVqJ gUhfeA6BHkENXTyhg7mAL9bMY01UIR1Atj+itYCWSiblHIefeEI9PGnTkyFEfjxv6+T1 4mCw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pBWajwyC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r7-20020a056402018700b004aa9a77fea3si9820478edv.626.2023.02.13.23.09.10; Mon, 13 Feb 2023 23:09:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pBWajwyC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230259AbjBNHHp (ORCPT <rfc822;tebrre53rla2o@gmail.com> + 99 others); Tue, 14 Feb 2023 02:07:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbjBNHH0 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 14 Feb 2023 02:07:26 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7C3081F5E7; Mon, 13 Feb 2023 23:07:00 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 63043B81C03; Tue, 14 Feb 2023 07:06:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57FCAC433A1; Tue, 14 Feb 2023 07:06:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1676358414; bh=wu6LTRXru7nWyi2Ep9Lymkp1Vs6jli+8qnKXJEfRRlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pBWajwyC6eZHxl5YTbqnE/95CYn//yQCVENJWaDj5KhoUt1aag5nvaHja/0HdJ1mW X4MWumwa8fgVpZVuVCKQjcQ2ErPDfuq9EWIL1C6CsOcO4hXctxKlHJVwMXOUF+JTiF B+//nYfwgDdiV1oKlcXo9Hd0YLE8QOjNVv1BQhhcOsgmaTkK99tBhbNQ1crwms+Ua9 am/PeEUzKk2CCwsnSgTjTS3Ztlw5wa3G6w/fqp3eeOJYZuKeyUDi3bvvzbM718WHOi Uuem/JRBOqIzvtXYvVZXF1W4bCz75afEA61iOZpnVcnNwJStxDuuCWKI6Hr+grLu3E hXdS10io+JBzg== From: Josh Poimboeuf <jpoimboe@kernel.org> To: linux-kernel@vger.kernel.org Cc: jgross@suse.com, richard.henderson@linaro.org, ink@jurassic.park.msu.ru, mattst88@gmail.com, linux-alpha@vger.kernel.org, linux@armlinux.org.uk, linux-arm-kernel@lists.infradead.org, catalin.marinas@arm.com, will@kernel.org, guoren@kernel.org, linux-csky@vger.kernel.org, linux-ia64@vger.kernel.org, chenhuacai@kernel.org, kernel@xen0n.name, loongarch@lists.linux.dev, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, tsbogend@alpha.franken.de, linux-mips@vger.kernel.org, jiaxun.yang@flygoat.com, mpe@ellerman.id.au, npiggin@gmail.com, christophe.leroy@csgroup.eu, linuxppc-dev@lists.ozlabs.org, ysato@users.sourceforge.jp, dalias@libc.org, linux-sh@vger.kernel.org, davem@davemloft.net, sparclinux@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, dave.hansen@linux.intel.com, x86@kernel.org, hpa@zytor.com, chris@zankel.net, jcmvbkbc@gmail.com, linux-xtensa@linux-xtensa.org, peterz@infradead.org, juri.lelli@redhat.com, vincent.guittot@linaro.org, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, paulmck@kernel.org Subject: [PATCH v2 03/24] arm/cpu: Make sure arch_cpu_idle_dead() doesn't return Date: Mon, 13 Feb 2023 23:05:37 -0800 Message-Id: <ed361403b8ee965f758fe491c47336dddcfb8fd5.1676358308.git.jpoimboe@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <cover.1676358308.git.jpoimboe@kernel.org> References: <cover.1676358308.git.jpoimboe@kernel.org> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1757789368565838809?= X-GMAIL-MSGID: =?utf-8?q?1757789368565838809?= |
Series |
cpu,sched: Mark arch_cpu_idle_dead() __noreturn
|
|
Commit Message
Josh Poimboeuf
Feb. 14, 2023, 7:05 a.m. UTC
arch_cpu_idle_dead() doesn't return. Make that more explicit with a
BUG().
BUG() is preferable to unreachable() because BUG() is a more explicit
failure mode and avoids undefined behavior like falling off the edge of
the function into whatever code happens to be next.
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
---
arch/arm/kernel/smp.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On Mon, Feb 13, 2023 at 11:05:37PM -0800, Josh Poimboeuf wrote: > arch_cpu_idle_dead() doesn't return. Make that more explicit with a > BUG(). > > BUG() is preferable to unreachable() because BUG() is a more explicit > failure mode and avoids undefined behavior like falling off the edge of > the function into whatever code happens to be next. This is silly. Just mark the function __noreturn and be done with it. If the CPU ever executes code past the "b" instruction, it's already really broken that the extra instructions that BUG() gives will be meaningless. This patch does nothing except add yet more bloat the kernel. Sorry, but NAK.
On Tue, Feb 14, 2023 at 11:15:23AM +0000, Russell King (Oracle) wrote: > On Mon, Feb 13, 2023 at 11:05:37PM -0800, Josh Poimboeuf wrote: > > arch_cpu_idle_dead() doesn't return. Make that more explicit with a > > BUG(). > > > > BUG() is preferable to unreachable() because BUG() is a more explicit > > failure mode and avoids undefined behavior like falling off the edge of > > the function into whatever code happens to be next. > > This is silly. Just mark the function __noreturn and be done with it. > If the CPU ever executes code past the "b" instruction, it's already > really broken that the extra instructions that BUG() gives will be > meaningless. > > This patch does nothing except add yet more bloat the kernel. > > Sorry, but NAK. Problem is, the compiler can't read inline asm. So you'd get a "'noreturn' function does return" warning. We can do an unreachable() instead of a BUG() here if you prefer undefined behavior.
On Tue, Feb 14, 2023 at 10:39:26AM -0800, Josh Poimboeuf wrote: > On Tue, Feb 14, 2023 at 11:15:23AM +0000, Russell King (Oracle) wrote: > > On Mon, Feb 13, 2023 at 11:05:37PM -0800, Josh Poimboeuf wrote: > > > arch_cpu_idle_dead() doesn't return. Make that more explicit with a > > > BUG(). > > > > > > BUG() is preferable to unreachable() because BUG() is a more explicit > > > failure mode and avoids undefined behavior like falling off the edge of > > > the function into whatever code happens to be next. > > > > This is silly. Just mark the function __noreturn and be done with it. > > If the CPU ever executes code past the "b" instruction, it's already > > really broken that the extra instructions that BUG() gives will be > > meaningless. > > > > This patch does nothing except add yet more bloat the kernel. > > > > Sorry, but NAK. > > Problem is, the compiler can't read inline asm. So you'd get a > "'noreturn' function does return" warning. > > We can do an unreachable() instead of a BUG() here if you prefer > undefined behavior. That's fine.
diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c index 0b8c25763adc..adcd417c526b 100644 --- a/arch/arm/kernel/smp.c +++ b/arch/arm/kernel/smp.c @@ -382,6 +382,8 @@ void arch_cpu_idle_dead(void) : "r" (task_stack_page(current) + THREAD_SIZE - 8), "r" (current) : "r0"); + + BUG(); } #endif /* CONFIG_HOTPLUG_CPU */