arc: stack guard: bug fix with multi push stack situation
accessing the stack below guard_end is always a bug. some instrustions (like enter_s {r13-r26, fp, blink}) push a collection of registers on to the stack. In this situation, the fault_addr will less than guard_end, but sp will greater than guard_end. |------stack base-------| <--- high address | | | | <--- sp |------stack top--------| |------guard_end--------| | | <--- fault_addr | | |------guard_start------| <--- low address So we need to remove the SP check. Trade-off here is if we prefer 'false' classifications of MPU stack guard area accesses as stack error or as general mpu error. The faults get caught anyway, this is just about classification: don't see a strong need for the extra check to only report stack pointer accesses to guard area as stack error, instead of all accesses. Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
This commit is contained in:
parent
cad96852a2
commit
2609101eda
1 changed files with 5 additions and 4 deletions
|
@ -88,11 +88,12 @@ static bool z_check_thread_stack_fail(const uint32_t fault_addr, uint32_t sp)
|
|||
}
|
||||
|
||||
/* treat any MPU exceptions within the guard region as a stack
|
||||
* overflow if the stack pointer is at or below the end of the guard
|
||||
* region.
|
||||
* overflow.As some instrustions
|
||||
* (like enter_s {r13-r26, fp, blink}) push a collection of
|
||||
* registers on to the stack. In this situation, the fault_addr
|
||||
* will less than guard_end, but sp will greater than guard_end.
|
||||
*/
|
||||
if (sp <= guard_end && fault_addr < guard_end &&
|
||||
fault_addr >= guard_start) {
|
||||
if (fault_addr < guard_end && fault_addr >= guard_start) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue