-
Notifications
You must be signed in to change notification settings - Fork 3k
Thread class tz #6486
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
Thread class tz #6486
Conversation
dd3b64c
to
0bdaaee
Compare
@0xc0170 - Optional parameter |
@deepikabhavnani It's definitely considered a feature, but I don't think this would be considered a breaking change, especially since its an optional addition. |
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'm very concerned with not having docs for that:
- doxygen
- Some proper technology page in handbook explaining what is it tz_module
it is a binary breakage so would be careful , as odin might be affected. To have it in constructor method OK, but Thread - why not overload it and add it there? |
5cffb24
to
52caf5e
Compare
|
52caf5e
to
8dfff17
Compare
Non-Secure threads can access secure calls only when tz_module attribute is set as 1(OS_SECURE_CALLABLE_THREAD), while thread creation. Hence adding tz_module as an argument to ctor.
8dfff17
to
044dfb1
Compare
f4fe709
to
ceb44f9
Compare
Thread(osPriority priority=osPriorityNormal, | ||
uint32_t stack_size=OS_STACK_SIZE, | ||
unsigned char *stack_mem=NULL, const char *name=NULL) { | ||
constructor(priority, stack_size, stack_mem, name); | ||
} | ||
|
||
/** Allocate a new thread without starting execution | ||
@param tz_module trustzone thread identifier (osThreadAttr_t::tz_module) |
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.
What's a trustzone thread identifier ? How a user gets one and how does it alter a thread behavior ?
It would be interesting to have pointers to those answers in the function documentation.
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.
@0xc0170 @pan- I have added description after this comment. Description is below this line, hence the comment is not outdated.
Does below description explain enough?
Context of RTOS threads in non-secure state must be saved when calling secure functions. tz_module ID is used to allocate context memory for threads, and it can be safely set to zero for threads not using secure calls at all. See "TrustZone RTOS Context Management" for more details.
rtos/Thread.h
Outdated
@@ -73,6 +73,15 @@ namespace rtos { | |||
* and underlying RTOS objects (static or dynamic RTOS memory pools are not being used). | |||
* Additionally the stack memory for this thread will be allocated on the heap, if it wasn't supplied to the constructor. | |||
*/ | |||
|
|||
/* This flag can be used to change the default access of all threads in non-secure 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.
Is there any reason to have this in the Thread header file ? Looks to me that it is only used as the default tz_module
value used in implementation file.
If this value is useful for users; could you move this block above the thread documentation and doxygen it ?
Could you also indicates what it means if MBED_TZ_DEFAULT_ACCESS
is set to 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.
Is there any reason to have this in the Thread header file ?
I wanted to leave the description in header file, since different target devices can use it the way they want. In case of Nuvoton few of there peripherals are in secure mode, hence they need all user threads to have secure access (specially for green-tea testing). But some other target device might keep it as no secure access for user threads.
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 compatibility and minimized impact, this is the better way for target specific setting and we could pass all green-tea & CI-Test on Nuvoton Cortex-M23 chip based on this change.
please review (approve/change requested) |
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.
It looks fine to me, but have similar question to what @pan- asked here https://github.com/ARMmbed/mbed-os/pull/6486/files#r179068247
/morph build |
Build : SUCCESSBuild number : 1757 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 1394 |
Test : SUCCESSBuild number : 1564 |
@sg- @bulislaw @SenRamakri Care to review/re-review? |
@deepikabhavnani One check - isn't this dependent on the CMSIS update that is currently under review? If yes, should be referenced and let us know about this. |
@0xc0170 - This PR is not dependent on CMSIS update, required CMSIS changes are already part of master branch. https://github.com/ARMmbed/mbed-os/blob/master/rtos/TARGET_CORTEX/rtx5/RTX/Include/rtx_os.h#L129 |
Description
tz_module
Thread attribute for trustzone identifier is added in RTX, to allow non-secure thread to access secure functions. Adding access of this parameter in Thread class constructor.Pull request type
[ ] Fix
[ ] Refactor
[ ] New target
[X] Feature
[ ] Breaking change
@ccli8 @cyliangtw