From mboxrd@z Thu Jan 1 00:00:00 1970 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 6336FC25B7C for ; Tue, 28 May 2024 16:41:56 +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=MhORQICIGpbb6M9oedMlLJreC61Oy+kbrpBTjf452mQ=; b=Cs+a/WdwDkiFWi KuxZUSY2yagHlnkchlV3y8gw+AgVxOsv3mp4ZQVLJfXahSGZg0zjjPF9w2xJCVslnj23fw/jNVyWC aWduNwQZPaKpwnFCpLr1L/6U5uLJnaUfGcGPH5rCp2MOTVwMoXF9sFEfYOTVphU6vbsuQhIWBBene wyFYHquVVpj8IKsDTDAX4M+eWfGGllyd+obVV/lNW3LhP0muoDnHRYDwiBOXTqexIYFDnArkBrVg9 vSCz2b34sY7CeyiCfXdvaLq8W49bBiEM9es41m66Z3AA6yaI6y7mcPy/Qgc9auO7PqlxwITS3Cuga WHLk1LJsuanTfQCz4S9w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBztV-00000001S6J-15tF; Tue, 28 May 2024 16:41:49 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBztQ-00000001S51-3aKl; Tue, 28 May 2024 16:41:46 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7EBF9CE1397; Tue, 28 May 2024 16:41:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B0DBC32782; Tue, 28 May 2024 16:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716914501; bh=DMgXSKpLwPGnXLdeaUen3gAjKmTX+D3leZxLgkVaXlo=; h=From:To:Cc:Subject:Date:From; b=XaJNwDtpSAmeDSf7UPYDPLYGzpjNandQwPlj4GqQNQMcy84ByAlU3Jz0OHUP5+8Pw F3B4baLUu3xBWWefsQ5bso6eja0kPvl4biz8ZDs1ac7Kt3mQFdFSaf4rWNz2iR2NID q2QjpeudjuYrh/fZRoPMLfJUl3dNnjySoE5Zoc7cX8UKkgGqA9g4UAEkiALZ+3RAo6 MUsUvU7mmpcVz4i5c5f2qODMpMyigWOINSOU4B4b48LkUqQPOngA9s6C51pl3DavAB f3zYOwUQcdBmE0Sc+4Sy+Le2wXBCivSf1qZY6hkwVVLuwMBumCGq8gnolDv3e3/tTU fsPAVXik0dSiw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sBztL-00GNOx-CY; Tue, 28 May 2024 17:41:39 +0100 From: Marc Zyngier To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org Cc: Anup Patel , Saravana Kannan , Rob Herring Subject: [PATCH] of: property: Fix fw_devlink handling of interrupt-map Date: Tue, 28 May 2024 17:41:32 +0100 Message-Id: <20240528164132.2451685-1-maz@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, apatel@ventanamicro.com, saravanak@google.com, robh@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240528_094145_267820_6171BF20 X-CRM114-Status: GOOD ( 16.10 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Commit d976c6f4b32c ("of: property: Add fw_devlink support for interrupt-map property") tried to do what it says on the tin, but failed on a couple of points: - it confuses bytes and cells. Not a huge deal, except when it comes to pointer arithmetic - it doesn't really handle anything but interrupt-maps that have their parent #address-cells set to 0 The combinations of the two leads to some serious fun on my M1 box, with plenty of WARN-ON() firing all over the shop, and amusing values being generated for interrupt specifiers. Address both issues so that I can boot my machines again. Fixes: d976c6f4b32c ("of: property: Add fw_devlink support for interrupt-map property") Signed-off-by: Marc Zyngier Cc: Anup Patel Cc: Saravana Kannan Cc: Rob Herring (Arm) --- drivers/of/property.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 1c83e68f805b..9adebc63bea9 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1322,7 +1322,13 @@ static struct device_node *parse_interrupt_map(struct device_node *np, addrcells = of_bus_n_addr_cells(np); imap = of_get_property(np, "interrupt-map", &imaplen); - if (!imap || imaplen <= (addrcells + intcells)) + imaplen /= sizeof(*imap); + + /* + * Check that we have enough runway for the child unit interrupt + * specifier and a phandle. That's the bare minimum we can expect. + */ + if (!imap || imaplen <= (addrcells + intcells + 1)) return NULL; imap_end = imap + imaplen; @@ -1346,8 +1352,14 @@ static struct device_node *parse_interrupt_map(struct device_node *np, if (!index) return sup_args.np; - of_node_put(sup_args.np); + /* + * Account for the full parent unit interrupt specifier + * (address cells, interrupt cells, and phandle). + */ + imap += of_bus_n_addr_cells(sup_args.np); imap += sup_args.args_count + 1; + + of_node_put(sup_args.np); index--; } -- 2.39.2 _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv From mboxrd@z Thu Jan 1 00:00:00 1970 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 280ABC25B78 for ; Tue, 28 May 2024 16:42:03 +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=mtwHnnDwKferTMR/h6PFt1/nBDB+HLBB+L0pxMyiesA=; b=qq0UbOwXqwp9En kHAN0zmX7T18fcgvoloUYlhiKvkZZoItxxTHAsqW6AFK++hWeFx69SDh76nEUfje5rmsdYW503iNz mf3CMcJMDRzEviCFia6BRkT04h5I+tmKz2tWag4zGx3QSFgoN9M649Sa20lzlBS0nmtmAuDgL9VRG iSNIaghFD/U3fzvuBy/sF27zrehlbJpHjw9ZMy0G75e5nQAAccK1GokIQRtxs6wEk0fY0xyrzLbCA QU7YaGgGB6gct1vxMekdXd10MabEYekW2COmz3zRWk1LkbDVHY4hPrHLkPC65ZxHXpFiePzF6SFGr JmC3mTd9/2VgX9b6kSRg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBztU-00000001S5o-2bX5; Tue, 28 May 2024 16:41:48 +0000 Received: from sin.source.kernel.org ([2604:1380:40e1:4800::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sBztQ-00000001S51-3aKl; Tue, 28 May 2024 16:41:46 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 7EBF9CE1397; Tue, 28 May 2024 16:41:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B0DBC32782; Tue, 28 May 2024 16:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716914501; bh=DMgXSKpLwPGnXLdeaUen3gAjKmTX+D3leZxLgkVaXlo=; h=From:To:Cc:Subject:Date:From; b=XaJNwDtpSAmeDSf7UPYDPLYGzpjNandQwPlj4GqQNQMcy84ByAlU3Jz0OHUP5+8Pw F3B4baLUu3xBWWefsQ5bso6eja0kPvl4biz8ZDs1ac7Kt3mQFdFSaf4rWNz2iR2NID q2QjpeudjuYrh/fZRoPMLfJUl3dNnjySoE5Zoc7cX8UKkgGqA9g4UAEkiALZ+3RAo6 MUsUvU7mmpcVz4i5c5f2qODMpMyigWOINSOU4B4b48LkUqQPOngA9s6C51pl3DavAB f3zYOwUQcdBmE0Sc+4Sy+Le2wXBCivSf1qZY6hkwVVLuwMBumCGq8gnolDv3e3/tTU fsPAVXik0dSiw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sBztL-00GNOx-CY; Tue, 28 May 2024 17:41:39 +0100 From: Marc Zyngier To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org Cc: Anup Patel , Saravana Kannan , Rob Herring Subject: [PATCH] of: property: Fix fw_devlink handling of interrupt-map Date: Tue, 28 May 2024 17:41:32 +0100 Message-Id: <20240528164132.2451685-1-maz@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, apatel@ventanamicro.com, saravanak@google.com, robh@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240528_094145_267820_6171BF20 X-CRM114-Status: GOOD ( 16.10 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit d976c6f4b32c ("of: property: Add fw_devlink support for interrupt-map property") tried to do what it says on the tin, but failed on a couple of points: - it confuses bytes and cells. Not a huge deal, except when it comes to pointer arithmetic - it doesn't really handle anything but interrupt-maps that have their parent #address-cells set to 0 The combinations of the two leads to some serious fun on my M1 box, with plenty of WARN-ON() firing all over the shop, and amusing values being generated for interrupt specifiers. Address both issues so that I can boot my machines again. Fixes: d976c6f4b32c ("of: property: Add fw_devlink support for interrupt-map property") Signed-off-by: Marc Zyngier Cc: Anup Patel Cc: Saravana Kannan Cc: Rob Herring (Arm) --- drivers/of/property.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 1c83e68f805b..9adebc63bea9 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1322,7 +1322,13 @@ static struct device_node *parse_interrupt_map(struct device_node *np, addrcells = of_bus_n_addr_cells(np); imap = of_get_property(np, "interrupt-map", &imaplen); - if (!imap || imaplen <= (addrcells + intcells)) + imaplen /= sizeof(*imap); + + /* + * Check that we have enough runway for the child unit interrupt + * specifier and a phandle. That's the bare minimum we can expect. + */ + if (!imap || imaplen <= (addrcells + intcells + 1)) return NULL; imap_end = imap + imaplen; @@ -1346,8 +1352,14 @@ static struct device_node *parse_interrupt_map(struct device_node *np, if (!index) return sup_args.np; - of_node_put(sup_args.np); + /* + * Account for the full parent unit interrupt specifier + * (address cells, interrupt cells, and phandle). + */ + imap += of_bus_n_addr_cells(sup_args.np); imap += sup_args.args_count + 1; + + of_node_put(sup_args.np); index--; } -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1A53961FC5; Tue, 28 May 2024 16:41:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716914502; cv=none; b=k8IQjy7dkqWlzOeWqwJOpgPRcq981uuGFwQvTO/+caX/kcH1xNhyk5xeJz4BbVowIPflKIzneUvLkMG8sPfZ8csCfxeL1BaXPVp4P7Yd+fJ/x1o6Y1UvFqZijHc0iugiENaggRKvoMyS/4MZ4/osshe8l8PXLXc9ga5Ys9JkFHM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716914502; c=relaxed/simple; bh=DMgXSKpLwPGnXLdeaUen3gAjKmTX+D3leZxLgkVaXlo=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=kmsf0TiewWvioe4Lq3SqH0M82lc8ctkyzZ+OLJclMGGTNyTa9SF4yA9jA1cxo4N4kwqj0KYdEkDFG7BKHZ4KrM4DV66W/J4ZV/LrJl1C4g4UFbgVEe42DvcxHmSnpLBYv5fPbz8+zLxq10aRL+FIr0cur3Ois9RoWXZfqrjouTg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=XaJNwDtp; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XaJNwDtp" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B0DBC32782; Tue, 28 May 2024 16:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1716914501; bh=DMgXSKpLwPGnXLdeaUen3gAjKmTX+D3leZxLgkVaXlo=; h=From:To:Cc:Subject:Date:From; b=XaJNwDtpSAmeDSf7UPYDPLYGzpjNandQwPlj4GqQNQMcy84ByAlU3Jz0OHUP5+8Pw F3B4baLUu3xBWWefsQ5bso6eja0kPvl4biz8ZDs1ac7Kt3mQFdFSaf4rWNz2iR2NID q2QjpeudjuYrh/fZRoPMLfJUl3dNnjySoE5Zoc7cX8UKkgGqA9g4UAEkiALZ+3RAo6 MUsUvU7mmpcVz4i5c5f2qODMpMyigWOINSOU4B4b48LkUqQPOngA9s6C51pl3DavAB f3zYOwUQcdBmE0Sc+4Sy+Le2wXBCivSf1qZY6hkwVVLuwMBumCGq8gnolDv3e3/tTU fsPAVXik0dSiw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1sBztL-00GNOx-CY; Tue, 28 May 2024 17:41:39 +0100 From: Marc Zyngier To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org Cc: Anup Patel , Saravana Kannan , Rob Herring Subject: [PATCH] of: property: Fix fw_devlink handling of interrupt-map Date: Tue, 28 May 2024 17:41:32 +0100 Message-Id: <20240528164132.2451685-1-maz@kernel.org> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, apatel@ventanamicro.com, saravanak@google.com, robh@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Commit d976c6f4b32c ("of: property: Add fw_devlink support for interrupt-map property") tried to do what it says on the tin, but failed on a couple of points: - it confuses bytes and cells. Not a huge deal, except when it comes to pointer arithmetic - it doesn't really handle anything but interrupt-maps that have their parent #address-cells set to 0 The combinations of the two leads to some serious fun on my M1 box, with plenty of WARN-ON() firing all over the shop, and amusing values being generated for interrupt specifiers. Address both issues so that I can boot my machines again. Fixes: d976c6f4b32c ("of: property: Add fw_devlink support for interrupt-map property") Signed-off-by: Marc Zyngier Cc: Anup Patel Cc: Saravana Kannan Cc: Rob Herring (Arm) --- drivers/of/property.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/of/property.c b/drivers/of/property.c index 1c83e68f805b..9adebc63bea9 100644 --- a/drivers/of/property.c +++ b/drivers/of/property.c @@ -1322,7 +1322,13 @@ static struct device_node *parse_interrupt_map(struct device_node *np, addrcells = of_bus_n_addr_cells(np); imap = of_get_property(np, "interrupt-map", &imaplen); - if (!imap || imaplen <= (addrcells + intcells)) + imaplen /= sizeof(*imap); + + /* + * Check that we have enough runway for the child unit interrupt + * specifier and a phandle. That's the bare minimum we can expect. + */ + if (!imap || imaplen <= (addrcells + intcells + 1)) return NULL; imap_end = imap + imaplen; @@ -1346,8 +1352,14 @@ static struct device_node *parse_interrupt_map(struct device_node *np, if (!index) return sup_args.np; - of_node_put(sup_args.np); + /* + * Account for the full parent unit interrupt specifier + * (address cells, interrupt cells, and phandle). + */ + imap += of_bus_n_addr_cells(sup_args.np); imap += sup_args.args_count + 1; + + of_node_put(sup_args.np); index--; } -- 2.39.2