arch: arm: update arch.mode in user thread system calls
This commit updates the thread.mode variable, in system calls, whenever we modify the execution privilege level. We need to do this, in order to be able to properly handle context-switching triggered by ISRs, while doing the system calls. The commit ensures that a context-switch, triggered by an ISR during or after,a system call will preserve the right privilege level. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
84b1bba8ee
commit
4a58fa1186
2 changed files with 18 additions and 0 deletions
|
@ -418,6 +418,14 @@ _do_syscall:
|
|||
ldr r6, =K_SYSCALL_BAD
|
||||
|
||||
valid_syscall_id:
|
||||
push {r0, r1}
|
||||
ldr r0, =_kernel
|
||||
ldr r0, [r0, #_kernel_offset_to_current]
|
||||
ldr r1, [r0, #_thread_offset_to_mode]
|
||||
bic r1, #1
|
||||
/* Store (privileged) mode in thread's mode state variable */
|
||||
str r1, [r0, #_thread_offset_to_mode]
|
||||
dsb
|
||||
/* set mode to privileged, r2 still contains value from CONTROL */
|
||||
bic r2, #1
|
||||
msr CONTROL, r2
|
||||
|
@ -427,6 +435,7 @@ valid_syscall_id:
|
|||
* instructions with the previous privilege.
|
||||
*/
|
||||
isb
|
||||
pop {r0, r1}
|
||||
|
||||
/* return from SVC to the modified LR - _arm_do_syscall */
|
||||
bx lr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue