-
Notifications
You must be signed in to change notification settings - Fork 72
Provide a structure with the debug information to debug_halt() handler #470
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
Conversation
api/inc/halt_exports.h
Outdated
| uint32_t r0; | ||
| uint32_t r1; | ||
| uint32_t r2; | ||
| uint32_t r3; |
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.
(Check if for v8-M more registers are stacked and can be made available to the debug box by uVisor.)
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.
On S to NS exception there may be more registers, but that doesn't seem to be our case.
|
|
||
| halt_info->valid_data = 0; | ||
| if (no_halt_info) { | ||
| return false; |
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.
Note to self: We don't want to print uVisor faults, since it could expose secrets. To debug uVisor faults users will have to use a uVisor debug build with semihosting.
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 extend the "For security reasons" comment with this information.
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.
api/inc/halt_exports.h
Outdated
| uint32_t lr; | ||
| uint32_t pc; | ||
| uint32_t xpsr; | ||
| } stack_frame; |
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.
Check if we haven't already defined a stack frame type somewhere in uVisor.
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.
Changed a few files to use the same structure for the stack frame.
| if (halt_info) { | ||
| g_debug_interrupt_sp[g_debug_box.box_id] -= sizeof(THaltInfo); | ||
| info = (void *)g_debug_interrupt_sp[g_debug_box.box_id]; | ||
| memcpy(info, halt_info, sizeof(THaltInfo)); |
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 is okish. The alternative would be that the debug box reserves a THaltInfo in static memory and passes the pointer explicitly to uVisor either when registering the debug driver, or through the uVisor header input.
Note that memory consumption is the same, the additional memory on the stack has to be always considered.
| uint32_t xpsr; | ||
| } stack_frame; | ||
|
|
||
| /* A few registers that may be useful for debug. */ |
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.
Try implementing the the BSOD printing code (debug_fault) in uVisor lib. Then, try calling the unprivileged BSOD printing code from the debug fault example (https://github.com/ARMmbed/mbed-os-example-uvisor-debug-fault). By attempting an implementation of the BSOD printing code, you should find out whether or not these registers (lr, control, ipsr) are useful for printing the debug BSOD.
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.
Moving the printing code into a separate file (should be used by both core and lib) is relatively a big task. We agreed to file a separate ticket for it.
|
|
||
| halt_info->valid_data = 0; | ||
| if (no_halt_info) { | ||
| return false; |
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 extend the "For security reasons" comment with this information.
a430def to
8494b89
Compare
|
retest uvisor |
|
Oren hi,
I forgot to mention one important thing - my commit breaks compilation on NUC42 due to flash image becoming to big. Alex is aware of that.
Roman
On 7 Aug 2017, at 11:10, Oren Cohen <notifications@github.com<mailto:notifications@github.com>> wrote:
retest uvisor
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub<#470 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AWhOBZvdPQ1CvpgETY5GNczc9Qcisd5Zks5sVsZdgaJpZM4OoV2S>.
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.
|
|
retest uvisor |
2 similar comments
|
retest uvisor |
|
retest uvisor |
|
Please follow our commit guidelines at https://docs.mbed.com/docs/mbed-os-handbook/en/latest/cont/code_style/
Please also rebase the commits in this PR on the latest master. |
4022218 to
9c3c001
Compare
|
I get this error when building. |
|
retest uvisor |
|
fixed that |
core/debug/src/debug.c
Outdated
| * don't have a valid exception stack frame. | ||
| * Stacking error may happen in case of Bus Fault, MemManage Fault or | ||
| * their escalation to Hard Fault. */ | ||
| uint32_t stack_error_msk = SCB_CFSR_MSTKERR_Msk | SCB_CFSR_STKERR_Msk; |
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.
Make stack_error_msk "static const"
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.
@Patater, what is the reason for making stack_error_msk static?
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.
Without "static const", the compiler is likely to allocate the variable on the stack and copy the value from flash. This isn't necessary with constants, which can be used directly from flash.
6f07f92 to
453db49
Compare
Enhance debug box functionality. debug_halt now recieves a struct with the stack frame for better debugging.
Ticket: https://jira.arm.com/browse/IOTSEC-369
I added a structure with the basic info that's supposed to aid debugging (some registers and exception stack frame when it's present).
A function debug_collect_halt_info() is used to fill this structure from within uVisor.
A new macro HALT_ERROR_EXTENDED() is used to issue halt with this debug information.
Out of the scope of this pull request: implementation of debug_halt() handler that accepts the debug information and prints it.
All the tests and examples that use debug box must be updated, this wasn't done yet.