From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=205.220.180.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796246496; b=LuzXszm5qwLNtQKRe6J3tHcTCIis4dtCVKw9ATPqEBlyBzpyrnsNVsA6y7N5xjAFCmB9 q3OTa3P3uWsqoeAvf1KQEKA3lKyGM/HAmWiv2TuXfabx57uDNrpJ50v8uMUdQ+nUkXxUy AylMKGfoaoFKtfrcvgxl3B9WD+qlfRzdb/1GAZVUQl6ehq4hQqFdwEDUaFyMNy8YPJ64p k1tbK9bmsmOvL27cEYD2A9DwBxN65qnV45+hbHbi9DP9sC2XNeAWlLTZ03EELSMCH29iR xqq/BZClnzkDqnA5xFfbcpeBd8v4EZWH+6WtW/2QRu2mdVb4tQzNfJ0FlyplvfbaWEA== 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-Spam-Info:X-Proofpoint-GUID:X-Authority-Analysis: X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Virus-Version:X-Proofpoint-Spam-Details; bh=z8gnjv/UM4ImQY8OOuormJBN278/MPnTL+KXvR76+Sk=; b=OVtm3/C1iYGjDB6xk2xNdzORvIi7eRBeltGWfAeyGV211qDd4BP5FoBeSTJM71gepw5o xN+qTJD20yk8HnWmpsVGaoKMLQ2KygpeuoYdVDO+uEedMAX3NRaSkKi02tHwdGWbqeFz5 nCPWeRBPdNPmQ388HBEau5QqsArvEx7MZqT4wyh7SUeS4Aa3yQ59hXxFTw8u7HHuie5B8 3mjz5HHuf4Z5tRKPXyCL2s7kOLQyUbGGgJWip+DuLRC+DW1Wh5SEy6ibzdI1V3scXovUA +A6X/mwRoiqxRTg3x/L+CmuMH0M3E426X6BLZaJcBRZ6Xr9/TNBEWNfd/smESwHPl7A== 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.180.131 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 608FA606A32D for ; Wed, 2 Dec 2026 21:21:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 608FA606A32D 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 (m0279872.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6B2LGd5a1425039 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 4jamyp9psx-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 02 Dec 2026 21:21:35 +0000 (GMT) Received: by mail-dl1-f72.google.com with SMTP id a92af1059eb24-1b592e9841bso14803284c88.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=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=BrDBDiRlccT6RZJ/uWLxIB+6DjEHuctmUe2FSUbw3XY/Q0TDnfdJsZTzDPXzzlebr5 ncVUJrSyfawdvdBKHlvMrgFVmt0LY3ywkbvuhviMTCDxmwxwDkpsfkUeSor/HQYFTFgK v4yDyBmBBIwBXZnbo14VxvehpW1OR7r6iXJEjzeIfw/ghzKqiDwmyI5JJMB5ULiMQyWu AtnpazeFCNAeMwg7BQIhfQR8h/U+rt7ySOB2sAJ2yaGWc2hvARP8zF3wejBA9jZbbkXS IP+Ub4k8mNA+DYO4F3jgfvru2sWoL64Ft5oM7mydQ5DPXjzIVhxmGLAFGH02m+Hk3bOx RC0g== X-Forwarded-Encrypted: i=1; AL+hErFR0rTvniEJE3a7ls5v6SBFoQuWh5IIdLWb6Bd7YpnKXgy0ovz8Cn8x1pMy8sPtRSgc1cqdav/XgJE=@vger.kernel.org X-Gm-Message-State: APuU4Z+SoWk2NxD3JF3BZMOYGQoXd6z0MN/tQV2Q20Q/pBKScy/lagSO M8ykTKDdyGCvo94IFm2Y/LdwWuSeBpAaIH/8mL+I1s9bCgKxpzzhoDNJYzuu+rBGUbSU6yyAApL Kzew5PG/uqe9OJEZvuls3qOkpg/4Z/C5LRwV6sevR6LuosEgrA14NsyG563IwIE0= X-Gm-Gg: AZFdTZdkNVjQvW69lUkwhA6P/l5LT/rRixH6g9HUsxtWAAOzz96llVQBvYYTFyJNdUh +30hpu7LSBCvgAvggevXq6IpVV8OsuO0ipJWT71IX+TDaGGu7J2yEs4cQuwXQ287VECjIAk/75R xfNxTsOWivUZWDF10qBKvDgG30RSpHSuf163p/FGdb9Mb1PvoWLZGh7AMedLhr37AgW+u6+HcFC vPArBGvbig3vKr8FKMIpUqsKN3ojEDxUmOHaorUJ63w3CB9FWnNUJwSDocKHqvZi8VvZL+0oSGr 8zK2ybNTQOfAMh3uoLiOMoPTNW5XUqDv+47ZljP2Gc/yRyMejk9Y1q7JiEWE+S/mH1AlfAYigmv 8Oyxl6ikgO/DKXowPguKpXCN4RMVGfLsyWgPInqMf549ii83XsNTDxumJwAMIpX8RbF9QBUlmeE 6xf7Tp/xJFeKaLJujEMmv1DCLigWQ= X-Received: by 2002:a05:701b:2504:b0:1b5:b252:cd68 with SMTP id a92af1059eb24-1b5b252cfe1mr11176253c88.15.1796246493608; 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-doc@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-Spam-Info: AW1haW4tMjYxMjAyMDA4NSBTYWx0ZWRfX6wpI3wvQBtlS KDA8OgrAYsjxaSUb+FApQdHV8lKSJ4q5Q1dK2jlDFV1HhpQ6hxwPb/swm0YfJSPDuJTUFYcCuPT ymyD4gLjlTHc6wgM1GnOBOaE8uvGcPM= X-Proofpoint-GUID: 7P0aSza8p0RiT9p_S4q-8jJW1w60CXAy X-Authority-Analysis: v=2.4 cv=U/8Hnuru c=1 sm=1 tr=0 ts=6b108bdf 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=yx91gb_oNiZeI1HMLzn7:22 a=Ikd4Dj_1AAAA:8 a=EUspDBNiAAAA:8 a=hxPuknAiZnPdgHUYtZ8A:9 a=CjuIK1q_8ugA:10 a=vBUdepa8ALXHeOFLBtFW:22 X-Proofpoint-ORIG-GUID: 7P0aSza8p0RiT9p_S4q-8jJW1w60CXAy X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAyMDA4NSBTYWx0ZWRfXyJ7tUjCnnu2m uDU4uJviUrkTkPscCEzU7BCm2Kiu6xx7/3UiegwWXqgRXCIyKnVOKuedYghErDqg0SY4qU0Np6X NEa1lfNV7qg/3V2mavzhyZ5eY5FrjBG7lAcoFLxH60r02QPrJU1sa602E07+gq3MfqZD6nCIISe Byyb+myPxT1p5cL0BJ0bHvDXqLvmCW/oRC04w/cx+AeyfalAEM2y7UAXZ144P/z5R1s7I0Ug2Vi bMOnJOmzIwgeSqV65bK6s/0XSbjHayvbxfQLLNtCKFoyxnvZ7eUSRTUZR44YX8sk7O9/tIAC2NL YoHHTfqC/lnnt2id+Mtmwx+OwpJkkFd5HgkDCBuK4c2JKuupjrJzlI3dGSOO7SYsLAeD8lCpLaa Way+MTe0c4Avm81AyNdXe3IKXwMryJMqq+cVrOpMS3Dh68q/18JZERRP1wPv0c7Gy4feD+8I9JS JyKYTJVtVi4Yemt3ZAA== 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 impostorscore=0 priorityscore=1501 adultscore=0 spamscore=0 phishscore=0 clxscore=1015 malwarescore=0 bulkscore=0 lowpriorityscore=0 suspectscore=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; > + }