Re: [PATCH v4 1/4] remoteproc: Add TEE support

2024-04-01 Thread Mathieu Poirier
On Fri, Mar 29, 2024 at 09:58:11AM +0100, Arnaud POULIQUEN wrote:
> Hello Mathieu,
> 
> On 3/27/24 18:07, Mathieu Poirier wrote:
> > On Tue, Mar 26, 2024 at 08:18:23PM +0100, Arnaud POULIQUEN wrote:
> >> Hello Mathieu,
> >>
> >> On 3/25/24 17:46, Mathieu Poirier wrote:
> >>> On Fri, Mar 08, 2024 at 03:47:05PM +0100, 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 device offers a client
> >>>
> >>> Device or driver?  I thought I touched on that before.
> >>
> >> Right, I changed the first instance and missed this one
> >>
> >>>
>  interface to load a firmware in the secure part.
>  This firmware could be authenticated by the secure trusted application.
> 
>  Signed-off-by: Arnaud Pouliquen 
>  ---
>  Updates from V3:
>  - rework TEE_REMOTEPROC description in Kconfig
>  - fix some namings
>  - add tee_rproc_parse_fw  to support rproc_ops::parse_fw
>  - add proc::tee_interface;
>  - add rproc struct as parameter of the tee_rproc_register() function
>  ---
>   drivers/remoteproc/Kconfig  |  10 +
>   drivers/remoteproc/Makefile |   1 +
>   drivers/remoteproc/tee_remoteproc.c | 434 
>   include/linux/remoteproc.h  |   4 +
>   include/linux/tee_remoteproc.h  | 112 +++
>   5 files changed, 561 insertions(+)
>   create mode 100644 drivers/remoteproc/tee_remoteproc.c
>   create mode 100644 include/linux/tee_remoteproc.h
> 
>  diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
>  index 48845dc8fa85..2cf1431b2b59 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 TEE_REMOTEPROC
>  +tristate "remoteproc support by a TEE application"
> >>>
> >>> s/remoteproc/Remoteproc
> >>>
>  +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..fa8daebce277 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_TEE_REMOTEPROC)+= tee_remoteproc.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/tee_remoteproc.c 
>  b/drivers/remoteproc/tee_remoteproc.c
>  new file mode 100644
>  index ..c855210e52e3
>  --- /dev/null
>  +++ b/drivers/remoteproc/tee_remoteproc.c
>  @@ -0,0 +1,434 @@
>  +// SPDX-License-Identifier: GPL-2.0-or-later
>  +/*
>  + * Copyright (C) STMicroelectronics 2024 - All Rights Reserved
>  + * Author: Arnaud Pouliquen 
>  + */
>  +
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +#include 
>  +
>  +#include "remoteproc_internal.h"
>  +
>  +#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 

Re: [PATCH v4 1/4] remoteproc: Add TEE support

2024-03-29 Thread Arnaud POULIQUEN
Hello Mathieu,

On 3/27/24 18:07, Mathieu Poirier wrote:
> On Tue, Mar 26, 2024 at 08:18:23PM +0100, Arnaud POULIQUEN wrote:
>> Hello Mathieu,
>>
>> On 3/25/24 17:46, Mathieu Poirier wrote:
>>> On Fri, Mar 08, 2024 at 03:47:05PM +0100, 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 device offers a client
>>>
>>> Device or driver?  I thought I touched on that before.
>>
>> Right, I changed the first instance and missed this one
>>
>>>
 interface to load a firmware in the secure part.
 This firmware could be authenticated by the secure trusted application.

 Signed-off-by: Arnaud Pouliquen 
 ---
 Updates from V3:
 - rework TEE_REMOTEPROC description in Kconfig
 - fix some namings
 - add tee_rproc_parse_fw  to support rproc_ops::parse_fw
 - add proc::tee_interface;
 - add rproc struct as parameter of the tee_rproc_register() function
 ---
  drivers/remoteproc/Kconfig  |  10 +
  drivers/remoteproc/Makefile |   1 +
  drivers/remoteproc/tee_remoteproc.c | 434 
  include/linux/remoteproc.h  |   4 +
  include/linux/tee_remoteproc.h  | 112 +++
  5 files changed, 561 insertions(+)
  create mode 100644 drivers/remoteproc/tee_remoteproc.c
  create mode 100644 include/linux/tee_remoteproc.h

 diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
 index 48845dc8fa85..2cf1431b2b59 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 TEE_REMOTEPROC
 +  tristate "remoteproc support by a TEE application"
