-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Core: Introduce stm32mp remoteproc PTA and driver #6470
Conversation
2f08ff7
to
6735610
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commit "drivers: Add stm32mp1 remoteproc driver" should define a default value for CFG_DRIVERS_REMOTEPROC
and provide an inline description comment.
Ditto for commit "pta: stm32mp: add new remoteproc pta" regarding CFG_RPROC_PTA
.
My main concern here is detailed in my review comment on stm32_rproc_get()
function (see #6470 (comment)).
(edited: add a link to my comment)
Please could you detail where I should declare default value? I was expecting that platforms declare it if supported, else config was set to |
952fad3
to
584efe1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have taken into account @etienne-lms comment or responded to them.
However, I have not yet take into account #6470 (comment). I would waiting feedback from
@jforissier, @jenswi-linaro on the way I propose to use UUID for the platform PTA.
return TEE_ERROR_ACCESS_DENIED; | ||
} | ||
|
||
TEE_Result stm32_rproc_unmap(uint32_t firmware_id, paddr_t pa, size_t size) |
This comment was marked as resolved.
This comment was marked as resolved.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have few comments on the fixup commits. I'm fine if you squash and rebase once addressed.
struct stm32_rproc_mem *mems = NULL; | ||
vaddr_t *va = NULL; | ||
paddr_t pa = virt_to_phys(va); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you replace the 2 space chars with a single one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -174,14 +174,14 @@ TEE_Result stm32_rproc_map(uint32_t firmware_id, paddr_t pa, size_t size, | |||
return TEE_ERROR_ACCESS_DENIED; | |||
} | |||
|
|||
TEE_Result stm32_rproc_unmap(uint32_t firmware_id, paddr_t pa, size_t size) | |||
TEE_Result stm32_rproc_unmap(uint32_t rproc_id, vaddr_t *va, size_t size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this passes a va or a pointer to a va?
I think it should be either void *va
or vaddr_t va
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, I will keep void *
to be aligned with core_mmu_add_mapping
and core_mmu_add_mapping
functions
unsigned int i = 0; | ||
|
||
if (!rproc) | ||
if (!rproc || !va) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!va
or !pa
(note: pa will be 0 if va is 0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, pa
seems more interesting to test as set to 0 if virt_to_phys
fails.
core/pta/stm32mp/remoteproc_pta.c
Outdated
TEE_PARAM_TYPE_NONE, | ||
TEE_PARAM_TYPE_NONE, | ||
TEE_PARAM_TYPE_NONE); | ||
struct ts_ctx *ctx; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= NULL
8aab84f
to
3dce5d2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As requested by @etienne-lms, I have updated the PR based on comment, squashed the fixups and rebased the PR.
On top of that I have added a new fixup that adds additional fixes.
@@ -174,14 +174,14 @@ TEE_Result stm32_rproc_map(uint32_t firmware_id, paddr_t pa, size_t size, | |||
return TEE_ERROR_ACCESS_DENIED; | |||
} | |||
|
|||
TEE_Result stm32_rproc_unmap(uint32_t firmware_id, paddr_t pa, size_t size) | |||
TEE_Result stm32_rproc_unmap(uint32_t rproc_id, vaddr_t *va, size_t size) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch, I will keep void *
to be aligned with core_mmu_add_mapping
and core_mmu_add_mapping
functions
struct stm32_rproc_mem *mems = NULL; | ||
vaddr_t *va = NULL; | ||
paddr_t pa = virt_to_phys(va); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
unsigned int i = 0; | ||
|
||
if (!rproc) | ||
if (!rproc || !va) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, pa
seems more interesting to test as set to 0 if virt_to_phys
fails.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com>
for commits
"drivers: Add stm32mp1 remoteproc driver" and
"pta: stm32mp: add new remoteproc pta" with a comment in each addressed.
for (i = 0; i < nranges; i++) { | ||
uint32_t da = fdt32_to_cpu(list[i++]); | ||
uint32_t pa = fdt32_to_cpu(list[i++]); | ||
uint32_t size = fdt32_to_cpu(list[i]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpicking: here I would prefer:
for (i = 0; i < nranges; i += 3) {
uint32_t da = fdt32_to_cpu(list[i]);
uint32_t pa = fdt32_to_cpu(list[i + 1]);
uint32_t size = fdt32_to_cpu(list[i + 2]);
(...)
core/pta/stm32mp/remoteproc_pta.c
Outdated
*/ | ||
static TEE_Result | ||
rproc_pta_open_session(uint32_t pt, TEE_Param params[TEE_NUM_PARAMS], | ||
void **sess_ctx __unused) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefer:
static TEE_Result rproc_pta_open_session(uint32_t pt,
TEE_Param params[TEE_NUM_PARAMS],
void **sess_ctx __unused)
3dce5d2
to
74ff81e
Compare
Done, thanks @etienne-lms for the reviews! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Acked-by: Etienne Carriere <etienne.carriere@foss.st.com>
for commits
"plat-stm32mp1: Add the remoteproc TA in early-TA list" and
"dts: stm32: update m4_rproc to support the remoteproc OPTEE framework".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments on "drivers: Add stm32mp1 remoteproc driver".
s/coherence/consistency/ in the commit description. Other comments below.
mk/config.mk
Outdated
CFG_DRIVERS_REMOTEPROC ?= n | ||
|
||
# CFG_RPROC_PTA, when enabled, embeds remote processor management PTA service. | ||
CFG_RPROC_PTA ?= n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind s/CFG_RPROC_PTA/CFG_REMOTEPROC_PTA/
for consistency with CFG_DRIVERS_REMOTEPROC
(and better "grepability", too)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes much better I also move the declaration in the patch that introduce the remoteproc PTA
return res; | ||
} | ||
|
||
static TEE_Result __stm32_rproc_stop(struct stm32_rproc_instance *rproc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leading underscores/double underscores are not really recommended, why not simply rproc_stop()
? It is a static function the name can remain very short and generic with no risk of collision.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For commit " pta: stm32mp: add new remoteproc pta"
s/pta/PTA/ in the suject (the pta:
prefix is OK in lowercase).
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
core/arch/arm/plat-stm32mp1/conf.mk
Outdated
@@ -151,6 +151,7 @@ CFG_CORE_ASLR ?= n | |||
|
|||
CFG_STM32MP_REMOTEPROC ?= n | |||
CFG_DRIVERS_REMOTEPROC ?= $(CFG_STM32MP_REMOTEPROC) | |||
CFG_RPROC_PTA ?= $(CFG_STM32MP_REMOTEPROC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As already mentioned I would prefer CFG_REMOTEPROC_PTA
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For "plat-stm32mp1: Add the remoteproc TA in early-TA list":
s/early-TA/early TA/
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For "dts: stm32: update m4_rproc to support the remoteproc OPTEE framework":
s/OPTEE/OP-TEE/
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
74ff81e
to
bbf28bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jforissier : I have take, into account your comments. In addition I have re-dispatched the CFG-REMOTEPROC-PTA between commits. As consequence, I don't add your tag and @etienne-lms one in commits.
Please, could you confirm that the fixups are ok for you then i will squash them add the tags in commits messages.
return res; | ||
} | ||
|
||
static TEE_Result __stm32_rproc_stop(struct stm32_rproc_instance *rproc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
core/arch/arm/plat-stm32mp1/conf.mk
Outdated
@@ -151,6 +151,7 @@ CFG_CORE_ASLR ?= n | |||
|
|||
CFG_STM32MP_REMOTEPROC ?= n | |||
CFG_DRIVERS_REMOTEPROC ?= $(CFG_STM32MP_REMOTEPROC) | |||
CFG_RPROC_PTA ?= $(CFG_STM32MP_REMOTEPROC) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
mk/config.mk
Outdated
CFG_DRIVERS_REMOTEPROC ?= n | ||
|
||
# CFG_RPROC_PTA, when enabled, embeds remote processor management PTA service. | ||
CFG_RPROC_PTA ?= n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes much better I also move the declaration in the patch that introduce the remoteproc PTA
bbf28bc
to
86ac2f0
Compare
@arnopo yes the fixups look good, thanks. When squashing you may also add:
... to "drivers: Add stm32mp1 remoteproc driver". |
86ac2f0
to
f195d6d
Compare
The remoteproc PTA is charge of providing interface to authenticate firmware images and managing the remote processor live cycle. The remoteproc PTA supports platform specificity in the management of a remote processor: - firmware authentication based on a platform key, - load of the segments in remote processor memories, - start/stop of the remote processor, - remote processor addresses conversion. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
This driver is responsible for configuring the registers and memories of the remote processor. - It stores information about memories assigned to the remote processor based on the device tree. - It ensures consistency between the registered memory and the addresses of the firmware segments to be loaded. - Additionally, it is responsible for starting and stopping the remote processor core. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Add remoteproc PTA for the stm32mp1 platform. The PTA relies on the stm32_remoteproc driver for the remoteproc management. It is charge of providing interface for authenticating firmware images and managing the remote processor live cycle. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Reviewed-by: Etienne Carriere <etienne.carriere@foss.st.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
f195d6d
to
1132ebf
Compare
I rebased on top of |
On the stm32mp1 platform, it is possible to load firmware during the bootloader stage, for instance, by U-boot. To enable this feature, The remoteproc TA should be added to the list of early-TAs. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Update device tree to support the load of the remoteproc firmware by OP-TEE. - declare m_ipc_shm memory region that can contain the remote processor resource table and trace buffer, - update reset to align declaration with the Linux devicetree To enable the load of the coprocessor firmware by OP-TEE, user have to update the m4_rproc node compatible property: -"st,stm32mp1-m4": the load is managed by Linux or U-boot, -"st,stm32mp1-m4-tee": the load is managed by OP-TEE. Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com> Acked-by: Etienne Carriere <etienne.carriere@foss.st.com> Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
1132ebf
to
a1ff7cd
Compare
+1 update to fix a typo in commit adding the acked-by |
This series introduces the stm32mp remoteproc PTA and the stm32_remoteproc driver , which enable the authentication of signed images for the stm32mp157 platform.
The remote proc TA implements platform-specific requirements associated to the remoteproc PTA API introduced in Introduce remote proc trusted application #6300. The API commit is also part of this PR for build purposes, and should be removed if Introduce remote proc trusted application #6300 is merged.
The stm32mp_remoteproc driver is responsible for relying on the device tree, which is very similar to the Linux one. Note that the remoteproc node is a sub-node of the AHB simple bus. The AHB bus defines the dma-range property that specifoes memory translation between the Cortex-M4 mapping and the Cortex-A7 mapping. This is necessary to find the address translation between the address found in the ELF file and the address to load the segment. For instance, the RETRAM address is 0 from the Cortex-M4 perspective and 0x38000000 from the Cortex-A7 perspective.
For more details a presentation is available here: LHR23-214 OP-TEE to extend the root of trust to the coprocessor
Related pull request:
[RFC PATCH] introduction of a remoteproc framework to load signed coprocessor firmware images #6027
Introduce remote proc trusted application #6300
Code associated to the Linux Kernel is proposed as RFC for upstream:
https://lore.kernel.org/lkml/20230523091350.292221-1-arnaud.pouliquen@foss.st.com/