Skip to content

PSA: TFM import #10829

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

Merged
merged 9 commits into from
Jul 1, 2019
Merged

Conversation

urutva
Copy link
Contributor

@urutva urutva commented Jun 13, 2019

Description

Import TF-M sources from master branch at hash e7efdc6e8d89a22c4cac5b6ccc8e7d0d332ff034

Pull request type

[ ] Fix
[x] Refactor
[ ] Target update
[ ] Functionality change
[ ] Docs update
[ ] Test update
[ ] Breaking change

Reviewers

@alzix @orenc17 @Patater

Release Notes

urutva and others added 5 commits June 6, 2019 14:47
- Remove un-needed files
- Disable printf and uart
- Modify include paths
- Guard macros from mbed_lib with ifndef

(cherry picked from commit 1f30b52)
(cherry picked from commit 71cd34d)
(cherry picked from commit 185d286)
(cherry picked from commit fb068d2)
- Link to bug tracking: https://developer.trustedfirmware.org/T239

(cherry picked from commit 5f2e4b3)
(cherry picked from commit 5d41a2a)
@ciarmcom ciarmcom requested review from alzix, orenc17, Patater and a team June 13, 2019 19:00
@ciarmcom
Copy link
Member

@Devran01, thank you for your changes.
@alzix @Patater @orenc17 @ARMmbed/mbed-os-tools @ARMmbed/mbed-os-maintainers please review.

Copy link
Contributor

@mark-edgeworth mark-edgeworth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, comments added as I see it. Apologies in advance if I'm out of step with the whole of Mbed OS so far, and feel free to disregard if you want. Your comments are welcome though.
Most general point - abbreviating names to this extent makes the code less readable for me.

* ctxb - State context storage pointer
*
* Notes:
* This is a staging API. Scheduler should be called in SPM finally and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In light of this comment should this be marked as deprecated in some way?

*/
void tfm_pendsv_do_schedule(struct tfm_state_context_ext *ctxb);
void tfm_thrd_exit(void);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why abbreviate so aggressively? tfm_thread_exit(), anyone?

return IPC_SUCCESS;
}

return IPC_ERROR_MEMORY_CHECK;
}

uint32_t tfm_spm_partition_get_privileged_mode(uint32_t partition_idx)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I'd prefer something along the lines of '..._is_priviledged_mode()' that returns TRUE or FALSE, but that might be too many years of Java. The function as it stands will still need its (typeless) return value checking against one of these constants; an opportunity for a bug later...

struct spm_partition_desc_t,
sp_thrd);

if (p_next_partition->static_data.partition_flags &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a duplicate of that 'tfm_spm_partition_get_privileged_mode()' function above.

tfm_thrd_context_switch(ctxb, CURR_THRD, pth);
}
/* Update current thread indicator */
CURR_THRD = next;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CURRENT_THREAD

}

/* Remove current thread out of the schedulable list */
void tfm_thrd_do_exit(void)
void tfm_svcall_thrd_exit(void)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thrd->thread. This is currently inconsistent with other functions defined, eg 'tfm_nspm_thread_entry'

}

/* Scheduling won't happen immediately but after the exception returns */
void tfm_thrd_activate_schedule(void)
void tfm_thrd_start_scheduler(struct tfm_thrd_ctx *pth)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thrd->thread

@@ -23,6 +23,7 @@ typedef enum {
#ifdef TFM_PSA_API
TFM_SVC_IPC_REQUEST,
TFM_SVC_SCHEDULE,
TFM_SVC_EXIT_THRD,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFM_SVC_EXIT_THREAD


ctrl.w = __get_CONTROL();

if (privileged == TFM_PARTITION_PRIVILEGED_MODE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer a ternary operator here.

"280715f9b74ab29459d81edaf02b39e7a6acb13c",
"ea81bf91c90ae23dd9de012bfd7498613be00601",
"5342015bb12a486a1c563175a8a7129f0737c925"
"11bff3f3cbfbd3e2c284e884d0066531e6b47d7e",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't know what these are - should they be committed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are commit hashes of patches present in the Mbed OS repo (in this very PR, in fact!), necessary to complete the import and integration of TF-M into Mbed OS. Yes, they are needed and should be committed.

@orenc17
Copy link
Contributor

orenc17 commented Jun 18, 2019

@mark-edgeworth

  • all of your comments are on TF-M sources, these sources are imported as is from trusted-firmware.org
  • the change in tools/importer/tfm_importer.json is due to bug fixes getting merged into TF-M.

@ARMmbed/mbed-os-maintainers i think that the changes require tests results of the PSA tests on Arm v8-m PSA targets (e.g. LPC55s69)

@mark-edgeworth
Copy link
Contributor

@mark-edgeworth

* all of your comments are on TF-M sources, these sources are imported as is from trusted-firmware.org

Ok, thanks for clarifying.

@adbridge
Copy link
Contributor

@Patater could we have your review please ?

Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Do we need the patch "TF-M patch/workaround related to (TF-M issue #T240)"? TF-M has merged the fix.
  • There seems to be a patch open for https://developer.trustedfirmware.org/T396, with a request for your comment. Could we use that patchset instead of our own?

#endif
};

/* Macros to pick linker symbols and allow to form the partition data base */
#define REGION(a, b, c) a##b##c
#define REGION_NAME(a, b, c) REGION(a, b, c)
#if (TFM_LVL == 1) && !defined(TFM_PSA_API)
#if (TFM_LVL == 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment in our patch why this check is changed from the original.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -286,7 +290,6 @@ uint32_t tfm_spm_partition_get_flags(uint32_t partition_idx)
partition_flags;
}

