arch: arm: userspace: z_arm_userspace_enter: reduce push/pop overhead
ARM user space requires ARM_MPU. We can, therefore, remove the unnecessary #ifdef CONFIG_ARM_MPU blocks in userspace.S. In addition, we do minor refactoring in z_arm_userspace_enter(), and z_arm_pendsv(), and z_arm_svc(), aiming at reducing the push/pop overhead as much as possible. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
b8add4aa0b
commit
237033c61b
2 changed files with 11 additions and 14 deletions
|
@ -249,8 +249,7 @@ in_fp_endif:
|
|||
#if defined (CONFIG_ARM_MPU)
|
||||
/* Re-program dynamic memory map */
|
||||
push {r2,lr}
|
||||
ldr r0, =_kernel
|
||||
ldr r0, [r0, #_kernel_offset_to_current]
|
||||
mov r0, r2 /* _current thread */
|
||||
bl z_arm_configure_dynamic_mpu_regions
|
||||
pop {r2,lr}
|
||||
#endif
|
||||
|
@ -501,7 +500,6 @@ _do_syscall:
|
|||
/* Bad syscalls treated as valid syscalls with ID 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]
|
||||
|
@ -518,7 +516,6 @@ valid_syscall_id:
|
|||
* instructions with the previous privilege.
|
||||
*/
|
||||
isb
|
||||
pop {r0, r1}
|
||||
|
||||
/* return from SVC to the modified LR - z_arm_do_syscall */
|
||||
bx lr
|
||||
|
|
|
@ -62,7 +62,10 @@ SECTION_FUNC(TEXT,z_arm_userspace_enter)
|
|||
msr PSPLIM, r0
|
||||
#endif
|
||||
|
||||
#if defined (CONFIG_ARM_MPU)
|
||||
/* push args to stack */
|
||||
push {r1,r2,r3,lr}
|
||||
push {r0,ip}
|
||||
|
||||
/* Re-program dynamic memory map.
|
||||
*
|
||||
* Important note:
|
||||
|
@ -77,20 +80,17 @@ SECTION_FUNC(TEXT,z_arm_userspace_enter)
|
|||
* stack, since we do not control how much stack is actually left, when
|
||||
* user invokes z_arm_userspace_enter().
|
||||
*/
|
||||
push {r0,r1,r2,r3,ip,lr}
|
||||
ldr r0, =_kernel
|
||||
ldr r0, [r0, #_kernel_offset_to_current]
|
||||
bl z_arm_configure_dynamic_mpu_regions
|
||||
pop {r0,r1,r2,r3,ip,lr}
|
||||
#endif
|
||||
|
||||
pop {r0,ip}
|
||||
|
||||
/* load up stack info from user stack */
|
||||
ldr r0, [ip]
|
||||
ldr ip, [ip, #4]
|
||||
|
||||
|
||||
/* push args to stack */
|
||||
push {r0,r1,r2,r3,ip,lr}
|
||||
push {r0,ip}
|
||||
|
||||
/* clear the user stack area to clean out privileged data */
|
||||
/* from right past the guard right up to the end */
|
||||
|
@ -102,18 +102,18 @@ SECTION_FUNC(TEXT,z_arm_userspace_enter)
|
|||
#endif
|
||||
bl memset
|
||||
|
||||
pop {r0,r1,r2,r3,ip,lr}
|
||||
pop {r0,ip}
|
||||
|
||||
/* r0 contains user stack start, ip contains user stack size */
|
||||
add r0, r0, ip /* calculate top of stack */
|
||||
|
||||
#if defined(CONFIG_BUILTIN_STACK_GUARD)
|
||||
/* clear stack limit (stack protection not required in user mode) */
|
||||
push {r3}
|
||||
mov r3, #0
|
||||
msr PSPLIM, r3
|
||||
pop {r3}
|
||||
#endif
|
||||
/* pop remaining arguments from stack before switching stacks */
|
||||
pop {r1,r2,r3,lr}
|
||||
|
||||
/* set stack to user stack */
|
||||
msr PSP, r0
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue