From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796246496; b=GKY9TZzQHzbmF0S3grXzGR9X6OmyUwODau6XqXPFv0b/slB+a1k4Gsr1T3PIdSMR/c7U YVCKDzwO2QAMm8ILWTSBCVKFXHYbOov1MMgpXwkkBhxlX15SlXXVdr8SOBX0R4ABB7ZXS xNFTxv2dPsoCH9vZxzmetjgQ6r4CPPT90i7jx4I9iANQAhfbIXiz7Dy70MDJU/neHEtcB 2kWQVwTDTiW44As1OaoSsGa7z7XW+c71iNs/OuRkEvbCtX/+2mw6cJCJy4Z6g9xEcGsqb ehPt9IOpFXchDq9FH4FVwTW2E3tla8kg8UqPkoGqmSEuGERpm1uo1FbeGeeMYdpOODQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796246496; h=DMARC-Filter:Received:DKIM-Signature:Received:Received: DKIM-Signature:X-Google-DKIM-Signature:X-Forwarded-Encrypted: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Date:From: To:Cc:Subject:Message-ID:In-Reply-To:References:Organization:X-Mailer: MIME-Version:Content-Type:Content-Transfer-Encoding: X-Authority-Analysis:X-Proofpoint-Spam-Info:X-Proofpoint-ORIG-GUID: X-Proofpoint-Spam-Details-Enc:X-Proofpoint-GUID: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=z8gnjv/UM4ImQY8OOuormJBN278/MPnTL+KXvR76+Sk=; b=VaH/IgzTEQfa8I2hJ8PN0MqNzVL8cVvgB0GbjWQIfBSUuNrz4/rGv+xPWx9ZakmmAr+5 k6zZHPrd2i0XBTgn+4CoGLEBeZ1DX0gblAjcK/I0wR4qDjrRaRz/uq8zN+Z5UC002zEyI XhM3xttsnpwgGxf7isyT3K95oR5fOnxI3YXZQP22Xibfr7A/nIODzPgTLLxCDJwKjYqrr 6kNITNNIIJb98zmKexAJUdHWl8tEtuxw1VSiXCo+/gRost2n17BDDMBGEsq2rJexUWE0b 5NMkovYQ/gMUpeAow36kkaO08EFWl4pDrzUceu4P56Mpz5yY6H2NLAzYnQmGgDK1TGw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=hNUz+3CT; dkim=pass header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=iiWFiZLy; arc=none smtp.remote-ip=205.220.168.131 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75C5C606A32F for ; Wed, 2 Dec 2026 21:21:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 75C5C606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=hNUz+3CT; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=iiWFiZLy Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2LGjQn2795290 for ; Wed, 2 Dec 2026 21:21:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= z8gnjv/UM4ImQY8OOuormJBN278/MPnTL+KXvR76+Sk=; b=hNUz+3CTbty6RBAx mtLAdKwLolDLgY/pILH5ydEhD85TSUBgDrnyEpW9WwwjH10XnDgXYQbbsT9udxfy RkiGe1mjkr6G3xfAUQ5KGZlh5lYpfQF01hF5DsQHA3a5yiiTWCK+t1JP3Gt9ncxT Cy9bvcCr+ukE85R8x4ldKF6hk++jbs7f2uRK2+m+uKTpqGEEMt9ZXIYVOtb4CmME HVEB+vshyxQQgugujQRfYHoShrDaQKXujXYul799cRixzv6HBnJAUAhUce5qyLI3 DNjikTtxbA8gTOWVLg5wygA2L8JlFPXOAirGNhEaH13dvx3MSykTpBK6/7TpJmfH GnstBQ== Received: from mail-dl1-f72.google.com (mail-dl1-f72.google.com [74.125.82.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4jajuq28dh-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 02 Dec 2026 21:21:34 +0000 (GMT) Received: by mail-dl1-f72.google.com with SMTP id a92af1059eb24-139b62317d0so21067108c88.0 for ; Wed, 02 Dec 2026 13:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1796246494; x=1796851294; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:organization :references:in-reply-to:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to:content-type; bh=z8gnjv/UM4ImQY8OOuormJBN278/MPnTL+KXvR76+Sk=; b=iiWFiZLy0/9WJ3ZSF40jIo+h1rB7MIgVfIk+gKjB6u0iby+SKJYX9FaBX8tuMruHYN NMxP+o7svbFh1mSYZx1tnDS+uS9T0itO/rDi8tzCOpoJRg8oJknVBLSVdFsBLiwNte4q XHXTD6D2dmGWtcP8bPZBCQ0lscD/42Xw8ifQJANveX79Eycd4zPfvyYx7cr8wzeeLe7K Fr33kjvDhiKRGAmXtxXZkZO0AyRv7n9/aLMzTNWM5rEm2A8bEqaCh8i3zPUM7b3BwSbl b5OhUhj/vm7m7hmdsnrwDJNwC+vFsZwuqywz8laALFnMJ+Xn6y+khKfhTeICe/UtHXDP Sakg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796246494; x=1796851294; h=content-transfer-encoding:content-type:mime-version:organization :references:in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=z8gnjv/UM4ImQY8OOuormJBN278/MPnTL+KXvR76+Sk=; b=iUFLSzVMu7pmoG0E+wi4F1qWytx/J0yj4/rJQ/RFZJnrc+Ni/lHOspwQ4bLlrN1d90 ySeGj8GcOZT6yGdLk9P0/HAdHR7Io4JL9eXFSk/E8uqei///r6ysQITvgGkNB2FH/oGt VU5WupCoiVLodV6xyUEgJymny+nRkNR9Axf58qH42jlHx4SULyR7VEdiZZk6338EkkfD W5R7yyHe6YwqdfGW7pBozxRtJ4YmKAAem6Xg86EUzDs3HEZ+boAAvNjjWJrIYIodR8mn MMM+y9yIl0+kTPyeBMiBbk7ggT/8gL3dPM5FBR2RcZ4ewKIDpnpOGqBffQQudMp1NzKj 2xAA== X-Forwarded-Encrypted: i=1; AL+hErGMC2V/cVA/m9cD9rvIo168CjcMSl0wMfN1DmlmFoJYV8d7J212NprXO3R0OSumX+64LbgiG0YPgQI=@vger.kernel.org X-Gm-Message-State: APuU4Z+m77SWowg6g6m+MxW5Zi2f5y6pXOig5G5OB9ZjyU1A4pPWSCVU bOTfGPHQaSe9Zrw7/BmXuGwcJorz+uOka6lEo7X8AITtkSdAAvF/nj0ZlFxvJl9fkX2pXA+7eVY 2zdicvLJHAdl6apwKQCxUJuFuPma3Uyhy1oGyV5blWpKOvxBVLCG9K8yXoRjETeo= X-Gm-Gg: AZFdTZc7/ssTcmc5RTCJrYrVgR0BCwPfnlvBHx+235b2YlsUfKfl3er6q6foJYdb+SB U62DL0PS+cGIokTUL9rhkEtmgi9LheUyElBuNnDepjE4or7LAMM0FUnhO+iZvXQYYYmdxwMfH9O U3ZciBnsEaKySgUVZfbd8eASTv9h1Fnx5ROmsw+Kmrj8/gFcrSI6AvgmPUXXGLSEZOLkjHuf0YB TUDbHp7Iu1Gm4V4TV9HPoGyxdjGJ6p3q70pqmc2Y7FIGh1/k+F3780gP2JuxQS4DeboNCfC0nEH rbf5v4qY5Vfmyg/3DY9IX/i+f1ZYWzXDnMHGYRvlh8kPMdLB9MQqE+pPAmEW/nlRWbesoT2ww/Y cDmTRu5+eGN8/mg165XpPsrucKrCaouF+mxlDO3fpDXfdQloITwWKPHDZak8zDVjCeZHqocXCQw nuMj665iTOjE82pGyoHdynChW2jGs= X-Received: by 2002:a05:701b:2504:b0:1b5:b252:cd68 with SMTP id a92af1059eb24-1b5b252cfe1mr11176263c88.15.1796246493625; Wed, 02 Dec 2026 13:21:33 -0800 (PST) X-Received: by 2002:a05:701b:2504:b0:1b5:b252:cd68 with SMTP id a92af1059eb24-1b5b252cfe1mr11176224c88.15.1796246492911; Wed, 02 Dec 2026 13:21:32 -0800 (PST) Received: from localhost (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1b556829d31sm156833809c88.9.2026.12.02.13.21.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 13:21:32 -0800 (PST) Date: Wed, 2 Dec 2026 13:21:26 -0800 From: Jonathan Cameron To: Jason Gunthorpe Cc: Alexandre Ghiti , Albert Ou , Ard Biesheuvel , Catalin Marinas , Jonathan Corbet , Ilias Apalodimas , Justin Stitt , 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 , Bill Wendling , Nathan Chancellor , Nick Desaulniers , Palmer Dabbelt , Paul Walmsley , Randy Dunlap , Shuah Khan , Will Deacon , linux-integrity@vger.kernel.org, patches@lists.linux.dev, Piotr =?ISO-8859-1?Q?Kr=F3l?= , Ross Philipson Subject: Re: [PATCH v3 10/11] efi/arm64: Add a way to detect if SMCC 1.1 can be used Message-ID: <20261202132126.00003151@oss.qualcomm.com> In-Reply-To: <10-v3-22d1a1eb7d2e+17de-arm64_drtm_jgg@nvidia.com> References: <0-v3-22d1a1eb7d2e+17de-arm64_drtm_jgg@nvidia.com> <10-v3-22d1a1eb7d2e+17de-arm64_drtm_jgg@nvidia.com> Organization: Qualcomm X-Mailer: Claws Mail 4.4.0 (GTK 3.24.51; x86_64-w64-mingw32) X-Mailing-List: linux-efi@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=B8QsQ+tM c=1 sm=1 tr=0 ts=6b108bde cx=c_pps a=bS7HVuBVfinNPG3f6cIo3Q==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=WZJADADnZ8VQ7vuQ:21 a=kj9zAlcOel0A:10 a=pUM-KoujPXoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=Ikd4Dj_1AAAA:8 a=EUspDBNiAAAA:8 a=hxPuknAiZnPdgHUYtZ8A:9 a=CjuIK1q_8ugA:10 a=vBUdepa8ALXHeOFLBtFW:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA4NSBTYWx0ZWRfX/V8KqVQpyS6Z hU3Vc4od0YE77IlTQIzhSWDqasxbOjjyQgFCHGNB5WkZu11k+dHc6aLaSWh7GoeL8WQcgAevxNU GTrBXH2IVmH5BXgekE3XSC88qEE5Ue0= X-Proofpoint-ORIG-GUID: 2FfFw63VzW_z1LxoP825Gmtx2HWrcXwt X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA4NSBTYWx0ZWRfX+4CFQPOcvkDt bgyER8Uu243qqk/LUHdIP/ttnSiufP0d549Y/Ggs8khjg8p8FBM24meo9+/ewuf+1863rgDKvQE tvwXwuWlvgug58x3ATJ8HTVunLp+soClQB4+nkOZL1J4M0BjSPPKIIknAq13Q2lnfIZ1JtqiKrN /ldsQuyzex7bJh3SeYlxkcLAHNOmMB3ELegll9fWLEWElfdl4rzWe4wanJnPUxsbErgwdzRkJTV GgmNPZF209B3oGjYfj9wHRs2zdfn1Y2Wjr7yHrPAgCejBzi0fRj8Oo4cekRhGqyFg0vdE4xr0+O qCcYCxLO2YGH+L3n5GRrKSK5zFcInyrUHZI4KMArQozXy51+Tr2izNiObDMAZsKPd8sfouWON8Z 3OMJqa6pxBGukaJRhb8Ogmg19aEsynFMo8YaUBmXzJSJVbJ8vCYQlRBBanrNfsArhXEnhnP05BK ycymks8uvA2AiuCWdRQ== X-Proofpoint-GUID: 2FfFw63VzW_z1LxoP825Gmtx2HWrcXwt X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-02_06,2026-12-02_07,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 adultscore=0 malwarescore=0 suspectscore=0 spamscore=0 phishscore=0 impostorscore=0 lowpriorityscore=0 clxscore=1015 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020085 On Fri, 20 Nov 2026 13:52:03 -0400 Jason Gunthorpe 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 > --- Few trivial things. Reviewed-by: Jonathan Cameron > 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 > + > +#include > + > +#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; > + }