Re: [PATCH v8 2/5] remoteproc: Add TEE support

2024-07-09 Thread Arnaud POULIQUEN



On 7/8/24 17:43, Mathieu Poirier wrote:
> On Fri, Jul 05, 2024 at 09:33:55AM +0200, Arnaud POULIQUEN wrote:
>>
>>
>> On 7/4/24 17:32, Mathieu Poirier wrote:
>>> On Thu, Jul 04, 2024 at 10:05:24AM +0200, Arnaud POULIQUEN wrote:


 On 7/3/24 17:14, Mathieu Poirier wrote:
> On Wed, Jul 03, 2024 at 09:19:44AM +0200, Arnaud POULIQUEN wrote:
>> Hello Mathieu
>>
>> On 7/2/24 18:44, Mathieu Poirier wrote:
>>> Good morning,
>>>
>>> On Fri, Jun 21, 2024 at 04:37:56PM +0200, Arnaud Pouliquen wrote:
 Add a remoteproc TEE (Trusted Execution Environment) driver
 that will be probed by the TEE bus. If the associated Trusted
 application is supported on secure part this driver offers a client
 interface to load a firmware by the secure part.
 This firmware could be authenticated by the secure trusted application.

 Signed-off-by: Arnaud Pouliquen 
 ---
 Updates vs previous version:
 - rename tee_remoteproc.* file to rmeoteproc_tee.*,
 - rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
 - remove "stm32" in some variable declarations,
 - remove useless "remoteproc_internal.h" include,
 - fix tee_rproc_ctx devm_kzalloc.
 - rework module description
 ---
  drivers/remoteproc/Kconfig  |  10 +
  drivers/remoteproc/Makefile |   1 +
  drivers/remoteproc/remoteproc_tee.c | 446 
  include/linux/remoteproc.h  |   4 +
  include/linux/remoteproc_tee.h  | 100 +++
  5 files changed, 561 insertions(+)
  create mode 100644 drivers/remoteproc/remoteproc_tee.c
  create mode 100644 include/linux/remoteproc_tee.h

 diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
 index 48845dc8fa85..278f197acb90 100644
 --- a/drivers/remoteproc/Kconfig
 +++ b/drivers/remoteproc/Kconfig
 @@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
  
  It's safe to say N if not interested in using RPU r5f cores.
  
 +
 +config REMOTEPROC_TEE
 +  tristate "Remoteproc support by a TEE application"
 +  depends on OPTEE
 +  help
 +Support a remote processor with a TEE application. The Trusted
 +Execution Context is responsible for loading the trusted 
 firmware
 +image and managing the remote processor's lifecycle.
 +This can be either built-in or a loadable module.
 +
  endif # REMOTEPROC
  
  endmenu
 diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
 index 91314a9b43ce..b4eb37177005 100644
 --- a/drivers/remoteproc/Makefile
 +++ b/drivers/remoteproc/Makefile
 @@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC)+= 
 rcar_rproc.o
  obj-$(CONFIG_ST_REMOTEPROC)   += st_remoteproc.o
  obj-$(CONFIG_ST_SLIM_REMOTEPROC)  += st_slim_rproc.o
  obj-$(CONFIG_STM32_RPROC) += stm32_rproc.o
 +obj-$(CONFIG_REMOTEPROC_TEE)  += remoteproc_tee.o
  obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)+= ti_k3_dsp_remoteproc.o
  obj-$(CONFIG_TI_K3_R5_REMOTEPROC) += ti_k3_r5_remoteproc.o
  obj-$(CONFIG_XLNX_R5_REMOTEPROC)  += xlnx_r5_remoteproc.o
 diff --git a/drivers/remoteproc/remoteproc_tee.c 
 b/drivers/remoteproc/remoteproc_tee.c
 new file mode 100644
 index ..70cb67451767
 --- /dev/null
 +++ b/drivers/remoteproc/remoteproc_tee.c
 @@ -0,0 +1,446 @@
 +// SPDX-License-Identifier: GPL-2.0-or-later
 +/*
 + * Copyright (C) STMicroelectronics 2024
 + * Author: Arnaud Pouliquen 
 + */
 +
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +
 +#define MAX_TEE_PARAM_ARRY_MEMBER 4
 +
 +/*
 + * Authentication of the firmware and load in the remote processor 
 memory
 + *
 + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
 processor
 + * [in]params[1].memref:  buffer containing the image of 
 the buffer
 + */
 +#define TA_RPROC_FW_CMD_LOAD_FW   1
 +
 +/*
 + * Start the remote processor
 + *
 + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
 processor
 + */
 +#define TA_RPROC_FW_CMD_START_FW  2
 +
 +/*
 + * Stop the remote processor
 + *
 + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
 processor

Re: [PATCH v8 2/5] remoteproc: Add TEE support

2024-07-08 Thread Mathieu Poirier
On Fri, Jul 05, 2024 at 09:33:55AM +0200, Arnaud POULIQUEN wrote:
> 
> 
> On 7/4/24 17:32, Mathieu Poirier wrote:
> > On Thu, Jul 04, 2024 at 10:05:24AM +0200, Arnaud POULIQUEN wrote:
> >>
> >>
> >> On 7/3/24 17:14, Mathieu Poirier wrote:
> >>> On Wed, Jul 03, 2024 at 09:19:44AM +0200, Arnaud POULIQUEN wrote:
>  Hello Mathieu
> 
>  On 7/2/24 18:44, Mathieu Poirier wrote:
> > Good morning,
> >
> > On Fri, Jun 21, 2024 at 04:37:56PM +0200, Arnaud Pouliquen wrote:
> >> Add a remoteproc TEE (Trusted Execution Environment) driver
> >> that will be probed by the TEE bus. If the associated Trusted
> >> application is supported on secure part this driver offers a client
> >> interface to load a firmware by the secure part.
> >> This firmware could be authenticated by the secure trusted application.
> >>
> >> Signed-off-by: Arnaud Pouliquen 
> >> ---
> >> Updates vs previous version:
> >> - rename tee_remoteproc.* file to rmeoteproc_tee.*,
> >> - rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
> >> - remove "stm32" in some variable declarations,
> >> - remove useless "remoteproc_internal.h" include,
> >> - fix tee_rproc_ctx devm_kzalloc.
> >> - rework module description
> >> ---
> >>  drivers/remoteproc/Kconfig  |  10 +
> >>  drivers/remoteproc/Makefile |   1 +
> >>  drivers/remoteproc/remoteproc_tee.c | 446 
> >>  include/linux/remoteproc.h  |   4 +
> >>  include/linux/remoteproc_tee.h  | 100 +++
> >>  5 files changed, 561 insertions(+)
> >>  create mode 100644 drivers/remoteproc/remoteproc_tee.c
> >>  create mode 100644 include/linux/remoteproc_tee.h
> >>
> >> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> >> index 48845dc8fa85..278f197acb90 100644
> >> --- a/drivers/remoteproc/Kconfig
> >> +++ b/drivers/remoteproc/Kconfig
> >> @@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
> >>  
> >>  It's safe to say N if not interested in using RPU r5f cores.
> >>  
> >> +
> >> +config REMOTEPROC_TEE
> >> +  tristate "Remoteproc support by a TEE application"
> >> +  depends on OPTEE
> >> +  help
> >> +Support a remote processor with a TEE application. The Trusted
> >> +Execution Context is responsible for loading the trusted 
> >> firmware
> >> +image and managing the remote processor's lifecycle.
> >> +This can be either built-in or a loadable module.
> >> +
> >>  endif # REMOTEPROC
> >>  
> >>  endmenu
> >> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
> >> index 91314a9b43ce..b4eb37177005 100644
> >> --- a/drivers/remoteproc/Makefile
> >> +++ b/drivers/remoteproc/Makefile
> >> @@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC)+= 
> >> rcar_rproc.o
> >>  obj-$(CONFIG_ST_REMOTEPROC)   += st_remoteproc.o
> >>  obj-$(CONFIG_ST_SLIM_REMOTEPROC)  += st_slim_rproc.o
> >>  obj-$(CONFIG_STM32_RPROC) += stm32_rproc.o
> >> +obj-$(CONFIG_REMOTEPROC_TEE)  += remoteproc_tee.o
> >>  obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)+= ti_k3_dsp_remoteproc.o
> >>  obj-$(CONFIG_TI_K3_R5_REMOTEPROC) += ti_k3_r5_remoteproc.o
> >>  obj-$(CONFIG_XLNX_R5_REMOTEPROC)  += xlnx_r5_remoteproc.o
> >> diff --git a/drivers/remoteproc/remoteproc_tee.c 
> >> b/drivers/remoteproc/remoteproc_tee.c
> >> new file mode 100644
> >> index ..70cb67451767
> >> --- /dev/null
> >> +++ b/drivers/remoteproc/remoteproc_tee.c
> >> @@ -0,0 +1,446 @@
> >> +// SPDX-License-Identifier: GPL-2.0-or-later
> >> +/*
> >> + * Copyright (C) STMicroelectronics 2024
> >> + * Author: Arnaud Pouliquen 
> >> + */
> >> +
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +
> >> +#define MAX_TEE_PARAM_ARRY_MEMBER 4
> >> +
> >> +/*
> >> + * Authentication of the firmware and load in the remote processor 
> >> memory
> >> + *
> >> + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
> >> processor
> >> + * [in]params[1].memref:  buffer containing the image of 
> >> the buffer
> >> + */
> >> +#define TA_RPROC_FW_CMD_LOAD_FW   1
> >> +
> >> +/*
> >> + * Start the remote processor
> >> + *
> >> + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
> >> processor
> >> + */
> >> +#define TA_RPROC_FW_CMD_START_FW  2
> >> +
> >> +/*
> >> + * Stop the remote processor
> >> + *
> >> + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
> >> processor
> >> + */
> >> +#define 

