xtensa port: Fixed crash on startup on CP enabled cores

The issue was that cpStack was changed to a memory buffer by commit
https://gerrit.zephyrproject.org/r/#/c/12816
However the assembly code was expecting it to be a pointer and thus
issuing an indirection, that leads to wrong addresses.

The fix removed this unnecessary indirection and thus the inherent
invalid memory access exception.

Issue: ZEP-1997
Change-Id: I843f049212f2d116a01b05367a284209f463a5e7
Signed-off-by: Mazen NEIFER <mazen@nestwave.com>
This commit is contained in:
Mazen NEIFER 2017-04-13 20:02:49 +02:00 committed by Andrew Boie
commit a6e0404983
3 changed files with 8 additions and 10 deletions

View file

@ -70,12 +70,9 @@ _Swap:
#if XCHAL_CP_NUM > 0
/* Clear CPENABLE, also in task's co-processor state save area. */
movi a3, 0
/* a4 := current->arch.preempCoprocReg.cpStack */
l32i a4, a4, THREAD_OFFSET(cpStack)
/* a4 = _kernel->current */
wsr a3, CPENABLE
beqz a4, 1f
s16i a3, a4, XT_CPENABLE /* clear saved cpenable */
1:
s16i a3, a4, THREAD_OFFSET(cpEnable) /* clear saved cpenable */
#endif
#ifdef CONFIG_KERNEL_EVENT_LOGGER_CONTEXT_SWITCH

View file

@ -66,8 +66,7 @@ _zxt_dispatch:
#if XCHAL_CP_NUM > 0
/* Restore CPENABLE from task's co-processor save area. */
l32i a2, a3, THREAD_OFFSET(cpStack)
l16ui a3, a2, XT_CPENABLE
l16ui a3, a3, THREAD_OFFSET(cpEnable) /* a3 := cp_state->cpenable */
wsr a3, CPENABLE
#endif
/*
@ -179,9 +178,8 @@ _zxt_int_exit:
#if XCHAL_CP_NUM > 0
l32i a3, a2, KERNEL_OFFSET(current) /* _thread := _kernel->current */
l32i a4, a3, THREAD_OFFSET(cpStack)
rsr a5, CPENABLE
s16i a5, a4, XT_CPENABLE /* cp_state->cpenable = CPENABLE; */
s16i a5, a3, THREAD_OFFSET(cpEnable) /* cp_state->cpenable = CPENABLE */
movi a3, 0
wsr a3, CPENABLE /* disable all co-processors */
#endif
@ -379,7 +377,7 @@ _zxt_task_coproc_state:
bnez a15, 1f
l32i a2, a2, KERNEL_OFFSET(current)
beqz a2, 1f
l32i a15, a2, THREAD_OFFSET(cpStack)
addi a15, a2, THREAD_OFFSET(cpStack)
ret
1: movi a15, 0

View file

@ -35,6 +35,9 @@
#define _thread_offset_to_cpStack \
(_thread_offset_to_preempCoprocReg + __tPreempCoprocReg_cpStack_OFFSET)
#define _thread_offset_to_cpEnable \
(_thread_offset_to_cpStack + XT_CPENABLE)
/* end - threads */
#endif /* _offsets_short_arch__h_ */