Linux-remoteproc Archive mirror
 help / color / mirror / Atom feed
From: Konrad Dybcio <konrad.dybcio@oss.qualcomm.com>
To: Mukesh Ojha <quic_mojha@quicinc.com>,
	Bjorn Andersson <andersson@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Rob Herring <robh@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	Konrad Dybcio <konradybcio@kernel.org>,
	Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,
	Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Cc: linux-arm-msm@vger.kernel.org, linux-remoteproc@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/6] remoteproc: qcom: Add support of SHM bridge to enable memory protection
Date: Fri, 25 Oct 2024 21:03:01 +0200	[thread overview]
Message-ID: <23f3558b-e620-437a-a014-0bf4e6efbb13@oss.qualcomm.com> (raw)
In-Reply-To: <20241004212359.2263502-6-quic_mojha@quicinc.com>

On 4.10.2024 11:23 PM, Mukesh Ojha wrote:
> Qualcomm SoCs running with the Qualcomm EL2 hypervisor(QHEE) have been
> utilizing the Peripheral Authentication Service (PAS) from its TrustZone
> (TZ) firmware to securely authenticate and reset via sequence of SMC
> calls like qcom_scm_pas_init_image(), qcom_scm_pas_mem_setup(), and
> qcom_scm_pas_auth_and_reset().
> 
> Memory protection need to be enabled for both meta data memory region and
> remoteproc carveout memory region.

Will TZ refuse to start the remoteprocs if this is not the case?

> For memory passed to Qualcomm TrustZone, the memory should be part of
> SHM bridge memory. However, when QHEE is present, PAS SMC calls are
> getting trapped in QHEE, which create or gets memory from SHM bridge for
> both meta data memory and for remoteproc carve out regions before it get
> passed to TZ.  However, in absence of QHEE hypervisor, Linux need to
> create SHM bridge for both meta data in qcom_scm_pas_init_image() and
> for remoteproc memory before the call being made to
> qcom_scm_pas_auth_and_reset().
> 
> For qcom_scm_pas_init_image() call, metadata content need to be copied
> to the buffer allocated from SHM bridge before making the SMC call.
> 
> For qcom_scm_pas_auth_and_reset(), remoteproc memory region need to be
> protected and for that SHM bridge need to be created. Make
> qcom_tzmem_init_area() and qcom_tzmem_cleanup_area() exported symbol so
> that it could be used to create SHM bridge for remoteproc region.
> 
> Signed-off-by: Mukesh Ojha <quic_mojha@quicinc.com>
> ---
>  drivers/firmware/qcom/qcom_scm.c         | 29 +++++++++++-----
>  drivers/firmware/qcom/qcom_tzmem.c       | 14 +++-----
>  drivers/remoteproc/qcom_q6v5_pas.c       | 44 ++++++++++++++++++++++++
>  include/linux/firmware/qcom/qcom_scm.h   |  1 +
>  include/linux/firmware/qcom/qcom_tzmem.h | 10 ++++++
>  5 files changed, 80 insertions(+), 18 deletions(-)

This changes files in two separate subsystems. That implies this
patch should be split in two. Or three.

