Skip to content
Browse files

arc: Preserve STATUS32 flags while resetting AE flag

KFLAG instruction might affect multiple flags in STATUS32 register
and so when we need just AE-bit to be reset we need first read current
state of STATUS32, then change our bit and set STATUS32 again.

Otherwise critical flags including stack checking, unaligned access etc
will be dropped for good.

Signed-off-by: Alexey Brodkin <>
  • Loading branch information...
abrodkin authored and andrewboie committed Jul 16, 2019
1 parent 46b7fd1 commit a312c7a756306a19ee94083fb86ce7e04d2421cc
Showing with 8 additions and 4 deletions.
  1. +8 −4 arch/arc/core/userspace.S
@@ -155,12 +155,14 @@ _arc_go_to_user_space:

mov r1, z_thread_entry_wrapper1

/* fake exception return */
kflag _ARC_V2_STATUS32_AE

sr r0, [_ARC_V2_ERSTATUS]
sr r1, [_ARC_V2_ERET]

/* fake exception return */
lr r0, [_ARC_V2_STATUS32]
bclr r0, r0, _ARC_V2_STATUS32_AE_BIT
kflag r0

lr r0, [_ARC_V2_SEC_STAT]
/* the mode returns from exception return is secure mode */
@@ -225,7 +227,9 @@ SECTION_FUNC(TEXT, _arc_do_syscall)
pop_s blink

/* through fake exception return, go back to the caller */
kflag _ARC_V2_STATUS32_AE
lr r6, [_ARC_V2_STATUS32]
bclr r6, r6, _ARC_V2_STATUS32_AE_BIT
kflag r6

/* the status and return address are saved in trap_s handler */
pop r6

0 comments on commit a312c7a

Please sign in to comment.
You can’t perform that action at this time.