From patchwork Thu Apr 21 03:39:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Zhongjin X-Patchwork-Id: 12821019 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 43E47C433EF for ; Thu, 21 Apr 2022 03:41:54 +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:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=jj6POT0kKILexfMtGKyKXYyKCRBJAr0FCvn5OZp/kig=; b=YVn2SSSiWcw4n3 8GwN3A0ZDUG+0D+qBrzrhpLsoYzWJYO9AE7lM8Rm7XGhEcfAljslV+uIcXKPZ9yxgTm/P9wQUi3QM b+psRvXpYgkjRFksbpn7vHo0KS+qOf77NjPn/ldImSWLStVGPEFOmtkyd2og+DLJVRXErSmLT2T9+ YH5uRdFHPbGLriWlhTFbh60E8zbZkSJ9oLauN7+651D41LjfYXfFuWT8wXD5CAa1ZLsdmV9I7rwnA eO7JEbKPiFRPND6v4YUS1JnwxcU0ruQtaPNY0qGH5kSnOFhw3DOB+Hb9EdO1Plqd0cfr32+jgSvZ5 WlBY5K0yxMKxLYNYQjUA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhNgJ-00BLKt-CT; Thu, 21 Apr 2022 03:40:35 +0000 Received: from szxga01-in.huawei.com ([45.249.212.187]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nhNgG-00BLJP-DJ for linux-arm-kernel@lists.infradead.org; Thu, 21 Apr 2022 03:40:33 +0000 Received: from dggpemm500021.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KkNbK5nXkzhY1t; Thu, 21 Apr 2022 11:40:13 +0800 (CST) Received: from dggpemm500013.china.huawei.com (7.185.36.172) by dggpemm500021.china.huawei.com (7.185.36.109) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 21 Apr 2022 11:40:20 +0800 Received: from ubuntu1804.huawei.com (10.67.175.36) by dggpemm500013.china.huawei.com (7.185.36.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Thu, 21 Apr 2022 11:40:20 +0800 From: Chen Zhongjin To: , CC: , , , , , Subject: [PATCH 5.10] fix csdlock_debug cause arm64 boot panic Date: Thu, 21 Apr 2022 11:39:14 +0800 Message-ID: <20220421033914.217622-1-chenzhongjin@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.67.175.36] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500013.china.huawei.com (7.185.36.172) X-CFilter-Loop: Reflected X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220420_204032_641501_AA0190AE X-CRM114-Status: GOOD ( 11.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org csdlock_debug is a early_param to enable csd_lock_wait feature. It uses static_branch_enable in early_param which triggers a panic on arm64 with config: CONFIG_SPARSEMEM=y CONFIG_SPARSEMEM_VMEMMAP=n The log shows: Unable to handle kernel NULL pointer dereference at virtual address ", '0' , " ... Call trace: __aarch64_insn_write+0x9c/0x18c ... static_key_enable+0x1c/0x30 csdlock_debug+0x4c/0x78 do_early_param+0x9c/0xcc parse_args+0x26c/0x3a8 parse_early_options+0x34/0x40 parse_early_param+0x80/0xa4 setup_arch+0x150/0x6c8 start_kernel+0x8c/0x720 ... Kernel panic - not syncing: Oops: Fatal exception Call trace inside __aarch64_insn_write: __nr_to_section __pfn_to_page phys_to_page patch_map __aarch64_insn_write Here, with CONFIG_SPARSEMEM_VMEMMAP=n, __nr_to_section returns NULL and makes the NULL dereference because mem_section is initialized in sparse_init after parse_early_param stage. So, static_branch_enable shouldn't be used inside early_param. To avoid this, I changed it to __setup and fixed this. Reported-by: Chen jingwen Signed-off-by: Chen Zhongjin --- kernel/smp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/smp.c b/kernel/smp.c index 65a630f62363..1ce64de460d0 100644 --- a/kernel/smp.c +++ b/kernel/smp.c @@ -176,7 +176,7 @@ static int __init csdlock_debug(char *str) return 0; } -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);