>>>
>>> s/remoteproc/Remoteproc
>>>
 +  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..fa8daebce277 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_TEE_REMOTEPROC)  += tee_remoteproc.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/tee_remoteproc.c 
 b/drivers/remoteproc/tee_remoteproc.c
 new file mode 100644
 index ..c855210e52e3
 --- /dev/null
 +++ b/drivers/remoteproc/tee_remoteproc.c
 @@ -0,0 +1,434 @@
 +// SPDX-License-Identifier: GPL-2.0-or-later
 +/*
 + * Copyright (C) STMicroelectronics 2024 - All Rights Reserved
 + * Author: Arnaud Pouliquen 
 + */
 +
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +#include 
 +
 +#include "remoteproc_internal.h"
 +
 +#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]  

Re: [PATCH v4 1/4] remoteproc: Add TEE support

2024-03-27 Thread Mathieu Poirier
On Tue, Mar 26, 2024 at 08:18:23PM +0100, Arnaud POULIQUEN wrote:
> Hello Mathieu,
> 
> On 3/25/24 17:46, Mathieu Poirier wrote:
> > On Fri, Mar 08, 2024 at 03:47:05PM +0100, 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 device offers a client
> > 
> > Device or driver?  I thought I touched on that before.
> 
> Right, I changed the first instance and missed this one
> 
> > 
> >> interface to load a firmware in the secure part.
> >> This firmware could be authenticated by the secure trusted application.
> >>
> >> Signed-off-by: Arnaud Pouliquen 
> >> ---
> >> Updates from V3:
> >> - rework TEE_REMOTEPROC description in Kconfig
> >> - fix some namings
> >> - add tee_rproc_parse_fw  to support rproc_ops::parse_fw
> >> - add proc::tee_interface;
> >> - add rproc struct as parameter of the tee_rproc_register() function
> >> ---
> >>  drivers/remoteproc/Kconfig  |  10 +
> >>  drivers/remoteproc/Makefile |   1 +
> >>  drivers/remoteproc/tee_remoteproc.c | 434 
> >>  include/linux/remoteproc.h  |   4 +
> >>  include/linux/tee_remoteproc.h  | 112 +++
> >>  5 files changed, 561 insertions(+)
> >>  create mode 100644 drivers/remoteproc/tee_remoteproc.c
> >>  create mode 100644 include/linux/tee_remoteproc.h
> >>
> >> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> >> index 48845dc8fa85..2cf1431b2b59 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 TEE_REMOTEPROC
> >> +  tristate "remoteproc support by a TEE application"
> > 
> > s/remoteproc/Remoteproc
> > 
> >> +  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..fa8daebce277 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_TEE_REMOTEPROC)  += tee_remoteproc.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/tee_remoteproc.c 
> >> b/drivers/remoteproc/tee_remoteproc.c
> >> new file mode 100644
> >> index ..c855210e52e3
> >> --- /dev/null
> >> +++ b/drivers/remoteproc/tee_remoteproc.c
> >> @@ -0,0 +1,434 @@
> >> +// SPDX-License-Identifier: GPL-2.0-or-later
> >> +/*
> >> + * Copyright (C) STMicroelectronics 2024 - All Rights Reserved
> >> + * Author: Arnaud Pouliquen 
> >> + */
> >> +
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +#include 
> >> +
> >> +#include "remoteproc_internal.h"
> >> +
> >> +#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
> 

Re: [PATCH v4 1/4] remoteproc: Add TEE support

2024-03-26 Thread Arnaud POULIQUEN
Hello Mathieu,

On 3/25/24 17:46, Mathieu Poirier wrote:
> On Fri, Mar 08, 2024 at 03:47:05PM +0100, 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 device offers a client
> 
> Device or driver?  I thought I touched on that before.

Right, I changed the first instance and missed this one

> 
>> interface to load a firmware in the secure part.
>> This firmware could be authenticated by the secure trusted application.
>>
>> Signed-off-by: Arnaud Pouliquen 
>> ---
>> Updates from V3:
>> - rework TEE_REMOTEPROC description in Kconfig
>> - fix some namings
>> - add tee_rproc_parse_fw  to support rproc_ops::parse_fw
>> - add proc::tee_interface;
>> - add rproc struct as parameter of the tee_rproc_register() function
>> ---
>>  drivers/remoteproc/Kconfig  |  10 +
>>  drivers/remoteproc/Makefile |   1 +
>>  drivers/remoteproc/tee_remoteproc.c | 434 
>>  include/linux/remoteproc.h  |   4 +
>>  include/linux/tee_remoteproc.h  | 112 +++
>>  5 files changed, 561 insertions(+)
>>  create mode 100644 drivers/remoteproc/tee_remoteproc.c
>>  create mode 100644 include/linux/tee_remoteproc.h
>>
>> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
>> index 48845dc8fa85..2cf1431b2b59 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 TEE_REMOTEPROC
>> +tristate "remoteproc support by a TEE application"
> 
> s/remoteproc/Remoteproc
> 
>> +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..fa8daebce277 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_TEE_REMOTEPROC)+= tee_remoteproc.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/tee_remoteproc.c 
>> b/drivers/remoteproc/tee_remoteproc.c
>> new file mode 100644
>> index ..c855210e52e3
>> --- /dev/null
>> +++ b/drivers/remoteproc/tee_remoteproc.c
>> @@ -0,0 +1,434 @@
>> +// SPDX-License-Identifier: GPL-2.0-or-later
>> +/*
>> + * Copyright (C) STMicroelectronics 2024 - All Rights Reserved
>> + * Author: Arnaud Pouliquen 
>> + */
>> +
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +#include 
>> +
>> +#include "remoteproc_internal.h"
>> +
>> +#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 

