From patchwork Mon Jun 20 22:20:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Paul E. McKenney" X-Patchwork-Id: 12888331 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 938A8C433EF for ; Mon, 20 Jun 2022 22:20:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343873AbiFTWUu (ORCPT ); Mon, 20 Jun 2022 18:20:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244759AbiFTWUn (ORCPT ); Mon, 20 Jun 2022 18:20:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DF7191BE82; Mon, 20 Jun 2022 15:20:37 -0700 (PDT) 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 2ABB7B8164E; Mon, 20 Jun 2022 22:20:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F8C3C341CF; Mon, 20 Jun 2022 22:20:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1655763634; bh=lyNCAIvYhX/+kHwlAad/y9gHMFmiZO/u932Jluyi4aA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AjIFk5YxhEODc2yYfvgjOXXFHf3Ik38rQd+LeQZ+Oek9uUtSZ38cy8J4RZ5+l8XFm VaGTwCO0bXakKzgxFSgEVtK9UY2il7+RWQB5d4UhfLFHZ2CpRVi2ae9cVhnm/gQNbF G5UKOuoFendHYd+tezPrBS6rqLpFqaoU6c3BWoiKv1sdt223xkCpQ2ukK7mY8z8HRq HPvGFZRgHmnCv3Vov0EbAtgGgrnE168NzYsNNwSbZgpVYDQypzNhn5ntHLf1DbaWcW pbOaB5ccgWHX/Mce4mAr+4kwdYKKRkZSymeKTQzMnIij7QUwx+cTX/X/h0vEZAC9Ji ugsXHrG/y59Tg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 078495C0B06; Mon, 20 Jun 2022 15:20:34 -0700 (PDT) From: "Paul E. McKenney" To: rcu@vger.kernel.org Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com, rostedt@goodmis.org, Chen Zhongjin , stable@vger.kernel.org, Chen jingwen , "Paul E . McKenney" Subject: [PATCH rcu 06/12] locking/csd_lock: Change csdlock_debug from early_param to __setup Date: Mon, 20 Jun 2022 15:20:26 -0700 Message-Id: <20220620222032.3839547-6-paulmck@kernel.org> X-Mailer: git-send-email 2.31.1.189.g2e36527f23 In-Reply-To: <20220620222022.GA3839466@paulmck-ThinkPad-P17-Gen-1> References: <20220620222022.GA3839466@paulmck-ThinkPad-P17-Gen-1> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: rcu@vger.kernel.org From: Chen Zhongjin The csdlock_debug kernel-boot parameter is parsed by the early_param() function csdlock_debug(). If set, csdlock_debug() invokes static_branch_enable() to enable csd_lock_wait feature, which triggers a panic on arm64 for kernels built with CONFIG_SPARSEMEM=y and CONFIG_SPARSEMEM_VMEMMAP=n. With CONFIG_SPARSEMEM_VMEMMAP=n, __nr_to_section is called in static_key_enable() and returns NULL, resulting in a NULL dereference because mem_section is initialized only later in sparse_init(). This is also a problem for powerpc because early_param() functions are invoked earlier than jump_label_init(), also resulting in static_key_enable() failures. These failures cause the warning "static key 'xxx' used before call to jump_label_init()". Thus, early_param is too early for csd_lock_wait to run static_branch_enable(), so changes it to __setup to fix these. Fixes: 8d0968cc6b8f ("locking/csd_lock: Add boot parameter for controlling CSD lock debugging") Cc: stable@vger.kernel.org Reported-by: Chen jingwen Signed-off-by: Chen Zhongjin Signed-off-by: Paul E. McKenney --- kernel/smp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/smp.c b/kernel/smp.c index dd215f4394264..650810a6f29b3 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -174,9 +174,9 @@ static int __init csdlock_debug(char *str) if (val) static_branch_enable(&csdlock_debug_enabled); - return 0; + return 1; } -early_param("csdlock_debug", csdlock_debug); +__setup("csdlock_debug=", csdlock_debug); static DEFINE_PER_CPU(call_single_data_t *, cur_csd); static DEFINE_PER_CPU(smp_call_func_t, cur_csd_func);