> 
> diff --git a/drivers/firmware/qcom/qcom_scm.c b/drivers/firmware/qcom/qcom_scm.c
> index 10986cb11ec0..dafc07dc181f 100644
> --- a/drivers/firmware/qcom/qcom_scm.c
> +++ b/drivers/firmware/qcom/qcom_scm.c
> @@ -591,15 +591,19 @@ int qcom_scm_pas_init_image(u32 peripheral, const void *metadata, size_t size,
>  	 * data blob, so make sure it's physically contiguous, 4K aligned and
>  	 * non-cachable to avoid XPU violations.
>  	 *
> -	 * For PIL calls the hypervisor creates SHM Bridges for the blob
> -	 * buffers on behalf of Linux so we must not do it ourselves hence
> -	 * not using the TZMem allocator here.
> +	 * For PIL calls the hypervisor like Gunyah or older QHEE creates SHM
> +	 * Bridges for the blob buffers on behalf of Linux so we must not do it
> +	 * ourselves hence use TZMem allocator only when these hypervisors are
> +	 * not present.

This is a bit hard to read.. How about:

PIL calls require SHMBridge is set up for shared memory regions.
Qualcomm hypervisors (Gunyah, QHEE) already take care of this.
Only create new bridges if they're absent.

[...]

Konrad

  parent reply	other threads:[~2024-10-25 19:03 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-04 21:23 [PATCH 0/6] Peripheral Image Loader support for Qualcomm SoCs Mukesh Ojha
2024-10-04 21:23 ` [PATCH 1/6] dt-bindings: remoteproc: qcom,pas-common: Introduce iommus and qcom,devmem property Mukesh Ojha
2024-10-06 19:38   ` Dmitry Baryshkov
2024-10-07 15:35     ` Mukesh Ojha
2024-10-07 16:25       ` Dmitry Baryshkov
2024-10-09 14:04         ` Shiraz Hashim
2024-10-10  7:15           ` Krzysztof Kozlowski
2024-10-10  8:30             ` Shiraz Hashim
2024-10-04 21:23 ` [PATCH 2/6] remoteproc: qcom: Add iommu map_unmap helper function Mukesh Ojha
2024-10-06  2:04   ` kernel test robot
2024-10-06  4:29   ` kernel test robot
2024-10-04 21:23 ` [PATCH 3/6] remoteproc: qcom: Add helper function to support IOMMU devmem translation Mukesh Ojha
2024-10-07  8:08   ` neil.armstrong
2024-10-07 14:37     ` Mukesh Ojha
2024-10-10  6:59       ` neil.armstrong
2024-10-17 21:25         ` Konrad Dybcio
2024-10-04 21:23 ` [PATCH 4/6] remoteproc: qcom: Add support to parse qcom,devmem property Mukesh Ojha
2024-10-04 21:23 ` [PATCH 5/6] remoteproc: qcom: Add support of SHM bridge to enable memory protection Mukesh Ojha
2024-10-05 22:26   ` kernel test robot
2024-10-25 19:03   ` Konrad Dybcio [this message]
2024-10-04 21:23 ` [PATCH 6/6] remoteproc: qcom: Enable map/unmap and SHM bridge support Mukesh Ojha
2024-10-07  8:05   ` neil.armstrong
2024-10-07 14:52     ` Mukesh Ojha
2024-10-08  6:21       ` Mukesh Ojha
2024-10-10  6:57         ` neil.armstrong
2024-10-11  5:05           ` Shiraz Hashim
2024-10-11  6:23             ` Dmitry Baryshkov
2024-10-11  7:09               ` Shiraz Hashim
2024-10-11  7:12                 ` Dmitry Baryshkov
2024-10-14 12:31                   ` Shiraz Hashim
2024-10-14 12:38                     ` Dmitry Baryshkov
2024-10-11  7:11               ` Mukesh Ojha
2024-10-11  7:09             ` neil.armstrong
2024-10-14 12:29               ` Shiraz Hashim
2024-10-25 19:07   ` Konrad Dybcio
2024-10-06 19:34 ` [PATCH 0/6] Peripheral Image Loader support for Qualcomm SoCs Dmitry Baryshkov
2024-10-07 18:39   ` Mukesh Ojha
2024-10-09 13:50   ` Shiraz Hashim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=23f3558b-e620-437a-a014-0bf4e6efbb13@oss.qualcomm.com \
    --to=konrad.dybcio@oss.qualcomm.com \
    --cc=andersson@kernel.org \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=konradybcio@kernel.org \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=manivannan.sadhasivam@linaro.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=quic_mojha@quicinc.com \
    --cc=robh@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).