Re: [PATCH v4 1/4] remoteproc: Add TEE support

2024-03-25 Thread Mathieu Poirier
On Fri, Mar 08, 2024 at 03:47:05PM +0100, 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 device offers a client

Device or driver?  I thought I touched on that before.

> interface to load a firmware in the secure part.
> This firmware could be authenticated by the secure trusted application.
> 
> Signed-off-by: Arnaud Pouliquen 
> ---
> Updates from V3:
> - rework TEE_REMOTEPROC description in Kconfig
> - fix some namings
> - add tee_rproc_parse_fw  to support rproc_ops::parse_fw
> - add proc::tee_interface;
> - add rproc struct as parameter of the tee_rproc_register() function
> ---
>  drivers/remoteproc/Kconfig  |  10 +
>  drivers/remoteproc/Makefile |   1 +
>  drivers/remoteproc/tee_remoteproc.c | 434 
>  include/linux/remoteproc.h  |   4 +
>  include/linux/tee_remoteproc.h  | 112 +++
>  5 files changed, 561 insertions(+)
>  create mode 100644 drivers/remoteproc/tee_remoteproc.c
>  create mode 100644 include/linux/tee_remoteproc.h
> 
> diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
> index 48845dc8fa85..2cf1431b2b59 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 TEE_REMOTEPROC
> + tristate "remoteproc support by a TEE application"

s/remoteproc/Remoteproc

> + 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..fa8daebce277 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_TEE_REMOTEPROC) += tee_remoteproc.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/tee_remoteproc.c 
> b/drivers/remoteproc/tee_remoteproc.c
> new file mode 100644
> index ..c855210e52e3
> --- /dev/null
> +++ b/drivers/remoteproc/tee_remoteproc.c
> @@ -0,0 +1,434 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) STMicroelectronics 2024 - All Rights Reserved
> + * Author: Arnaud Pouliquen 
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +#include "remoteproc_internal.h"
> +
> +#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;
> +

Re: [PATCH v4 1/4] remoteproc: Add TEE support

2024-03-09 Thread kernel test robot
Hi Arnaud,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 62210f7509e13a2caa7b080722a45229b8f17a0a]

