Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp383933pxt; Wed, 4 Aug 2021 13:50:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgNVKzwNlHISB6y8aOii0GqXm1DTBGTne/8YsYaFV/ROtzZuAn74IXAuSIcI1g8+5vGj0b X-Received: by 2002:a92:b712:: with SMTP id k18mr9245ili.187.1628110236522; Wed, 04 Aug 2021 13:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628110236; cv=none; d=google.com; s=arc-20160816; b=BTfZVvs2cbQxN8Kmvb0aM+8vX+p2+qpZ+YDPgfI6uWYNOLkIiiRrVsIJEZEpVJSFE4 nHe9eyenliRBr5zDnqsqnu4s5OSb5xrG6+sYM0ZvoxviVt8wJiLYVDnFKkGNUHaNYLSL Q8V1LUR9+mZpwrKlV3GWYtANbFy+afhGG7YHNnEdHzHy/g3JkhZsNpdgJLL+hYvPXf+O +xx8iHkHpXPOs1Dtz0rdO36f4LeGLiXX0OIidQxCjHnbWzbtLxHGV70/Zj8Nz6bwltOn TWg373fENrtFtcurAsRMPppoYrU3aPyPpLPlvTREdh5syGa3buPgxcHwQardmpGXkP80 WC4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:cc:to:subject:from:message-id; bh=LI8YEy8YduOF4Rs6a+gOM8XFLg0zo2uup0434F6uZsQ=; b=XgHjVQSCgwEwjOc4yLlMiUihwmmeu3AYU8WVXZxbWo+SX0lk5WX1mxnQyq6hbYaexg 4tpxhNMIzmyirt3s+9yPQjRsapsInQf/fe12HIm0eu2xzJ7xoQzJPaNUEnl/xwNdrmgl UBz+ldD6GsBc1lpMeY7ObfqbJ3xGhVe6TLMccnSePXJLfS/nmHlDMPG8eSGbvE5LedE6 8AhXNp3K0Isr3gKtyKDy4WDF+1wn5urCLYElSSjsxq7miH6+bKSPiBDplXSSZIz1gRia PSLjsKCekxvm9aU+pA+dGQuBjx+emIehK9gvY8JeU2XXWRfOjOgoFXW+TSKHWJG1JpTg Cimw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si3464532ilq.105.2021.08.04.13.50.24; Wed, 04 Aug 2021 13:50:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240167AbhHDSY1 (ORCPT + 99 others); Wed, 4 Aug 2021 14:24:27 -0400 Received: from pegase2.c-s.fr ([93.17.235.10]:58035 "EHLO pegase2.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235223AbhHDSY0 (ORCPT ); Wed, 4 Aug 2021 14:24:26 -0400 Received: from localhost (mailhub3.si.c-s.fr [172.26.127.67]) by localhost (Postfix) with ESMTP id 4Gg0WH6QzDz9sWW; Wed, 4 Aug 2021 20:24:11 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase2.c-s.fr ([172.26.127.65]) by localhost (pegase2.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0L_DWaTW1BYS; Wed, 4 Aug 2021 20:24:11 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase2.c-s.fr (Postfix) with ESMTP id 4Gg0WH5NCTz9sWL; Wed, 4 Aug 2021 20:24:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9108D8B7AE; Wed, 4 Aug 2021 20:24:11 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id HDyRtP5JMZTt; Wed, 4 Aug 2021 20:24:11 +0200 (CEST) Received: from po9473vm.idsi0.si.c-s.fr (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 52B188B7A1; Wed, 4 Aug 2021 20:24:11 +0200 (CEST) Received: by po9473vm.idsi0.si.c-s.fr (Postfix, from userid 0) id 0620766190; Wed, 4 Aug 2021 18:24:10 +0000 (UTC) Message-Id: <75287841cbb8740edd44880fe60be66d489160d9.1628097995.git.christophe.leroy@csgroup.eu> From: Christophe Leroy Subject: [PATCH] powerpc/smp: Fix OOPS in topology_init() To: Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org Date: Wed, 4 Aug 2021 18:24:10 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Running an SMP kernel on an UP platform not prepared for it, I encountered the following OOPS: BUG: Kernel NULL pointer dereference on read at 0x00000034 Faulting instruction address: 0xc0a04110 Oops: Kernel access of bad area, sig: 11 [#1] BE PAGE_SIZE=4K SMP NR_CPUS=2 CMPCPRO Modules linked in: CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.13.0-pmac-00001-g230fedfaad21 #5234 NIP: c0a04110 LR: c0a040d8 CTR: c0a04084 REGS: e100dda0 TRAP: 0300 Not tainted (5.13.0-pmac-00001-g230fedfaad21) MSR: 00009032 CR: 84000284 XER: 00000000 DAR: 00000034 DSISR: 20000000 GPR00: c0006bd4 e100de60 c1033320 00000000 00000000 c0942274 00000000 00000000 GPR08: 00000000 00000000 00000001 00000063 00000007 00000000 c0006f30 00000000 GPR16: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000005 GPR24: c0c67d74 c0c67f1c c0c60000 c0c67d70 c0c0c558 1efdf000 c0c00020 00000000 NIP [c0a04110] topology_init+0x8c/0x138 LR [c0a040d8] topology_init+0x54/0x138 Call Trace: [e100de60] [80808080] 0x80808080 (unreliable) [e100de90] [c0006bd4] do_one_initcall+0x48/0x1bc [e100def0] [c0a0150c] kernel_init_freeable+0x1c8/0x278 [e100df20] [c0006f44] kernel_init+0x14/0x10c [e100df30] [c00190fc] ret_from_kernel_thread+0x14/0x1c Instruction dump: 7c692e70 7d290194 7c035040 7c7f1b78 5529103a 546706fe 5468103a 39400001 7c641b78 40800054 80c690b4 7fb9402e <81060034> 7fbeea14 2c080000 7fa3eb78 ---[ end trace b246ffbc6bbbb6fb ]--- Fix it by checking smp_ops before using it, as already done in several other places in the arch/powerpc/kernel/smp.c Fixes: 39f87561454d ("powerpc/smp: Move ppc_md.cpu_die() to smp_ops.cpu_offline_self()") Cc: stable@vger.kernel.org Signed-off-by: Christophe Leroy --- arch/powerpc/kernel/sysfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index 5ff0e55d0db1..defecb3b1b15 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c @@ -1167,7 +1167,7 @@ static int __init topology_init(void) * CPU. For instance, the boot cpu might never be valid * for hotplugging. */ - if (smp_ops->cpu_offline_self) + if (smp_ops && smp_ops->cpu_offline_self) c->hotpluggable = 1; #endif -- 2.25.0