From patchwork Wed Sep 16 19:17:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11780629 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26C1E6CA for ; Wed, 16 Sep 2020 19:19:48 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDE342075E for ; Wed, 16 Sep 2020 19:19:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tKAjYFhL"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Y9ZKLVzN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EDE342075E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=zo2opuubXr/2h9QqLKnQ0L4n5fpKT2JSlFVWoJrOzBo=; b=tKAjYFhL+xIfij70S7ufc5ime T7XC/ZNxriTI9DaoG5GTpiOm2sQC/rEpZrKdXoAUQWC/cXUT8rsf4tlxyreQcVWhMy95xySwCydpm ojaP3h5tghlP2I5qhx+IsKAaTW8Gyn7iJqe45w6705pNQUp7OsdnSHJhsLwqnNDPSfVLZSCo17aFI MzV2OwyUKHQYCOZnHsWu7LaJd3VgECDzIuJ10jIvYe5MGaHbMjw/VeLQmlbBCz0FO9d3zZb5qpUeS jfO42HBZIV4X0C8Q2qL+KKGSLdkmwMZZtqxM/wDc1VYYM4c+V0j0yy+FGf0XKjnUoDAc12T7cQxu/ CRd2Em81g==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIcwN-0005CP-EA; Wed, 16 Sep 2020 19:18:03 +0000 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kIcw5-000568-GN for linux-arm-kernel@lists.infradead.org; Wed, 16 Sep 2020 19:17:47 +0000 Received: by mail-pl1-x641.google.com with SMTP id bg9so3715306plb.2 for ; Wed, 16 Sep 2020 12:17:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zqVd5aJCn3jWe+cLGn+cDLVmuUTYejBKrMGwZzLg0eA=; b=Y9ZKLVzNc/nkjU1/CyaKQ2tsDuZ0qQO9dBf3jmNBAa/cCQJif4eqy8Jxu69IhNVDJg UBOYI1objMHVqMgcvVNtWvxjibaeJklTvMR6wCpGQglJ7ukuDB5kYD7KGDPLPFCJbPQf ZjwpBBylRtHkxubA8fHTvzqi2lNMHxTpb+iW/cDAw3Xnhd5tmbOqoryKGpbJHZNO/9gv CtQ+fENL3YHadXcs+XoasGrdd3GRDpIsh3UKYZVirD4WyoHOkIausNQ+7NsXSJOAoe/6 jFXSSfXrPJvWsalQjI1MKsAwScRfkcS8UudrVthiSLmP+H9ONpev/dOaBNfgUB/f9DIZ zMmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zqVd5aJCn3jWe+cLGn+cDLVmuUTYejBKrMGwZzLg0eA=; b=h89AB94LTbbjSib38qoxza/AiwqldEDN+f2dO+S6iU5uJ/Uoz1KSWXZMAwjh0e+4ta wqhcgsaOhz6SfzA0VyZQw1PM9uo4Zb4mOAOvQkSXtIcixGhV38A/rZXvnZ44LGjA60cO XJ6tBVIRHDYy0a3BHnMLMRxKLQbfRk3HDKalWQT4n6ZIx9HoRbhgejExB4Bc7pGQhVZj sH4feIaK5rHT+AN4Z0lxsq6qprlL7YzAMZ8uum8N+M1mneeWesg71ciBPrxVO7x50qkm RBx5BCWfeXThKRSbEF8bx5EBiZ+LAxKyK35eLQ4mcuc+J2/xgYDt4CEXnaefkTo+t9mQ N5LQ== X-Gm-Message-State: AOAM533V6qvRmq4NxSy4EmJ8iWNZN79PkYhXMpOHSPBvyOvKllaJsfz0 e3mcWUGj2xEbAst/sZJostzXlbleVeTo/w== X-Google-Smtp-Source: ABdhPJzLYqy0aga5oYoEC1V8aQ1YRhCJMYbaeWrOEjaU8Z2bhDPgdxNoE8d76Iew49j9klf7Dl2C6w== X-Received: by 2002:a17:902:a70c:b029:d1:e5e7:be56 with SMTP id w12-20020a170902a70cb02900d1e5e7be56mr7873079plq.48.1600283863147; Wed, 16 Sep 2020 12:17:43 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id b2sm11373688pfp.3.2020.09.16.12.17.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Sep 2020 12:17:42 -0700 (PDT) From: Mathieu Poirier To: gregkh@linuxfoundation.org Subject: [PATCH 03/16] coresight: fix offset by one error in counting ports Date: Wed, 16 Sep 2020 13:17:24 -0600 Message-Id: <20200916191737.4001561-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200916191737.4001561-1-mathieu.poirier@linaro.org> References: <20200916191737.4001561-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200916_151745_623152_FDA4F6A3 X-CRM114-Status: GOOD ( 18.91 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:641 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Mian Yousaf Kaukab Since port-numbers start from 0, add 1 to port-number to get the port count. Fix following crash when Coresight is enabled on ACPI based systems: [ 61.061736] Unable to handle kernel NULL pointer dereference at virtual address 0000000000000008 ... [ 61.135494] pc : acpi_coresight_parse_graph+0x1c4/0x37c [ 61.140705] lr : acpi_coresight_parse_graph+0x160/0x37c [ 61.145915] sp : ffff800012f4ba40 [ 61.145917] x29: ffff800012f4ba40 x28: ffff00becce62f98 [ 61.159896] x27: 0000000000000005 x26: ffff00becd8a7c88 [ 61.165195] x25: ffff00becd8a7d88 x24: ffff00becce62f80 [ 61.170492] x23: ffff800011ef99c0 x22: ffff009efb8bc010 [ 61.175790] x21: 0000000000000018 x20: 0000000000000005 [ 61.181087] x19: ffff00becce62e80 x18: 0000000000000020 [ 61.186385] x17: 0000000000000001 x16: 00000000000002a8 [ 61.191682] x15: ffff000838648550 x14: ffffffffffffffff [ 61.196980] x13: 0000000000000000 x12: ffff00becce62d87 [ 61.202277] x11: 00000000ffffff76 x10: 000000000000002e [ 61.207575] x9 : ffff8000107e1a68 x8 : ffff00becce63000 [ 61.212873] x7 : 0000000000000018 x6 : 000000000000003f [ 61.218170] x5 : 0000000000000000 x4 : 0000000000000000 [ 61.223467] x3 : 0000000000000000 x2 : 0000000000000000 [ 61.228764] x1 : ffff00becce62f80 x0 : 0000000000000000 [ 61.234062] Call trace: [ 61.236497] acpi_coresight_parse_graph+0x1c4/0x37c [ 61.241361] coresight_get_platform_data+0xdc/0x130 [ 61.246225] tmc_probe+0x138/0x2dc [ 61.246227] amba_probe+0xdc/0x220 [ 61.255779] really_probe+0xe8/0x49c [ 61.255781] driver_probe_device+0xec/0x140 [ 61.255782] device_driver_attach+0xc8/0xd0 [ 61.255785] __driver_attach+0xac/0x180 [ 61.265857] bus_for_each_dev+0x78/0xcc [ 61.265859] driver_attach+0x2c/0x40 [ 61.265861] bus_add_driver+0x150/0x244 [ 61.265863] driver_register+0x80/0x13c [ 61.273591] amba_driver_register+0x60/0x70 [ 61.273594] tmc_driver_init+0x20/0x2c [ 61.281582] do_one_initcall+0x50/0x230 [ 61.281585] do_initcalls+0x104/0x144 [ 61.291831] kernel_init_freeable+0x168/0x1dc [ 61.291834] kernel_init+0x1c/0x120 [ 61.299215] ret_from_fork+0x10/0x18 [ 61.299219] Code: b9400022 f9400660 9b277c42 8b020000 (f9400404) [ 61.307381] ---[ end trace 63c6c3d7ec6a9b7c ]--- [ 61.315225] Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b Fixes: d375b356e687 ("coresight: Fix support for sparsely populated ports") Reported-by: Ruediger Oertel Signed-off-by: Mian Yousaf Kaukab Reviewed-by: Suzuki K Poulose Tested-by: Jeremy Linton Reviewed-by: Jeremy Linton Signed-off-by: Mathieu Poirier --- drivers/hwtracing/coresight/coresight-platform.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/hwtracing/coresight/coresight-platform.c b/drivers/hwtracing/coresight/coresight-platform.c index bfd44231d7ad..227e234a2470 100644 --- a/drivers/hwtracing/coresight/coresight-platform.c +++ b/drivers/hwtracing/coresight/coresight-platform.c @@ -711,11 +711,11 @@ static int acpi_coresight_parse_graph(struct acpi_device *adev, return dir; if (dir == ACPI_CORESIGHT_LINK_MASTER) { - if (ptr->outport > pdata->nr_outport) - pdata->nr_outport = ptr->outport; + if (ptr->outport >= pdata->nr_outport) + pdata->nr_outport = ptr->outport + 1; ptr++; } else { - WARN_ON(pdata->nr_inport == ptr->child_port); + WARN_ON(pdata->nr_inport == ptr->child_port + 1); /* * We do not track input port connections for a device. * However we need the highest port number described, @@ -723,8 +723,8 @@ static int acpi_coresight_parse_graph(struct acpi_device *adev, * record for an output connection. Hence, do not move * the ptr for input connections */ - if (ptr->child_port > pdata->nr_inport) - pdata->nr_inport = ptr->child_port; + if (ptr->child_port >= pdata->nr_inport) + pdata->nr_inport = ptr->child_port + 1; } }