Received: by 2002:a05:6500:1b8f:b0:1fa:5c73:8e2d with SMTP id df15csp99371lqb; Tue, 28 May 2024 09:51:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVlUngPzeEwsliaJpkqkwXs22L1TwIM/VkR72kVVaT+UvVTbx+LgRbrBOldQi6zoiBl0ElrmRIdl8NW69NGlvBEQUXIG7cYOiv7AHkGFw== X-Google-Smtp-Source: AGHT+IFBKxWptYTiBTGONTMfRMyTJuotMDWlYNvAagltIjNdjZ+qCK39NVB7WoqV045uFJeQgMhb X-Received: by 2002:a05:6a20:564b:b0:1af:e3f1:9af7 with SMTP id adf61e73a8af0-1b212d461a6mr13245407637.36.1716915062196; Tue, 28 May 2024 09:51:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716915062; cv=pass; d=google.com; s=arc-20160816; b=ArujCkeiQsDw38vU1v1QL5S4tJrMo0/+P0JWjFjpYtaxSy5qnoGVnNieJ0KS3S6J2U PWcPk8oRutLftnYTceFiyMaynHzFiLe2Y+9vTST2TVxOlVCz94Gu5hic6fyUR/fkk5/b 9mLRkv+NoejdJBfcpcgz9BJwQO2wKe4YbHVL6CncnU+XYyHaqRrxDBz4YP/yNRpLVBtd IscQjOvHMG5cWMxLg2WE6olfhPLoizlqo9WYHppSoPU/LHtRRvgG0g0IoAMWKNlaf+TS 0NPxGVY+5Kym/4uoffDSlU1QJE8yCE4pLRVRK9rshQDZ6vdigdnOY4wp7wjY/vxG02Sl xSQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=ckruHn5kn/iIoCjhZIWFkUu0+Fr84ouamhD2v34UuQ8=; fh=gKb/Z89BnSVlJgVZl7vW6SRjyyMWUdiHcUk7S+BMmxo=; b=QyOwJkPJvWfiX8HOQqCrMzsxG+TyyFtFCHjR4aF+50nt7UoJDi9VNKwlxXjTgsJNwj R3Xiv4mdCZChEFHM6oMeycWZrvc9ElW8TV8SUPmRx0/8XB86+zHBCtdcKE0/iZimmRzB T4oPDi6kqHFhmDkZOSyjKm6j22zIjeafAfjAnmu+eSllp7JbnE5Cjidq4pzqFExEPA5W biq9ajxZoNaapbkky6wJpyYbX0baZ7rjjnVd0FLh/gt1NPbG4ZO4qE5XhJOmChz2RgPV EACwlOQnCPQEZezzxvyNDTYDzSnAs2w6bweLqNI+UD5kLGNmhUcLVkZAAxKcMbsgEZsW pRpw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XaJNwDtp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-6822a98fe92si8356682a12.758.2024.05.28.09.51.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 May 2024 09:51:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-192769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=XaJNwDtp; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-192769-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-192769-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5973128A604 for ; Tue, 28 May 2024 16:41:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E85BC172BD2; Tue, 28 May 2024 16:41:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="XaJNwDtp" 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 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: linux-kernel@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