From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Jason Gunthorpe <jgg@nvidia.com>
Cc: "Alexandre Ghiti" <alex@ghiti.fr>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Ard Biesheuvel" <ardb@kernel.org>,
"Catalin Marinas" <catalin.marinas@arm.com>,
"Jonathan Corbet" <corbet@lwn.net>,
"Ilias Apalodimas" <ilias.apalodimas@linaro.org>,
"Justin Stitt" <justinstitt@google.com>,
linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org,
linux-efi@vger.kernel.org, linux-riscv@lists.infradead.org,
llvm@lists.linux.dev, "Mark Rutland" <mark.rutland@arm.com>,
"Bill Wendling" <morbo@google.com>,
"Nathan Chancellor" <nathan@kernel.org>,
"Nick Desaulniers" <ndesaulniers@google.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Paul Walmsley" <pjw@kernel.org>,
"Randy Dunlap" <rdunlap@infradead.org>,
"Shuah Khan" <skhan@linuxfoundation.org>,
"Will Deacon" <will@kernel.org>,
linux-integrity@vger.kernel.org, patches@lists.linux.dev,
"Piotr Król" <piotr.krol@3mdeb.com>,
"Ross Philipson" <ross.philipson@gmail.com>
Subject: Re: [PATCH v3 10/11] efi/arm64: Add a way to detect if SMCC 1.1 can be used
Date: Wed, 2 Dec 2026 13:21:26 -0800 [thread overview]
Message-ID: <20261202132126.00003151@oss.qualcomm.com> (raw)
In-Reply-To: <10-v3-22d1a1eb7d2e+17de-arm64_drtm_jgg@nvidia.com>
On Fri, 20 Nov 2026 13:52:03 -0400
Jason Gunthorpe <jgg@nvidia.com> wrote:
> DRTM is defined over SMCs, but if the stub blindly issues an SMC the
> machine might crash. To do this safely and automatically, the stub has to
> extract the ACPI_FADT_PSCI_COMPLIANT (without HVC) from the ACPI table,
> then check with PSCI if SMCC 1.1 is supported
>
> Implement a really basic ACPI walk down to the FACP and pull it out. Be
> strict about parsing the ACPI. Put it in the drtm file for now as it is
> the only expected user.
>
> Follow the overall design in the kernel and finish up with trying to call
> ARM_SMCCC_VERSION_FUNC_ID like the kernel does.
>
> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
> ---
Few trivial things.
Reviewed-by: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
> diff --git a/drivers/firmware/efi/libstub/arm64-smcc.c b/drivers/firmware/efi/libstub/arm64-smcc.c
> new file mode 100644
> index 00000000000000..a722522e1af85e
> --- /dev/null
> +++ b/drivers/firmware/efi/libstub/arm64-smcc.c
> @@ -0,0 +1,212 @@
> +// SPDX-License-Identifier: GPL-2.0
> +/* Copyright (c) 2026, NVIDIA CORPORATION & AFFILIATES
> + *
> + * Determine if ARM64 can use SMCC 1.1 calls.
> + */
> +#include <linux/acpi.h>
> +
> +#include <uapi/linux/psci.h>
> +
> +#include "efistub.h"
> +#include "arm64-stub.h"
> +
> +static bool efi_acpi_checksum_valid(const void *table, u32 length)
> +{
> + const u8 *p = table;
> + u8 checksum = 0;
> +
> + /*
> + * Nothing this code walks is remotely close to this large. The length
> + * fields are firmware supplied and are used to bound checksum loops, so
> + * cap them to avoid checksumming forever if one is corrupt.
> + */
> + if (length > SZ_1M)
> + return false;
> +
> + while (length--)
> + checksum += *p++;
> +
> + return checksum == 0;
> +}
> +
> +static const struct acpi_table_fadt *
> +efi_acpi_find_fadt(const struct acpi_table_xsdt *xsdt)
> +{
> + u32 nr_entries;
> + u32 i;
> +
> + nr_entries = (xsdt->header.length -
> + offsetof(struct acpi_table_xsdt, table_offset_entry)) /
> + sizeof(xsdt->table_offset_entry[0]);
> + for (i = 0; i < nr_entries; i++) {
Might as well do
for (u32 i = 0;
> + u64 address = xsdt->table_offset_entry[i];
> + const struct acpi_table_header *table;
> +
> + if (!address)
> + continue;
> +
> + table = (const void *)address;
> + if (!memcmp(table->signature, ACPI_SIG_FADT,
> + sizeof(table->signature)))
> + return (const void *)table;
> + }
> +
> + return NULL;
> +}
> +static bool efi_arm64_smc_conduit_available(void)
> +{
> + const struct acpi_table_fadt *fadt;
> + const struct acpi_table_xsdt *xsdt;
> + const struct acpi_table_rsdp *rsdp;
> + u32 length;
> + u16 flags;
> +
> + rsdp = get_efi_config_table(ACPI_20_TABLE_GUID);
> + if (!rsdp) {
> + efi_debug(
> + "DRTM: ACPI 2.0 RSDP is unavailable; SMC conduit is unknown\n");
It is long anyway, so definitely go longer and avoid that ugliness!
> + return false;
> + }
> +
> + if (memcmp(rsdp->signature, ACPI_SIG_RSDP, sizeof(rsdp->signature))) {
> + efi_err("DRTM: ACPI RSDP signature is invalid\n");
> + return false;
> + }
> +
> + if (rsdp->revision < 2) {
> + efi_err("DRTM: ACPI RSDP revision does not provide an XSDT\n");
> + return false;
> + }
> +
> + length = rsdp->length;
> + if (length < sizeof(*rsdp)) {
> + efi_err("DRTM: ACPI RSDP length is invalid\n");
> + return false;
> + }
> + if (!efi_acpi_checksum_valid(rsdp, offsetof(struct acpi_table_rsdp,
> + length))) {
Could use acpi_rsdp_common instead of offset in the combined structure.
Not sure it is much clearer though.
> + efi_err("DRTM: ACPI RSDP legacy checksum is invalid\n");
> + return false;
> + }
next prev parent reply other threads:[~2026-12-02 21:21 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 17:51 [PATCH v3 00/11] arm64: DRTM, boot portion Jason Gunthorpe
2026-11-20 17:51 ` [PATCH v3 01/11] efi/libstub: Add generic arch callbacks for DRTM Jason Gunthorpe
2026-11-20 17:51 ` [PATCH v3 02/11] efi/libstub: Use free_addr/size as the arg to handle_kernel_image Jason Gunthorpe
2026-12-02 19:41 ` Jonathan Cameron
2026-11-20 17:51 ` [PATCH v3 03/11] efi/libstub: Have efi_kaslr_relocate_kernel() handle extra_size Jason Gunthorpe
2026-11-20 23:33 ` Ard Biesheuvel
2026-11-22 14:41 ` Jason Gunthorpe
2026-12-02 19:48 ` Jonathan Cameron
2026-11-20 17:51 ` [PATCH v3 04/11] efi: Add a __efi_data_handoff section annotation Jason Gunthorpe
2026-11-20 17:51 ` [PATCH v3 05/11] efi/libstub: Put the stub's writable data in unique sections for DRTM Jason Gunthorpe
2026-11-20 17:51 ` [PATCH v3 06/11] arm64: drtm: Add macro definitions for DEN0113 Jason Gunthorpe
2026-11-20 17:52 ` [PATCH v3 07/11] arm64: drtm: Update the linker script for EFI_STUB_DRTM Jason Gunthorpe
2026-11-20 17:52 ` [PATCH v3 08/11] arm64: drtm: Add drtm_entry point to head.S Jason Gunthorpe
2026-11-20 17:52 ` [PATCH v3 09/11] arm64: drtm: Call UNPROTECT_MEMORY Jason Gunthorpe
2026-12-02 19:54 ` Jonathan Cameron
2026-11-20 17:52 ` [PATCH v3 10/11] efi/arm64: Add a way to detect if SMCC 1.1 can be used Jason Gunthorpe
2026-12-02 21:21 ` Jonathan Cameron [this message]
2026-11-20 17:52 ` [PATCH v3 11/11] efi/arm64: Implement ARM64 DRTM in the stub Jason Gunthorpe
2026-12-02 21:34 ` Jonathan Cameron
2026-12-02 19:33 ` [PATCH v3 00/11] arm64: DRTM, boot portion Jason Gunthorpe
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=20261202132126.00003151@oss.qualcomm.com \
--to=jonathan.cameron@oss.qualcomm.com \
--cc=alex@ghiti.fr \
--cc=aou@eecs.berkeley.edu \
--cc=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=ilias.apalodimas@linaro.org \
--cc=jgg@nvidia.com \
--cc=justinstitt@google.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=llvm@lists.linux.dev \
--cc=mark.rutland@arm.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=palmer@dabbelt.com \
--cc=patches@lists.linux.dev \
--cc=piotr.krol@3mdeb.com \
--cc=pjw@kernel.org \
--cc=rdunlap@infradead.org \
--cc=ross.philipson@gmail.com \
--cc=skhan@linuxfoundation.org \
--cc=will@kernel.org \
/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