From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE551CD4851 for ; Fri, 15 May 2026 12:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:In-Reply-To: Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uBzfgW0qtBXhxFvclZQRqwoWEvow81+l0PS3ctqnHQY=; b=ZgieGyhK5tJ5KDLUm++RCQSyjQ 9VkVgb4IhSEH7CPFJAx4iP2JNQtRzXrlgIGps7g85CiuZWa0FQENUDRHUY28VsDdAVOzaAxpHJGyN lYkAGP20/8Fq/URF5z0iwYTC6dFHAGheITreFanQWbSbXo/XlA8WhnsBU4duXcXnbvEHfSNRiFP+J kXbbjcPpxtoEVUIb0GGfNKw04gD09mVw4cLjuBXgiMZpJ2BmjS3jq8/dmf8CEIYbMFuBINqZwVv7N MwZvzOENU3lD2MXAsReBM+5x8Hhj2YVH3hGGVruh0BxjjstQ2GIZfmq9NxnQI2k+vXT1cuGaoPPTU gtHmPS6A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wNs1g-00000008NC6-0HN4; Fri, 15 May 2026 12:52:24 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wNs1d-00000008NBS-0Svf for linux-arm-kernel@lists.infradead.org; Fri, 15 May 2026 12:52:22 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id 1311B43EB5; Fri, 15 May 2026 12:52:20 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C40FBC2BCB0; Fri, 15 May 2026 12:52:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1778849539; bh=5o6LcG/vxhfqiQV9se/iRFOt5vrH9A9e5YPVJb41mtw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UXNXeVPzBEGfGCmQ6Zh9balsm9/02tDjxIvzcZ74o357Kj3TLMs5Xfcb9ZDKWUHZs ig7KXiHw98Zc3EGJ78sJw2h326fCayz5R/+BRUwjc5/6zwFqc9FuG7MRZUMBo97aXs m41dbxwzJ11MrhVgLwvHa/mYCcdwkV9SlTVec9IKa99pdqnAIgvOIQzkqNQmw6H8Oq WysXyObH5DQ32PZJn0Zpwcwr5HSwpT4UwCutUx1cqseRCfhexogpZ36ByUxcGZF3VY McM+sIfpFi/ln6F0XyLSohKlvmXH4fV41RMlYusKqxXUhqaOsn2rdi2KpJVCNGjQn+ UqTD9IdYw4Mrg== Date: Fri, 15 May 2026 13:52:10 +0100 From: Sudeep Holla To: Marc Zyngier Cc: linux-arm-kernel@lists.infradead.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Lorenzo Pieralisi , Hanjun Guo , Catalin Marinas , Will Deacon , "Rafael J. Wysocki" , Mark Rutland , Daniel Lezcano , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Neil Armstrong , Kevin Hilman , Jerome Brunet , Martin Blumenstingl , Ge Gordon , BST Linux Kernel Upstream Group , Jesper Nilsson , Lars Persson , Alim Akhtar , Ivaylo Ivanov , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Dinh Nguyen , Matthias Brugger , AngeloGioacchino Del Regno , Thierry Reding , Jonathan Hunter , Bjorn Andersson , Konrad Dybcio , Andreas =?iso-8859-1?Q?F=E4rber?= , Heiko Stuebner , Shawn Lin , Orson Zhai , Baolin Wang , Michal Simek Subject: Re: [PATCH v2 01/17] ACPI: GTDT: Account for GTDTv3 size when walking the platform timer descriptors Message-ID: <20260515-crafty-thundering-frigatebird-ea6db0@sudeepholla> References: <20260514150945.3917510-1-maz@kernel.org> <20260514150945.3917510-2-maz@kernel.org> <20260515-prudent-vagabond-beetle-cad34b@sudeepholla> <864ik8ykzd.wl-maz@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <864ik8ykzd.wl-maz@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260515_055221_278976_5DFE842C X-CRM114-Status: GOOD ( 32.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, May 15, 2026 at 12:23:50PM +0100, Marc Zyngier wrote: > On Fri, 15 May 2026 10:51:52 +0100, > Sudeep Holla wrote: > > > > On Thu, May 14, 2026 at 04:09:29PM +0100, Marc Zyngier wrote: > > > Since ARMv8.1, the architecture has grown an EL2-private virtual > > > timer. This has been described in ACPI since ACPI v6.3 and revision > > > 3 of the GTDT table. > > > > > > An aditional structure was added in ACPICA, though in a rather > > > bizarre way, and merged in v5.1 as 8f5a14d053100 ("ACPICA: ACPI 6.3: > > > add GTDT Revision 3 support"). > > > > > > Finally plug the table parsing in GTDT, and correct the parsing of > > > the platform timer subtables to account for the expanded size of > > > the base table. > > > > > > Suggested-by: Sudeep Holla > > > Signed-off-by: Marc Zyngier > > > --- > > > drivers/acpi/arm64/gtdt.c | 15 ++++++++++++++- > > > 1 file changed, 14 insertions(+), 1 deletion(-) > > > > > > diff --git a/drivers/acpi/arm64/gtdt.c b/drivers/acpi/arm64/gtdt.c > > > index ffc867bac2d60..b9d9b8edf2df7 100644 > > > --- a/drivers/acpi/arm64/gtdt.c > > > +++ b/drivers/acpi/arm64/gtdt.c > > > @@ -32,6 +32,12 @@ struct acpi_gtdt_descriptor { > > > struct acpi_table_gtdt *gtdt; > > > void *gtdt_end; > > > void *platform_timer; > > > + bool v3; > > > +}; > > > + > > > +struct gtdt_v3 { > > > + struct acpi_table_gtdt gtdt_v2; > > > + struct acpi_gtdt_el2 el2_vtimer; > > > }; > > > > > > static struct acpi_gtdt_descriptor acpi_gtdt_desc __initdata; > > > @@ -39,8 +45,14 @@ static struct acpi_gtdt_descriptor acpi_gtdt_desc __initdata; > > > static __init bool platform_timer_valid(void *platform_timer) > > > { > > > struct acpi_gtdt_header *gh = platform_timer; > > > + void *platform_timer_begin; > > > + > > > + if (acpi_gtdt_desc.v3) > > > + platform_timer_begin = container_of(acpi_gtdt_desc.gtdt, struct gtdt_v3, gtdt_v2) + 1; > > > + else > > > + platform_timer_begin = acpi_gtdt_desc.gtdt + 1; > > > > > > - return (platform_timer >= (void *)(acpi_gtdt_desc.gtdt + 1) && > > > + return (platform_timer >= platform_timer_begin && > > > platform_timer < acpi_gtdt_desc.gtdt_end && > > > gh->length != 0 && > > > platform_timer + gh->length <= acpi_gtdt_desc.gtdt_end); > > > @@ -169,6 +181,7 @@ int __init acpi_gtdt_init(struct acpi_table_header *table, > > > acpi_gtdt_desc.gtdt = gtdt; > > > acpi_gtdt_desc.gtdt_end = (void *)table + table->length; > > > acpi_gtdt_desc.platform_timer = NULL; > > > + acpi_gtdt_desc.v3 = gtdt->header.revision >= 3 && gtdt->header.length >= sizeof(struct gtdt_v3); > > > > Regarding Sashiko’s comment about the missing length validation for GTDT v2, I > > realised that the current check could cause a malformed v3 table to be > > interpreted as v2 if its length does not match the expected v3 > > length. > > Yeah, that's overall dodgy. As much as I hate having to write a > validating parser for ACPI, we need to be prepared for the worst. > > > It would be better to fail early and return an error rather than allow > > processing to continue with the table incorrectly interpreted as v2. > > How about something like the hack below? > LGTM and might please Sashiko too. Reviewed-by: Sudeep Holla -- Regards, Sudeep