From patchwork Sat Oct 9 02:20:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Florian Fainelli X-Patchwork-Id: 12547263 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3F0AC433EF for ; Sat, 9 Oct 2021 03:10:34 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 94E3C60FC1 for ; Sat, 9 Oct 2021 03:10:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 94E3C60FC1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:References:In-Reply-To: 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: List-Owner; bh=cbXc//a3QKMZb5S6hDJlArxbGE2QXmiK2nSjyVtT4AY=; b=b/a6qsP33a2fZn qTfl2B6bqPYl1rDTyFejhOJpXXPDz/5MXJX0M624larMVka5IJ+Uaic9WeAMTvybDUg1Pl3XMmt1N 1Nt4W9RIFBGw/ZpY5CGSPucy5YjVt2o2ZFz3aMyH4N9wHu68CTGFIw8q4NiTmWUie1itax8Gns3V6 o5QK+fEI5Wtt8Gzl9qXJn822OhZAzDgHqBqsNPd10TGAErV1MDQWuJzCZFi1HcPzm5MKJZHhIH9b0 hODEKTWJE9U/g8kT9o98LIEi3h/m6nhTNktHmKLUIEzRxCeIkP7Po/n0nAoWsjBcYVUfpXc2tggLy Xhfpw9tx9pOVt9OI2hnw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZ2iq-004qBA-HN; Sat, 09 Oct 2021 03:08:29 +0000 Received: from mail-pl1-x629.google.com ([2607:f8b0:4864:20::629]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mZ1yW-004Xsn-G5 for linux-arm-kernel@lists.infradead.org; Sat, 09 Oct 2021 02:20:37 +0000 Received: by mail-pl1-x629.google.com with SMTP id x8so7256592plv.8 for ; Fri, 08 Oct 2021 19:20:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=G1RiT4GRKPcXSkOjyrks/jOWZL3DTQpMJtRhCsgVjY8=; b=bJ9KuSL5TgeWyqKaNO+GyL79xvaPjqlHFkgNvb4kUgxAmLsjpp8VRQ+Gx7VrYcypLZ abv3tPhR4NhdT1ba5/pktaJs0V2aQ0bulDU+3q7PxtU0kLZbKHktoBROaTbyBPqU56Ob 2KDuqvy30PtmXSomEAvNea3kdOxaoNSBnz3/JgNyxLRqBLvP45gpHGDPaL3+suQaP92s d1MlnJUTc5eAEd4YjTFmAu8icn5KR72wyfbVCe7FqXlqsz1h5uNZ1ltr06TL5JqShMqu AerdQraWSF2a+EwBXrgumcUlnzD9Mr4vtYumZkHIu79I4Ja4vwvjCyK27QonQzMqUe0N gyGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=G1RiT4GRKPcXSkOjyrks/jOWZL3DTQpMJtRhCsgVjY8=; b=6qlBB9YlRFpw9wO4h9/LKUcZ+/oJI+cLaaimN2Qilbmicq/nG5RpAJizHk1iAnNg+N eLQ1jRjdzTJ7yJ1IDpTT6GiJtyvU6ia9mBKILo42yRgy5aZ8AMYB4VwYjuuaiuSM5vRi gKy6Xwpux160p7qZdXZQakPSsXBFZUsWeUFd733+sgCalnD7/bpVYbbStH5lUkA0CWC5 2/gbs3uacqRyFOI4+ACCgVIS/JVirDyZ0sYD/bFylzYjRE/Mijm8QVXIwHUYU3TUU05G fOlTm0d+YHZ6i8Y+MYgkl9oUZXuW6v8qv9+QVWJoO2zjWcDN7Yp/3rRE5yIeEbFnWQ+7 hH+Q== X-Gm-Message-State: AOAM533HAfI2Nxiytt/LOQLPqIC9ROWEI7b4GuL7DsRWB1igsJT67QUx rX3CjzQ4y9vudp3RrfPCwo4= X-Google-Smtp-Source: ABdhPJzt3cUT0qN+Y44kkLg1/73jsgwdfZQ+cXkdb/8YqpQ6audqUIfOzS1omAW67biNzXtaW92lFA== X-Received: by 2002:a17:90b:390d:: with SMTP id ob13mr15368899pjb.49.1633746035050; Fri, 08 Oct 2021 19:20:35 -0700 (PDT) Received: from fainelli-desktop.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id pi9sm444692pjb.31.2021.10.08.19.20.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Oct 2021 19:20:34 -0700 (PDT) From: Florian Fainelli To: linux-kernel@vger.kernel.org Cc: Florian Fainelli , Ray Jui , Scott Branden , bcm-kernel-feedback-list@broadcom.com (maintainer:BROADCOM BCM281XX/BCM11XXX/BCM216XX ARM ARCHITE...), Russell King , Catalin Marinas , Will Deacon , Thomas Bogendoerfer , Thomas Gleixner , Marc Zyngier , Rob Herring , Frank Rowand , linux-arm-kernel@lists.infradead.org (moderated list:ARM SUB-ARCHITECTURES), linux-mips@vger.kernel.org (open list:MIPS), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE) Subject: [PATCH v4 04/14] irqchip/irq-bcm7038-l1: Gate use of CPU logical map to MIPS Date: Fri, 8 Oct 2021 19:20:13 -0700 Message-Id: <20211009022023.3796472-5-f.fainelli@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211009022023.3796472-1-f.fainelli@gmail.com> References: <20211009022023.3796472-1-f.fainelli@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211008_192036_609126_16A4E692 X-CRM114-Status: GOOD ( 18.33 ) 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The use of the cpu_logical_map[] array is only relevant for MIPS based platform where this driver is used as a first level interrupt controller and contains multiple register groups to map with an associated CPU. On ARM/ARM64 based systems this interrupt controller is present and used as a second level interrupt controller hanging off the ARM GIC. That copy of the interrupt controller contains a single group, resulting in the intc->cpus[] array to be of size 1. Things happened to work in that case because we install that interrupt controller as a chained handler which does not allow it to be affine to any CPU but the boot CPU which happens to be 0, therefore we never de-reference past intc->cpus[] but with the current code in place, we do leave a chance of de-referencing the array past its bounds. Signed-off-by: Florian Fainelli --- drivers/irqchip/irq-bcm7038-l1.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-bcm7038-l1.c b/drivers/irqchip/irq-bcm7038-l1.c index 14caf32dc23e..3c4e348c661e 100644 --- a/drivers/irqchip/irq-bcm7038-l1.c +++ b/drivers/irqchip/irq-bcm7038-l1.c @@ -28,9 +28,6 @@ #include #include #include -#ifdef CONFIG_ARM -#include -#endif #define IRQS_PER_WORD 32 #define REG_BYTES_PER_IRQ_WORD (sizeof(u32) * 4) @@ -127,7 +124,7 @@ static void bcm7038_l1_irq_handle(struct irq_desc *desc) struct irq_chip *chip = irq_desc_get_chip(desc); unsigned int idx; -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && defined(CONFIG_MIPS) cpu = intc->cpus[cpu_logical_map(smp_processor_id())]; #else cpu = intc->cpus[0]; @@ -301,7 +298,7 @@ static int bcm7038_l1_suspend(void) u32 val; /* Wakeup interrupt should only come from the boot cpu */ -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && defined(CONFIG_MIPS) boot_cpu = cpu_logical_map(0); #else boot_cpu = 0; @@ -325,7 +322,7 @@ static void bcm7038_l1_resume(void) struct bcm7038_l1_chip *intc; int boot_cpu, word; -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) && defined(CONFIG_MIPS) boot_cpu = cpu_logical_map(0); #else boot_cpu = 0;