Ken,
thanks for all your swift answers.
Sorry, I need to check on this part of the answer again:
* What happens worst case when an RTOS does not implement TZ RTOS Context Management?
Ken.L: If there is no locking protection in NS and multiple ns calling would panic.
TZ RTOS Context Management does not prevent from that. Correct.
So the only feature that is enabled with TZ RTOS Context Management is 'client ID identification' for Protected Storage (and potentially other services).
Reinhard
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Hi all.
My personal comments on this.
I would like to point out that the CI is a tool, not the core project. I do not believe we should be changing our development strategy based on what the tool is doing. We should instead adjust the tool to fit our requirements.
* No patches should be/ are merged to master when CI fails. If master breaks it should most commonly be because of something we are not testing for. Using an integration branch would not change that.
* As a developer I find it more convoluted to work with projects who use different integration strategies. The most common assumption in open source projects is that you have a master branch which is the bleeding edge, but can contain untested bugs, and the release immutable git tags for versioning. Using branch merges as versioning is a design for the pull request model which is not quite compatible with Gerrit.
* Most of the CI downtime has nothing to do with the merge strategy, they are more of a chicken and the egg philosophical problem. If your patch or branch introduced a change which affects the tests outputs, how will you test it if the CI expects the old output? An integration branch would not solve the merge freeze periods, would just affect a different branch from master.
* I believe feature branches are quite useful, since changes to master do not disrupt the development flow of a big change, and even though they will require some maintenance to re-sync before the final patch , it will be handled by an engineer who knows the feature, and full understands the regression vectors.
If I were to suggest some changes for stability purposes, I would start smaller:
* Update documentation to instruct users to check out from release tags, warning then that master is constantly changing.
* Adjust the CI to detect an Allow-CI flag from every branch. That way developers can test any patch from any feature branch. The logic for that is already present in the code, but requires Gerrit to be configured accordingly.
* Add an undo process. This would be the only case for an integration branch. All patches are merged to a temporary branch, after confirming they have passed testing individually. On the once per day nightly test, the group of different patches, will be tested against an extensive job, in models and hardware, and only if successful it will fast forward master to that state.
Regards
Minos
________________________________
From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org> on behalf of Edison Ai (Arm Technology China) via TF-M <tf-m(a)lists.trustedfirmware.org>
Sent: 13 December 2019 08:55
To: Soby Mathew <Soby.Mathew(a)arm.com>; 'tf-m(a)lists.trustedfirmware.org' <tf-m(a)lists.trustedfirmware.org>
Cc: nd <nd(a)arm.com>
Subject: Re: [TF-M] Create another branch for feature development
Hi Soby,
Thanks for your detail description.
> Integration is a temporary merge branch to merge several patches and run the CI against. Usually once CI passes, the master will be fast forwarded to integration within a day.
> This helps us to test integration of patches and detect any failure before master is updated. This means the master will pass CI at any given merge point.
I think it's a good method like this so that we can double confirm the "master" branch is stable.
And this also can fix one case even the CI can work normally: one patch is ready to merge, and it is not based on the latest HEAD, but there is no conflict. We can merge the patch directly and let gerrit do rebase by itself. But we cannot confirm the CI test can pass.
Any comment for this from others?
For multiple feature branches, I think we can stop to discuss about it now until we have some strong demands for it. It is indeed a big change for us now.
Thanks,
Edison
-----Original Message-----
From: Soby Mathew <Soby.Mathew(a)arm.com>
Sent: Friday, December 13, 2019 5:14 AM
To: Edison Ai (Arm Technology China) <Edison.Ai(a)arm.com>; 'tf-m(a)lists.trustedfirmware.org' <tf-m(a)lists.trustedfirmware.org>
Cc: nd <nd(a)arm.com>
Subject: Re: [TF-M] Create another branch for feature development
On 11/12/2019 09:05, Edison Ai (Arm Technology China) via TF-M wrote:
> Hi Gyorgy,
>
> Thanks to point it out. I agree with you that it will be better if we can align these two projects in this. I had a quick check the branches from TF-A: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/.
> There are three branches in TF-A:
> - "integration" branch, should be used for new features.
> - "master" branch, which is behind of "integration" branch. But I am nor sure what is the strategy to update it.
Hi Edison,
Integration is a temporary merge branch to merge several patches and run the CI against. Usually once CI passes, the master will be fast forwarded to integration within a day.
This helps us to test integration of patches and detect any failure before master is updated. This means the master will pass CI at any given merge point.
> - "topics/epic_beta0_spmd", I thinks it should like a feature branch for big feature.
> @Soby Mathew Could you help to share more information about it? Thanks very much.
We usually do not have feature branches in TF-A. The topics/epic_beta0_spmd is a prototyping branch where we wanted to share code with collaborators outside TF-A. The patches on this branch are not visible in gerrit review and no patches in gerrit review will be merged to this branch. Once the prototyping is complete, then patches on this branch will be reworked and pushed to gerrit review and finally get merged to integration and this branch will be deleted.
Our experience have been, long running development branches are generally a maintenance overhead. Merging these development branches before a release may also be risky as some of the changes may have unknown interactions and may become difficult to resolve.
The "topic" in gerrit review is effectively a branch. For example, this
review:
https://review.trustedfirmware.org/#/q/topic:od/debugfs+(status:open+OR+sta…
is a set of patches on topic "od/debugfs" and can be treated as development branch. This branch is alive as long as patches are not merged.
We need to understand the motivations for the change. Broken CI is an argument but development branches will only exacerbate that problem since we don't know the stability of each of those branches. Also merge conflict will not reduce due to development branches. Its just delaying the merge conflict to a later point.
There may be other reasons, but generally it is better to merge sensible patches (+2ed) within a feature even before the feature is complete as it will reduce merge conflicts (we have to ensure testing/build coverage for the patch). These are my thoughts on this.
Best Regards
Soby Mathew
--
TF-M mailing list
TF-M(a)lists.trustedfirmware.org
https://lists.trustedfirmware.org/mailman/listinfo/tf-m
Ken,
Thanks for your reply. Let me summarize what I have understood:
TF-M SFC mode:
* Allows only one thread at the time to call secure services.
* When secure services are called recursively (multiple threads) TF-M goes into 'panic' state. This should not happen with proper mutex locks.
* TZ RTOS Context Management interface is only required when "Client Oriented Policy" is used.
I have updated the diagram to reflect what I have understood. Obviously the SVC would be only executed when the call into "secure" is from Thread mode. Is my understanding correct? (diagram is also under: https://developer.trustedfirmware.org/T615) - I just realized that you made a similar picture).
[cid:image003.jpg@01D5B197.BE352670]
The initial question can be then refined to:
* TZ RTOS Context management is only needed when "Client Oriented Policy" is used.
* When and why is "Client Oriented Policy" a requirement on v8-M systems?
* Is there a way to disable ""Client Oriented Policy" in the current TF-M Core?
* This applies for both the TF-M firmware itself and the related test suite.
* What happens worst case when an RTOS does not implement TZ RTOS Context Management?
Reinhard
_______________________________________________________________________________
Reinhard Keil | Phone: +49 89 456040-13 | Email: reinhard.keil(a)arm.com<mailto:reinhard.keil@arm.com> | www.keil.com<http://www.keil.com>
ARM Germany GmbH | Bretonischer Ring 16 | D-85630 Grasbrunn,Germany
Sitz der Gesellschaft: Grasbrunn | Handelsregister: München (HRB 175362)
Geschäftsführer: Andrew Smith, Joachim Krech, Reinhard Keil
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
Hi Matt,
Thanks for your quick patch.
Hi All,
The patch link is here: https://review.trustedfirmware.org/#/c/trusted-firmware-m/+/2792/. Please help to review it if you are interested.
Thanks,
Edison
-----Original Message-----
From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org> On Behalf Of lg via TF-M
Sent: Thursday, December 12, 2019 4:42 PM
To: tf-m(a)lists.trustedfirmware.org
Subject: Re: [TF-M] Secure storage and Internal trusted storage code logic check
Hi Edison,
Thanks for your quick reply. I will try to upstream a patch later.
Thanks,
Matt
At 2019-12-12 11:15:51, "Edison Ai \\(Arm Technology China\\) via TF-M" <tf-m(a)lists.trustedfirmware.org> wrote:
>Hi Matt,
>
>Thanks very much for your mail. It looks like it is indeed a problem here.
>Can you upstream a patch to help to fix them directly?
>
>Thanks,
>Edison
>
>-----Original Message-----
>From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org> On Behalf Of lg via TF-M
>Sent: Thursday, December 12, 2019 9:43 AM
>To: tf-m(a)lists.trustedfirmware.org
>Subject: [TF-M] Secure storage and Internal trusted storage code logic check
>
>Hi TFM Secure storage & Internal trusted storage experts,
>
>
> It seems there are code logic errors in both files sst_flash_fs_mblock.c and its_flash_fs_mblock.c.
> There are following codes in function its_flash_fs_mblock_reset_metablock in its_flash_fs_mblock.c:
>
>
> for (i = ITS_INIT_DBLOCK_START; i < ITS_NUM_DEDICATED_DBLOCKS; i++) {
> /* If a flash error is detected, the code erases the rest
> * of the blocks anyway to remove all data stored in them.
> */
> err |= its_flash_erase_block(i);
> }
> This loop starts from ITS_INIT_DBLOCK_START and ends to ITS_NUM_DEDICATED_DBLOCKS.
> If there are four ITS blocks including meta blocks and data blocks in all, that means ITS_INIT_DBLOCK_START
> is 3 and ITS_NUM_DEDICATED_DBLOCKS is 1. But the above loop can not erase the data block any way.
> Should it be the following logic?
>
>
> for (i = 0; i < ITS_NUM_DEDICATED_DBLOCKS; i++) {
> /* If a flash error is detected, the code erases the rest
> * of the blocks anyway to remove all data stored in them.
> */
> err |= its_flash_erase_block(i+ITS_INIT_DBLOCK_START);
> }
> It is the same logic in function sst_flash_fs_mblock_reset_metablock in file sst_flash_fs_mblock.c.
>
>
> Please help to check.
>
>
>Thanks.
>Matt.
>
>--
>TF-M mailing list
>TF-M(a)lists.trustedfirmware.org
>https://lists.trustedfirmware.org/mailman/listinfo/tf-m
>--
>TF-M mailing list
>TF-M(a)lists.trustedfirmware.org
>https://lists.trustedfirmware.org/mailman/listinfo/tf-m
--
TF-M mailing list
TF-M(a)lists.trustedfirmware.org
https://lists.trustedfirmware.org/mailman/listinfo/tf-m
On 11/12/2019 09:05, Edison Ai (Arm Technology China) via TF-M wrote:
> Hi Gyorgy,
>
> Thanks to point it out. I agree with you that it will be better if we can align these two projects in this. I had a quick check the branches from TF-A: https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/.
> There are three branches in TF-A:
> - "integration" branch, should be used for new features.
> - "master" branch, which is behind of "integration" branch. But I am nor sure what is the strategy to update it.
Hi Edison,
Integration is a temporary merge branch to merge several patches and run
the CI against. Usually once CI passes, the master will be fast
forwarded to integration within a day.
This helps us to test integration of patches and detect any failure
before master is updated. This means the master will pass CI at any
given merge point.
> - "topics/epic_beta0_spmd", I thinks it should like a feature branch for big feature.
> @Soby Mathew Could you help to share more information about it? Thanks very much.
We usually do not have feature branches in TF-A. The
topics/epic_beta0_spmd is a prototyping branch where we wanted to share
code with collaborators outside TF-A. The patches on this branch are not
visible in gerrit review and no patches in gerrit review will be merged
to this branch. Once the prototyping is complete, then patches on this
branch will be reworked and pushed to gerrit review and finally get
merged to integration and this branch will be deleted.
Our experience have been, long running development branches are
generally a maintenance overhead. Merging these development branches
before a release may also be risky as some of the changes may have
unknown interactions and may become difficult to resolve.
The "topic" in gerrit review is effectively a branch. For example, this
review:
https://review.trustedfirmware.org/#/q/topic:od/debugfs+(status:open+OR+sta…
is a set of patches on topic "od/debugfs" and can be treated as
development branch. This branch is alive as long as patches are not merged.
We need to understand the motivations for the change. Broken CI is an
argument but development branches will only exacerbate that problem
since we don't know the stability of each of those branches. Also merge
conflict will not reduce due to development branches. Its just delaying
the merge conflict to a later point.
There may be other reasons, but generally it is better to merge sensible
patches (+2ed) within a feature even before the feature is complete as
it will reduce merge conflicts (we have to ensure testing/build coverage
for the patch). These are my thoughts on this.
Best Regards
Soby Mathew
Hi Reinhard,
Guess this diagram for a long time ago design since the latest version there is no need for NS SVC. (Check diagram attached in the ticket).
I think the existing library model implementation is almost the one you described, just some points:
- We use a secure SVC in SPM for sanitization input/output buffers.
- We do secure partition maintenance in SPM (forward call, maintain state).
The TZ API implementation under SFC is for the purpose that some services have bound the client with policies so they need to know which client is calling. It can be skipped if there is no such client-orient policy.
And one thing to mention, even we propose to use locks in RTOS for locking the interface, there would be a chance that some RTOS has a limitation on these lock APIs, or someone just acts as an attacker who skips the necessary locking operations, then we need to provide some detection in the secure side as countermeasures, and this part needs to be documented to remind users that, please make sure there is only one ongoing secure call or a panic is generated. Then it would be RTOS' choice to decide if they want to avoid this panic by locking.
/Ken
-----Original Message-----
From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org> On Behalf Of Reinhard Keil via TF-M
Sent: Thursday, December 12, 2019 11:22 PM
To: tf-m(a)lists.trustedfirmware.org
Subject: Re: [TF-M] Simplify RTOS / TF-M interface (single thread execution)
As the picture got lost, I did create also https://developer.trustedfirmware.org/T615
This contains the picture
Reinhard
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
--
TF-M mailing list
TF-M(a)lists.trustedfirmware.org
https://lists.trustedfirmware.org/mailman/listinfo/tf-m
Next issue.
For some reason the secure image runs into a MemManage exception fairly
early in the irq test of the ConfigRegressionIPCTfmLevel2 config and I
have not yet been able to figure out why.
It happens in the psa_wait() call in:
---
int32_t tfm_irq_test_1_init(void)
{
tfm_enable_irq(SPM_CORE_IRQ_TEST_1_SIGNAL_TIMER_0_IRQ);
#ifdef TFM_PSA_API
psa_signal_t signals = 0;
while (1) {
signals = psa_wait(PSA_WAIT_ANY, PSA_BLOCK);
---
The exact point of the exception is the SVC call in:
---
__attribute__((naked, section("SFN")))
psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout)
{
__ASM volatile("SVC %0 \n"
"BX LR \n"
: : "I" (TFM_SVC_PSA_WAIT));
}
---
The cause is IACCVIOL, "The processor attempted an instruction fetch
from a location that does not permit execution."
The stack frame indicates that it happened on the SVC instruction, but I
as far as I can see none of the MPU regions maps the address so I
assumed it should be allowed as it should be handled by the background
map, which should allow secure access.
If I don't enable the mpu (just skipping the enable call) then all tests
run without problems.
I have tried to compare it with an image built with ARMCLANG, and I
don't see anything obviously different. The regions are roughly the
same, all regions with fixed addresses are the same, the enable bits are
the same and the SVC handler is not mapped to any MPU region there
either. I wish there were an MPU status register that would tell exactly
what region was causing the exception.
The odd thing is that there is an SVC call in the tfm_enable_irq() call
prior to the psa_wait() call, and that works.
This is on a Musca A by the way.
Ideas?
--
*Thomas Törnblom*, /Product Engineer/
IAR Systems AB
Box 23051, Strandbodgatan 1
SE-750 23 Uppsala, SWEDEN
Mobile: +46 76 180 17 80 Fax: +46 18 16 78 01
E-mail: thomas.tornblom(a)iar.com <mailto:thomas.tornblom@iar.com>
Website: www.iar.com <http://www.iar.com>
Twitter: www.twitter.com/iarsystems <http://www.twitter.com/iarsystems>
Hello,
To continuing our open discussion, started a week ago let me propose the 2nd session and create this mail thread to discuss related topics.
1. The time slot.
Looking on participants' distribution [Asia:6, Europe:20, US East:1, US Cent:1, US West:4, Total:32] I see the majority is in Europe. The Asian region could be more presented giving a more comfortable time. Having this in mind, I would propose to have the 2nd session on Dec 19 at 7:00 UTC time. This compromise gives US West coast a chance to join at 23:00 (Dec 18!). Here is the summary:
https://www.timeanddate.com/worldclock/meetingdetails.html?year=2019&month=…
Please share your thoughts and alternatives. The related question: shall we fix the time or rotating?
You can play with the time slot here:
https://www.timeanddate.com/worldclock/meetingtime.html?day=19&month=12&yea…
2. Agenda as a proposal
- The interrupts' topic was followed by email and looks like closed. Are there remaining points for discussion?
- TF-M and Amazon FreeRTOS integration update
- Cryptocell integration
- ?
Best regards,
Anton Komlev
Hi,
Sorry the image did not got trough. One way to share the image could be to create a ticket here https://developer.trustedfirmware.org/maniphest/ where the image can be uploaded.
/George
-----Original Message-----
From: TF-M <tf-m-bounces(a)lists.trustedfirmware.org> On Behalf Of Reinhard Keil via TF-M
Sent: 12 December 2019 13:13
To: tf-m(a)lists.trustedfirmware.org
Cc: Bruno Mendes <Bruno.Mendes(a)arm.com>
Subject: [TF-M] Simplify RTOS / TF-M interface (single thread execution)
When using TF-M on v8-M with Secure Function Call SFC (aka Library) mode, the entry to the secure side is protected by a Mutex.
Thus only one thread at the time is calling a secure service. The picture below should therefore represent the execution flow (Level 1 isolation).
[cid:image003.jpg@01D5B0ED.DEEA6A60]
Under this assumption there is no need to implement TZ_context management in the RTOS (https://arm-software.github.io/CMSIS_5/Core/html/using_TrustZone_pg.html#RT…). Any RTOS could be used, provided that the Mutex capability is sufficient.
Moreover this design should create a really simple secure side:
* Only one stack is needed on the secure side for Thread mode execution
* No multi-threading issues that need to be resolved (i.e. with access of hardware crypto accelerators)
The drawback of course is that only one task at a time can use a secure service. However an RTOS with priority inversion will ensure that the Secure service is executed as fast as possible, once a scheduling conflict arises.
I would like to gather feedback on that approach. Let me know what you think.
Reinhard
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
--
TF-M mailing list
TF-M(a)lists.trustedfirmware.org
https://lists.trustedfirmware.org/mailman/listinfo/tf-m
When using TF-M on v8-M with Secure Function Call SFC (aka Library) mode, the entry to the secure side is protected by a Mutex.
Thus only one thread at the time is calling a secure service. The picture below should therefore represent the execution flow (Level 1 isolation).
[cid:image003.jpg@01D5B0ED.DEEA6A60]
Under this assumption there is no need to implement TZ_context management in the RTOS (https://arm-software.github.io/CMSIS_5/Core/html/using_TrustZone_pg.html#RT…). Any RTOS could be used, provided that the Mutex capability is sufficient.
Moreover this design should create a really simple secure side:
* Only one stack is needed on the secure side for Thread mode execution
* No multi-threading issues that need to be resolved (i.e. with access of hardware crypto accelerators)
The drawback of course is that only one task at a time can use a secure service. However an RTOS with priority inversion will ensure that the Secure service is executed as fast as possible, once a scheduling conflict arises.
I would like to gather feedback on that approach. Let me know what you think.
Reinhard
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.