Re: [PATCH v8 2/5] remoteproc: Add TEE support

2024-07-05 Thread Arnaud POULIQUEN



On 7/4/24 17:32, Mathieu Poirier wrote:
> On Thu, Jul 04, 2024 at 10:05:24AM +0200, Arnaud POULIQUEN wrote:
>>
>>
>> On 7/3/24 17:14, Mathieu Poirier wrote:
>>> On Wed, Jul 03, 2024 at 09:19:44AM +0200, Arnaud POULIQUEN wrote:
 Hello Mathieu

 On 7/2/24 18:44, Mathieu Poirier wrote:
> Good morning,
>
> On Fri, Jun 21, 2024 at 04:37:56PM +0200, Arnaud Pouliquen wrote:
>> Add a remoteproc TEE (Trusted Execution Environment) driver
>> that will be probed by the TEE bus. If the associated Trusted
>> application is supported on secure part this driver offers a client
>> interface to load a firmware by the secure part.
>> This firmware could be authenticated by the secure trusted application.
>>
>> Signed-off-by: Arnaud Pouliquen 
>> ---
>> Updates vs previous version:
>> - rename tee_remoteproc.* file to rmeoteproc_tee.*,
>> - rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
>> - remove "stm32" in some variable declarations,
>> - remove useless "remoteproc_internal.h" include,
>> - fix tee_rproc_ctx devm_kzalloc.
>> - rework module description
>> ---
>>  drivers/remoteproc/Kconfig  |  10 +
>>  drivers/remoteproc/Makefile |   1 +
>>  drivers/remoteproc/remoteproc_tee.c | 446 
>>  include/linux/remoteproc.h  |   4 +
>>  include/linux/remoteproc_tee.h  | 100 +++
>>  5 files changed, 561 insertions(+)
>>  create mode 100644 drivers/remoteproc/remoteproc_tee.c
>>  create mode 100644 include/linux/remoteproc_tee.h
>>
>> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
>> index 48845dc8fa85..278f197acb90 100644
>> --- a/drivers/remoteproc/Kconfig
>> +++ b/drivers/remoteproc/Kconfig
>> @@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
>>  
>>It's safe to say N if not interested in using RPU r5f cores.
>>  
>> +
>> +config REMOTEPROC_TEE
>> +tristate "Remoteproc support by a TEE application"
>> +depends on OPTEE
>> +help
>> +  Support a remote processor with a TEE application. The Trusted
>> +  Execution Context is responsible for loading the trusted 
>> firmware
>> +  image and managing the remote processor's lifecycle.
>> +  This can be either built-in or a loadable module.
>> +
>>  endif # REMOTEPROC
>>  
>>  endmenu
>> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
>> index 91314a9b43ce..b4eb37177005 100644
>> --- a/drivers/remoteproc/Makefile
>> +++ b/drivers/remoteproc/Makefile
>> @@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC)  += rcar_rproc.o
>>  obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o
>>  obj-$(CONFIG_ST_SLIM_REMOTEPROC)+= st_slim_rproc.o
>>  obj-$(CONFIG_STM32_RPROC)   += stm32_rproc.o
>> +obj-$(CONFIG_REMOTEPROC_TEE)+= remoteproc_tee.o
>>  obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)  += ti_k3_dsp_remoteproc.o
>>  obj-$(CONFIG_TI_K3_R5_REMOTEPROC)   += ti_k3_r5_remoteproc.o
>>  obj-$(CONFIG_XLNX_R5_REMOTEPROC)+= xlnx_r5_remoteproc.o
>> diff --git a/drivers/remoteproc/remoteproc_tee.c 
>> b/drivers/remoteproc/remoteproc_tee.c
>> new file mode 100644
>> index ..70cb67451767
>> --- /dev/null
>> +++ b/drivers/remoteproc/remoteproc_tee.c
>> @@ -0,0 +1,446 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +/*
>> + * Copyright (C) STMicroelectronics 2024
>> + * Author: Arnaud Pouliquen 
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define MAX_TEE_PARAM_ARRY_MEMBER   4
>> +
>> +/*
>> + * Authentication of the firmware and load in the remote processor 
>> memory
>> + *
>> + * [in]  params[0].value.a: unique 32bit identifier of the remote 
>> processor
>> + * [in]  params[1].memref:  buffer containing the image of the 
>> buffer
>> + */
>> +#define TA_RPROC_FW_CMD_LOAD_FW 1
>> +
>> +/*
>> + * Start the remote processor
>> + *
>> + * [in]  params[0].value.a: unique 32bit identifier of the remote 
>> processor
>> + */
>> +#define TA_RPROC_FW_CMD_START_FW2
>> +
>> +/*
>> + * Stop the remote processor
>> + *
>> + * [in]  params[0].value.a: unique 32bit identifier of the remote 
>> processor
>> + */
>> +#define TA_RPROC_FW_CMD_STOP_FW 3
>> +
>> +/*
>> + * Return the address of the resource table, or 0 if not found
>> + * No check is done to verify that the address returned is accessible by
>> + * the non secure context. If the resource table is loaded in a 
>> protected
>> + * memory 

Re: [PATCH v8 2/5] remoteproc: Add TEE support

2024-07-04 Thread Mathieu Poirier
On Thu, Jul 04, 2024 at 10:05:24AM +0200, Arnaud POULIQUEN wrote:
> 
> 
> On 7/3/24 17:14, Mathieu Poirier wrote:
> > On Wed, Jul 03, 2024 at 09:19:44AM +0200, Arnaud POULIQUEN wrote:
> >> Hello Mathieu
> >>
> >> On 7/2/24 18:44, Mathieu Poirier wrote:
> >>> Good morning,
> >>>
> >>> On Fri, Jun 21, 2024 at 04:37:56PM +0200, Arnaud Pouliquen wrote:
>  Add a remoteproc TEE (Trusted Execution Environment) driver
>  that will be probed by the TEE bus. If the associated Trusted
>  application is supported on secure part this driver offers a client
>  interface to load a firmware by the secure part.
>  This firmware could be authenticated by the secure trusted application.
> 
>  Signed-off-by: Arnaud Pouliquen 
>  ---
>  Updates vs previous version:
>  - rename tee_remoteproc.* file to rmeoteproc_tee.*,
>  - rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
>  - remove "stm32" in some variable declarations,
>  - remove useless "remoteproc_internal.h" include,
>  - fix tee_rproc_ctx devm_kzalloc.
>  - rework module description
>  ---
>   drivers/remoteproc/Kconfig  |  10 +
>   drivers/remoteproc/Makefile |   1 +
>   drivers/remoteproc/remoteproc_tee.c | 446 
>   include/linux/remoteproc.h  |   4 +
>   include/linux/remoteproc_tee.h  | 100 +++
>   5 files changed, 561 insertions(+)
>   create mode 100644 drivers/remoteproc/remoteproc_tee.c
>   create mode 100644 include/linux/remoteproc_tee.h
> 
>  diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
>  index 48845dc8fa85..278f197acb90 100644
>  --- a/drivers/remoteproc/Kconfig
>  +++ b/drivers/remoteproc/Kconfig
>  @@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
>   
> It's safe to say N if not interested in using RPU r5f cores.
>   
>  +
>  +config REMOTEPROC_TEE
>  +tristate "Remoteproc support by a TEE application"
>  +depends on OPTEE
>  +help
>  +  Support a remote processor with a TEE application. The Trusted
>  +  Execution Context is responsible for loading the trusted 
>  firmware
>  +  image and managing the remote processor's lifecycle.
>  +  This can be either built-in or a loadable module.
>  +
>   endif # REMOTEPROC
>   
>   endmenu
>  diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
>  index 91314a9b43ce..b4eb37177005 100644
>  --- a/drivers/remoteproc/Makefile
>  +++ b/drivers/remoteproc/Makefile
>  @@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC)  += rcar_rproc.o
>   obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o
>   obj-$(CONFIG_ST_SLIM_REMOTEPROC)+= st_slim_rproc.o
>   obj-$(CONFIG_STM32_RPROC)   += stm32_rproc.o
>  +obj-$(CONFIG_REMOTEPROC_TEE)+= remoteproc_tee.o
>   obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)  += ti_k3_dsp_remoteproc.o
>   obj-$(CONFIG_TI_K3_R5_REMOTEPROC)   += ti_k3_r5_remoteproc.o
>   obj-$(CONFIG_XLNX_R5_REMOTEPROC)+= xlnx_r5_remoteproc.o
>  diff --git a/drivers/remoteproc/remoteproc_tee.c 
>  b/drivers/remoteproc/remoteproc_tee.c
>  new file mode 100644
>  index ..70cb67451767
>  --- /dev/null
>  +++ b/drivers/remoteproc/remoteproc_tee.c
>  @@ -0,0 +1,446 @@
>  +// SPDX-License-Identifier: GPL-2.0-or-later
>  +/*
>  + * Copyright (C) STMicroelectronics 2024
>  + * Author: Arnaud Pouliquen 
>  + */
>  +
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +
>  +#define MAX_TEE_PARAM_ARRY_MEMBER   4
>  +
>  +/*
>  + * Authentication of the firmware and load in the remote processor 
>  memory
>  + *
>  + * [in]  params[0].value.a: unique 32bit identifier of the remote 
>  processor
>  + * [in]  params[1].memref:  buffer containing the image of the 
>  buffer
>  + */
>  +#define TA_RPROC_FW_CMD_LOAD_FW 1
>  +
>  +/*
>  + * Start the remote processor
>  + *
>  + * [in]  params[0].value.a: unique 32bit identifier of the remote 
>  processor
>  + */
>  +#define TA_RPROC_FW_CMD_START_FW2
>  +
>  +/*
>  + * Stop the remote processor
>  + *
>  + * [in]  params[0].value.a: unique 32bit identifier of the remote 
>  processor
>  + */
>  +#define TA_RPROC_FW_CMD_STOP_FW 3
>  +
>  +/*
>  + * Return the address of the resource table, or 0 if not found
>  + * No check is done to verify that the address returned is accessible by
>  + * the non secure context. If the resource table is loaded in a 
>  protected
>  + * memory the access by the non secure context will 

Re: [PATCH v8 2/5] remoteproc: Add TEE support

2024-07-04 Thread Arnaud POULIQUEN



On 7/3/24 17:14, Mathieu Poirier wrote:
> On Wed, Jul 03, 2024 at 09:19:44AM +0200, Arnaud POULIQUEN wrote:
>> Hello Mathieu
>>
>> On 7/2/24 18:44, Mathieu Poirier wrote:
>>> Good morning,
>>>
>>> On Fri, Jun 21, 2024 at 04:37:56PM +0200, Arnaud Pouliquen wrote:
 Add a remoteproc TEE (Trusted Execution Environment) driver
 that will be probed by the TEE bus. If the associated Trusted
 application is supported on secure part this driver offers a client
 interface to load a firmware by the secure part.
 This firmware could be authenticated by the secure trusted application.

 Signed-off-by: Arnaud Pouliquen 
 ---
 Updates vs previous version:
 - rename tee_remoteproc.* file to rmeoteproc_tee.*,
 - rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
 - remove "stm32" in some variable declarations,
 - remove useless "remoteproc_internal.h" include,
 - fix tee_rproc_ctx devm_kzalloc.
 - rework module description
 ---
  drivers/remoteproc/Kconfig  |  10 +
  drivers/remoteproc/Makefile |   1 +
  drivers/remoteproc/remoteproc_tee.c | 446 
  include/linux/remoteproc.h  |   4 +
  include/linux/remoteproc_tee.h  | 100 +++
  5 files changed, 561 insertions(+)
  create mode 100644 drivers/remoteproc/remoteproc_tee.c
  create mode 100644 include/linux/remoteproc_tee.h

 diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
 index 48845dc8fa85..278f197acb90 100644
 --- a/drivers/remoteproc/Kconfig
 +++ b/drivers/remoteproc/Kconfig
 @@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
  
  It's safe to say N if not interested in using RPU r5f cores.
  
 +
 +config REMOTEPROC_TEE
 +  tristate "Remoteproc support by a TEE application"
 +  depends on OPTEE
 +  help
 +Support a remote processor with a TEE application. The Trusted
 +Execution Context is responsible for loading the trusted firmware
 +image and managing the remote processor's lifecycle.
 +This can be either built-in or a loadable module.
 +
  endif # REMOTEPROC
  
  endmenu
 diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
 index 91314a9b43ce..b4eb37177005 100644
 --- a/drivers/remoteproc/Makefile
 +++ b/drivers/remoteproc/Makefile
 @@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC)+= rcar_rproc.o
  obj-$(CONFIG_ST_REMOTEPROC)   += st_remoteproc.o
  obj-$(CONFIG_ST_SLIM_REMOTEPROC)  += st_slim_rproc.o
  obj-$(CONFIG_STM32_RPROC) += stm32_rproc.o
 +obj-$(CONFIG_REMOTEPROC_TEE)  += remoteproc_tee.o
  obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)+= ti_k3_dsp_remoteproc.o
  obj-$(CONFIG_TI_K3_R5_REMOTEPROC) += ti_k3_r5_remoteproc.o
  obj-$(CONFIG_XLNX_R5_REMOTEPROC)  += xlnx_r5_remoteproc.o
 diff --git a/drivers/remoteproc/remoteproc_tee.c 
 b/drivers/remoteproc/remoteproc_tee.c
 new file mode 100644
 index ..70cb67451767
 --- /dev/null
 +++ b/drivers/remoteproc/remoteproc_tee.c
 @@ -0,0 +1,446 @@
 +// SPDX-License-Identifier: GPL-2.0-or-later
 +/*
 + * Copyright (C) STMicroelectronics 2024
 + * Author: Arnaud Pouliquen 
 + */
 +
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +
 +#define MAX_TEE_PARAM_ARRY_MEMBER 4
 +
 +/*
 + * Authentication of the firmware and load in the remote processor memory
 + *
 + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
 processor
 + * [in]params[1].memref:  buffer containing the image of the 
 buffer
 + */
 +#define TA_RPROC_FW_CMD_LOAD_FW   1
 +
 +/*
 + * Start the remote processor
 + *
 + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
 processor
 + */
 +#define TA_RPROC_FW_CMD_START_FW  2
 +
 +/*
 + * Stop the remote processor
 + *
 + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
 processor
 + */
 +#define TA_RPROC_FW_CMD_STOP_FW   3
 +
 +/*
 + * Return the address of the resource table, or 0 if not found
 + * No check is done to verify that the address returned is accessible by
 + * the non secure context. If the resource table is loaded in a protected
 + * memory the access by the non secure context will lead to a data abort.
 + *
 + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
 processor
 + * [out]  params[1].value.a:  32bit LSB resource table memory address
 + * [out]  params[1].value.b:  32bit MSB resource table memory address
 + * [out]  params[2].value.a:  32bit LSB resource table memory size
 + * [out]  params[2].value.b: 

Re: [PATCH v8 2/5] remoteproc: Add TEE support

2024-07-03 Thread Mathieu Poirier
On Fri, Jun 21, 2024 at 04:37:56PM +0200, Arnaud Pouliquen wrote:
> Add a remoteproc TEE (Trusted Execution Environment) driver
> that will be probed by the TEE bus. If the associated Trusted
> application is supported on secure part this driver offers a client
> interface to load a firmware by the secure part.
> This firmware could be authenticated by the secure trusted application.
> 
> Signed-off-by: Arnaud Pouliquen 
> ---
> Updates vs previous version:
> - rename tee_remoteproc.* file to rmeoteproc_tee.*,
> - rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
> - remove "stm32" in some variable declarations,
> - remove useless "remoteproc_internal.h" include,
> - fix tee_rproc_ctx devm_kzalloc.
> - rework module description
> ---
>  drivers/remoteproc/Kconfig  |  10 +
>  drivers/remoteproc/Makefile |   1 +
>  drivers/remoteproc/remoteproc_tee.c | 446 
>  include/linux/remoteproc.h  |   4 +
>  include/linux/remoteproc_tee.h  | 100 +++
>  5 files changed, 561 insertions(+)
>  create mode 100644 drivers/remoteproc/remoteproc_tee.c
>  create mode 100644 include/linux/remoteproc_tee.h
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index 48845dc8fa85..278f197acb90 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
>  
> It's safe to say N if not interested in using RPU r5f cores.
>  
> +
> +config REMOTEPROC_TEE
> + tristate "Remoteproc support by a TEE application"
> + depends on OPTEE
> + help
> +   Support a remote processor with a TEE application. The Trusted
> +   Execution Context is responsible for loading the trusted firmware
> +   image and managing the remote processor's lifecycle.
> +   This can be either built-in or a loadable module.
> +
>  endif # REMOTEPROC
>  
>  endmenu
> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
> index 91314a9b43ce..b4eb37177005 100644
> --- a/drivers/remoteproc/Makefile
> +++ b/drivers/remoteproc/Makefile
> @@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC)   += rcar_rproc.o
>  obj-$(CONFIG_ST_REMOTEPROC)  += st_remoteproc.o
>  obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o
>  obj-$(CONFIG_STM32_RPROC)+= stm32_rproc.o
> +obj-$(CONFIG_REMOTEPROC_TEE) += remoteproc_tee.o
>  obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)   += ti_k3_dsp_remoteproc.o
>  obj-$(CONFIG_TI_K3_R5_REMOTEPROC)+= ti_k3_r5_remoteproc.o
>  obj-$(CONFIG_XLNX_R5_REMOTEPROC) += xlnx_r5_remoteproc.o
> diff --git a/drivers/remoteproc/remoteproc_tee.c 
> b/drivers/remoteproc/remoteproc_tee.c
> new file mode 100644
> index ..70cb67451767
> --- /dev/null
> +++ b/drivers/remoteproc/remoteproc_tee.c
> @@ -0,0 +1,446 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) STMicroelectronics 2024
> + * Author: Arnaud Pouliquen 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define MAX_TEE_PARAM_ARRY_MEMBER4
> +
> +/*
> + * Authentication of the firmware and load in the remote processor memory
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + * [in]   params[1].memref:  buffer containing the image of the 
> buffer
> + */
> +#define TA_RPROC_FW_CMD_LOAD_FW  1
> +
> +/*
> + * Start the remote processor
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + */
> +#define TA_RPROC_FW_CMD_START_FW 2
> +
> +/*
> + * Stop the remote processor
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + */
> +#define TA_RPROC_FW_CMD_STOP_FW  3
> +
> +/*
> + * Return the address of the resource table, or 0 if not found
> + * No check is done to verify that the address returned is accessible by
> + * the non secure context. If the resource table is loaded in a protected
> + * memory the access by the non secure context will lead to a data abort.
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + * [out]  params[1].value.a: 32bit LSB resource table memory address
> + * [out]  params[1].value.b: 32bit MSB resource table memory address
> + * [out]  params[2].value.a: 32bit LSB resource table memory size
> + * [out]  params[2].value.b: 32bit MSB resource table memory size
> + */
> +#define TA_RPROC_FW_CMD_GET_RSC_TABLE4
> +
> +/*
> + * Return the address of the core dump
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + * [out] params[1].memref:   address of the core dump image if exist,
> + *   else return Null
> + */
> +#define TA_RPROC_FW_CMD_GET_COREDUMP 5
> +
> +struct tee_rproc_context {
> + struct list_head sessions;
> + struct tee_context *tee_ctx;
> + struct device *dev;
> +};
> +
> +static struct 

