From nobody Tue Feb 10 12:40:26 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 290B4334C11 for ; Thu, 13 Nov 2025 10:36:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763030202; cv=none; b=G2JUDOdmR9zP5up5nmfJZZL5jti4qaplAo5y5B6cUWiBwRoi31nthQFYbPZaaYqNbVQJDG7VNxFIULWlTXp2WJwpSRTz68LR3xJq6DB6HZ64Ut4sxcpJ+O6z9kldA9VWunJ7tFxiOj9UKf8y6EpJV/gendcws2L7Exvq9vRddEE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763030202; c=relaxed/simple; bh=fTjoksev6NSdPOE7J+AhEJwpfMDv/+Zt/Wrlk/KJAC8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Ui8XSxD6Km7Oa5/0x1pnDG0Ub2Mm6FGz1tUXHecgX4duR7PHlBMRfIoUOMBw2YyMkB3ty2O2U///yRuxOP/nLH4TpiOHhCidd34BUyJ8gHDJUm4ikbXlqo+3Hvkxv+sEzaCn+VjPAi6JXwZpgC0R+UZ6W+iSvj/+Wag4nAvO7Hc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=ojTVvO+q; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Paywa9Mn; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject 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.b="ojTVvO+q"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Paywa9Mn" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5AD8YddH2993638 for ; Thu, 13 Nov 2025 10:36: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= 57ueJYK719oVT/uBqCyzf3ryZv6JEk0H+rqU0vfXro0=; b=ojTVvO+qeTUZRnWi h74oJZG+YjG9dUAGXdH3+tDkeE2hKF3Te1yhfeyv2gTfPKPxg/CBGize0PVQYhyZ pZwIDnSo0+Bkcu1ohLxSoZ6MUGNzkjTwrbRYCa6+PTgwpNo1Xnm4EYb395vT5uzZ yLVi+7+lXt9sJa0Go/wC0QOjgP6QBosTAslIYfaK5UoNmF2IqEYTjdk/8ReHgQpL MUo9bla0diq3PgWOe9Qu+Bizs0D7/hYzX3Rn27NPhiLZXPXOeCK3HCyO60rxTpou BK36h/Xak0ZkqONOn3gLtr6g+6zNkZByUKofMGK4VxyMqpWwUiwFW4ncjm2pK4RJ yzklqw== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ad47jhvsy-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 13 Nov 2025 10:36:39 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-7aac981b333so622062b3a.2 for ; Thu, 13 Nov 2025 02:36:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1763030199; x=1763634999; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=57ueJYK719oVT/uBqCyzf3ryZv6JEk0H+rqU0vfXro0=; b=Paywa9Mnb3nUfmcH2OEgRwu5mTihAWsHWoHzuvNvZCgdfjgomY/LhvoeEI6oMNQ9GK ESSwv3X0u/WWsJvYNjNO/i1iTy1ROCxcSdezrNmz3UhKWoX18kwNMnOEPrdIpja9dzO/ DGiydE9frQlMDwnN7RRN1fvbxcf4MEI2ZY9rSleAkhezQ6SxmyYNk6MjqCqMv8NqyLCs 4UZf1jejI44psd/p2aDQF3KK0si28reao/AkOQ/9AC770sLOrdLyM5pdMBNwgF5ZuXUC DQM204fEP+7ihSzphkatasLybe9tDp36+z9y0n6Tz8snx3z5Ybf//Hl8JS3IyApQXfiI sAFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763030199; x=1763634999; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=57ueJYK719oVT/uBqCyzf3ryZv6JEk0H+rqU0vfXro0=; b=Qqq11RJfyAaGniguXz6alb/A5YGznBLElPsrE0CjT2Stbly6+njWRkeTNUgx0cmetN rFnwyJl6Y/Y3i+Efwstr8WZtT0k37t+psJQptibOnhtkj3pWoiLQ1YmrJcn8eBuUMEvu 5hmILogg3G/OJ6BkWvpwjGFXPkM4/QFYYYhrPLg55T71Hs54gMrkc3K5toJroaTENF0k TLf0wtIQcfNgiWBfWaQmjN+6myBJnSZhRom2oiC/TWM6ZHp0C6LGaRQpe9mL6cqxSG1+ i47RCKD9RAjVwkQAjfy3T+eTOKTTvVVN81l8I9QrCQzK4lW/gZf2Oi7XYvm1GcwTKngU v2/A== X-Forwarded-Encrypted: i=1; AJvYcCVbJn5Rg1XQwl/EZeof1yzgGZHr1YbaoQ86oAGjr5z52M1Nv+SB4HiyJ23se8h5rIG2Y4RA8yfKr6b2a/4=@vger.kernel.org X-Gm-Message-State: AOJu0YxwRfjBA6gCK8897HCe47rGD7yBHspRCPtlENEWdoAOEYrNATie JeavnNX65331TrjxEPybhhnUIfddEs+0gsdGo5dDYC7ClCFcNslFA5z7vfVtkPGK+oRlrrh4u1T 2Nb7860rOgo2J1b8+D37iDiS4FGMqypRE1JFUL/3/a/s/dU8SUIF/wGA/wNgeHX5pZ/A= X-Gm-Gg: ASbGnctliPXPpyRSsOG4im8C14aS5GMSwl23JchncUY8LXuu9XySCvT0PsrLYZDiGVP UoA4ZCsmwwD5s+UQFoJLt+AbolqXr1ByzvRMObE0LV2RVX1zp6E5rlkuJ6MegPMHdb7QumUkGFG uAEAqmaGFySrkzy2pj7c1Yc83lLIu6ZPJGsJDtNkYiguDVcQJcGDCCh2W5ZI1Qvl4MsBopvGH8N leUWLX7rz/l2j1kjr9agzol91tbuDWIECEjuklkAnRy4SFxnrDfjCUiGI5WMbR2vCYFGYbu//0i DZLDpKO594fdmYpzRq+JMXKFfvJXz/06Zal1HIzRT+IvGufHhLWqsSFskd4nfXLq6Ipys/EWgra hr9SnOFoJ+8UmJqY7jWB1fhCGiw== X-Received: by 2002:aa7:9f4a:0:b0:7b8:383d:8706 with SMTP id d2e1a72fcca58-7b8383d9ceemr5110956b3a.18.1763030198765; Thu, 13 Nov 2025 02:36:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFY1XfjujpWXtu3a8hAbzT70O9BoYL8drTuLVZXmHo0Uv7PJ8TP7RToqZbKFTrDLuGpWscZ+A== X-Received: by 2002:aa7:9f4a:0:b0:7b8:383d:8706 with SMTP id d2e1a72fcca58-7b8383d9ceemr5110915b3a.18.1763030198037; Thu, 13 Nov 2025 02:36:38 -0800 (PST) Received: from hu-mojha-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7b9250d2d16sm1886922b3a.22.2025.11.13.02.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Nov 2025 02:36:37 -0800 (PST) From: Mukesh Ojha Date: Thu, 13 Nov 2025 16:05:58 +0530 Subject: [PATCH v7 08/14] firmware: qcom_scm: Add a prep version of auth_and_reset function Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251113-kvm-rproc-v7-v7-8-df4910b7c20a@oss.qualcomm.com> References: <20251113-kvm-rproc-v7-v7-0-df4910b7c20a@oss.qualcomm.com> In-Reply-To: <20251113-kvm-rproc-v7-v7-0-df4910b7c20a@oss.qualcomm.com> To: Bjorn Andersson , Mathieu Poirier , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Manivannan Sadhasivam , Konrad Dybcio Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Mukesh Ojha X-Mailer: b4 0.14-dev-f7c49 X-Developer-Signature: v=1; a=ed25519-sha256; t=1763030164; l=4475; i=mukesh.ojha@oss.qualcomm.com; s=20250708; h=from:subject:message-id; bh=fTjoksev6NSdPOE7J+AhEJwpfMDv/+Zt/Wrlk/KJAC8=; b=DqGnoxhJ4Pq4/3B9CxegA3jPcBh0483Tyj81cM0Ey8W3aLtmUu8mJppZhHHZL6TTap1k1Je7N JvbdhWcTbKzDydbqsBYqwi8MFERKkOMqcHY+OjL4n5kZxqN0RAhnWKs X-Developer-Key: i=mukesh.ojha@oss.qualcomm.com; a=ed25519; pk=eX8dr/7d4HJz/HEXZIpe3c+Ukopa/wZmxH+5YV3gdNc= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTEzMDA3OCBTYWx0ZWRfXzed8Z2rm22i0 xE2eVx4rEzBuwIRBMqddHdwMk5WKb4SADEPQC/sTFMbxklBSEbk2e/uwtZKQJNmx+GNtGLg3OQC HX65oFnuwn2CiOF7Ocd/QCQj0DeTCuQRjNUvo2UGZ1Jo1svLZVyjHPh3vDU+q0RpSiTXiFbAE62 /3Sdv0USAT/s8b9ing9FI1XrThezopEar6QgGR4hzdXk92qGBVSiU2UFVk2mvajdFceyxrFq3ir SNhc5FiAydFrV2Ilfzqbzm7SChJDcQrMkCOxjggwPIR73lWv8TiHXiBU8972KXCoBvV8HuwxXu5 ZCdRnYTslHe68eVugeyd+JNZx30ChS4JGTLCHlIKian8iOZY8ZFGUQtU/QdoWRXL6PKD/uDo4vp 1l0jupMWBSones5Oqbmj56B1xDYVDw== X-Proofpoint-GUID: -2x-67-wpYWEb2w5Kq3qhvpKSeowkBic X-Authority-Analysis: v=2.4 cv=A5Fh/qWG c=1 sm=1 tr=0 ts=6915b4b8 cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=XGel9bHSJmg9pP0w-tEA:9 a=QEXdDO2ut3YA:10 a=2VI0MkxyNR6bbpdq8BZq:22 X-Proofpoint-ORIG-GUID: -2x-67-wpYWEb2w5Kq3qhvpKSeowkBic X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-11-13_01,2025-11-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 clxscore=1015 spamscore=0 phishscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511130078 For memory passed to TrustZone (TZ), it must either be part of a pool registered with TZ or explicitly registered via SHMbridge SMC calls. When Gunyah hypervisor is present, PAS SMC calls from Linux running at EL1 are trapped by Gunyah running @ EL2, which handles SHMbridge creation for both metadata and remoteproc carveout memory before invoking the calls to TZ. On SoCs running with a non-Gunyah-based hypervisor, Linux must take responsibility for creating the SHM bridge before invoking PAS SMC calls. For the auth_and_reset() call, the remoteproc carveout memory must first be registered with TZ via a SHMbridge SMC call and once authentication and reset are complete, the SHMbridge memory can be deregistered. Introduce qcom_scm_pas_prepare_and_auth_reset(), which sets up the SHM bridge over the remoteproc carveout memory when Linux operates at EL2. This behavior is indicated by a new field added to the PAS context data structure. The function then invokes the auth_and_reset SMC call. Signed-off-by: Mukesh Ojha --- drivers/firmware/qcom/qcom_scm.c | 48 ++++++++++++++++++++++++++++++= ++++ include/linux/firmware/qcom/qcom_scm.h | 2 ++ 2 files changed, 50 insertions(+) diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_= scm.c index ba28b5d6254e..550707f2b46d 100644 --- a/drivers/firmware/qcom/qcom_scm.c +++ b/drivers/firmware/qcom/qcom_scm.c @@ -763,6 +763,54 @@ int qcom_scm_pas_auth_and_reset(u32 pas_id) } EXPORT_SYMBOL_GPL(qcom_scm_pas_auth_and_reset); =20 +/** + * qcom_scm_pas_prepare_and_auth_reset() - Prepare, authenticate, and rese= t the + * remote processor + * + * @ctx: Context saved during call to qcom_scm_pas_context_init() + * + * This function performs the necessary steps to prepare a PAS subsystem, + * authenticate it using the provided metadata, and initiate a reset seque= nce. + * + * It should be used when Linux is in control setting up the IOMMU hardware + * for remote subsystem during secure firmware loading processes. The prep= aration + * step sets up a shmbridge over the firmware memory before TrustZone acce= sses the + * firmware memory region for authentication. The authentication step veri= fies + * the integrity and authenticity of the firmware or configuration using s= ecure + * metadata. Finally, the reset step ensures the subsystem starts in a cle= an and + * sane state. + * + * Return: 0 on success, negative errno on failure. + */ +int qcom_scm_pas_prepare_and_auth_reset(struct qcom_scm_pas_context *ctx) +{ + u64 handle; + int ret; + + if (!ctx->has_iommu) + return qcom_scm_pas_auth_and_reset(ctx->pas_id); + + /* + * When Linux running @ EL1, Gunyah hypervisor running @ EL2 traps the + * auth_and_reset call and create an shmbridge on the remote subsystem + * memory region and then invokes a call to TrustZone to authenticate. + * When Linux runs @ EL2 Linux must create the shmbridge itself and then + * subsequently call TrustZone for authenticate and reset. + */ + ret =3D qcom_tzmem_shm_bridge_create(ctx->mem_phys, ctx->mem_size, &handl= e); + if (ret) { + dev_err(__scm->dev, "Failed to create shmbridge for PAS ID (%u): %d\n", + ctx->pas_id, ret); + return ret; + } + + ret =3D qcom_scm_pas_auth_and_reset(ctx->pas_id); + qcom_tzmem_shm_bridge_delete(handle); + + return ret; +} +EXPORT_SYMBOL_GPL(qcom_scm_pas_prepare_and_auth_reset); + /** * qcom_scm_pas_shutdown() - Shut down the remote processor * @pas_id: peripheral authentication service id diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmwar= e/qcom/qcom_scm.h index 94daf3aa89fc..42621770edd2 100644 --- a/include/linux/firmware/qcom/qcom_scm.h +++ b/include/linux/firmware/qcom/qcom_scm.h @@ -74,6 +74,7 @@ struct qcom_scm_pas_context { void *ptr; dma_addr_t phys; ssize_t size; + bool has_iommu; }; =20 void *devm_qcom_scm_pas_context_init(struct device *dev, u32 pas_id, phys_= addr_t mem_phys, @@ -85,6 +86,7 @@ int qcom_scm_pas_mem_setup(u32 pas_id, phys_addr_t addr, = phys_addr_t size); int qcom_scm_pas_auth_and_reset(u32 pas_id); int qcom_scm_pas_shutdown(u32 pas_id); bool qcom_scm_pas_supported(u32 pas_id); +int qcom_scm_pas_prepare_and_auth_reset(struct qcom_scm_pas_context *ctx); =20 int qcom_scm_io_readl(phys_addr_t addr, unsigned int *val); int qcom_scm_io_writel(phys_addr_t addr, unsigned int val); --=20 2.50.1