From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 87B2F30E85D for ; Wed, 29 Apr 2026 10:36:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777458965; cv=none; b=fSdm6+OK3TRpXdDEXBtSlvNd7dAXZ8cHKp5GU/rQ3n73MgsH8SgG6igfp+zoRWow++oy+o2ARFqv5oA3NEpQK06Si058KdFjmYLXVibxyogcBQWW38SmDXouRnKtoF576VoImPeXgmKAR0RV72QqNcPSGdeU2EA0GNORWrfLgYA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777458965; c=relaxed/simple; bh=gEQoOm606sq0QAeMXDk5A5t5RiKdbJXtdZhq1rCtCcc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Z4o+z4IqxL8gOBnqR9OncBNX04t3IYDcOC5jEVw/ywu4o5XVBPq1HepC7B5wjUkgDR64XKQ6Muj5P9399EZUqbmjIcvAJLqYVXimZOq4In8r6N9VZ1o0QiAZAe+vsDqK7lhNt847zjJDfRPNUgp6RHTxTqmLjyrspzvJ5e6m1QA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=s3UbOyqw; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="s3UbOyqw" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2D26D2A68; Wed, 29 Apr 2026 03:35:57 -0700 (PDT) Received: from ewhatever.cambridge.arm.com (ewhatever.cambridge.arm.com [10.1.197.1]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1059E3F763; Wed, 29 Apr 2026 03:36:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1777458962; bh=gEQoOm606sq0QAeMXDk5A5t5RiKdbJXtdZhq1rCtCcc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s3UbOyqwiwf1NDujghcg+67PfHz+/NC6F5J+TBy4mrw4Q7hC00iUreGMvap4NiOBF VJ33w9MfQIbc8mdsoOHoDEsFNDyJobLyZabUUXbAksCfp5ok6+7ohTSjbb8uL/xRUJ 4S/FbqnJKgTXIul0BofwGB4LdyFWgB0p6LAZoMpQ= From: Suzuki K Poulose To: linux-arm-kernel@lists.infradead.org Cc: linux-kernel@vger.kernel.org, catalin.marinas@arm.com, will@kernel.org, ardb@kernel.org, lpieralisi@kernel.org, mark.rutland@arm.com, steven.price@arm.com, aneesh.kumar@kernel.org, sudeep.holla@arm.com, robh@kernel.org, maz@kernel.org, Suzuki K Poulose Subject: [RFC PATCH 1/4] arm64: acpi: Refactor FADT table verification Date: Wed, 29 Apr 2026 11:35:32 +0100 Message-ID: <20260429103535.266728-2-suzuki.poulose@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260429103535.266728-1-suzuki.poulose@arm.com> References: <20260429103535.266728-1-suzuki.poulose@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Refactor the FADT sanity check, such that this could be reused. We are soon going to consume the FADT early at boot for probing the PSCI conduit, and this will be of use. Signed-off-by: Suzuki K Poulose --- arch/arm64/kernel/acpi.c | 55 +++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/arch/arm64/kernel/acpi.c b/arch/arm64/kernel/acpi.c index af90128cfed5..30c7b11a8a9d 100644 --- a/arch/arm64/kernel/acpi.c +++ b/arch/arm64/kernel/acpi.c @@ -118,6 +118,34 @@ bool acpi_psci_use_hvc(void) return acpi_gbl_FADT.arm_boot_flags & ACPI_FADT_PSCI_USE_HVC; } +static int __init __acpi_fadt_sanity_check(struct acpi_table_fadt *fadt) +{ + struct acpi_table_header *table = (struct acpi_table_header *)fadt; + + /* + * Revision in table header is the FADT Major revision, and there + * is a minor revision of FADT which was introduced by ACPI 5.1, + * we only deal with ACPI 5.1 or newer revision to get GIC and SMP + * boot protocol configuration data. + */ + if (table->revision < 5 || + (table->revision == 5 && fadt->minor_revision < 1)) { + pr_err(FW_BUG "Unsupported FADT revision %d.%d, should be 5.1+\n", + table->revision, fadt->minor_revision); + + if (!fadt->arm_boot_flags) { + return -EINVAL; + } + pr_err("FADT has ARM boot flags set, assuming 5.1\n"); + } + + if (!(fadt->flags & ACPI_FADT_HW_REDUCED)) { + pr_err("FADT not ACPI hardware reduced compliant\n"); + return -EINVAL; + } + return 0; +} + /* * acpi_fadt_sanity_check() - Check FADT presence and carry out sanity * checks on it @@ -127,7 +155,6 @@ bool acpi_psci_use_hvc(void) static int __init acpi_fadt_sanity_check(void) { struct acpi_table_header *table; - struct acpi_table_fadt *fadt; acpi_status status; int ret = 0; @@ -143,32 +170,8 @@ static int __init acpi_fadt_sanity_check(void) return -ENODEV; } - fadt = (struct acpi_table_fadt *)table; + ret = __acpi_fadt_sanity_check((struct acpi_table_fadt *)table); - /* - * Revision in table header is the FADT Major revision, and there - * is a minor revision of FADT which was introduced by ACPI 5.1, - * we only deal with ACPI 5.1 or newer revision to get GIC and SMP - * boot protocol configuration data. - */ - if (table->revision < 5 || - (table->revision == 5 && fadt->minor_revision < 1)) { - pr_err(FW_BUG "Unsupported FADT revision %d.%d, should be 5.1+\n", - table->revision, fadt->minor_revision); - - if (!fadt->arm_boot_flags) { - ret = -EINVAL; - goto out; - } - pr_err("FADT has ARM boot flags set, assuming 5.1\n"); - } - - if (!(fadt->flags & ACPI_FADT_HW_REDUCED)) { - pr_err("FADT not ACPI hardware reduced compliant\n"); - ret = -EINVAL; - } - -out: /* * acpi_get_table() creates FADT table mapping that * should be released after parsing and before resuming boot -- 2.43.0