Skip to content

Commit f818227

Browse files
ouptonwilldeacon
authored andcommitted
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 <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: Zheng Zengkai <[email protected]> Cc: [email protected] Fixes: 263e22d ("ACPI: GTDT: Tighten the check for the array of platform timer structures") Signed-off-by: Oliver Upton <[email protected]> Acked-by: Marc Zyngier <[email protected]> Reviewed-by: Lorenzo Pieralisi <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent d923782 commit f818227

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/acpi/arm64/gtdt.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ int __init acpi_gtdt_init(struct acpi_table_header *table,
163163
{
164164
void *platform_timer;
165165
struct acpi_table_gtdt *gtdt;
166-
int cnt = 0;
166+
u32 cnt = 0;
167167

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

190190
if (cnt != gtdt->platform_timer_count) {
191+
cnt = min(cnt, gtdt->platform_timer_count);
192+
pr_err(FW_BUG "limiting Platform Timer count to %d\n", cnt);
193+
}
194+
195+
if (!cnt) {
191196
acpi_gtdt_desc.platform_timer = NULL;
192-
pr_err(FW_BUG "invalid timer data.\n");
193-
return -EINVAL;
197+
return 0;
194198
}
195199

196200
if (platform_timer_count)
197-
*platform_timer_count = gtdt->platform_timer_count;
201+
*platform_timer_count = cnt;
198202

199203
return 0;
200204
}

0 commit comments

Comments
 (0)