Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp1943582ybv; Fri, 14 Feb 2020 08:37:57 -0800 (PST) X-Google-Smtp-Source: APXvYqxAGIZETJ8s6NAdc5DLmaLl8g6HN8zv5KQsrVTusAVkR5IrfasoYjU8NzZk5/WDx1BIth8O X-Received: by 2002:a54:468b:: with SMTP id k11mr2400028oic.134.1581698277727; Fri, 14 Feb 2020 08:37:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581698277; cv=none; d=google.com; s=arc-20160816; b=OiAVHZ7l0t2naTTtok2o8KflNLwmk9YXkosgWrl/9RIIftVj/Oa9hKU/KvZuMj9LHQ sn7RHzffZXiqCMSMEFXzewkO+qRN53shuX9e+BqrFFfXusEXrDngTlm/f/jJPlN5dBu0 v+EVp19Hl4ixYUivonNPof/zlVvVM4H/aPJstjZuHCN4MD3PpKp/bZYuDCXgtVjGJWFB B0st/9MGZx1uNjM9BdSJ7UvxJ9IdVGUG6jNcKZk6pJFxd7v8KgVVzmFKLyBUq6lKYQKf 2hOzMHbQ4xW4uPPpjDijVy9kKuXRfwqXJ+lE+LWESIIWE9k14AlqJ50kBUsmIYET3THO VNDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HV7VY6cZ8fZX8jbnd1Z+KNTidP5YW5K2HPvWKsvewtg=; b=j6R6cTUESkAwxTLoRANM9Fkiqa+06pFABxJ50RmTtSEw4c4kMr7l4H9FsjJOpezHwh ozmmylG2NzWZZVNmjDgeMRbGXM7eI2BYrKOduZisx7fAjb6y6S7TSXHPgqsJ47TyZx6D aVg/t7cWRF3vzMl2zFMqPQ9a0YIlcAznRgFaeEJX8fUVHU0p4rPQIFIzB6N2pJ5NdYFB F+9DeZC96AJYrb2QSlCYVGWSKk+ox9WuBYbd14c7hvSbcn7tCWzPHadVsmbrg0RoN2z3 6Nun/ANpP9S+sH+1+95iahvuQHxCC3CSSQrRlPc28NNsOOKNHILZBCQXBONbLsGNsyoT FqyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="fSp49Vh/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f9si3321517oti.44.2020.02.14.08.37.45; Fri, 14 Feb 2020 08:37:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="fSp49Vh/"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393754AbgBNQhF (ORCPT + 99 others); Fri, 14 Feb 2020 11:37:05 -0500 Received: from mail.kernel.org ([198.145.29.99]:60566 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405784AbgBNQYB (ORCPT ); Fri, 14 Feb 2020 11:24:01 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EAB162476A; Fri, 14 Feb 2020 16:23:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581697440; bh=HbAn6k20+yu3zZgzeEFmtlXzxSAT9wm5pIPskitcQIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fSp49Vh/i6mfPH2WxxLaGNMjXCs/DL82T/vwhR+YxSwt/8cVKTyaJzFWucWp43Ici zC/pLNW545Vsv/+oNLnwLaHj7698lKRxbKZ/d+4MzC44tK+BD/zZkWRRx9Rg+ssC+H AV+r0PVPKRadlK/5MaL2lX+t06QUnzpVSR/ndNy4= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Marc Zyngier , Heyi Guo , Sasha Levin Subject: [PATCH AUTOSEL 4.9 126/141] irqchip/gic-v3: Only provision redistributors that are enabled in ACPI Date: Fri, 14 Feb 2020 11:21:06 -0500 Message-Id: <20200214162122.19794-126-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200214162122.19794-1-sashal@kernel.org> References: <20200214162122.19794-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Marc Zyngier [ Upstream commit 926b5dfa6b8dc666ff398044af6906b156e1d949 ] We currently allocate redistributor region structures for individual redistributors when ACPI doesn't present us with compact MMIO regions covering multiple redistributors. It turns out that we allocate these structures even when the redistributor is flagged as disabled by ACPI. It works fine until someone actually tries to tarse one of these structures, and access the corresponding MMIO region. Instead, track the number of enabled redistributors, and only allocate what is required. This makes sure that there is no invalid data to misuse. Signed-off-by: Marc Zyngier Reported-by: Heyi Guo Tested-by: Heyi Guo Link: https://lore.kernel.org/r/20191216062745.63397-1-guoheyi@huawei.com Signed-off-by: Sasha Levin --- drivers/irqchip/irq-gic-v3.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index f7b8681aed3f4..2ab6060031a43 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -1195,6 +1195,7 @@ static struct struct redist_region *redist_regs; u32 nr_redist_regions; bool single_redist; + int enabled_rdists; u32 maint_irq; int maint_irq_mode; phys_addr_t vcpu_base; @@ -1289,8 +1290,10 @@ static int __init gic_acpi_match_gicc(struct acpi_subtable_header *header, * If GICC is enabled and has valid gicr base address, then it means * GICR base is presented via GICC */ - if ((gicc->flags & ACPI_MADT_ENABLED) && gicc->gicr_base_address) + if ((gicc->flags & ACPI_MADT_ENABLED) && gicc->gicr_base_address) { + acpi_data.enabled_rdists++; return 0; + } /* * It's perfectly valid firmware can pass disabled GICC entry, driver @@ -1320,8 +1323,10 @@ static int __init gic_acpi_count_gicr_regions(void) count = acpi_table_parse_madt(ACPI_MADT_TYPE_GENERIC_INTERRUPT, gic_acpi_match_gicc, 0); - if (count > 0) + if (count > 0) { acpi_data.single_redist = true; + count = acpi_data.enabled_rdists; + } return count; } -- 2.20.1