From nobody Tue Dec 2 02:03:04 2025 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 5EA3934D3AB for ; Fri, 21 Nov 2025 11:02:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763722939; cv=none; b=Kbw6I5FpMB9yttLcv4S9IYdzqDSZmvviXGCQLDdJcWMmRSKd/8BKm1Dyjjj9J3vACbW3YeE8/DEkwuESgjCz3bFC5aqCHc8Af5pePQu5PJk5/gGDs7yBemE/gC1goBlcBufWYPAOjwdIXXKPGQXtSF/ZcnqHP6w4oEmoYil+4ug= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763722939; c=relaxed/simple; bh=LDWAD2OdrCo60t+xziU/S1D39LdH7Wm0TjQa6U2Nrp8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GcjRWRAP5zus/CslxV2h68l8E251DTMVuchS+YJLri409IU4DzOOFUg36jWgZTF3S2azKt3KzimT8TSSKY0pI3xuTkVZrCX0cwE8y3tIZq4Nb45GdBrSz1YEZVRIBeFUKU48Ba7g+k9X61SbOHujKwrXM24BX9ToT0c/bKPC8C4= 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=cF0gYsn6; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=XPViP7Lc; arc=none smtp.client-ip=205.220.168.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="cF0gYsn6"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="XPViP7Lc" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5AL5T7ql2831702 for ; Fri, 21 Nov 2025 11:02:16 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= wzDVse6SiyFvQ9mA2qbhi5suczpNw/QR0pHgsig8MBw=; b=cF0gYsn6xQ0AnMBw j3pwXOI2LjN+UVs26wL8O66Y0Rxf1hn/m1FmJnwo9Y1IKn8PppW1imnRCzVCGM4M udCmBjtmjSCaoQ/JGL+b6vOHJRTBce8aYikF3sGRokZVhv96h4XDReLrK2SycA0f e0EpCuFdtp8y/ZWekQYMleUHR2+r4ZR3UNASwc/V/gmqISo8LIba3bmjsgAER66v IkyAn8jgSeV9xYdM/wetZ0phOMhvX09ZRIeoRg678OcRy13W5X362Xd9C2mSS9fR /i/RCxh6VvUygNja4k9jVETXyyrasOhsZA6qLOOLuYV4qZjU5ftYfuIwtJaHY7il jSilcw== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ajhyq14cj-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 21 Nov 2025 11:02:16 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2956cdcdc17so23733455ad.3 for ; Fri, 21 Nov 2025 03:02:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1763722936; x=1764327736; 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=wzDVse6SiyFvQ9mA2qbhi5suczpNw/QR0pHgsig8MBw=; b=XPViP7Lcn3db+8/Qdd8rChevhW6rw1LqEoxZUgr9+8zGb6mmlcfTmg8conPOXYiNKk uBg7jKhFkzjTorLCjFjMBf7mVA7rUeZcsGhxd0O7C7cJAc3Q4tKtcsWZEyJ+qF5ptWl2 MZeUgShwGs9xLJP4WBt1fSiYMrtATRwgAY0lOOU38D3T8nvUEOiOsLrOl7nAWRDCag8F rkhbhEtQv6U1pXuhdKrOogTQnkdiMJdQPicU4OXsETMUxSn81MXqXoMNr+axibmnv377 vNpIwllBrRsHVpayyP+IFLc30sDWNGZs0UGi+3FvlpRNLtB6YO49EP6bIg8vmOthfddW ZkiA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763722936; x=1764327736; 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=wzDVse6SiyFvQ9mA2qbhi5suczpNw/QR0pHgsig8MBw=; b=ah2D71qYZ7ZU2aaZ6HMhm23zAxWNgk1R/LS6LRVxaXs8liH4gK0AN+i/pTCXFSFJ5n lOlkbKNo3rzA1Jz/AQc5WbiKFr+H7WuZesdWiNAHEbPtKlL5qTsajHByeedkubbsY6Hj O0Qp4pghuEMftmz4MLA3yemwqSpyrBiovs/OPYa1dHWDs/DbkULsqPIMi0Rf4M4XSgoJ UJaJEiEv2oKsqnlcHCx6ieIA4lJh47R2dYGH0KcRMmCh0mvbW3hYNPxpu+DdMRbrRMPy 9GyTHQSBWeYN3AxsxSunGMYgxmpf0Kn+aYPZXOb5b6VDF703Lb7Xi1i3Lrg6cAkL3ryT /4mg== X-Forwarded-Encrypted: i=1; AJvYcCUIOTXtMxSwLj2ObsOtxo2GGKEcgS+v95TaqrlmaM/+ShZSZ3GgE9E1HF0DqW9Qje78Hx0kJ5VmlXwL+k4=@vger.kernel.org X-Gm-Message-State: AOJu0YwAM+hH0jkpnsvZsxEa2jWCFIg4o2jBifw+RtIC2d9sLy4ffIM2 A0haoUxM6rXPgQprTdIkjoSMttQM/OvWleFWs0dnzdyhAIxceqekD3yDjDBkzrGysum5QS4y6Vr tOBPxswDVAeYG2XoRXiV+lX3MR1Uhpatu+qhS3snz78uPjEPK3Ggl3IsHkeybOqTrpOcgwiJsu5 0= X-Gm-Gg: ASbGncvSrFdKdoXHl0aKhgOV7pVZ5Iltdsep8pr+8KKG7KQ/gNM+ubuQQ7/z1tHACFB CYTHSoUMTQs+gNMGeqAnS1YyCuMC8mptZxLcaT+5vmq3bWd+VZWmONcLgU7OX2wYmb9QBBKlA6z /I6Co9s9ccy3mdi1dtHuZr7oc9LSuLwPoUSO/+WPYkpfVTWY7mBJclu5M5JON35K/pv7wIr0R9+ 3dUngFWX/t8VibnnV4bzozZIi8PDJrq4FNG3HiXXyETB3XIx1Ta3Eq07lPS8nnd/P7O3dgTsuPO dmUNrC+BJqt4NECoCwRCLxeGTBvtBuQdI1ONB8EL1mBfiANScub6FJoqzTeClAVJbl2+B9hUNYa 1nwihBEVGu9d7eIa5lJmDCAoEnc3KQGiaQ0CD X-Received: by 2002:a17:90b:2f85:b0:341:88c5:2073 with SMTP id 98e67ed59e1d1-34733e4ce7fmr1636081a91.2.1763722935300; Fri, 21 Nov 2025 03:02:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IFEyx4OJNMZDxNS2Lv8sRqqfI93j+bv62197cKPsmEzMrlYJCRV60V11I6/4w8n3Fr2p97tdA== X-Received: by 2002:a17:90b:2f85:b0:341:88c5:2073 with SMTP id 98e67ed59e1d1-34733e4ce7fmr1636050a91.2.1763722934637; Fri, 21 Nov 2025 03:02:14 -0800 (PST) Received: from hu-mojha-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-34727d5208csm5191165a91.15.2025.11.21.03.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Nov 2025 03:02:14 -0800 (PST) From: Mukesh Ojha Date: Fri, 21 Nov 2025 16:31:15 +0530 Subject: [PATCH v8 13/14] remoteproc: qcom: pas: Enable Secure PAS support with IOMMU managed by Linux 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: <20251121-kvm_rproc_v8-v8-13-8e8e9fb0eca0@oss.qualcomm.com> References: <20251121-kvm_rproc_v8-v8-0-8e8e9fb0eca0@oss.qualcomm.com> In-Reply-To: <20251121-kvm_rproc_v8-v8-0-8e8e9fb0eca0@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=1763722879; l=5426; i=mukesh.ojha@oss.qualcomm.com; s=20250708; h=from:subject:message-id; bh=LDWAD2OdrCo60t+xziU/S1D39LdH7Wm0TjQa6U2Nrp8=; b=2gjk5vgALyrjvuFLK7nI+VjRGLP6ywbIIC5ra95eCjN5uxwfcOkjsn0g1Vz5CqJbtgIzIQLgm zowm8xjK2/mAz1ZWEGy66cLuE3XVHlYZoQEAxjOElE7ucna9zVzTChU X-Developer-Key: i=mukesh.ojha@oss.qualcomm.com; a=ed25519; pk=eX8dr/7d4HJz/HEXZIpe3c+Ukopa/wZmxH+5YV3gdNc= X-Proofpoint-GUID: 6Ga39FTE9YL_S_lLvS1CZvqEdiZZYLMM X-Proofpoint-ORIG-GUID: 6Ga39FTE9YL_S_lLvS1CZvqEdiZZYLMM X-Authority-Analysis: v=2.4 cv=N94k1m9B c=1 sm=1 tr=0 ts=692046b8 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=6UeiqGixMTsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=58pnfTnN0ARRJNaB1lkA:9 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMTIxMDA4NCBTYWx0ZWRfXxuU5iYV6DFWc VWvn43fxvhMxPBkiO5tmHRprWw+wGHka/pjE4saeNEpmKHutMqdjYkpwKr+RZWptN1lwB0nNHYP 5ctAShu0nMTGbxJW8eurOSMHyzs4fWzb07QwVeNliKEu4W+1VQSvtoqhuU08Awq7V3uF+H3kPMn ex/XkC5Dt+LXiOEHU+z65YKdBQg730YL2JDhpwi+abUpRTRLyn2ZbkEZduYhU+8OW2yiqtnj13X to7vxqArttqaZPQoSb36FeGeo78Rkf29PQ5sgUp88oNaz75LrCDU3lqx5QrqtF683C+kNmRf2Js gclKlXQIS4wduS6xcO0Nl++n4PUSN9P5C7FiYx+lw0iYysbRGPGGTW2rXiGnea1j0+c6jSMHrXa OcOTJMfrcH5wMSZpU1ofg+HP9oJqow== 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-21_03,2025-11-20_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 suspectscore=0 spamscore=0 adultscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2510240001 definitions=main-2511210084 Most Qualcomm platforms feature Gunyah hypervisor, which typically handles IOMMU configuration. This includes mapping memory regions and device memory resources for remote processors by intercepting qcom_scm_pas_auth_and_reset() calls. These mappings are later removed during teardown. Additionally, SHM bridge setup is required to enable memory protection for both remoteproc metadata and its memory regions. When the aforementioned hypervisor is absent, the operating system must perform these configurations instead. When Linux runs as the hypervisor (@ EL2) on a SoC, it will have its own device tree overlay file that specifies the firmware stream ID now managed by Linux for a particular remote processor. If the iommus property is specified in the remoteproc device tree node, it indicates that IOMMU configuration must be handled by Linux. In this case, the has_iommu flag is set for the remote processor, which ensures that the resource table, carveouts, and SHM bridge are properly configured before memory is passed to TrustZone for authentication. Otherwise, the has_iommu flag remains unset, which indicates default behavior. Enables Secure PAS support for remote processors when IOMMU configuration is managed by Linux. Signed-off-by: Mukesh Ojha --- drivers/remoteproc/qcom_q6v5_pas.c | 48 ++++++++++++++++++++++++++++++++++= ---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q= 6v5_pas.c index 186a90d6c83a..2df3b06f8157 100644 --- a/drivers/remoteproc/qcom_q6v5_pas.c +++ b/drivers/remoteproc/qcom_q6v5_pas.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -256,6 +257,22 @@ static int qcom_pas_load(struct rproc *rproc, const st= ruct firmware *fw) return ret; } =20 +static void qcom_pas_unmap_carveout(struct rproc *rproc, phys_addr_t mem_p= hys, size_t size) +{ + if (rproc->has_iommu) + iommu_unmap(rproc->domain, mem_phys, size); +} + +static int qcom_pas_map_carveout(struct rproc *rproc, phys_addr_t mem_phys= , size_t size) +{ + int ret =3D 0; + + if (rproc->has_iommu) + ret =3D iommu_map(rproc->domain, mem_phys, mem_phys, size, + IOMMU_READ | IOMMU_WRITE, GFP_KERNEL); + return ret; +} + static int qcom_pas_start(struct rproc *rproc) { struct qcom_pas *pas =3D rproc->priv; @@ -290,11 +307,15 @@ static int qcom_pas_start(struct rproc *rproc) } =20 if (pas->dtb_pas_id) { - ret =3D qcom_scm_pas_auth_and_reset(pas->dtb_pas_id); + ret =3D qcom_pas_map_carveout(rproc, pas->dtb_mem_phys, pas->dtb_mem_siz= e); + if (ret) + goto disable_px_supply; + + ret =3D qcom_scm_pas_prepare_and_auth_reset(pas->dtb_pas_ctx); if (ret) { dev_err(pas->dev, "failed to authenticate dtb image and release reset\n"); - goto disable_px_supply; + goto unmap_dtb_carveout; } } =20 @@ -305,18 +326,22 @@ static int qcom_pas_start(struct rproc *rproc) =20 qcom_pil_info_store(pas->info_name, pas->mem_phys, pas->mem_size); =20 - ret =3D qcom_scm_pas_auth_and_reset(pas->pas_id); + ret =3D qcom_pas_map_carveout(rproc, pas->mem_phys, pas->mem_size); + if (ret) + goto release_pas_metadata; + + ret =3D qcom_scm_pas_prepare_and_auth_reset(pas->pas_ctx); if (ret) { dev_err(pas->dev, "failed to authenticate image and release reset\n"); - goto release_pas_metadata; + goto unmap_carveout; } =20 ret =3D qcom_q6v5_wait_for_start(&pas->q6v5, msecs_to_jiffies(5000)); if (ret =3D=3D -ETIMEDOUT) { dev_err(pas->dev, "start timed out\n"); qcom_scm_pas_shutdown(pas->pas_id); - goto release_pas_metadata; + goto unmap_carveout; } =20 qcom_scm_pas_metadata_release(pas->pas_ctx); @@ -328,10 +353,16 @@ static int qcom_pas_start(struct rproc *rproc) =20 return 0; =20 +unmap_carveout: + qcom_pas_unmap_carveout(rproc, pas->mem_phys, pas->mem_size); release_pas_metadata: qcom_scm_pas_metadata_release(pas->pas_ctx); if (pas->dtb_pas_id) qcom_scm_pas_metadata_release(pas->dtb_pas_ctx); + +unmap_dtb_carveout: + if (pas->dtb_pas_id) + qcom_pas_unmap_carveout(rproc, pas->dtb_mem_phys, pas->dtb_mem_size); disable_px_supply: if (pas->px_supply) regulator_disable(pas->px_supply); @@ -387,8 +418,12 @@ static int qcom_pas_stop(struct rproc *rproc) ret =3D qcom_scm_pas_shutdown(pas->dtb_pas_id); if (ret) dev_err(pas->dev, "failed to shutdown dtb: %d\n", ret); + + qcom_pas_unmap_carveout(rproc, pas->dtb_mem_phys, pas->dtb_mem_size); } =20 + qcom_pas_unmap_carveout(rproc, pas->mem_phys, pas->mem_size); + handover =3D qcom_q6v5_unprepare(&pas->q6v5); if (handover) qcom_pas_handover(&pas->q6v5); @@ -758,6 +793,7 @@ static int qcom_pas_probe(struct platform_device *pdev) return -ENOMEM; } =20 + rproc->has_iommu =3D of_property_present(pdev->dev.of_node, "iommus"); rproc->auto_boot =3D desc->auto_boot; rproc_coredump_set_elf_info(rproc, ELFCLASS32, EM_NONE); =20 @@ -837,6 +873,8 @@ static int qcom_pas_probe(struct platform_device *pdev) goto remove_ssr_sysmon; } =20 + pas->pas_ctx->has_iommu =3D rproc->has_iommu; + pas->dtb_pas_ctx->has_iommu =3D rproc->has_iommu; ret =3D rproc_add(rproc); if (ret) goto remove_ssr_sysmon; --=20 2.50.1