Re: [PATCH v8 2/5] remoteproc: Add TEE support

2024-07-03 Thread Mathieu Poirier
On Wed, Jul 03, 2024 at 09:19:44AM +0200, Arnaud POULIQUEN wrote:
> Hello Mathieu
> 
> On 7/2/24 18:44, Mathieu Poirier wrote:
> > Good morning,
> > 
> > On Fri, Jun 21, 2024 at 04:37:56PM +0200, Arnaud Pouliquen wrote:
> >> Add a remoteproc TEE (Trusted Execution Environment) driver
> >> that will be probed by the TEE bus. If the associated Trusted
> >> application is supported on secure part this driver offers a client
> >> interface to load a firmware by the secure part.
> >> This firmware could be authenticated by the secure trusted application.
> >>
> >> Signed-off-by: Arnaud Pouliquen 
> >> ---
> >> Updates vs previous version:
> >> - rename tee_remoteproc.* file to rmeoteproc_tee.*,
> >> - rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
> >> - remove "stm32" in some variable declarations,
> >> - remove useless "remoteproc_internal.h" include,
> >> - fix tee_rproc_ctx devm_kzalloc.
> >> - rework module description
> >> ---
> >>  drivers/remoteproc/Kconfig  |  10 +
> >>  drivers/remoteproc/Makefile |   1 +
> >>  drivers/remoteproc/remoteproc_tee.c | 446 
> >>  include/linux/remoteproc.h  |   4 +
> >>  include/linux/remoteproc_tee.h  | 100 +++
> >>  5 files changed, 561 insertions(+)
> >>  create mode 100644 drivers/remoteproc/remoteproc_tee.c
> >>  create mode 100644 include/linux/remoteproc_tee.h
> >>
> >> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> >> index 48845dc8fa85..278f197acb90 100644
> >> --- a/drivers/remoteproc/Kconfig
> >> +++ b/drivers/remoteproc/Kconfig
> >> @@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
> >>  
> >>  It's safe to say N if not interested in using RPU r5f cores.
> >>  
> >> +
> >> +config REMOTEPROC_TEE
> >> +  tristate "Remoteproc support by a TEE application"
> >> +  depends on OPTEE
> >> +  help
> >> +Support a remote processor with a TEE application. The Trusted
> >> +Execution Context is responsible for loading the trusted firmware
> >> +image and managing the remote processor's lifecycle.
> >> +This can be either built-in or a loadable module.
> >> +
> >>  endif # REMOTEPROC
> >>  
> >>  endmenu
> >> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
> >> index 91314a9b43ce..b4eb37177005 100644
> >> --- a/drivers/remoteproc/Makefile
> >> +++ b/drivers/remoteproc/Makefile
> >> @@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC)+= rcar_rproc.o
> >>  obj-$(CONFIG_ST_REMOTEPROC)   += st_remoteproc.o
> >>  obj-$(CONFIG_ST_SLIM_REMOTEPROC)  += st_slim_rproc.o
> >>  obj-$(CONFIG_STM32_RPROC) += stm32_rproc.o
> >> +obj-$(CONFIG_REMOTEPROC_TEE)  += remoteproc_tee.o
> >>  obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)+= ti_k3_dsp_remoteproc.o
> >>  obj-$(CONFIG_TI_K3_R5_REMOTEPROC) += ti_k3_r5_remoteproc.o
> >>  obj-$(CONFIG_XLNX_R5_REMOTEPROC)  += xlnx_r5_remoteproc.o
> >> diff --git a/drivers/remoteproc/remoteproc_tee.c 
> >> b/drivers/remoteproc/remoteproc_tee.c
> >> new file mode 100644
> >> index ..70cb67451767
> >> --- /dev/null
> >> +++ b/drivers/remoteproc/remoteproc_tee.c
> >> @@ -0,0 +1,446 @@
> >> +// SPDX-License-Identifier: GPL-2.0-or-later
> >> +/*
> >> + * Copyright (C) STMicroelectronics 2024
> >> + * Author: Arnaud Pouliquen 
> >> + */
> >> +
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +
> >> +#define MAX_TEE_PARAM_ARRY_MEMBER 4
> >> +
> >> +/*
> >> + * Authentication of the firmware and load in the remote processor memory
> >> + *
> >> + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
> >> processor
> >> + * [in]params[1].memref:  buffer containing the image of the 
> >> buffer
> >> + */
> >> +#define TA_RPROC_FW_CMD_LOAD_FW   1
> >> +
> >> +/*
> >> + * Start the remote processor
> >> + *
> >> + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
> >> processor
> >> + */
> >> +#define TA_RPROC_FW_CMD_START_FW  2
> >> +
> >> +/*
> >> + * Stop the remote processor
> >> + *
> >> + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
> >> processor
> >> + */
> >> +#define TA_RPROC_FW_CMD_STOP_FW   3
> >> +
> >> +/*
> >> + * Return the address of the resource table, or 0 if not found
> >> + * No check is done to verify that the address returned is accessible by
> >> + * the non secure context. If the resource table is loaded in a protected
> >> + * memory the access by the non secure context will lead to a data abort.
> >> + *
> >> + * [in]  params[0].value.a:   unique 32bit identifier of the remote 
> >> processor
> >> + * [out]  params[1].value.a:  32bit LSB resource table memory address
> >> + * [out]  params[1].value.b:  32bit MSB resource table memory address
> >> + * [out]  params[2].value.a:  32bit LSB resource table memory size
> >> + * [out]  params[2].value.b:  32bit MSB resource table memory size
> >> + 

Re: [PATCH v8 2/5] remoteproc: Add TEE support

2024-07-03 Thread Arnaud POULIQUEN
Hello Mathieu

On 7/2/24 18:44, Mathieu Poirier wrote:
> Good morning,
> 
> On Fri, Jun 21, 2024 at 04:37:56PM +0200, Arnaud Pouliquen wrote:
>> Add a remoteproc TEE (Trusted Execution Environment) driver
>> that will be probed by the TEE bus. If the associated Trusted
>> application is supported on secure part this driver offers a client
>> interface to load a firmware by the secure part.
>> This firmware could be authenticated by the secure trusted application.
>>
>> Signed-off-by: Arnaud Pouliquen 
>> ---
>> Updates vs previous version:
>> - rename tee_remoteproc.* file to rmeoteproc_tee.*,
>> - rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
>> - remove "stm32" in some variable declarations,
>> - remove useless "remoteproc_internal.h" include,
>> - fix tee_rproc_ctx devm_kzalloc.
>> - rework module description
>> ---
>>  drivers/remoteproc/Kconfig  |  10 +
>>  drivers/remoteproc/Makefile |   1 +
>>  drivers/remoteproc/remoteproc_tee.c | 446 
>>  include/linux/remoteproc.h  |   4 +
>>  include/linux/remoteproc_tee.h  | 100 +++
>>  5 files changed, 561 insertions(+)
>>  create mode 100644 drivers/remoteproc/remoteproc_tee.c
>>  create mode 100644 include/linux/remoteproc_tee.h
>>
>> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
>> index 48845dc8fa85..278f197acb90 100644
>> --- a/drivers/remoteproc/Kconfig
>> +++ b/drivers/remoteproc/Kconfig
>> @@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
>>  
>>It's safe to say N if not interested in using RPU r5f cores.
>>  
>> +
>> +config REMOTEPROC_TEE
>> +tristate "Remoteproc support by a TEE application"
>> +depends on OPTEE
>> +help
>> +  Support a remote processor with a TEE application. The Trusted
>> +  Execution Context is responsible for loading the trusted firmware
>> +  image and managing the remote processor's lifecycle.
>> +  This can be either built-in or a loadable module.
>> +
>>  endif # REMOTEPROC
>>  
>>  endmenu
>> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
>> index 91314a9b43ce..b4eb37177005 100644
>> --- a/drivers/remoteproc/Makefile
>> +++ b/drivers/remoteproc/Makefile
>> @@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC)  += rcar_rproc.o
>>  obj-$(CONFIG_ST_REMOTEPROC) += st_remoteproc.o
>>  obj-$(CONFIG_ST_SLIM_REMOTEPROC)+= st_slim_rproc.o
>>  obj-$(CONFIG_STM32_RPROC)   += stm32_rproc.o
>> +obj-$(CONFIG_REMOTEPROC_TEE)+= remoteproc_tee.o
>>  obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)  += ti_k3_dsp_remoteproc.o
>>  obj-$(CONFIG_TI_K3_R5_REMOTEPROC)   += ti_k3_r5_remoteproc.o
>>  obj-$(CONFIG_XLNX_R5_REMOTEPROC)+= xlnx_r5_remoteproc.o
>> diff --git a/drivers/remoteproc/remoteproc_tee.c 
>> b/drivers/remoteproc/remoteproc_tee.c
>> new file mode 100644
>> index ..70cb67451767
>> --- /dev/null
>> +++ b/drivers/remoteproc/remoteproc_tee.c
>> @@ -0,0 +1,446 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +/*
>> + * Copyright (C) STMicroelectronics 2024
>> + * Author: Arnaud Pouliquen 
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#define MAX_TEE_PARAM_ARRY_MEMBER   4
>> +
>> +/*
>> + * Authentication of the firmware and load in the remote processor memory
>> + *
>> + * [in]  params[0].value.a: unique 32bit identifier of the remote processor
>> + * [in]  params[1].memref:  buffer containing the image of the 
>> buffer
>> + */
>> +#define TA_RPROC_FW_CMD_LOAD_FW 1
>> +
>> +/*
>> + * Start the remote processor
>> + *
>> + * [in]  params[0].value.a: unique 32bit identifier of the remote processor
>> + */
>> +#define TA_RPROC_FW_CMD_START_FW2
>> +
>> +/*
>> + * Stop the remote processor
>> + *
>> + * [in]  params[0].value.a: unique 32bit identifier of the remote processor
>> + */
>> +#define TA_RPROC_FW_CMD_STOP_FW 3
>> +
>> +/*
>> + * Return the address of the resource table, or 0 if not found
>> + * No check is done to verify that the address returned is accessible by
>> + * the non secure context. If the resource table is loaded in a protected
>> + * memory the access by the non secure context will lead to a data abort.
>> + *
>> + * [in]  params[0].value.a: unique 32bit identifier of the remote processor
>> + * [out]  params[1].value.a:32bit LSB resource table memory address
>> + * [out]  params[1].value.b:32bit MSB resource table memory address
>> + * [out]  params[2].value.a:32bit LSB resource table memory size
>> + * [out]  params[2].value.b:32bit MSB resource table memory size
>> + */
>> +#define TA_RPROC_FW_CMD_GET_RSC_TABLE   4
>> +
>> +/*
>> + * Return the address of the core dump
>> + *
>> + * [in]  params[0].value.a: unique 32bit identifier of the remote processor
>> + * [out] params[1].memref:  address of the core dump image if exist,
>> + *  else return Null
>> + */