#ifndef TFM_PSA_API
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment in our patch (in the code, not the commit description) why this check is removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is not relevant anymore. Retained the code from TF-M.

@@ -38,7 +38,7 @@ struct spm_partition_db_t {
data.partition_priority = TFM_PRIORITY(priority); \
} while (0)

#if (TFM_LVL == 1) && !defined(TFM_PSA_API)
#if (TFM_LVL == 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please comment in our patch why this change is needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

"910a402ce6c96b654cb6ae1a5b679e4f856c5419",
"d3c610e090282893ba1820c30fc8be3c03195091",
"fb35880cecff7205fd19aaaed02b9958b9bfce5a",
"be5cfdf18e6e70c9360dea7456c85189a56f277e"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a while ago i've added an option to specify a help message/description for each hash. Take a look here https://github.com/ARMmbed/mbed-os/blob/master/tools/importer/importer.py#L239

Consider specifying a commit message for each hash - after couple of months when you will be back for new re-import - it will help you a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alzix Ah cool. Thanks. I'll update the json file.

@urutva
Copy link
Contributor Author

urutva commented Jun 26, 2019

@mark-edgeworth

  • all of your comments are on TF-M sources, these sources are imported as is from trusted-firmware.org
  • the change in tools/importer/tfm_importer.json is due to bug fixes getting merged into TF-M.

@ARMmbed/mbed-os-maintainers i think that the changes require tests results of the PSA tests on Arm v8-m PSA targets (e.g. LPC55s69)

@orenc17 @ARMmbed/mbed-os-maintainers I ran PSA relevant test cases on LPC55S69 and all of them pass.

urutva added 3 commits June 26, 2019 14:23
compiler errors as mbed-cli only generates "-D" macros only for
"macros" defined in targets.json

TF-M task link: https://developer.trustedfirmware.org/T396

Signed-off-by: Devaraj Ranganna <[email protected]>
when TFM_PSA_API is not set

Signed-off-by: Devaraj Ranganna <[email protected]>
- Link to bug tracking: https://developer.trustedfirmware.org/T240

The issue is fixed by TF-M team. However they autogenerate region details
(code, ro, rw, zi and stack ) using linker scripts and in mbed-os we
also autogenerate region details but using mix of service definition in
json file and other template files.

Signed-off-by: Devaraj Ranganna <[email protected]>
@0xc0170
Copy link
Contributor

0xc0170 commented Jun 26, 2019

@Devran01 Can you answer @Patater review?

@urutva
Copy link
Contributor Author

urutva commented Jun 26, 2019

  • Do we need the patch "TF-M patch/workaround related to (TF-M issue #T240)"? TF-M has merged the fix.

We can't avoid this patch even though the issue is fixed by TF-M team. They autogenerate region details (code, ro, rw, zi and stack ) using linker scripts and in mbed-os we also autogenerate region details but using mix of service definition in json file and other template files.
However, I adapted our solution to work with TF-M changes except using linker scripts. I'll push the changes soon.

The patchset is for code quality improvement and is a single commit and has lot of other changes. This patch will be removed while updating to next release of TM-M (assuming that the patchset would land in master by that time).

Signed-off-by: Devaraj Ranganna <[email protected]>
@urutva urutva force-pushed the feature_trusted-firmware-m_e7efdc6 branch from 61e9f71 to 98fa63a Compare June 26, 2019 16:02
@mbed-ci
Copy link

mbed-ci commented Jun 28, 2019

Test run: FAILED

Summary: 1 of 11 test jobs failed
Build number : 1
Build artifacts

Failed test jobs:

  • jenkins-ci/mbed-os-ci_cloud-client-test

@urutva
Copy link
Contributor Author

urutva commented Jul 1, 2019

@0xc0170 CI failed. Can you please check?

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 1, 2019

@Devran01 CI is all good (was restarted and now green). We should now get approvals as there were earlier requests above.

@Patater Is this needs work or ready to progress?

Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@0xc0170
Copy link
Contributor

0xc0170 commented Jul 1, 2019

Set to 5.14 based on the changes and PR type.

@0xc0170 0xc0170 merged commit 1aad06b into ARMmbed:master Jul 1, 2019
@urutva urutva deleted the feature_trusted-firmware-m_e7efdc6 branch July 2, 2019 08:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants