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 76BA2606A322 for ; Wed, 2 Dec 2026 21:21:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=N0bvNbEM; dkim=fail reason="signature verification failed" (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256 header.s=qcppdkim1 header.b=hNUz+3CT; dkim=fail reason="signature verification failed" (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.a=rsa-sha256 header.s=google header.b=JOjsaXfQ DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id: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-Unsubscribe-Post:List-Owner; bh=TRX1es6+rj+u/LzVR8dzr4f4B3GJVrav6lTeH6GfaWs=; b=N0bvNbEMlcVSJQlmCcObE2nYHF rLpwhQh9ophW+JzR5Ufu2wdH48MLKLCIUT/5uPE/GPRUC2LEhaBAjgncTQZ0oIxGV3e032U5k2qQm Uqi3LJQIBr+H99yztEP+gBTmgwT5D6vkuEIDlg4xuCJkX/cnBX3DL8rdM+5oOfF9kFwdeCgcD9Tcr 6/LovbGUK/LbAy7S8RHhu6OL/g+ZejnpIz7EfuqRaRBlLoh12/BbxQ/QX8JHaL8PmbuaL5mtK/nu1 D3Yp6zu+glVx4jCWmbrAS+DoNLNe4aJhk3C9+ZTIN7pepsHiIy2JxPkClAnCDknHbpThvdnskxqHr 3KGhlidg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYrlj-0000000Cobq-0epw; Wed, 02 Dec 2026 21:21:39 +0000 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xYrlg-0000000Coan-39I3 for linux-riscv@lists.infradead.org; Wed, 02 Dec 2026 21:21:38 +0000 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2LH8fj1959423 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 4jamhystqm-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-1b592e9841bso14803271c88.1 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=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=z8gnjv/UM4ImQY8OOuormJBN278/MPnTL+KXvR76+Sk=; b=JOjsaXfQsLoYKdnq8/7KXAzoi2QYTfUtgGnOaGGoc7fLKaq7X7QHLva6779oQvVAsi DAxQaGQHbDY6y+amAOAq5Txse1f+DLVz9vG/r4LwXECbuw4GRA2RS7UQvxW1zLIosmTI m5iDDQ4kg/v2QUOasHVy57wthmcjIzdtPid2F+ZCWYpIEa50NFI7zWBfXZ6nM2+X1bhP sZkKGJ+N8N4LoiuAZolk6DX16Lp3inCF8SJlJbHdkXQ+v7y7kv9NTDha229jeLj9iFyC z35u8TQo6DIxE6HqrLclp0wYlNEHt9Or7IEZOXI0d2Z6DnPoON0ZfPSIkLXpNze3iSVe YDtg== 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=Og2MoaqzuxLAMTQYfqrk00QsRqhc/P+2E7vmwxhJQLCnS2QqXVMo/zpRI5tQ5mXorG EAsoZy5+g9ym3o+5Kh+zcjCFk1NcKWgBvVmTwgSUif+8UgY1OZgqtUIGsOaAbHGVCGRF LErnQ77YTkpYeJmmWm3EcySPFGv+9s4y6fP+7p2oaOqDoxE8Ka8SWgXG70UeX8eYwYRN XUjbWRqBJFFYuulqZoDXI/6sUHPGHsvtwoxjNEz4wKVuQMvEJPaQoEYNFmCLe/5kt2yt 0KlVjlvYYPraQ2CAi7NOC8W76WVg10bpvbhjMv2S2LeXhYSTEac0lqZ97GMlB5yt1OHr CHKQ== X-Forwarded-Encrypted: i=1; AL+hErFSlVRuMs3O0vIqqhDdjbyUxcrtUIpgElmADeoQMx4WdQlWk7p4xuf0GT/Hw10bgyLDcCGTP7FXqE+92g==@lists.infradead.org X-Gm-Message-State: APuU4Z/UMrUj188U1YmKmwZ0JWXvgKbKkuc74m0UkPY78zZp13wGaP0P S+hUtWa5/rdwn97u3bUQo0nuQ9FF9Mm3xvUmC69XjeNqh/zwbed2o/Iy6nFUMWPuqgj+rpXZrv+ Sr24Vjimc29iZ6ILu9CLI/IceuqtPYruiQabZ1kaMwx4INk2yv1lJAsovs9irJZfHSVclTdE= X-Gm-Gg: AZFdTZdMYtDkEA+Y1wXN0MBargVE1VbEaEOP0DHDzTQ01QhQ5OeKqfPEs9I126eEadq CBMQ0BcyjiFOV6fWUh79OrKcjK/okFRmFeVBcxxiTPbFc7CZaxwkwreNvN76KjEfymfDVxIrB/v yWtcgJ38l+fbyaNINpQ5FJqb0hKwhyhtQz4Jh7sWvlIIuEJsMcfOLq2kY6JVQPTy4yuRb6laHv3 hEgAphkDf607CR+uSi6R/rGQbpK1DxI1NF60RUn5LtX8HlZIO2Ml9QxTcBRlstcowqhVK9IZGmZ f4B/TXH1etFwBiMEg/qY5uqc5AjKuO1XmrVhrc6GW36RzXzr+EdIYJcXbAd5fdRsLPhDthZ+h3N UpX98MNyb61+iFHFUHy0WbNP+fgEdgKodFCeoOGS43mFqC+gBv7U4kyyYMqmI56IjMqpUzol4Rd ULQnW0b1026u3D/J2fel7ITEPIzdk= X-Received: by 2002:a05:701b:2504:b0:1b5:b252:cd68 with SMTP id a92af1059eb24-1b5b252cfe1mr11176257c88.15.1796246493614; 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-Archived-By: MIME-Version: 1.0 X-Proofpoint-GUID: OUwUsPg_Dxm-xQ_dOjKqHRlKXcAj5neU X-Proofpoint-ORIG-GUID: OUwUsPg_Dxm-xQ_dOjKqHRlKXcAj5neU X-Authority-Analysis: v=2.4 cv=E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point-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 impostorscore=0 lowpriorityscore=0 spamscore=0 adultscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 suspectscore=0 malwarescore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2611040001 definitions=main-2612020085 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20261202_132136_937389_1D25322F X-CRM114-Status: GOOD ( 31.31 ) X-Spam-Score: -2.8 (--) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-riscv" X-Spam-Status: No, score=-15.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,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, 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; > + } _______________________________________________ linux-riscv mailing list linux-riscv@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-riscv