url:
https://github.com/intel-lab-lkp/linux/commits/Arnaud-Pouliquen/remoteproc-Add-TEE-support/20240308-225116
base:   62210f7509e13a2caa7b080722a45229b8f17a0a
patch link:
https://lore.kernel.org/r/20240308144708.62362-2-arnaud.pouliquen%40foss.st.com
patch subject: [PATCH v4 1/4] remoteproc: Add TEE support
config: arm-randconfig-r123-20240310 
(https://download.01.org/0day-ci/archive/20240310/202403101139.nizjmqwp-...@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 13.2.0
reproduce: 
(https://download.01.org/0day-ci/archive/20240310/202403101139.nizjmqwp-...@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot 
| Closes: 
https://lore.kernel.org/oe-kbuild-all/202403101139.nizjmqwp-...@intel.com/

sparse warnings: (new ones prefixed by >>)
>> drivers/remoteproc/tee_remoteproc.c:163:19: sparse: sparse: incorrect type 
>> in assignment (different address spaces) @@ expected struct 
>> resource_table *rsc_table @@ got void [noderef] __iomem * @@
   drivers/remoteproc/tee_remoteproc.c:163:19: sparse: expected struct 
resource_table *rsc_table
   drivers/remoteproc/tee_remoteproc.c:163:19: sparse: got void [noderef] 
__iomem *
>> drivers/remoteproc/tee_remoteproc.c:276:23: sparse: sparse: incorrect type 
>> in argument 1 (different address spaces) @@ expected void volatile 
>> [noderef] __iomem *io_addr @@ got struct resource_table *rsc_table @@
   drivers/remoteproc/tee_remoteproc.c:276:23: sparse: expected void 
volatile [noderef] __iomem *io_addr
   drivers/remoteproc/tee_remoteproc.c:276:23: sparse: got struct 
resource_table *rsc_table
   drivers/remoteproc/tee_remoteproc.c:399:38: sparse: sparse: incorrect type 
in argument 1 (different address spaces) @@ expected void volatile 
[noderef] __iomem *io_addr @@ got struct resource_table *rsc_table @@
   drivers/remoteproc/tee_remoteproc.c:399:38: sparse: expected void 
volatile [noderef] __iomem *io_addr
   drivers/remoteproc/tee_remoteproc.c:399:38: sparse: got struct 
resource_table *rsc_table
   drivers/remoteproc/tee_remoteproc.c: note: in included file (through 
arch/arm/include/asm/traps.h, arch/arm/include/asm/thread_info.h, 
include/linux/thread_info.h, ...):
   include/linux/list.h:83:21: sparse: sparse: self-comparison always evaluates 
to true

vim +163 drivers/remoteproc/tee_remoteproc.c

   131  
   132  struct resource_table *tee_rproc_get_loaded_rsc_table(struct rproc 
*rproc, size_t *table_sz)
   133  {
   134  struct tee_ioctl_invoke_arg arg;
   135  struct tee_param param[MAX_TEE_PARAM_ARRY_MEMBER];
   136  struct tee_rproc *trproc = rproc->tee_interface;
   137  struct resource_table *rsc_table;
   138  int ret;
   139  
   140  if (!trproc)
   141  return ERR_PTR(-EINVAL);
   142  
   143  tee_rproc_prepare_args(trproc, TA_RPROC_FW_CMD_GET_RSC_TABLE, 
, param, 2);
   144  
   145  param[1].attr = TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT;
   146  param[2].attr = TEE_IOCTL_PARAM_ATTR_TYPE_VALUE_OUTPUT;
   147  
   148  ret = tee_client_invoke_func(tee_rproc_ctx->tee_ctx, , 
param);
   149  if (ret < 0 || arg.ret != 0) {
   150  dev_err(tee_rproc_ctx->dev,
   151  "TA_RPROC_FW_CMD_GET_RSC_TABLE invoke failed 
TEE err: %x, ret:%x\n",
   152  arg.ret, ret);
   153  return ERR_PTR(-EIO);
   154  }
   155  
   156  *table_sz = param[2].u.value.a;
   157  
   158  /* If the size is null no resource table defined in the image */
   159  if (!*table_sz)
   160  return NULL;
   161  
   162  /* Store the resource table address that would be updated by 
the remote core. */
 > 163  rsc_table = ioremap_wc(param[1].u.value.a, *table_sz);
   164  if (IS_ERR_OR_NULL(rsc_table)) {
   165  dev_err(tee_rproc_ctx->dev, "Unable to map memory 
region: %lld+%zx\n",
   166  param[1].u.value.a, *table_sz);
   167  return ERR_PTR(-ENOMEM);
   168  }
   169  
   170  return rsc_table;
   171  }
   172  EXPORT_SYMBOL_GPL(tee_rproc_get_loaded_rsc_table);
   173  
   174  int tee_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
   175  {
   176  struct tee_rproc *trproc = rproc->tee_interface;
   177  struct resource_table *rsc_table;
   178  size_t table_sz;
   179  int ret;
   180  
   181  ret = tee_rproc_load_fw(rproc, fw);
   182  if (ret)
   183  re

[PATCH v4 1/4] remoteproc: Add TEE support

2024-03-08 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 device offers a client
interface to load a firmware in the secure part.
This firmware could be authenticated by the secure trusted application.

Signed-off-by: Arnaud Pouliquen 
---
Updates from V3:
- rework TEE_REMOTEPROC description in Kconfig
- fix some namings
- add tee_rproc_parse_fw  to support rproc_ops::parse_fw
- add proc::tee_interface;
- add rproc struct as parameter of the tee_rproc_register() function
---
 drivers/remoteproc/Kconfig  |  10 +
 drivers/remoteproc/Makefile |   1 +
 drivers/remoteproc/tee_remoteproc.c | 434 
 include/linux/remoteproc.h  |   4 +
 include/linux/tee_remoteproc.h  | 112 +++
 5 files changed, 561 insertions(+)
 create mode 100644 drivers/remoteproc/tee_remoteproc.c
 create mode 100644 include/linux/tee_remoteproc.h

diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig
index 48845dc8fa85..2cf1431b2b59 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 TEE_REMOTEPROC
+   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..fa8daebce277 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_TEE_REMOTEPROC)   += tee_remoteproc.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/tee_remoteproc.c 
b/drivers/remoteproc/tee_remoteproc.c
new file mode 100644
index ..c855210e52e3
--- /dev/null
+++ b/drivers/remoteproc/tee_remoteproc.c
@@ -0,0 +1,434 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (C) STMicroelectronics 2024 - All Rights Reserved
+ * Author: Arnaud Pouliquen 
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "remoteproc_internal.h"
+
+#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,
+