From: Lorenzo Pieralisi <lpieralisi@kernel.org>
To: Oliver Upton <oliver.upton@linux.dev>
Cc: linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Hanjun Guo <guohanjun@huawei.com>,
Sudeep Holla <sudeep.holla@arm.com>,
Will Deacon <will@kernel.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Marc Zyngier <maz@kernel.org>,
Zheng Zengkai <zhengzengkai@huawei.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] ACPI: GTDT: Relax sanity checking on Platform Timers array count
Date: Tue, 28 Jan 2025 11:50:55 +0100 [thread overview]
Message-ID: <Z5i2j9gFB2iyN9g4@lpieralisi> (raw)
In-Reply-To: <20250128001749.3132656-1-oliver.upton@linux.dev>
On Tue, Jan 28, 2025 at 12:17:49AM +0000, Oliver Upton wrote:
> Perhaps unsurprisingly there are some platforms where the GTDT isn't
https://lore.kernel.org/lkml/Zw6b3V5Mk2tIGmy5@lpieralisi
An accident waiting to happen :)
> 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: 263e22d6bd1f ("ACPI: GTDT: Tighten the check for the array of platform timer structures")
> Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
> ---
> drivers/acpi/arm64/gtdt.c | 12 ++++++++----
> 1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/acpi/arm64/gtdt.c b/drivers/acpi/arm64/gtdt.c
> index 3561553eff8b..70f8290b659d 100644
> --- a/drivers/acpi/arm64/gtdt.c
> +++ b/drivers/acpi/arm64/gtdt.c
> @@ -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);
Thank you for reporting this.
There is something I need to understand.
What's wrong cnt (because platform_timer_valid() fails for some
reason on some entries whereas before the commit we
are fixing was applied we *were* parsing those entries) or
gtdt->platform_timer_count ?
I *guess* the issue is the following:
gtdt->platform_timer_count reports the number of GT blocks in the
GTDT not including Arm generic watchdogs, whereas cnt counts both
structure types (and that's what gtdt->platform_timer_count should
report too if it was correct).
I am asking just to understand if platform_timer_valid() forced skipping
some entries that we were parsing before the commit we are fixing
was applied I doubt it but it is worth checking.
> + 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;
I think this should be fine as things stand (but see above).
It is used in:
gtdt_sbsa_gwdt_init() - just to check if there are platform timers entries
arch_timer_mem_acpi_init() - to create a temporary array to init arch mem timer
entries (the array is oversized because it
includes watchdog entries in the count)
In both cases taking the
min(cnt, gtdt->platform_timer_count);
should work AFAICS (hard to grok though, we - as in ACPI maintainers -
need to clean this up).
Reviewed-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
>
> return 0;
> }
>
> base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04
> --
> 2.48.1.262.g85cc9f2d1e-goog
>
next prev parent reply other threads:[~2025-01-28 10:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-28 0:17 [PATCH] ACPI: GTDT: Relax sanity checking on Platform Timers array count Oliver Upton
2025-01-28 8:46 ` Marc Zyngier
2025-01-28 10:50 ` Lorenzo Pieralisi [this message]
2025-01-28 20:42 ` Oliver Upton
2025-01-30 17:37 ` Lorenzo Pieralisi
2025-02-12 10:33 ` Lorenzo Pieralisi
2025-02-13 11:45 ` Will Deacon
2025-02-13 13:59 ` Will Deacon
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=Z5i2j9gFB2iyN9g4@lpieralisi \
--to=lpieralisi@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=guohanjun@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@kernel.org \
--cc=oliver.upton@linux.dev \
--cc=stable@vger.kernel.org \
--cc=sudeep.holla@arm.com \
--cc=will@kernel.org \
--cc=zhengzengkai@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).