Message ID | 20210421164317.1718831-3-maz@kernel.org (mailing list archive) |
---|---|
State | Not Applicable, archived |
Headers | show |
Series | arm64: ACPI GTDT watchdog fixes | expand |
On Wed, Apr 21, 2021 at 05:43:17PM +0100, Marc Zyngier wrote: > 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. > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Just curious if this is just precaution or do we have a platform doing something stupid like this ? -- Regards, Sudeep
On Wed, 21 Apr 2021 18:15:16 +0100, Sudeep Holla <sudeep.holla@arm.com> wrote: > > On Wed, Apr 21, 2021 at 05:43:17PM +0100, Marc Zyngier wrote: > > 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. > > > > Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> > > Just curious if this is just precaution or do we have a platform doing > something stupid like this ? Without this, it could be really hard to pinpoint which driver messes with IPIs. Having this in place would have caught the GTDT bug much earlier (several years ago actually). The only reason I managed to track it down in a short amount of time is that the driver actually printed an error message before the kernel exploded while probing a completely unrelated driver. Without this message, I'd still be scratching my head. The WARN_ON() would definitely point at the guilty party, and keep the kernel running. Thanks, M.
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);
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(-)