From patchwork Tue Feb 27 10:32:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Neuling X-Patchwork-Id: 878445 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zrFR865Z2z9s1j for ; Tue, 27 Feb 2018 21:33:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3zrFR83jlczF12X for ; Tue, 27 Feb 2018 21:33:40 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from ozlabs.org (ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3zrFR25rf3zDr0b for ; Tue, 27 Feb 2018 21:33:34 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=neuling.org Received: from localhost.localdomain (localhost [127.0.0.1]) by ozlabs.org (Postfix) with ESMTP id 3zrFR22B24z9s1j; Tue, 27 Feb 2018 21:33:34 +1100 (AEDT) Received: by localhost.localdomain (Postfix, from userid 1000) id 03F7FEE7901; Tue, 27 Feb 2018 21:33:33 +1100 (AEDT) From: Michael Neuling To: stewart@linux.vnet.ibm.com Date: Tue, 27 Feb 2018 21:32:13 +1100 Message-Id: <20180227103213.23399-1-mikey@neuling.org> X-Mailer: git-send-email 2.14.1 Subject: [Skiboot] [PATCH] core/pci-dt-slot: Fix booting with no slot map X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: grimm@linux.vnet.ibm.com, skiboot@lists.ozlabs.org, Michael Neuling , alistair@popple.id.au MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Currently if you don't have a slot map in the device tree in /ibm,pcie-slots, you can crash with a back trace like this: CPU 0034 Backtrace: S: 0000000031cd3370 R: 000000003001362c .backtrace+0x48 S: 0000000031cd3410 R: 0000000030019e38 ._abort+0x4c S: 0000000031cd3490 R: 000000003002760c .exception_entry+0x180 S: 0000000031cd3670 R: 0000000000001f10 * S: 0000000031cd3850 R: 00000000300b4f3e * cpu_features_table+0x1d9e S: 0000000031cd38e0 R: 000000003002682c .dt_node_is_compatible+0x20 S: 0000000031cd3960 R: 0000000030030e08 .map_pci_dev_to_slot+0x16c S: 0000000031cd3a30 R: 0000000030091054 .dt_slot_get_slot_info+0x28 S: 0000000031cd3ac0 R: 000000003001e27c .pci_scan_one+0x2ac S: 0000000031cd3ba0 R: 000000003001e588 .pci_scan_bus+0x70 S: 0000000031cd3cb0 R: 000000003001ee74 .pci_scan_phb+0x100 S: 0000000031cd3d40 R: 0000000030017ff0 .cpu_process_jobs+0xdc S: 0000000031cd3e00 R: 0000000030014cb0 .__secondary_cpu_entry+0x44 S: 0000000031cd3e80 R: 0000000030014d04 .secondary_cpu_entry+0x34 S: 0000000031cd3f00 R: 0000000030002770 secondary_wait+0x8c [ 73.016947149,3] Fatal MCE at 0000000030026054 .dt_find_property+0x30 [ 73.017073254,3] CFAR : 0000000030026040 [ 73.017138048,3] SRR0 : 0000000030026054 SRR1 : 9000000000201000 [ 73.017198375,3] HSRR0: 0000000000000000 HSRR1: 0000000000000000 [ 73.017263210,3] DSISR: 00000008 DAR : 7c7b1b7848002524 [ 73.017352517,3] LR : 000000003002602c CTR : 000000003009102c [ 73.017419778,3] CR : 20004204 XER : 20040000 [ 73.017502425,3] GPR00: 000000003002682c GPR16: 0000000000000000 [ 73.017586924,3] GPR01: 0000000031c23670 GPR17: 0000000000000000 [ 73.017643873,3] GPR02: 00000000300fd500 GPR18: 0000000000000000 [ 73.017767091,3] GPR03: fffffffffffffff8 GPR19: 0000000000000000 [ 73.017855707,3] GPR04: 00000000300b3dc6 GPR20: 0000000000000000 [ 73.017943944,3] GPR05: 0000000000000000 GPR21: 00000000300bb6d2 [ 73.018024709,3] GPR06: 0000000031c23910 GPR22: 0000000000000000 [ 73.018117716,3] GPR07: 0000000031c23930 GPR23: 0000000000000000 [ 73.018195974,3] GPR08: 0000000000000000 GPR24: 0000000000000000 [ 73.018278350,3] GPR09: 0000000000000000 GPR25: 0000000000000000 [ 73.018353795,3] GPR10: 0000000000000028 GPR26: 00000000300be6fb [ 73.018424362,3] GPR11: 0000000000000000 GPR27: 0000000000000000 [ 73.018533159,3] GPR12: 0000000020004208 GPR28: 0000000030767d38 [ 73.018642725,3] GPR13: 0000000031c20000 GPR29: 00000000300b3dc6 [ 73.018737925,3] GPR14: 0000000000000000 GPR30: 0000000000000010 [ 73.018794428,3] GPR15: 0000000000000000 GPR31: 7c7b1b7848002514 This has been seen in the lab on a witherspoon using the device tree entry point (ie. no HDAT). This fixes the null pointer deref. Signed-off-by: Michael Neuling Tested-by: Reza Arbab --- core/pci-dt-slot.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/pci-dt-slot.c b/core/pci-dt-slot.c index 9a93a74497..bee7ba47c4 100644 --- a/core/pci-dt-slot.c +++ b/core/pci-dt-slot.c @@ -47,6 +47,9 @@ static struct dt_node *map_phb_to_slot(struct phb *phb) if (!dt_slots) dt_slots = dt_find_by_path(dt_root, "/ibm,pcie-slots"); + if (!dt_slots) + return NULL; + dt_for_each_child(dt_slots, slot_node) { u32 reg[2];