Commit f818227a authored by Oliver Upton's avatar Oliver Upton Committed by Will Deacon
Browse files

ACPI: GTDT: Relax sanity checking on Platform Timers array count



Perhaps unsurprisingly there are some platforms where the GTDT isn't
quite right and the Platforms Timer array overflows the length of the
overall table.

While the recently-added sanity checking isn't wrong, it makes it
impossible to boot the kernel on offending platforms. Try to hobble
along and limit the Platform Timer count to the bounds of the table.

Cc: Marc Zyngier <maz@kernel.org>
Cc: Lorenzo Pieralisi <lpieralisi@kernel.org>
Cc: Zheng Zengkai <zhengzengkai@huawei.com>
Cc: stable@vger.kernel.org
Fixes: 263e22d6 ("ACPI: GTDT: Tighten the check for the array of platform timer structures")
Signed-off-by: default avatarOliver Upton <oliver.upton@linux.dev>
Acked-by: default avatarMarc Zyngier <maz@kernel.org>
Reviewed-by: default avatarLorenzo Pieralisi <lpieralisi@kernel.org>
Link: https://lore.kernel.org/r/20250128001749.3132656-1-oliver.upton@linux.dev


Signed-off-by: default avatarWill Deacon <will@kernel.org>
parent d923782b
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ int __init acpi_gtdt_init(struct acpi_table_header *table,
{
	void *platform_timer;
	struct acpi_table_gtdt *gtdt;
	int cnt = 0;
	u32 cnt = 0;

	gtdt = container_of(table, struct acpi_table_gtdt, header);
	acpi_gtdt_desc.gtdt = gtdt;
@@ -188,13 +188,17 @@ int __init acpi_gtdt_init(struct acpi_table_header *table,
		cnt++;

	if (cnt != gtdt->platform_timer_count) {
		cnt = min(cnt, gtdt->platform_timer_count);
		pr_err(FW_BUG "limiting Platform Timer count to %d\n", cnt);
	}

	if (!cnt) {
		acpi_gtdt_desc.platform_timer = NULL;
		pr_err(FW_BUG "invalid timer data.\n");
		return -EINVAL;
		return 0;
	}

	if (platform_timer_count)
		*platform_timer_count = gtdt->platform_timer_count;
		*platform_timer_count = cnt;

	return 0;
}