From nobody Sun Feb 8 14:31:37 2026 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 D8CA433E356 for ; Mon, 5 Jan 2026 13:24:08 +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=1767619451; cv=none; b=AD3tAz7lA7A75pJ9yZQ/W8OK1FkDEGklG+kA5T2NPjk6NIH6bE7pz2/zmuYKWEl8k6WIrRCF3uTMHwmQcM0S4ILMInxjT0Y1IBv7Ltk61Ujv7yp7+OSBU0kwyPAuPje6x39zhYZ5AfBmfqqGAgsjYM6KRsRR8+dcsat+4mUX21E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767619451; c=relaxed/simple; bh=SZMLL6envtkRQd8eBea0TMuWbkm/UcC4Ymddh/OwcXs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ECbyGO38FYRH6w5vs924YVOivm0dQVwWGXJmQOTdTyofMqkbJNg/3N2KYCacVdeQiHRKqeeUWa2UTu1FQRFGQyWQ705+MyH0w/yYlHuCt0yuTq88E7pVJqnMVvmXkDKiQeZtJP013GuwYJ6ph8lyiyLQfZhtfUeQxE2AuC4Kx9w= 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=LYV8BK36; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ShiETfgf; 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="LYV8BK36"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ShiETfgf" 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 6058w4Su593833 for ; Mon, 5 Jan 2026 13:24:08 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= ohQiEFekNMtUiDlK7Tte7+x0/iQw7PLc7Lalx3fyAvQ=; b=LYV8BK36KzzLFhFb nKD2UD28f5/C3C93p4RokgXGJ9Eu9TvazGYLHrezeuHHv/A2mIIv4gpoius4pM/a I85WVK9Cb8lw/SLvzbp2NoQqd0xCEOaiDTobCrnSohSSuUOtlV23N2FhYhYLFZvU TxNIj7TVmij6ota1WCC8rytIWm+oKWjIKVFpodvJvZfjfeEdddtvLKFYG6rUuhgl WcQjXCyN0p7eCyVD5DjRr3mTuL9XsjzKXG9mXCfkhNEaPz3gfzLKEBE39klebghf qcvONpp8Fbiy08pdyE3jqjJLMsCVWPU+xPUzeou1QuVlY+R4W5CrTwQZhi9NS3DF wbC9pQ== Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bga8pgnpd-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 05 Jan 2026 13:24:08 +0000 (GMT) Received: by mail-pf1-f198.google.com with SMTP id d2e1a72fcca58-7b9321b9312so30793131b3a.1 for ; Mon, 05 Jan 2026 05:24:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1767619448; x=1768224248; 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=ohQiEFekNMtUiDlK7Tte7+x0/iQw7PLc7Lalx3fyAvQ=; b=ShiETfgfZIWNtivbNAN5oYVfl0kE8h9kMWh9M2yZPvLUARbIhGqO4SmyY4x0nGDU97 4QHVXEm0QWSC2rwtToq4iY0jglPIgTrpDbGdJeBeeIj/PWigmMIj1DKHidgAuwZ0z03D 97UaKKmlBzIeQpI4CT8WqyKsu7xwzPWQZ7etIZYorSvhzPt1nmnj0DA5YtclUcjXbp79 O4W9lUW10g/Yzq9A4qGT19eT0czGDyhmsr8cWYUKTbxkdlVA6guJaf3mwPd4S5WPjPlE JDZDoxiuKt/EiHrw5APFxcS7q3wXYnGVqs2YnxvIF0AyGIwOoFuG6hVoZTrsgwQwQBa3 S+2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767619448; x=1768224248; 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=ohQiEFekNMtUiDlK7Tte7+x0/iQw7PLc7Lalx3fyAvQ=; b=ulIHIvI5RmnezGZSeiB/fKpo8hY3a3JsYpjN3kPJ/19dMdn03tw1CLEWe94WR4rTyR s2qQTi2ixVKCEJHFNPaBhoIueydAivfa9topu4TDV5eVQJNhvNRM3cQtThKUeoRU20fe DtPOjlGt72/9231BdA6zvd7bXVaIAw5/L7WH06tHKnFlIQ5ZQ8rLWmDadV4LDw2JqDFI wZCZg24y5tMyVVbWgy6nsmv015cNxjEGTbglQ67mfgPBgVuJgitWH6uVsj0lcKN22dAX ky3TOJGlSOWBI0R8fM+j+iT+7tuWx/Reb5cwOZljsbDxDo+b7epZ2G+nSx70qJiIbSVL 27Bw== X-Forwarded-Encrypted: i=1; AJvYcCXSSuCwg16rIhtKw1EcuSeioRHQR8sNwlotNv/HOFC5L5ClfiMOKIkRzyWzLdtl2QHhn949mhGsSSYMNBo=@vger.kernel.org X-Gm-Message-State: AOJu0YwUvX2S2FJIYo5pntC83hNGUJg9XEAP8JaSXvZNlYwjcTfSPg5r wBZA1UH97K3GhfynVhjOGScuhqLjTErlgjX8kmHQLOjkTxO4QQCm2WadrkTz5gmpDj/WawY6zFl Dq/+stAsuMd9vO3LwwhNsy7MeMHnZTnWEFUp3Rsrg64rw2Bf7ZdQWRGDCgDqa0AMPImk= X-Gm-Gg: AY/fxX5YG6Ttp7twIKZcu7TmtTHiz9rH6HLL+2rpRRiNOb0ieJjqv3BcC4gxTU3qEDc Q1bowX+F9QHnOCLFaSgMoHRWXxRCCmX7EJzd6fmPBQZtqtinmvCcbU8ofO1RRp5NXYKz+XtdX7E TJxEw82PcSS3+s4vRSe6NGCKsZSCQUy1sCeOSANiOuT70/+NJhyXOJiB9YmyARuj7MufsJhJZjP 7k1Kh//4R1G14tQsGYpTphol3NL+MhiXlwr0nwHpU3b5d6Ohm1ZfsbPOpmDXBk3n+OPK6ysECd0 JKR63uoEU1RnT4ZN/cNI/fSKnkcVQrMZAVQWM+9zUqUDWP0frVOI8ylHATerc5ygmk0DG3Iy7X7 rX5kWxHxmY9IJsiC//Yk13L7E1MH4syGt6HPc X-Received: by 2002:a05:6a00:9089:b0:772:8101:870c with SMTP id d2e1a72fcca58-7ff650c7d82mr39707458b3a.11.1767619447215; Mon, 05 Jan 2026 05:24:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IHrSy24RdLkJ6c7CQbabVzL9tb4PirLfLaJUXj19u3EireiiMIr6CF9FlfGlVHkbSwBXnGaTA== X-Received: by 2002:a05:6a00:9089:b0:772:8101:870c with SMTP id d2e1a72fcca58-7ff650c7d82mr39707429b3a.11.1767619446460; Mon, 05 Jan 2026 05:24:06 -0800 (PST) Received: from hu-mojha-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7b127b00sm48426542b3a.21.2026.01.05.05.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 05 Jan 2026 05:24:06 -0800 (PST) From: Mukesh Ojha Date: Mon, 05 Jan 2026 18:53:01 +0530 Subject: [PATCH v10 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: <20260105-kvmrprocv10-v10-13-022e96815380@oss.qualcomm.com> References: <20260105-kvmrprocv10-v10-0-022e96815380@oss.qualcomm.com> In-Reply-To: <20260105-kvmrprocv10-v10-0-022e96815380@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=1767619390; l=5426; i=mukesh.ojha@oss.qualcomm.com; s=20250708; h=from:subject:message-id; bh=SZMLL6envtkRQd8eBea0TMuWbkm/UcC4Ymddh/OwcXs=; b=/PPUDyUEow1Rl+NErMQSnDwMeIczmC1juCIWdIM2NZuQ4gc3m8I8jBR+sTXRaPvsUGBZSJSkf UYSWUTmynAVBWFtQ5WLdILE0NTpp3YFZi1Pc6ftLYKNa4xro0m9Qy8w X-Developer-Key: i=mukesh.ojha@oss.qualcomm.com; a=ed25519; pk=eX8dr/7d4HJz/HEXZIpe3c+Ukopa/wZmxH+5YV3gdNc= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTA1MDExNyBTYWx0ZWRfX1L+d3olP8edP zPTKQAJxMzGRQJR0A3XHALQHhaqPhY9AJKMgRVFXumlvKNblkYS+MnqWkm+bruclZoMUO4aE6TJ 70gdgOVKnxfexniCoeqsfolKRmAJeeUCafu88GHOL2fhLxB7uzpqeNEJmRKCzf0a2Dbtnl38EXj e3P9r3D82bRcvoFetVjpHl/aodjUL+DHZkt/kp2tdK5bMiuCXwYoSPAY1RE0ub91kJxsClqpd5T q4nOUURm8CLmkiyolUZCVA4VdCmy0foubUeYMiwTAcsjhLy+g0iIZOLBdepZjBAyjCNvUS7PW+a p5NlFbhB0wN3GTGA1ZC0Xfq+0lycfXdR55ntm51a1UZxFPMgl2UavW3UuPImc+5PObbmknFGVBD i+X5E7sW44tWEo+3puS8ojlre0DEdgsTSYViYadRViehUCG/LNiosbk0gbybrXpf5Oif9pNo2vl hFmk76ckQexYtu0jOSg== X-Authority-Analysis: v=2.4 cv=JfWxbEKV c=1 sm=1 tr=0 ts=695bbb78 cx=c_pps a=m5Vt/hrsBiPMCU0y4gIsQw==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=58pnfTnN0ARRJNaB1lkA:9 a=QEXdDO2ut3YA:10 a=IoOABgeZipijB_acs4fv:22 X-Proofpoint-ORIG-GUID: Rv_B7NJlXiIHKdXG-YTIRuG0yXwGxqCK X-Proofpoint-GUID: Rv_B7NJlXiIHKdXG-YTIRuG0yXwGxqCK 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=2026-01-05_01,2025-12-31_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2601050117 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 e0c7bf94bfc6..46204da046fa 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 @@ -255,6 +256,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; @@ -289,11 +306,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 @@ -304,18 +325,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); @@ -327,10 +352,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); @@ -386,8 +417,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); @@ -738,6 +773,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 @@ -817,6 +853,8 @@ static int qcom_pas_probe(struct platform_device *pdev) goto remove_ssr_sysmon; } =20 + pas->pas_ctx->use_tzmem =3D rproc->has_iommu; + pas->dtb_pas_ctx->use_tzmem =3D rproc->has_iommu; ret =3D rproc_add(rproc); if (ret) goto remove_ssr_sysmon; --=20 2.50.1