-
Notifications
You must be signed in to change notification settings - Fork 71
Add deprivilege/print/reprivilege flow #497
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
Changes from all commits
1fdf375
4344853
cf66699
0eeba6d
d452560
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,8 @@ void debug_die(void) | |
} | ||
|
||
/* Note: On ARMv8-M the return_handler is executed in S mode. */ | ||
void debug_deprivilege_and_return(void * debug_handler, void * return_handler, | ||
uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3) | ||
void debug_deprivilege_and_die(void * debug_handler, void * return_handler, | ||
uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3) | ||
{ | ||
/* Switch to the debug box. | ||
* We use a regular process switch, so we don't need a dedicated stack for | ||
|
@@ -37,7 +37,21 @@ void debug_deprivilege_and_return(void * debug_handler, void * return_handler, | |
|
||
/* De-privilege, call the debug box handler, re-privilege, call the return | ||
* handler. */ | ||
/* FIXME: the below way of deprivileging may be problematic when executed from an exception handler | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed. |
||
* since we're going to stay in the context of the exception with IPSR reflecting that. | ||
* We need to do deprivileging in a way similar to ARMv7 when an exception frame is forged | ||
* for that purpose. */ | ||
uint32_t caller = UVISOR_GET_NS_ALIAS(UVISOR_GET_NS_ADDRESS((uint32_t) debug_handler)); | ||
SECURE_TRANSITION_S_TO_NS(caller, a0, a1, a2, a3); | ||
((void (*)(void)) return_handler)(); | ||
} | ||
|
||
/* FIXME: replace these stubs by the actual implementation. */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the plan to implement these in this PR or a later one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably it's better to do it in a separate PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we remove these empty stubs or does that break the build? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Breaks the build. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
void UVISOR_NAKED UVISOR_NORETURN debug_return(void) | ||
{ | ||
} | ||
|
||
void debug_deprivilege_and_return(void * debug_handler, void * return_handler, | ||
uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3) | ||
{ | ||
} |
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 also need to include
lr
?{r4-r11, lr}
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.
No need since LR is automatically saved when executing SVC after this PUSH.
Also R0-R3, R12 and xPSR.
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