Re: [PATCH v8 2/5] remoteproc: Add TEE support

2024-07-02 Thread Mathieu Poirier
Good morning,

On Fri, Jun 21, 2024 at 04:37:56PM +0200, Arnaud Pouliquen wrote:
> Add a remoteproc TEE (Trusted Execution Environment) driver
> that will be probed by the TEE bus. If the associated Trusted
> application is supported on secure part this driver offers a client
> interface to load a firmware by the secure part.
> This firmware could be authenticated by the secure trusted application.
> 
> Signed-off-by: Arnaud Pouliquen 
> ---
> Updates vs previous version:
> - rename tee_remoteproc.* file to rmeoteproc_tee.*,
> - rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
> - remove "stm32" in some variable declarations,
> - remove useless "remoteproc_internal.h" include,
> - fix tee_rproc_ctx devm_kzalloc.
> - rework module description
> ---
>  drivers/remoteproc/Kconfig  |  10 +
>  drivers/remoteproc/Makefile |   1 +
>  drivers/remoteproc/remoteproc_tee.c | 446 
>  include/linux/remoteproc.h  |   4 +
>  include/linux/remoteproc_tee.h  | 100 +++
>  5 files changed, 561 insertions(+)
>  create mode 100644 drivers/remoteproc/remoteproc_tee.c
>  create mode 100644 include/linux/remoteproc_tee.h
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index 48845dc8fa85..278f197acb90 100644
> --- a/drivers/remoteproc/Kconfig
> +++ b/drivers/remoteproc/Kconfig
> @@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
>  
> It's safe to say N if not interested in using RPU r5f cores.
>  
> +
> +config REMOTEPROC_TEE
> + tristate "Remoteproc support by a TEE application"
> + depends on OPTEE
> + help
> +   Support a remote processor with a TEE application. The Trusted
> +   Execution Context is responsible for loading the trusted firmware
> +   image and managing the remote processor's lifecycle.
> +   This can be either built-in or a loadable module.
> +
>  endif # REMOTEPROC
>  
>  endmenu
> diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
> index 91314a9b43ce..b4eb37177005 100644
> --- a/drivers/remoteproc/Makefile
> +++ b/drivers/remoteproc/Makefile
> @@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC)   += rcar_rproc.o
>  obj-$(CONFIG_ST_REMOTEPROC)  += st_remoteproc.o
>  obj-$(CONFIG_ST_SLIM_REMOTEPROC) += st_slim_rproc.o
>  obj-$(CONFIG_STM32_RPROC)+= stm32_rproc.o
> +obj-$(CONFIG_REMOTEPROC_TEE) += remoteproc_tee.o
>  obj-$(CONFIG_TI_K3_DSP_REMOTEPROC)   += ti_k3_dsp_remoteproc.o
>  obj-$(CONFIG_TI_K3_R5_REMOTEPROC)+= ti_k3_r5_remoteproc.o
>  obj-$(CONFIG_XLNX_R5_REMOTEPROC) += xlnx_r5_remoteproc.o
> diff --git a/drivers/remoteproc/remoteproc_tee.c 
> b/drivers/remoteproc/remoteproc_tee.c
> new file mode 100644
> index ..70cb67451767
> --- /dev/null
> +++ b/drivers/remoteproc/remoteproc_tee.c
> @@ -0,0 +1,446 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) STMicroelectronics 2024
> + * Author: Arnaud Pouliquen 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#define MAX_TEE_PARAM_ARRY_MEMBER4
> +
> +/*
> + * Authentication of the firmware and load in the remote processor memory
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + * [in]   params[1].memref:  buffer containing the image of the 
> buffer
> + */
> +#define TA_RPROC_FW_CMD_LOAD_FW  1
> +
> +/*
> + * Start the remote processor
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + */
> +#define TA_RPROC_FW_CMD_START_FW 2
> +
> +/*
> + * Stop the remote processor
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + */
> +#define TA_RPROC_FW_CMD_STOP_FW  3
> +
> +/*
> + * Return the address of the resource table, or 0 if not found
> + * No check is done to verify that the address returned is accessible by
> + * the non secure context. If the resource table is loaded in a protected
> + * memory the access by the non secure context will lead to a data abort.
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + * [out]  params[1].value.a: 32bit LSB resource table memory address
> + * [out]  params[1].value.b: 32bit MSB resource table memory address
> + * [out]  params[2].value.a: 32bit LSB resource table memory size
> + * [out]  params[2].value.b: 32bit MSB resource table memory size
> + */
> +#define TA_RPROC_FW_CMD_GET_RSC_TABLE4
> +
> +/*
> + * Return the address of the core dump
> + *
> + * [in]  params[0].value.a:  unique 32bit identifier of the remote processor
> + * [out] params[1].memref:   address of the core dump image if exist,
> + *   else return Null
> + */
> +#define TA_RPROC_FW_CMD_GET_COREDUMP 5
> +
> +struct tee_rproc_context {
> + struct list_head sessions;
> + struct tee_context *tee_ctx;
> + struct device *dev;
> +};
> +
> 

