All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Hanjun Guo <guohanjun@huawei.com>
Cc: dann frazier <dann.frazier@canonical.com>,
	Fu Wei <wefu@redhat.com>, Len Brown <lenb@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kernel-team@android.com
Subject: [PATCH 2/2] ACPI: irq: Prevent unregistering of GIC SGIs
Date: Wed, 21 Apr 2021 17:43:17 +0100	[thread overview]
Message-ID: <20210421164317.1718831-3-maz@kernel.org> (raw)
In-Reply-To: <20210421164317.1718831-1-maz@kernel.org>

When using ACPI on arm64, which implies the GIC IRQ model, no
table should ever provide a GSI number in the range [0:15],
as these are reserved for IPIs.

However, drivers tend to call acpi_unregister_gsi() with any
random GSI number provided by half baked tables, which results
in an exploding kernel when its IPIs have been unconfigured.

In order to catch this, check for the silly case early, warn
that something is going wrong and avoid the above disaster.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/acpi/irq.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c
index e209081d644b..c68e694fca26 100644
--- a/drivers/acpi/irq.c
+++ b/drivers/acpi/irq.c
@@ -75,8 +75,12 @@ void acpi_unregister_gsi(u32 gsi)
 {
 	struct irq_domain *d = irq_find_matching_fwnode(acpi_gsi_domain_id,
 							DOMAIN_BUS_ANY);
-	int irq = irq_find_mapping(d, gsi);
+	int irq;
 
+	if (WARN_ON(acpi_irq_model == ACPI_IRQ_MODEL_GIC && gsi < 16))
+		return;
+
+	irq = irq_find_mapping(d, gsi);
 	irq_dispose_mapping(irq);
 }
 EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
-- 
2.29.2


WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Sudeep Holla <sudeep.holla@arm.com>,
	Hanjun Guo <guohanjun@huawei.com>
Cc: dann frazier <dann.frazier@canonical.com>,
	Fu Wei <wefu@redhat.com>, Len Brown <lenb@kernel.org>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, kernel-team@android.com
Subject: [PATCH 2/2] ACPI: irq: Prevent unregistering of GIC SGIs
Date: Wed, 21 Apr 2021 17:43:17 +0100	[thread overview]
Message-ID: <20210421164317.1718831-3-maz@kernel.org> (raw)
In-Reply-To: <20210421164317.1718831-1-maz@kernel.org>

When using ACPI on arm64, which implies the GIC IRQ model, no
table should ever provide a GSI number in the range [0:15],
as these are reserved for IPIs.

However, drivers tend to call acpi_unregister_gsi() with any
random GSI number provided by half baked tables, which results
in an exploding kernel when its IPIs have been unconfigured.

In order to catch this, check for the silly case early, warn
that something is going wrong and avoid the above disaster.

Signed-off-by: Marc Zyngier <maz@kernel.org>
---
 drivers/acpi/irq.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/acpi/irq.c b/drivers/acpi/irq.c
index e209081d644b..c68e694fca26 100644
--- a/drivers/acpi/irq.c
+++ b/drivers/acpi/irq.c
@@ -75,8 +75,12 @@ void acpi_unregister_gsi(u32 gsi)
 {
 	struct irq_domain *d = irq_find_matching_fwnode(acpi_gsi_domain_id,
 							DOMAIN_BUS_ANY);
-	int irq = irq_find_mapping(d, gsi);
+	int irq;
 
+	if (WARN_ON(acpi_irq_model == ACPI_IRQ_MODEL_GIC && gsi < 16))
+		return;
+
+	irq = irq_find_mapping(d, gsi);
 	irq_dispose_mapping(irq);
 }
 EXPORT_SYMBOL_GPL(acpi_unregister_gsi);
-- 
2.29.2


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  parent reply	other threads:[~2021-04-21 16:43 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-21 16:43 [PATCH 0/2] arm64: ACPI GTDT watchdog fixes Marc Zyngier
2021-04-21 16:43 ` Marc Zyngier
2021-04-21 16:43 ` [PATCH 1/2] ACPI: GTDT: Don't corrupt interrupt mappings on watchdow probe failure Marc Zyngier
2021-04-21 16:43   ` Marc Zyngier
2021-04-21 17:14   ` Sudeep Holla
2021-04-21 17:14     ` Sudeep Holla
2021-04-21 17:20   ` Sudeep Holla
2021-04-21 17:20     ` Sudeep Holla
2021-04-21 17:57     ` Marc Zyngier
2021-04-21 17:57       ` Marc Zyngier
2021-04-21 16:43 ` Marc Zyngier [this message]
2021-04-21 16:43   ` [PATCH 2/2] ACPI: irq: Prevent unregistering of GIC SGIs Marc Zyngier
2021-04-21 17:15   ` Sudeep Holla
2021-04-21 17:15     ` Sudeep Holla
2021-04-21 17:56     ` Marc Zyngier
2021-04-21 17:56       ` Marc Zyngier
2021-04-21 18:09 ` [PATCH 0/2] arm64: ACPI GTDT watchdog fixes dann frazier
2021-04-21 18:09   ` dann frazier
2021-04-22 13:42 ` Hanjun Guo
2021-04-22 13:42   ` Hanjun Guo
2021-04-22 14:23 ` Lorenzo Pieralisi
2021-04-22 14:23   ` Lorenzo Pieralisi
2021-04-23 13:43   ` Catalin Marinas
2021-04-23 13:43     ` Catalin Marinas
2021-04-23 17:11 ` Catalin Marinas
2021-04-23 17:11   ` Catalin Marinas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210421164317.1718831-3-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=dann.frazier@canonical.com \
    --cc=guohanjun@huawei.com \
    --cc=kernel-team@android.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=rjw@rjwysocki.net \
    --cc=sudeep.holla@arm.com \
    --cc=wefu@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.