Révision | 23295de1317433210cb0303ef304e68763607c78 (tree) |
---|---|
l'heure | 2022-10-26 21:00:50 |
Auteur | Luis Machado <luis.machado@arm....> |
Commiter | Luis Machado |
gdb/arm: Fix M-profile EXC_RETURN
Arm v8-M Architecture Reference Manual,
D1.2.95 EXC_RETURN, Exception Return Payload
describes ES bit:
"ES, bit [0]
arm-tdep.c:3443, arm_m_exception_cache () function tests this bit:
The test is negated!
Later on line 3553, the condition evaluates if an additional state
context is stacked:
RM, B3.19 Exception entry, context stacking
reads:
RPLHM "In a PE with the Security Extension, on taking an exception,
the PE hardware:
So we should test for !exception_domain_is_secure instead of non-negated
value!
These two bugs compensate each other so unstacking works correctly.
But another test of exception_domain_is_secure (negated due to the
first bug) prevents arm_unwind_secure_frames to work as expected:
Test with GNU gdb (GDB) 13.0.50.20221016-git.
Stopped in a non-secure handler:
The frames #3 and #4 are secure. backtrace should stop before #3.
Stopped in a secure handler:
The exception from secure to secure erroneously stops unwinding. It should
continue as far as the security unlimited backtrace:
Set exception_domain_is_secure to the value expected by its name.
Fix exception_domain_is_secure usage in the additional state context
stacking condition.
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
@@ -3489,7 +3489,7 @@ arm_m_exception_cache (frame_info_ptr this_frame) | ||
3489 | 3489 | { |
3490 | 3490 | secure_stack_used = (bit (lr, 6) != 0); |
3491 | 3491 | default_callee_register_stacking = (bit (lr, 5) != 0); |
3492 | - exception_domain_is_secure = (bit (lr, 0) == 0); | |
3492 | + exception_domain_is_secure = (bit (lr, 0) != 0); | |
3493 | 3493 | |
3494 | 3494 | /* Unwinding from non-secure to secure can trip security |
3495 | 3495 | measures. In order to avoid the debugger being |
@@ -3599,7 +3599,7 @@ arm_m_exception_cache (frame_info_ptr this_frame) | ||
3599 | 3599 | |
3600 | 3600 | /* With the Security extension, the hardware saves R4..R11 too. */ |
3601 | 3601 | if (tdep->have_sec_ext && secure_stack_used |
3602 | - && (!default_callee_register_stacking || exception_domain_is_secure)) | |
3602 | + && (!default_callee_register_stacking || !exception_domain_is_secure)) | |
3603 | 3603 | { |
3604 | 3604 | /* Read R4..R11 from the integer callee registers. */ |
3605 | 3605 | cache->saved_regs[4].set_addr (unwound_sp + 0x08); |