[PATCH v8 2/5] remoteproc: Add TEE support

2024-06-21 Thread Arnaud Pouliquen
Add a remoteproc TEE (Trusted Execution Environment) driver
that will be probed by the TEE bus. If the associated Trusted
application is supported on secure part this driver offers a client
interface to load a firmware by the secure part.
This firmware could be authenticated by the secure trusted application.

Signed-off-by: Arnaud Pouliquen 
---
Updates vs previous version:
- rename tee_remoteproc.* file to rmeoteproc_tee.*,
- rename TEE_REMOTEPROC config to REMOTEPROC_TEE,
- remove "stm32" in some variable declarations,
- remove useless "remoteproc_internal.h" include,
- fix tee_rproc_ctx devm_kzalloc.
- rework module description
---
 drivers/remoteproc/Kconfig  |  10 +
 drivers/remoteproc/Makefile |   1 +
 drivers/remoteproc/remoteproc_tee.c | 446 
 include/linux/remoteproc.h  |   4 +
 include/linux/remoteproc_tee.h  | 100 +++
 5 files changed, 561 insertions(+)
 create mode 100644 drivers/remoteproc/remoteproc_tee.c
 create mode 100644 include/linux/remoteproc_tee.h

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 48845dc8fa85..278f197acb90 100644
--- a/drivers/remoteproc/Kconfig
+++ b/drivers/remoteproc/Kconfig
@@ -365,6 +365,16 @@ config XLNX_R5_REMOTEPROC
 
  It's safe to say N if not interested in using RPU r5f cores.
 
