Skip to content

Commit 04ff8f0

Browse files
committed
arch: arm: fix USE_SWITCH for IAR
orr fix is as reported in review: ``` The add causes a crash with IAR tools as the address loaded to r8 already has the lowest bit set, and the add causes it to be set to ARM mode. The orr instruction works fine with both scenarios ``` `UDF 0` seems to break on IAR but `UDF #0` works for all. Signed-off-by: Sudan Landge <sudan.landge@arm.com>
1 parent 146b8b0 commit 04ff8f0

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

‎arch/arm/core/cortex_m/arm-m-switch.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ static bool fpu_state_pushed(uint32_t lr)
223223
*/
224224
__attribute__((naked)) void arm_m_iciit_stub(void)
225225
{
226-
__asm__("udf 0;");
226+
__asm__("udf #0;");
227227
}
228228

229229
/* Called out of interrupt entry to test for an interrupted instruction */

‎include/zephyr/arch/arm/arm-m-switch.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static ALWAYS_INLINE void arm_m_switch(void *switch_to, void **switched_from)
270270
"mov r6, r12;"
271271
"mov r7, lr;"
272272
"ldr r8, =3f;" /* address of restore PC */
273-
"add r8, r8, #1;" /* set thumb bit */
273+
"orr r8, r8, #1;" /* set thumb bit */
274274
"push {r6-r8};"
275275
"sub sp, sp, #24;" /* skip over space for r6-r11 */
276276
"push {r0-r5};"

0 commit comments

Comments
 (0)