-
Notifications
You must be signed in to change notification settings - Fork 3k
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
PSA: TFM import #10829
Conversation
- Link to bug tracking: https://developer.trustedfirmware.org/T239 (cherry picked from commit 5f2e4b3) (cherry picked from commit 5d41a2a)
…#230) - Link to bug tracking: https://developer.trustedfirmware.org/T230 (cherry picked from commit 0c23e86) (cherry picked from commit 9c1e080)
…RMmbed#241) - Link to bug tracking: https://developer.trustedfirmware.org/T241 (cherry picked from commit da01e34) (cherry picked from commit 280715f)
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.
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 |
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.
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); |
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.
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) |
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.
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 & |
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.
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; |
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.
CURRENT_THREAD
} | ||
|
||
/* Remove current thread out of the schedulable list */ | ||
void tfm_thrd_do_exit(void) | ||
void tfm_svcall_thrd_exit(void) |
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.
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) |
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.
thrd->thread
@@ -23,6 +23,7 @@ typedef enum { | |||
#ifdef TFM_PSA_API | |||
TFM_SVC_IPC_REQUEST, | |||
TFM_SVC_SCHEDULE, | |||
TFM_SVC_EXIT_THRD, |
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.
TFM_SVC_EXIT_THREAD
|
||
ctrl.w = __get_CONTROL(); | ||
|
||
if (privileged == TFM_PARTITION_PRIVILEGED_MODE) { |
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'd prefer a ternary operator here.
tools/importer/tfm_importer.json
Outdated
"280715f9b74ab29459d81edaf02b39e7a6acb13c", | ||
"ea81bf91c90ae23dd9de012bfd7498613be00601", | ||
"5342015bb12a486a1c563175a8a7129f0737c925" | ||
"11bff3f3cbfbd3e2c284e884d0066531e6b47d7e", |
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.
Don't know what these are - should they be committed?
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.
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.
@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) |
Ok, thanks for clarifying. |
@Patater could we have your review please ? |
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.
- 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) |
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.
Please comment in our patch why this check is changed from the original.
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
@@ -286,7 +290,6 @@ uint32_t tfm_spm_partition_get_flags(uint32_t partition_idx) | |||
partition_flags; | |||
} | |||
|
|||
#ifndef TFM_PSA_API |
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.
Please comment in our patch (in the code, not the commit description) why this check is removed.
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 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) |
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.
Please comment in our patch why this change is needed.
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
tools/importer/tfm_importer.json
Outdated
"910a402ce6c96b654cb6ae1a5b679e4f856c5419", | ||
"d3c610e090282893ba1820c30fc8be3c03195091", | ||
"fb35880cecff7205fd19aaaed02b9958b9bfce5a", | ||
"be5cfdf18e6e70c9360dea7456c85189a56f277e" |
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.
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.
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.
@alzix Ah cool. Thanks. I'll update the json file.
@orenc17 @ARMmbed/mbed-os-maintainers I ran PSA relevant test cases on LPC55S69 and all of them pass. |
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]>
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.
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]>
61e9f71
to
98fa63a
Compare
Test run: FAILEDSummary: 1 of 11 test jobs failed Failed test jobs:
|
@0xc0170 CI failed. Can you please check? |
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.
LGTM
Set to 5.14 based on the changes and PR type. |
Description
Import TF-M sources from master branch at hash e7efdc6e8d89a22c4cac5b6ccc8e7d0d332ff034
Pull request type
Reviewers
@alzix @orenc17 @Patater
Release Notes