+
+config REMOTEPROC_TEE
+   tristate "Remoteproc support by a TEE application"
+   depends on OPTEE
+   help
+ Support a remote processor with a TEE application. The Trusted
+ Execution Context is responsible for loading the trusted firmware
+ image and managing the remote processor's lifecycle.
+ This can be either built-in or a loadable module.
+
 endif # REMOTEPROC
 
 endmenu
diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile
index 91314a9b43ce..b4eb37177005 100644
--- a/drivers/remoteproc/Makefile
+++ b/drivers/remoteproc/Makefile
@@ -36,6 +36,7 @@ obj-$(CONFIG_RCAR_REMOTEPROC) += rcar_rproc.o
 obj-$(CONFIG_ST_REMOTEPROC)+= st_remoteproc.o
 obj-$(CONFIG_ST_SLIM_REMOTEPROC)   += st_slim_rproc.o
 obj-$(CONFIG_STM32_RPROC)  += stm32_rproc.o
+obj-$(CONFIG_REMOTEPROC_TEE)   += remoteproc_tee.o
 obj-$(CONFIG_TI_K3_DSP_REMOTEPROC) += ti_k3_dsp_remoteproc.o
 obj-$(CONFIG_TI_K3_R5_REMOTEPROC)  += ti_k3_r5_remoteproc.o
 obj-$(CONFIG_XLNX_R5_REMOTEPROC)   += xlnx_r5_remoteproc.o
