Received: by 2002:a05:6520:1682:b0:147:d1a0:b502 with SMTP id ck2csp5596724lkb; Mon, 11 Oct 2021 09:39:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9z0IZ0kl94rbEVB52Wa8axgpQMRXuBto4QTDMGfTNdKyjavxh+QJ8UIXzgRM5l9WB//3Z X-Received: by 2002:a05:6a00:140c:b0:44b:e251:fe13 with SMTP id l12-20020a056a00140c00b0044be251fe13mr26987132pfu.10.1633970355486; Mon, 11 Oct 2021 09:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633970355; cv=none; d=google.com; s=arc-20160816; b=SbrimJUgieYoXAfcDLUyy80D/QERIg+6TikdjAFEupRgi4L/e4yT868346DP40pT9f ewSrfRVsDZ2NYW4I+FnJhnm7kUnGwE3jFHgrueyff2C+eH2eCD1FWEqJNdSKAhl4cLA0 nb1S/ich9xE0ipyEi5PUGV7MfC/SvlTlyjiWVQhSdTgdUNM83hlj8UCskdudtqU2X35A tgkAxUDzxOnQ7GPDf+OZSS/qa56waiz2JKgXUyE/56nN97DbH5lNa43yWlbQtJOj+UGB QYBKFv8ycWZ5dssVAvdEXssIKJMfs1p53oI5Fj1NCwxox89QaHhb1TgokbseUXqsR0gT 0Suw== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xPJB2ZFwnPQeuB8JYMXUbzTfQFKqxZN5zQ3GZF4EG4w=; b=OXxXnfvdsudvKYNyzph+j4Uxh2mcHwT75y/PCMHsxUPLKsj8ECD7RBHoslCJFjyI/j z7kMLAizbppO5tbIRyKd9GITX7DecpKGdlNb4v7etwPRGL7ANNYpcBBzbaToo8loQwGg +YhmC1kFW1054lJ/T3mcneHVusemGulCnb0aHhyy7H0hD+fAPGE9504YTGRSFslIQDGa BlgyR3srqGkqXP2kzlvrSN3JdDXd1zuZVaTkR+JMnNx1rBe9VJEawqSy9d0r4oNtTJMV C7JP+CwwWDtwPdDGbJ4EINKWbctS2FCvldAAkIsnaDfxT32yEQFDpV0I3wMr9g7NqG38 0qdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZVNZhRxF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si10415715pfl.246.2021.10.11.09.39.03; Mon, 11 Oct 2021 09:39:15 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZVNZhRxF; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244352AbhJKOTQ (ORCPT + 99 others); Mon, 11 Oct 2021 10:19:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:35276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243632AbhJKONQ (ORCPT ); Mon, 11 Oct 2021 10:13:16 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 049776127A; Mon, 11 Oct 2021 14:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1633961045; bh=rEVO9h5dPrAKhMXiOAnTdJYD/oNvK73p+rQ5FiH2P6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZVNZhRxFSzqeeP5pTOvSFtp2zKribkGu2+Q5LWProoX3qdTzloYeKH2rmxHIvLXba AIspoFyGgpq533hFOt2XJfG6BLghi3xiWmmo2Fl3w71G5f6LYCBncx/aoIiyYfHzT2 yrikKZTSee0meQpqq6iQa23g/N5hKQ37qil6gYtw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mahesh Salgaonkar , Michael Ellerman , Sasha Levin Subject: [PATCH 5.14 143/151] pseries/eeh: Fix the kdump kernel crash during eeh_pseries_init Date: Mon, 11 Oct 2021 15:46:55 +0200 Message-Id: <20211011134522.434323279@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211011134517.833565002@linuxfoundation.org> References: <20211011134517.833565002@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mahesh Salgaonkar [ Upstream commit eb8257a12192f43ffd41bd90932c39dade958042 ] On pseries LPAR when an empty slot is assigned to partition OR in single LPAR mode, kdump kernel crashes during issuing PHB reset. In the kdump scenario, we traverse all PHBs and issue reset using the pe_config_addr of the first child device present under each PHB. However the code assumes that none of the PHB slots can be empty and uses list_first_entry() to get the first child device under the PHB. Since list_first_entry() expects the list to be non-empty, it returns an invalid pci_dn entry and ends up accessing NULL phb pointer under pci_dn->phb causing kdump kernel crash. This patch fixes the below kdump kernel crash by skipping empty slots: audit: initializing netlink subsys (disabled) thermal_sys: Registered thermal governor 'fair_share' thermal_sys: Registered thermal governor 'step_wise' cpuidle: using governor menu pstore: Registered nvram as persistent store backend Issue PHB reset ... audit: type=2000 audit(1631267818.000:1): state=initialized audit_enabled=0 res=1 BUG: Kernel NULL pointer dereference on read at 0x00000268 Faulting instruction address: 0xc000000008101fb0 Oops: Kernel access of bad area, sig: 7 [#1] LE PAGE_SIZE=64K MMU=Radix SMP NR_CPUS=2048 NUMA pSeries Modules linked in: CPU: 7 PID: 1 Comm: swapper/7 Not tainted 5.14.0 #1 NIP: c000000008101fb0 LR: c000000009284ccc CTR: c000000008029d70 REGS: c00000001161b840 TRAP: 0300 Not tainted (5.14.0) MSR: 8000000002009033 CR: 28000224 XER: 20040002 CFAR: c000000008101f0c DAR: 0000000000000268 DSISR: 00080000 IRQMASK: 0 ... NIP pseries_eeh_get_pe_config_addr+0x100/0x1b0 LR __machine_initcall_pseries_eeh_pseries_init+0x2cc/0x350 Call Trace: 0xc00000001161bb80 (unreliable) __machine_initcall_pseries_eeh_pseries_init+0x2cc/0x350 do_one_initcall+0x60/0x2d0 kernel_init_freeable+0x350/0x3f8 kernel_init+0x3c/0x17c ret_from_kernel_thread+0x5c/0x64 Fixes: 5a090f7c363fd ("powerpc/pseries: PCIE PHB reset") Signed-off-by: Mahesh Salgaonkar [mpe: Tweak wording and trim oops] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/163215558252.413351.8600189949820258982.stgit@jupiter Signed-off-by: Sasha Levin --- arch/powerpc/platforms/pseries/eeh_pseries.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/arch/powerpc/platforms/pseries/eeh_pseries.c b/arch/powerpc/platforms/pseries/eeh_pseries.c index bc15200852b7..09fafcf2d3a0 100644 --- a/arch/powerpc/platforms/pseries/eeh_pseries.c +++ b/arch/powerpc/platforms/pseries/eeh_pseries.c @@ -867,6 +867,10 @@ static int __init eeh_pseries_init(void) if (is_kdump_kernel() || reset_devices) { pr_info("Issue PHB reset ...\n"); list_for_each_entry(phb, &hose_list, list_node) { + // Skip if the slot is empty + if (list_empty(&PCI_DN(phb->dn)->child_list)) + continue; + pdn = list_first_entry(&PCI_DN(phb->dn)->child_list, struct pci_dn, list); config_addr = pseries_eeh_get_pe_config_addr(pdn); -- 2.33.0