From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 D8F7A606A31A for ; Wed, 21 Oct 2026 18:11:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=CI4IrNQw; dkim=pass (2048-bit key, unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=KBq8By91; dkim=pass (2048-bit key, unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=LZ5f+Tsr 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:Content-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To: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=zajgpZEWlkO9hnDwMwdkleexKLADl3q/zhIDBDjaWRQ=; b=CI4IrNQwRxX3gNhxVJD7HRt/IV 3a3c5OfdcjZBgbo8YmIXyU2ZiUF1GopWUmWcWF+6GLehvmtgbGVqUsFG1+sJljf+hVZfzS3OcPVx5 xOKISvw+SCSt3VSdV0+6F0/pzVdfe0xKgJFL+jN2UsyXtJ0KIvy5VUsOOZXY26FBxO2g1n+dFvrxs 0HN1bIHu1bgjZdnoQP2DPwFY4K6xOSIDyZegK6z8VSe0JB4zaagiVR2WgWDgJznt8CrBlbGOlTURn G+GofFPp8bdDsa1LEoLNHWIgF8i+EAO7FwudWQFcfxV8PoAkkj6Bu9+WSt1DZnbr6ntDiCclu74yw vQc+NRBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1xJamt-0000000CdEK-0VBD; Wed, 21 Oct 2026 18:11:43 +0000 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1xJamr-0000000CdDk-0ek8 for linux-arm-kernel@lists.infradead.org; Wed, 21 Oct 2026 18:11:42 +0000 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 69LHpLnF2416099 for ; Wed, 21 Oct 2026 18:11:40 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= zajgpZEWlkO9hnDwMwdkleexKLADl3q/zhIDBDjaWRQ=; b=KBq8By919CR0Wk6J i6AHGYv1uzl0plIu0g/ZjSagDkXy5EsbBsmzhImhAELaJ/l3SfReAUQpWiSHeVNf BufY1pa+JPkBGkez43hmPC7dSe/wTdocSPdgRHEIkjXg+77SAdYjTQAo3aTC702v wIJaXklJi5pC3EQlxvgOlS9JUMDPzA8ux1CypnFa/HaSbozJtLx5c4F1YuTj12X7 fPuROybpD306YEcuArWKV69DugzhWLf5aBj0QG/MFJEbJRpq1GRrz3FGnTg4Sr+J HgvYZbYSilPrBWCFEs8avj6fFE58i34cFDbduqKYWVEMlX2iQVhEPuzZodKWCD3h tK/n4A== Received: from mail-dy1-f197.google.com (mail-dy1-f197.google.com [74.125.82.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4heuhuhyv9-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 21 Oct 2026 18:11:40 +0000 (GMT) Received: by mail-dy1-f197.google.com with SMTP id 5a478bee46e88-36803927a49so1619875eec.1 for ; Wed, 21 Oct 2026 11:11:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1792606300; x=1793211100; darn=lists.infradead.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=zajgpZEWlkO9hnDwMwdkleexKLADl3q/zhIDBDjaWRQ=; b=LZ5f+Tsr7kX6LN5G10szs1ZQl29o17fBbRiBi+U1rKL+S+PYlPxlR152hh+ZrkZE47 x8Dvos2H0CROa2wP6SUGzuPzV1sBDDl0NRUN/EVqKoESklCiVJ3xPyCiZqUZw9SymOgP QJ3b3N/trTNaGVTU0d8Nz+dcgCZDXnDl07Lq+/QrUIVGKYHLYv3XxauTihKDZ6YN+9I9 l/lcFa6VEKIhlyDxHje4X2hORoJZ+jKNFhMbFXJPVE3qBKaLcc1ec1tX1ZrpYpYm8cDV 6iw95TlNZjyO7qHE1D1KheisKX8UUpv4FMa/z9UmqD85MXuPdpL0EOSJOsQf5TX4smMp esSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1792606300; x=1793211100; 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=zajgpZEWlkO9hnDwMwdkleexKLADl3q/zhIDBDjaWRQ=; b=DKbfmXrEOMuQ6ZkGTLS75WEKctK+D48SJ8G70YzEGhZhizKNfz9ctppBnY1npAAN4O T47aHDqNJz9hEkGzYQ4GwxJ9Kc3EQZBKvNxVDjGpzK9Ti6pYZLeattC5OOTmwwHW0S4y NWkomieMfBTa9xhu0gO6poR3UTCUzq1m13pOLJGEbXfg0rAPOB7Gbjuzlwxrjg3AlHfO HVhCgf2FToE56OIWIQDmu1qahUvOWpdFh21TorsgIHSKrxWn/zsS2NgAHx/GevcpoXKv qknPVJSnZgobursLTrEEgx23BRgtd3+w2U6kQ5x3lYgO3xLGb789bhcTGhaLmrchg5Vh iEWg== X-Forwarded-Encrypted: i=1; AKwUvBxz/5Mkm/ehPvWTLYaL5hg0j6u9MDzOfIjnWUkYVxBy1VxvqwcPefj5EGu8tZwY4T9gx5sNVzkytxLxYdVbIZLR@lists.infradead.org X-Gm-Message-State: AFq9FYJdlRIrjapmhhpSzz2CjN/n7rBxN1YdbKL6aNucIgzV9kjjOAE0 aJc1H3Z2H4Nn+5JpKPmlwAkXBeILMNPYsEwZGlQIruHk29YPHSDcwTc7ov0EJimbvqtPUJVF22d A5awzG1VCLGksM67Dw3j7WeHu1UBLNoPPy2GE7MP6EjfZTIQ5NqWxLlN6XsOo8NdO6ed22oijGe X+TA== X-Gm-Gg: AYBFou2xx7nJ6h9m2Zq0Q6gNaSftCk9g7b6vwdK4UTyXoMDdmi2stVqAkKReoVHo7/8 vx1dxiU0EoSFEsQmgRZDxFxQsR4+QmG6C3wfX7iG3ZiKp64+YunpVjpQ5qccRZmNPLxwkX0135J 41go0qPlOyLyDT6MixglIaBC+rBK8HhE+3O3mOyHe7jwV6G63KDcuoEdqI8UxyQtYnJz3vjPUKs TJOVCT22ajxbTSSAx062XT7m/nJ7X0fDQNjp4Y5p+rXumk8MU4wtffHlAZIkGHQ/q9dlDUFMXu4 elBkg7uiUrboNAGezNumU1+1DKWpxHxaNLUisSxhlhuFUdlALbVsp3sJOqW8WM8pdfDKT8QtT7H +gmtnC8SdVBmRkus9JRKTYytSJfpixPXsdWY+RT0NWdA= X-Received: by 2002:a05:693c:41cf:20b0:358:1f59:48c9 with SMTP id 5a478bee46e88-3674f21a97dmr3790648eec.24.1792606299644; Wed, 21 Oct 2026 11:11:39 -0700 (PDT) X-Received: by 2002:a05:693c:41cf:20b0:358:1f59:48c9 with SMTP id 5a478bee46e88-3674f21a97dmr3790596eec.24.1792606298974; Wed, 21 Oct 2026 11:11:38 -0700 (PDT) Received: from localhost (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-3674206d1f1sm9116156eec.28.2026.10.21.11.11.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Oct 2026 11:11:38 -0700 (PDT) Date: Wed, 21 Oct 2026 11:11:15 -0700 From: Jonathan Cameron To: Jason Gunthorpe Cc: Alexandre Ghiti , Albert Ou , Ard Biesheuvel , Arnd Bergmann , Catalin Marinas , Jonathan Corbet , David Sterba , Ilias Apalodimas , linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-doc@vger.kernel.org, linux-efi@vger.kernel.org, linux-riscv@lists.infradead.org, Mark Rutland , Palmer Dabbelt , Paul Walmsley , Randy Dunlap , Simon Glass , Shuah Khan , Nick Terrell , Will Deacon , Alexandre Ghiti , Conor Dooley , linux-integrity@vger.kernel.org, Palmer Dabbelt , patches@lists.linux.dev, Piotr =?ISO-8859-1?Q?Kr=F3l?= , Ross Philipson , Sami Tolvanen , Song Shuai Subject: Re: [PATCH v2 15/15] efi/arm64: Implement ARM64 DRTM in the stub Message-ID: <20261021111115.00004c5c@oss.qualcomm.com> In-Reply-To: <15-v2-989a18390eb1+486-arm64_drtm_jgg@nvidia.com> References: <0-v2-989a18390eb1+486-arm64_drtm_jgg@nvidia.com> <15-v2-989a18390eb1+486-arm64_drtm_jgg@nvidia.com> Organization: Qualcomm X-Mailer: Claws Mail 4.4.0 (GTK 3.24.51; x86_64-w64-mingw32) X-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=d4JgWhjE c=1 sm=1 tr=0 ts=6ad9005c cx=c_pps a=Uww141gWH0fZj/3QKPojxA==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=kj9zAlcOel0A:10 a=660iZSQnnn4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=Ikd4Dj_1AAAA:8 a=Sk9Lk7371zlc0StAK_oA:9 a=CjuIK1q_8ugA:10 a=PxkB5W3o20Ba91AHUih5:22 X-Proofpoint-Spam-Info: AW1haW4tMjYxMDIxMDA3MiBTYWx0ZWRfXx7kWmgQScLy6 +Onbdv/Ex92kzHqoyQ79l3BnoVAaKzvwdVMT9JZfzhYKsp7zmolCQNte9udCih8ckbu6GDk3snf bJXQlUU/g7HTQu2KHoQUWPCsazHMieM= X-Proofpoint-GUID: CxSxzeIxV9JUrS-JVkogQDJDDhvSjt9D X-Proofpoint-ORIG-GUID: CxSxzeIxV9JUrS-JVkogQDJDDhvSjt9D X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMDIxMDA3MiBTYWx0ZWRfX22UXKG34gNNV r67I+A7T44oOJ4jTC+SqM6I3Dy2CV7b4XHlVRYN5UW3zd+l+Eo6FuXJYC6PjTBtDlmqhcu+NA0R oJfiHQ+CBIy8vm7cVoerkulle+DqfDYBpuzOQfmmxUrkrNXY/CUDdOpI9kfncnWXoNR+kE5zW4z beCmjCe7fdKuquavVpGPEEfewwRdHlsWcLNLNgm9BK3Lr+pEciRPLswjbJHtcYs5gDaS6WIRiW9 QSYPo73kj7gC/dNdqSQxUIVLT5pbleo1hbHUvyVoBmGc7mTAl/j00yMsc/0UcxneF9zjpb99og9 FUxZBZoPVp8hNJnAQ6yWUfY41E6dbaABB0nVs5CEM+pPAK2QEtKBeBT6bv84iR81qkPwIhTGZD0 48IFR45I7ypf7zOjPJQ8h4L6Fz3dNC9oixwsDoiGvR8J100SUxP3orpVsRDh65HOsRnBnkHpQx2 rnMDdIvtJT9VqB7i5Bg== 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-10-21_05,2026-10-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 suspectscore=0 spamscore=0 malwarescore=0 priorityscore=1501 adultscore=0 impostorscore=0 bulkscore=0 lowpriorityscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610190000 definitions=main-2610210072 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261021_111141_243947_4948B408 X-CRM114-Status: GOOD ( 37.69 ) X-Spam-Score: -2.8 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-17.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_2 autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Fri, 2 Oct 2026 20:31:52 -0300 Jason Gunthorpe wrote: > Provide an implementation of the CONFIG_EFI_STUB_DRTM protocol for ARM64 > DEN0113 >= v1.1. > > First, it queries the FW for support and collects all the > information. This is needed to compute the extra_size, which comes > from FW reporting how much memory it needs during the launch for the > DLME Data and DCE-owned data. The generic stub ensures there is > trailing memory after Image for this. > > Then the DRTM_PARAMETERS launch structure is computed using the > offsets in the efi_info. > > Finally, the stub does ExitBootServices and calls the actual launch. > > The feature discovery process is deliberately fairly verbose to help > debug any FW weirdness in the field. Enable it with efi=debug > > It looks something like: > > EFI stub: DRTM: interface version 1.4 > EFI stub: DEBUG: DRTM: TPM algorithm 0xc, TPM hashing unavailable, PCR schemas 0x1 > EFI stub: DEBUG: DRTM: minimum DLME data 73728 bytes, Normal-world DCE 0 bytes > EFI stub: Decompressing Linux Kernel... > EFI stub: Generating empty DTB > EFI stub: Exiting boot services... > EFI stub: DEBUG: DRTM: will launch, selected launch features 0x0 > [ 0.000000] Booting Linux on physical CPU 0x0000000000 [0x000f0510] > > Eventually the launch'd kernel is going to require built in crypto > libraries that match what the FW is using so it can validate some of the > information left behind during early boot. Refuse to launch if these are > not built in and build in the most common ones from the ARM64_DRTM > kconfig. > > One nit, if the platform does not support SMC then using drtm=auto may > crash on the SMC op. As far as I can tell there is no way to discover SMC > support through EFI. Learning it from the ACPI FADT is doable and costs > about 250 lines of code. Ouch. Sounds like a must have if there is no easier way. > > Signed-off-by: Jason Gunthorpe One thing inline that confused me. Otherwise seems fine to me > diff --git a/drivers/firmware/efi/libstub/arm64-drtm.c b/drivers/firmware/efi/libstub/arm64-drtm.c > new file mode 100644 > index 00000000000000..2fc58babc3e7cb > --- /dev/null > +++ b/drivers/firmware/efi/libstub/arm64-drtm.c > @@ -0,0 +1,426 @@ > + > +/* True if SMCCC 1.0 or later is available. */ > +static bool efi_arm64_psci_smccc_compatible(void) > +{ > + struct arm_smccc_res res; > + s32 status; > + > + arm_smccc_1_1_smc(PSCI_0_2_FN_PSCI_VERSION, &res); A function that is meant to check for smccc 1.0 is using the smccc_1_1 namespaced calls? Maybe add a comment on why that is ok to do. Is anyone actually using SMCCC 1.0 on systems like this? I a bit surprised we don't have a common helper for this - I guess the version checks are often explicit in a particular driver being bound. > + if ((s32)res.a0 < 0) > + return false; > + > + if (PSCI_VERSION_MAJOR(res.a0) < 1) > + return false; > + > + arm_smccc_1_1_smc(PSCI_1_0_FN_PSCI_FEATURES, ARM_SMCCC_VERSION_FUNC_ID, > + &res); > + status = (s32)res.a0; > + if (status == PSCI_RET_NOT_SUPPORTED) { > + /* > + * SMCCC_VERSION was introduced by SMCCC 1.1, so firmware that > + * does not advertise that function through PSCI_FEATURES is > + * using the valid SMCCC 1.0 baseline. > + */ > + return true; > + } else if (status < 0) { > + return false; > + } else { > + u32 version; > + > + arm_smccc_1_1_smc(ARM_SMCCC_VERSION_FUNC_ID, &res); > + version = res.a0; > + if ((version >> 16) != 1 || version < ARM_SMCCC_VERSION_1_1) > + return false; > + } > + return true; > +}