diff --git a/drivers/remoteproc/remoteproc_tee.c 
b/drivers/remoteproc/remoteproc_tee.c
new file mode 100644
index ..70cb67451767
--- /dev/null
+++ b/drivers/remoteproc/remoteproc_tee.c
@@ -0,0 +1,446 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) STMicroelectronics 2024
+ * Author: Arnaud Pouliquen 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define MAX_TEE_PARAM_ARRY_MEMBER  4
+
+/*
+ * Authentication of the firmware and load in the remote processor memory
+ *
+ * [in]  params[0].value.a:unique 32bit identifier of the remote processor
+ * [in] params[1].memref:  buffer containing the image of the 
buffer
+ */
+#define TA_RPROC_FW_CMD_LOAD_FW1
+
+/*
+ * Start the remote processor
+ *
+ * [in]  params[0].value.a:unique 32bit identifier of the remote processor
+ */
+#define TA_RPROC_FW_CMD_START_FW   2
+
+/*
+ * Stop the remote processor
+ *
+ * [in]  params[0].value.a:unique 32bit identifier of the remote processor
+ */
+#define TA_RPROC_FW_CMD_STOP_FW3
+
+/*
+ * Return the address of the resource table, or 0 if not found
+ * No check is done to verify that the address returned is accessible by
+ * the non secure context. If the resource table is loaded in a protected
+ * memory the access by the non secure context will lead to a data abort.
+ *
+ * [in]  params[0].value.a:unique 32bit identifier of the remote processor
+ * [out]  params[1].value.a:   32bit LSB resource table memory address
+ * [out]  params[1].value.b:   32bit MSB resource table memory address
+ * [out]  params[2].value.a:   32bit LSB resource table memory size
+ * [out]  params[2].value.b:   32bit MSB resource table memory size
+ */
+#define TA_RPROC_FW_CMD_GET_RSC_TABLE  4
+
+/*
+ * Return the address of the core dump
+ *
+ * [in]  params[0].value.a:unique 32bit identifier of the remote processor
+ * [out] params[1].memref: address of the core dump image if exist,
+ * else return Null
+ */
+#define TA_RPROC_FW_CMD_GET_COREDUMP   5
+
+struct tee_rproc_context {
+   struct list_head sessions;
+   struct tee_context *tee_ctx;
+   struct device *dev;
+};
+
+static struct tee_rproc_context *tee_rproc_ctx;
+
+static void tee_rproc_prepare_args(struct tee_rproc *trproc, int cmd,
+  struct tee_ioctl_invoke_arg *arg,
+  struct tee_param *param,
+