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=ktXPkVGiynaNtiTZGLZKhrm8er1hwT2dniUAoQMuvhU6ri+452OWFhFygqyKKkoefSl6 hS1XtEHX2l63gUKIRCEJHe4fMoqOR9qlWDYmNoiwKe94vyvK7MzfTMYOgZjW2RCR6N40Q p1gBYGBSJUAcXS01iRJM/8xQmd2us9HoYHSDMS9+x0M2N+o/Gx2czNMOA2OGZlRIr7nL7 5AbT6IAOp9Zf0BwUG250DJasRDu8GJUpuvXIEbCDRaY9wGF7jRz2WaK5rBoiLS2TB9PXa cNBpM9eMse9Ih346lBKpR+4lWV+29dYdMGruZEcpd3L433/K18AFokU4m+wBuA6ivrA== 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-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Info:X-Proofpoint-GUID: X-Authority-Analysis:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=z8gnjv/UM4ImQY8OOuormJBN278/MPnTL+KXvR76+Sk=; b=s3jdWH6uTza7MgpeUgYP5G9RgDyvQn0MVwGLDYzB81kZryjJ+PTLfVfByDYsstj+gLJw P8fqaRTO6OszuD2lY09k+XxSbDbBQW+J7RN9+jA32X0VECMsKuoOCQlQ99LDe3ENtKrSq yop6HwRLD1eFIOR/yYsTrB1yD/iA0/mc8GpRHu/+9izA/m8tfvBtwzmgaSe1stiVzS87f Ocl9lt6B9Ta83z58uIkzrdfynmE3uUgi7vPgbj99kA6mOwWKKntRyePsxQYu9TyF2QGpK FVt4LCWGGipYK9dOK3TMZj1TEajsNOU7eHCNN5MVykLEW4vUhMfsYL5Sv+MR+wDG3zA== 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 74A88606A322 for ; Wed, 2 Dec 2026 21:21:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 74A88606A322 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 (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2LGuN71854500 for ; Wed, 2 Dec 2026 21:21:34 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-f71.google.com (mail-dl1-f71.google.com [74.125.82.71]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4jahwjtes6-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-f71.google.com with SMTP id a92af1059eb24-139b62317d0so21067122c88.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=dMvvAGMMw6X9H6DR2l5ZfK6lJm4bVbdtfnJli+6pUXkpz5PbVQsUHyEmgbOcZOfqtj 4V79MfPEJgBLoM50OywRrc1xnHZBMNW4z4oT9BvUbQTkQj+UIWlOcHdym6MDBEWRG6Uq oFcWjUmD2abxug3hDMD02PD99ze2q7p9xVrijWf/T8z98PLGjL24a+RRFmHFwuAQncdQ 1Mjq5ZPWpJPqmQzA0/Bb3L4YMIHaFNhj32O+GwydAZajrkjuSLLrXh15u7CwDiQpGugc MUp1+1uZpgT2fhGymRA0aaEQId8Z/xzJa6jjdjdnT7wM/Q9r120V023i3knvT90No9Q8 QUdg== X-Forwarded-Encrypted: i=1; AL+hErEeZGXuYEjflcv67sLnRYHu8WEDOSMkIH2cn0L2mM9kgteNrbT5nq8FpGXwpsQRvUtPX2JvI29UjkJ6ktRbDYM=@vger.kernel.org X-Gm-Message-State: APuU4Z+1Uc2TvNI+GlruwFnk1NOWT4AsrZrQj9tj+wgnBQat+DMLnOFa QkhlJZLmNlatE1jVLP0ih4t6k20EBbpyN/jOFFIto+mVEtNttHE4feNDmUyWkfO5+Bzl98MHC05 vs9w0v7r3sILqM7IRdNCEchhFD7rhgxG47nfSQWUBLT9Ot+8+LNZw/tUygFeskXOjbRLQsck= X-Gm-Gg: AZFdTZezATg16zQBo94hariX8qzVWlMn8o187qjJlmAVrIajnurxF8mC5B1zxP1xr1j SCmfA/WQi34gZH0CsAPtY0pqp0CTxWzefZCNAFa2EbEijTGOyly6Yv/oG7Aanh40STrZIaONbOj M/BbpcuMx1Zb5pwb3qbB1pRMjyBn9Zb3R6je9hDNEhKU/Egy1ZfE6FdYLM8wC+lsbYT9Ntkbw+K 5Ib7xvvVT4u0lPd7Kn+dKoP9bzuYCwazkktP4inWCSVr3BQ3WSxMz3+o1ImpdOpoPesCN6PnK/g 7R38JQyc2ViaAJlqLCeq6uSESmJlImOTXdwGFOKB5+x3CUhyCre5JuT90q7A6/ZkPmbpuWRcnwn RC06L2slv8L2YQkUO7UnUI8cVqu8HsWPpnNNS8pTERifpFDrc+8lm5aH5ydGIkRjmGedyeuG+2s 2jbrLBNL0Emzt4BVCj1UmVFEXTUE0= X-Received: by 2002:a05:701b:2504:b0:1b5:b252:cd68 with SMTP id a92af1059eb24-1b5b252cfe1mr11176273c88.15.1796246493647; 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-integrity@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-Proofpoint-ORIG-GUID: VWUm4q6yf7ZXtD7beoMOlP4tC2iJT0vQ X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAyMDA4NSBTYWx0ZWRfX/JoxNxZgaBtO lOsu8vK0mG3+1GmcCTlolHv2M67QjfdQ60Tk6uVMpxfyyVOPjkye1cdnQ6B0bOW3dxjBDzZkY3S EmfSYeQ+OXW8LKaWSRkVIRfCT69YOGY= X-Proofpoint-GUID: VWUm4q6yf7ZXtD7beoMOlP4tC2iJT0vQ X-Authority-Analysis: v=2.4 cv=JLuuIMKb c=1 sm=1 tr=0 ts=6b108bde cx=c_pps a=JYo30EpNSr/tUYqK9jHPoA==: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=yOCtJkima9RkubShWh1s:22 a=Ikd4Dj_1AAAA:8 a=EUspDBNiAAAA:8 a=hxPuknAiZnPdgHUYtZ8A:9 a=CjuIK1q_8ugA:10 a=Fk4IpSoW4aLDllm1B1p-:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA4NSBTYWx0ZWRfXxKJpM0owAOCp O8B7F4iomt9+P4GptYNdoaKh5Yb32I/12FQ7yFy3T723k0Ixci1ooimtsDdVMtl7pOXsyOkiDp4 XNmufWhOKB248V97t+BHTSZ+nTX9UU9sH3ezyn8qpLas4kYz6TVGOgVjMlgNhWz+9YttG0t1/Lj zD3KeHogAe3BOf1JLmpV0tyminID3RdIxJ+CZbDA+T1+9cT7qIhWO5EvPSbjUUzOfncWIYCptGy DzPuO2Yvf6wSxFUiU1H7xVi+Kb+4K4GAfVp5w15u6a4hWU5EzrMr/+BJ7kXdgnXXNWdOoopYDdW qL2gFnTgxMH933x/RIqxdDgM9YabuDV+mdOA/RgLNZhJwxtadzXBaZIgeR5l6d9Y/K58iH+Zmhr oRvu1EFEJQWpgSbVDS+EIQQSJ4PWGBejrTow9C5i3yrKfHDAxPz2HH/44n7QBZbMlexaz9JBGjD X5T1RdryZNPW8xZFKLw== 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 adultscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 phishscore=0 clxscore=1015 spamscore=0 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; > + }